lilliput-ae-reference-implementation

Implementations of Lilliput-AE submitted to the NIST LWC standardization process
git clone https://git.kevinlegouguec.net/lilliput-ae-reference-implementation
Log | Files | Refs | README

common.mk (1561B)


      1 # Use "make VERBOSE=1" to have full commands printed out.
      2 VERBOSE = 0
      3 ifeq ($(VERBOSE),1)
      4 Q =
      5 else
      6 Q = @
      7 endif
      8 
      9 
     10 # Use "make IMPLEMENTATION=..." to compile against other versions.
     11 IMPLEMENTATION = ref
     12 
     13 test_dir := $(dir $(lastword $(MAKEFILE_LIST)))
     14 root_dir = $(test_dir)..
     15 results_dir = $(root_dir)/results/$(mode)-$(keylen)
     16 src_dir = $(root_dir)/src/$(IMPLEMENTATION)
     17 variant_dir = $(root_dir)/src/$(mode)-$(keylen)
     18 
     19 
     20 nist_flags = -std=c99 -Wall -Wextra -Wshadow -fsanitize=address,undefined -O2
     21 CFLAGS += -I$(src_dir) -I$(variant_dir) -I$(test_dir) $(nist_flags) -Werror
     22 LDFLAGS += $(nist_flags)
     23 
     24 
     25 include $(src_dir)/implem.mk
     26 
     27 
     28 .PHONY: clean test $(tests) traces $(traces)
     29 
     30 
     31 clean:
     32 	- rm -r $(results_dir)
     33 
     34 $(results_dir) $(results_dir)/src $(results_dir)/test:
     35 	@ mkdir -p $@
     36 
     37 test: $(tests)
     38 trace: $(traces)
     39 
     40 $(tests): test-%: $(results_dir)/test-%
     41 	@ echo "TEST $@"
     42 	$(Q) $<
     43 
     44 $(traces): traces-%: $(results_dir)/traces-%
     45 	@ echo "TRACES $@"
     46 	$(Q) $< $(results_dir) $*-$(mode)-$(keylen)
     47 
     48 $(results_dir)/test-%: $(results_dir)/test/test-%.o
     49 	@ echo "LD $@"
     50 	$(Q) gcc $^ $(LDFLAGS) -o $@
     51 
     52 $(results_dir)/traces-%: $(results_dir)/test/traces-%.o
     53 	@ echo "LD $@"
     54 	$(Q) gcc $^ $(LDFLAGS) -o $@
     55 
     56 $(results_dir)/test/%.o: %.c $(test_dir)/test-helpers.h | $(results_dir)/test
     57 	@ echo "CC $@"
     58 	$(Q) gcc -c $< $(CFLAGS) -o $@
     59 
     60 $(results_dir)/src/%.o: $(src_dir)/%.c | $(results_dir)/src
     61 	@ echo "CC $@"
     62 	$(Q) gcc -c $< $(CFLAGS) -o $@
     63 
     64 
     65 # TODO: add valgrind, although it does not seem to play well with ASAN
     66 # TODO: use gcc -M... to generate .o -> .h dependencies