summaryrefslogtreecommitdiff
path: root/src/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'src/Makefile')
-rw-r--r--src/Makefile36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/Makefile b/src/Makefile
index 7be2382..5463c86 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -2,25 +2,40 @@ CC = gcc
2SHELL := /usr/bin/env 2SHELL := /usr/bin/env
3.SHELLFLAGS := -S bash -c 3.SHELLFLAGS := -S bash -c
4 4
5# I need to get better at makefiles so I can write this in a way that isn't absolutely insane/stupid 5CFLAGS := -std=c2x $$(pkg-config --cflags libsodium)
6# RELEASE_CFLAGS := -O3 -fipa-pta -fipa-cp -fuse-linker-plugin -flto=auto 6DEBUG_CFLAGS := -Wall -Wextra -Wpedantic -fanalyzer -Wanalyzer-too-complex -ggdb -g3 -O0
7# RELEASE_LDFLAGS := -fuse-linker-plugin -flto=auto 7RELEASE_CFLAGS := -O3 -fipa-pta -fipa-cp -fuse-linker-plugin -flto=auto
8 8
9CFLAGS = -std=c2x -Wall -Wextra -Wpedantic -pedantic-errors -fanalyzer -Wanalyzer-too-complex -ggdb -g3 -O0 9DEFS := -D_GNU_SOURCE=1
10DEBUG_DEFS := -DDEBUG=1
11RELEASE_DEFS := -DRELEASE=1
10 12
11CFLAGS += $$(pkg-config --cflags libsodium) 13LDLIBS := $$(pkg-config --libs-only-l libsodium)
12LDLIBS += $$(pkg-config --libs-only-l libsodium) 14
13LDFLAGS += $$(pkg-config --libs-only-L libsodium) 15LDFLAGS := $$(pkg-config --libs-only-L libsodium)
16RELEASE_LDFLAGS := -fuse-linker-plugin -flto=auto
14 17
15SOURCES := $(wildcard *.c) 18SOURCES := $(wildcard *.c)
16TIMESTAMP_DIR := .timestamps 19TIMESTAMP_DIR := .timestamps
17TIMESTAMPS := $(patsubst %.c,$(TIMESTAMP_DIR)/%.t,$(SOURCES)) 20TIMESTAMPS := $(patsubst %.c,$(TIMESTAMP_DIR)/%.t,$(SOURCES))
18 21
19.PHONY: all c clean v val t test 22.PHONY: debug release c clean v val t test test
20.DELETE_ON_ERROR: 23.DELETE_ON_ERROR:
21.ONESHELL: 24.ONESHELL:
22 25
23all: main 26tests debug: CFLAGS += $(DEBUG_CFLAGS)
27tests debug: DEFS += $(DEBUG_DEFS)
28debug: main
29
30release: CFLAGS += $(RELEASE_CFLAGS)
31release: LDFLAGS += $(RELEASE_LDFLAGS)
32release: DEFS += $(RELEASE_DEFS)
33release: main
34
35clay.h:
36 cd ..
37 git submodule update --init --recursive
38 cp -fl clay/clay.h src/
24 39
25$(TIMESTAMP_DIR): 40$(TIMESTAMP_DIR):
26 mkdir -p $(TIMESTAMP_DIR) 41 mkdir -p $(TIMESTAMP_DIR)
@@ -28,8 +43,9 @@ $(TIMESTAMP_DIR):
28$(TIMESTAMPS): $(TIMESTAMP_DIR)/%.t: %.c | $(TIMESTAMP_DIR) 43$(TIMESTAMPS): $(TIMESTAMP_DIR)/%.t: %.c | $(TIMESTAMP_DIR)
29 touch $@ 44 touch $@
30 45
46main: clay.h
31main tests: %: %.c $(TIMESTAMPS) 47main tests: %: %.c $(TIMESTAMPS)
32 $(CC) -D_GNU_SOURCE=1 $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ 48 $(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
33 49
34 50
35# Phony rules 51# Phony rules