blob: 0a729553792eb5bef8c33a69e2fd5892a9ebea7c (
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
|
CC = gcc
SHELL := /usr/bin/env
.SHELLFLAGS := -S bash -c
# I need to get better at makefiles so I can write this in a way that isn't absolutely insane/stupid
# RELEASE_CFLAGS := -O3 -fipa-pta -fipa-cp -fuse-linker-plugin -flto=auto
# RELEASE_LDFLAGS := -fuse-linker-plugin -flto=auto
CFLAGS = -std=c2x -Wall -Wextra -Wpedantic -pedantic-errors -fanalyzer -Wanalyzer-too-complex -ggdb -g3 -O0
CFLAGS += $$(pkg-config --cflags libsodium)
LDLIBS += $$(pkg-config --libs-only-l libsodium)
LDFLAGS += $$(pkg-config --libs-only-L libsodium)
SOURCES := $(wildcard *.c)
TIMESTAMP_DIR := .timestamps
TIMESTAMPS := $(patsubst %.c,$(TIMESTAMP_DIR)/%.t,$(SOURCES))
.PHONY: all c clean v val t test
.DELETE_ON_ERROR:
.ONESHELL:
all: main
$(TIMESTAMP_DIR):
mkdir -p $(TIMESTAMP_DIR)
$(TIMESTAMPS): $(TIMESTAMP_DIR)/%.t: %.c | $(TIMESTAMP_DIR)
touch $@
main tests: %: %.c $(TIMESTAMPS)
$(CC) -D_GNU_SOURCE=1 $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
# Phony rules
c clean:
-rm -rvf main $(TIMESTAMP_DIR) $(wildcard *.test*) $(wildcard *.enc)
v val:
$(MAKE) all
valgrind --leak-check=yes ./main
t test:
$(MAKE) tests
valgrind --leak-check=yes ./tests
|