My issue is that when running "make clean," it will not remove any of the files including the precompiled header files in the m directory (not sure of other directories as they did not have any files to remove). However, it does remove all of the files in the root directory where the makefile is. Note, M, D, N, and G are all subdirectories of the directory that the makefile is in. Futhermore, I tried manually running each of the terminal commands specified for the clean and it successfully removed all of the files in the m directory and root directory with no errors. I don't know why there is an inconsistency, any help is appreciated. Thanks in advance.
Shown below is my makefile:
#Compiler Variable
CMP=g++
#Compiler Flags Variable
CPPFLAGS= -c -std=c++17
#Directory Variables
m := ./M
ds := ./D
nn := ./N
g := ./G
M_HEAD = $(m)/L.h $(m)/M.h $(m)/T.h
M_SRC = $(m)/L.cpp $(m)/M.cpp $(m)/T.cpp
M_OJBS = L.o M.o T.o
#Targets and Dependencies
all: main.o m.o
$(CMP) main.o $(M_OJBS) -o test
main.o: main.cpp
$(CMP) $(CPPFLAGS) main.cpp
m.o: $(M_HEAD) $(M_SRC)
$(CMP) $(CPPFLAGS) $(M_HEAD) $(M_SRC)
clean:
rm -rf *.o *.h.gch test
cd $(m)
rm -rf *.o *.h.gch test
cd ..
cd $(ds)
rm -rf *.o *.h.gch test
cd ..
cd $(nn)
rm -rf *.o *.h.gch test
cd ..
cd $(g)
rm -rf *.o *.h.gch test