how can i include a re-compilation/update for my own “.h” files within my makefile.
This is my makefile:
COMPILER = g++
SOURCES = main.cpp
APP = executable/main
OBJECTS = $(SOURCES:.cpp=.o)
all: $(SOURCES) $(APP)
$(APP): $(OBJECTS)
$(COMPILER) $(OBJECTS) -o $@
clean:
rm -rf *.o $(APP)
suppose now i want to re-compile the project but i just modified whatever.h and whatever1.h. these files are included in the header of main.cpp.
It won’t do any good to add these files to the list of dependencies of
$(APP). That will cause Make to relink (that is, buildmainout ofmain.o) but not recompile (that is, buildmain.oout ofmain.cpp,whatever.handwhatever1.h). The behavior of the executable will not change– it will not reflect the changes you’ve made to the headers.You should add these files to the list of prerequisites of the object file: