I have 2 .cpp
files : main.cpp
A.cpp
and few header files in include
dir.
I am trying to write a makefile that recompiles whenever a header file changes.
Now I tried following the method outlines in the example here. However I could not get started. Here is my attempt so far.
CC := g++
OBJS := main.o A.o
OUTPUT := program.exe
INCLUDE_DIR := -I ./include \
#linking step
all: $(OBJS)
$(CC) $(INCLUDE_DIR) $(OBJS) -o $(OUTPUT)
#compile and generate dependency info
%.o : %.cpp
$(CC) $(INCLUDE_DIR) -c $*.cpp -o $*.o
$(CC) $(INCLUDE_DIR) -MMD -c -o $@ $<
-include *.d