summaryrefslogtreecommitdiff
path: root/src/Makefile
diff options
context:
space:
mode:
author@syxhe <https://t.me/syxhe>2025-04-17 18:53:36 -0500
committer@syxhe <https://t.me/syxhe>2025-04-17 18:53:36 -0500
commit18811c585d5ff1285446d3eee301e2139dc1a60b (patch)
treec121ce7f27909e9a22cdbaedb6e241fa37fd30fe /src/Makefile
parented4a91bcc1d68c26cd533c4432f93c799b1771c2 (diff)
Improve makefile slightly
Diffstat (limited to 'src/Makefile')
-rw-r--r--src/Makefile13
1 files changed, 9 insertions, 4 deletions
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
9CFLAGS = -std=c2x -Wall -Wextra -Wpedantic -pedantic-errors -fanalyzer -Wanalyzer-too-complex -ggdb -g3 -O0 $$(pkg-config --cflags libsodium) 9CFLAGS = -std=c2x -Wall -Wextra -Wpedantic -pedantic-errors -fanalyzer -Wanalyzer-too-complex -ggdb -g3 -O0 $$(pkg-config --cflags libsodium)
10LDLIBS += $$(pkg-config --libs-only-l libsodium) 10LDLIBS += $$(pkg-config --libs-only-l libsodium)
11LDFLAGS += $$(pkg-config --libs-only-L libsodium) 11LDFLAGS += $$(pkg-config --libs-only-L libsodium)
12DEPFLAGS = -MT $@ -MMD -MP -MF $*.d
12 13
13SOURCES := $(wildcard *.c) 14SOURCES := $(wildcard *.c)
14OBJECTS := $(patsubst %.c,%.o,$(SOURCES)) 15OBJECTS := $(patsubst %.c,%.o,$(SOURCES))
15DEPS := $(patsubst %.c,%.d,$(SOURCES)) 16DEPS := $(patsubst %.c,%.d,$(SOURCES))
16 17
18COMPILE.c = $(CC) $(DEPFLAGS) $(CFLAGS) -c
19
17.PHONY: all c clean val 20.PHONY: all c clean val
18.DELETE_ON_ERROR: 21.DELETE_ON_ERROR:
19.ONESHELL: 22.ONESHELL:
@@ -21,10 +24,12 @@ DEPS := $(patsubst %.c,%.d,$(SOURCES))
21all: main 24all: main
22main: $(OBJECTS) 25main: $(OBJECTS)
23 26
24$(OBJECTS): %.o: %.d 27%.o: %.c %.d
25include $(DEPS) # Make sure the dependencies are actually included 28 $(COMPILE.c) $<
26%.d: %.c 29
27 ./depend.sh $$(dirname $*) $(CFLAGS) $*.c > $@ 30$(DEPS):
31include $(wildcard $(DEPS))
32# Adopted from https://make.mad-scientist.net/papers/advanced-auto-dependency-generation/
28 33
29c clean: 34c clean:
30 @-rm -rv main $(OBJECTS) $(DEPS) $(wildcard *.test*) $(wildcard *.enc) 35 @-rm -rv main $(OBJECTS) $(DEPS) $(wildcard *.test*) $(wildcard *.enc)