aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorTomasz Kramkowski <tomasz@kramkow.ski>2024-05-02 20:36:14 +0100
committerTomasz Kramkowski <tomasz@kramkow.ski>2024-05-02 20:36:14 +0100
commit38f90d7bd6669bd6f48be178669a6186e40b30de (patch)
treeba9101d5039c5ac01a3ab888142f35d5b07d87a0 /Makefile
parent4738c0ffe90fc5e46a2a31b061b76d49317b6b1e (diff)
Makefile: Use a more complete dependency graph
Use the compiler to generate make-compatible dependency files and include them to ensure targets are recompiled when a header file changes. Also make objects depend on the Makefile explicitly to ensure objects are re-built when the makefile changes.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile6
1 files changed, 4 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 242e93f..9176f4d 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ TARGET := stem
SRCEXT := c
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o))
-CFLAGS :=
+CFLAGS := -MMD -MP
LIB := -L lib -lm
INC := -I include
@@ -13,7 +13,7 @@ $(TARGET): $(OBJECTS)
@echo " Linking..."
@echo " $(CC) $^ -o $(TARGET) $(LIB)"; $(CC) $^ -o $(TARGET) $(LIB) -O3
-$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT)
+$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT) Makefile
@echo " Building..."
@mkdir -p $(BUILDDIR)
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $< -save-temps -O3
@@ -33,3 +33,5 @@ doc:
site:
doxygen
rsync -uvrP --delete-after "html/" root@nullring.xyz:/var/www/stemdoc
+
+-include $(OBJECTS:.o=.d)