summaryrefslogtreecommitdiff
path: root/src/common.mk
blob: b854933dadec414ad90dfe1f9adf112cd7ed8f15 (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
nist_flags = -std=c99 -Wall -Wextra -Wshadow -fsanitize=address,undefined -O2
CFLAGS += -Isrc -I. $(nist_flags) -Werror
LDFLAGS += $(nist_flags)

# use "make VERBOSE=1" to have full commands printed out.
VERBOSE = 0
ifeq ($(VERBOSE),1)
Q =
else
Q = @
endif


.PHONY: clean test $(tests)


clean:
	-rm -r results

results:
	@ mkdir -p $@

results/%.o: %.c
	@ mkdir -p $(dir $@)
	@ echo "CC $@"
	$(Q) gcc -c $< $(CFLAGS) -o $@

results/test-%: results/test/test-%.o
	@ echo "LD $@"
	$(Q) gcc $^ $(LDFLAGS) -o $@

test: $(tests)

$(tests): %: results/%
	@ echo "TEST $@"
	$(Q) ./results/$@


results/src/cipher.o: src/cipher.h src/tweakey.h src/constants.h src/parameters.h _parameters.h
results/src/constants.o: src/constants.h
results/src/lilliput-ae-i.o: src/lilliput-ae.h src/cipher.h src/constants.h src/parameters.h _parameters.h
results/src/tweakey.o: src/tweakey.h src/constants.h src/parameters.h _parameters.h
results/test-*.o: test/helpers.h src/parameters.h _parameters.h

# TODO: should add order-only prerequisites to remove mkdirs inside recipes
# TODO: add valgrind, although it does not seem to play well with ASAN
# TODO: should use gcc -M... to generate .o -> .h dependencies
# TODO: auto-generate "tests" variable