Auto-Dependency Generation

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Auto-Dependency Generation

Игорь Спиридонов
Hello make experts. I decided to write this letter again since I forgot about
I'm trying to use Auto-Dependency Generation form this article - Auto-Dependency
GenerationThe article is very nice but i'm stuck. dependencies are generated in
.d folder correctly as written in the article but make doesn't build if i change
a header file.
Here is my Makefile:

# -*- Makefile -*-

DEP_DIR := .d

$(shell mkdir -p $(DEP_DIR) >/dev/null)


POSTCOMPILE = @mv -f $(DEP_DIR)/$*.Td $(DEP_DIR)/$*.d && touch $@

CXX := g++

CXXFLAGS := -std=c++17 -g

LIBS := -lsome_lib

PRODUCT := main

SRC_DIR := src

SRCFILES := $(wildcard $(SRC_DIR)/*.cpp)

OBJFILES := $(patsubst %.cpp,%.o,$(SRCFILES))

all: $(PRODUCT)

$(SRC_DIR)/%.o: $(SRC_DIR)/%.cpp $(DEP_DIR)/%.d

$(CXX) $(DEPFLAGS) $(CXXFLAGS) -o $@ -c $^



$(CXX) $^ $(LIBS) -o $@

$(DEP_DIR)/%.d: ;


.PHONY: clean


find ./src -name '*.o' -delete

find . -name '*.o' -delete


include $(wildcard $(patsubst %,$(DEP_DIR)/%.d,$(basename $(SRCFILES))))

Source files(cpp and hpp) are located in src folder.

I'm using gnu make 4.2.1 for mingw.

Have a wonderful time.
Help-make mailing list
[hidden email]