blob: 5463c86253451c3501fbd89c5e5e447505342d41 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
CC = gcc
SHELL := /usr/bin/env
.SHELLFLAGS := -S bash -c
CFLAGS := -std=c2x $$(pkg-config --cflags libsodium)
DEBUG_CFLAGS := -Wall -Wextra -Wpedantic -fanalyzer -Wanalyzer-too-complex -ggdb -g3 -O0
RELEASE_CFLAGS := -O3 -fipa-pta -fipa-cp -fuse-linker-plugin -flto=auto
DEFS := -D_GNU_SOURCE=1
DEBUG_DEFS := -DDEBUG=1
RELEASE_DEFS := -DRELEASE=1
LDLIBS := $$(pkg-config --libs-only-l libsodium)
LDFLAGS := $$(pkg-config --libs-only-L libsodium)
RELEASE_LDFLAGS := -fuse-linker-plugin -flto=auto
SOURCES := $(wildcard *.c)
TIMESTAMP_DIR := .timestamps
TIMESTAMPS := $(patsubst %.c,$(TIMESTAMP_DIR)/%.t,$(SOURCES))
.PHONY: debug release c clean v val t test test
.DELETE_ON_ERROR:
.ONESHELL:
tests debug: CFLAGS += $(DEBUG_CFLAGS)
tests debug: DEFS += $(DEBUG_DEFS)
debug: main
release: CFLAGS += $(RELEASE_CFLAGS)
release: LDFLAGS += $(RELEASE_LDFLAGS)
release: DEFS += $(RELEASE_DEFS)
release: main
clay.h:
cd ..
git submodule update --init --recursive
cp -fl clay/clay.h src/
$(TIMESTAMP_DIR):
mkdir -p $(TIMESTAMP_DIR)
$(TIMESTAMPS): $(TIMESTAMP_DIR)/%.t: %.c | $(TIMESTAMP_DIR)
touch $@
main: clay.h
main tests: %: %.c $(TIMESTAMPS)
$(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
# Phony rules
c clean:
-rm -rvf main tests $(TIMESTAMP_DIR) $(wildcard *.test*) $(wildcard *.enc)
v val: main
valgrind --leak-check=yes ./main
t test: tests
valgrind --leak-check=yes ./tests
|