-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
40 lines (27 loc) · 1.52 KB
/
Makefile
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
CC := gcc
.PHONY: all clean debug dev
all: dist/cmpr
CFLAGS := -O2 -Wall
LDFLAGS := -lm
# TODO: we should put the different builds in different output directories; currently switching requires `make -B`
#OUTDIR := dev/
debug: CFLAGS := -g -O0 -Wall -fsanitize=address
debug: dist/cmpr
dev: CFLAGS := -g -O2 -Wall -Werror -fsanitize=address
dev: dist/cmpr
dist/cmpr: cmpr.c ops/*.c prompt_templates.c fdecls.h spanio.c siphash/siphash.o siphash/halfsiphash.o
mkdir -p dist
(VER=8; D=$$(date +%Y%m%d-%H%M%S); GIT=$$(git log -1 --pretty="%h %f"); echo '#line 1 "cmpr.c"' >cmpr-sed.c; sed 's/\$$VERSION\$$/'"$$VER"' (build: '"$$D"' '"$$GIT"')/' <cmpr.c >>cmpr-sed.c; echo "Version: $$VER (build: $$D $$GIT)"; $(CC) -o dist/cmpr-$$D cmpr-sed.c siphash/siphash.o siphash/halfsiphash.o $(CFLAGS) $(LDFLAGS) && rm -f dist/cmpr && ln -s cmpr-$$D dist/cmpr)
prompt_list: cmpr.c ops/*.c fdecls.h spanio.c siphash/siphash.o siphash/halfsiphash.o
$(CC) -o prompt_list -D PROMPT_LIST cmpr.c siphash/siphash.o siphash/halfsiphash.o $(CFLAGS) $(LDFLAGS)
prompt_templates.c: prompt_list prompts/*
rm -f prompts/*.bak
(echo "// GENERATED CODE, do not edit (see Makefile)"; ./prompt_list) > prompt_templates.c
siphash/siphash.o: siphash/siphash.c
$(CC) -c siphash/siphash.c $(CFLAGS) -o siphash/siphash.o
siphash/halfsiphash.o: siphash/halfsiphash.c
$(CC) -c siphash/halfsiphash.c $(CFLAGS) -o siphash/halfsiphash.o
fdecls.h: cmpr.c ops/*.c
cat $^ | python3 extract_decls.py > fdecls.h
install: dist/cmpr
install -m 755 dist/cmpr /usr/local/bin/cmpr