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
topic.
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)

DEPFLAGS = -MT $@ -MMD -MP -MF $(DEP_DIR)/$*.Td

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 $^

$(POSTCOMPILE)

$(PRODUCT): $(OBJFILES)

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

$(DEP_DIR)/%.d: ;

.PRECIOUS: $(DEP_DIR)/%.d

.PHONY: clean

clean:

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

find . -name '*.o' -delete

rm $(PRODUCT)

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]
https://lists.gnu.org/mailman/listinfo/help-make