This is my make file.
all: observer
observer: main.o weather_center.o display.o subject.o observer.o
g++ main.o weather_center.o display.o subject.o observer.o -o observer
main.o: main.cpp
g++ -c main.cpp
weather_center.o: weather_center.cpp
g++ -c weather_center.cpp
display.o: display.cpp
g++ -c display.cpp
subject.o: subject.cpp
g++ -c subject.cpp
observer.o: observer.cpp
g++ -c observer.cpp
clean:
rm -f *o observer
Here I'm trying to use
clean:
rm -f *o observer
To clean up the temporary *.o files. But program compiles and generate the target assembly, but doesn't delete the *.o files. Not showing any errors also.
rm -f *o observer
in terminal. It works fine.Tab
for indentclean
or rm
in the directory.$(RM)
instead of rm
. but no luckyI found the issue. Have to specify clean
as a target of all
otherwise it wont call. generally like this.
all: [your executive names] clean
In above case
all: observer clean
Here is the full make file of above case
all: observer clean
observer: main.o weather_center.o display.o subject.o observer.o
g++ main.o weather_center.o display.o subject.o observer.o -o observer
main.o: main.cpp
g++ -c main.cpp
weather_center.o: weather_center.cpp
g++ -c weather_center.cpp
display.o: display.cpp
g++ -c display.cpp
subject.o: subject.cpp
g++ -c subject.cpp
observer.o: observer.cpp
g++ -c observer.cpp
clean:
rm -f *o observer