From 18811c585d5ff1285446d3eee301e2139dc1a60b Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Thu, 17 Apr 2025 18:53:36 -0500 Subject: Improve makefile slightly --- src/Makefile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/Makefile') diff --git a/src/Makefile b/src/Makefile index e32f72b..b045807 100644 --- a/src/Makefile +++ b/src/Makefile @@ -9,11 +9,14 @@ SHELL := /usr/bin/env CFLAGS = -std=c2x -Wall -Wextra -Wpedantic -pedantic-errors -fanalyzer -Wanalyzer-too-complex -ggdb -g3 -O0 $$(pkg-config --cflags libsodium) LDLIBS += $$(pkg-config --libs-only-l libsodium) LDFLAGS += $$(pkg-config --libs-only-L libsodium) +DEPFLAGS = -MT $@ -MMD -MP -MF $*.d SOURCES := $(wildcard *.c) OBJECTS := $(patsubst %.c,%.o,$(SOURCES)) DEPS := $(patsubst %.c,%.d,$(SOURCES)) +COMPILE.c = $(CC) $(DEPFLAGS) $(CFLAGS) -c + .PHONY: all c clean val .DELETE_ON_ERROR: .ONESHELL: @@ -21,10 +24,12 @@ DEPS := $(patsubst %.c,%.d,$(SOURCES)) all: main main: $(OBJECTS) -$(OBJECTS): %.o: %.d -include $(DEPS) # Make sure the dependencies are actually included -%.d: %.c - ./depend.sh $$(dirname $*) $(CFLAGS) $*.c > $@ +%.o: %.c %.d + $(COMPILE.c) $< + +$(DEPS): +include $(wildcard $(DEPS)) +# Adopted from https://make.mad-scientist.net/papers/advanced-auto-dependency-generation/ c clean: @-rm -rv main $(OBJECTS) $(DEPS) $(wildcard *.test*) $(wildcard *.enc) -- cgit v1.2.3