diff options
| 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 |
| commit | 18811c585d5ff1285446d3eee301e2139dc1a60b (patch) | |
| tree | c121ce7f27909e9a22cdbaedb6e241fa37fd30fe /src/Makefile | |
| parent | ed4a91bcc1d68c26cd533c4432f93c799b1771c2 (diff) | |
Improve makefile slightly
Diffstat (limited to 'src/Makefile')
| -rw-r--r-- | src/Makefile | 13 |
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 | |||
| 9 | CFLAGS = -std=c2x -Wall -Wextra -Wpedantic -pedantic-errors -fanalyzer -Wanalyzer-too-complex -ggdb -g3 -O0 $$(pkg-config --cflags libsodium) | 9 | CFLAGS = -std=c2x -Wall -Wextra -Wpedantic -pedantic-errors -fanalyzer -Wanalyzer-too-complex -ggdb -g3 -O0 $$(pkg-config --cflags libsodium) |
| 10 | LDLIBS += $$(pkg-config --libs-only-l libsodium) | 10 | LDLIBS += $$(pkg-config --libs-only-l libsodium) |
| 11 | LDFLAGS += $$(pkg-config --libs-only-L libsodium) | 11 | LDFLAGS += $$(pkg-config --libs-only-L libsodium) |
| 12 | DEPFLAGS = -MT $@ -MMD -MP -MF $*.d | ||
| 12 | 13 | ||
| 13 | SOURCES := $(wildcard *.c) | 14 | SOURCES := $(wildcard *.c) |
| 14 | OBJECTS := $(patsubst %.c,%.o,$(SOURCES)) | 15 | OBJECTS := $(patsubst %.c,%.o,$(SOURCES)) |
| 15 | DEPS := $(patsubst %.c,%.d,$(SOURCES)) | 16 | DEPS := $(patsubst %.c,%.d,$(SOURCES)) |
| 16 | 17 | ||
| 18 | COMPILE.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)) | |||
| 21 | all: main | 24 | all: main |
| 22 | main: $(OBJECTS) | 25 | main: $(OBJECTS) |
| 23 | 26 | ||
| 24 | $(OBJECTS): %.o: %.d | 27 | %.o: %.c %.d |
| 25 | include $(DEPS) # Make sure the dependencies are actually included | 28 | $(COMPILE.c) $< |
| 26 | %.d: %.c | 29 | |
| 27 | ./depend.sh $$(dirname $*) $(CFLAGS) $*.c > $@ | 30 | $(DEPS): |
| 31 | include $(wildcard $(DEPS)) | ||
| 32 | # Adopted from https://make.mad-scientist.net/papers/advanced-auto-dependency-generation/ | ||
| 28 | 33 | ||
| 29 | c clean: | 34 | c clean: |
| 30 | @-rm -rv main $(OBJECTS) $(DEPS) $(wildcard *.test*) $(wildcard *.enc) | 35 | @-rm -rv main $(OBJECTS) $(DEPS) $(wildcard *.test*) $(wildcard *.enc) |
