| 1 |
|
| 2 |
|
| 3 |
mydir = $(dir $(realpath $(word 2, $(MAKEFILE_LIST)))) |
| 4 |
|
| 5 |
entrypoint = $(word 1, $(subst @, ,$1)) |
| 6 |
sourcefile = $(word 2, $(subst @, ,$1)) |
| 7 |
|
| 8 |
ctverif := $(mydir)../bin/ct-verif.rb |
| 9 |
|
| 10 |
|
| 11 |
s2n_root := $(realpath $(mydir)../../..) |
| 12 |
cflags_prelude := -include $(s2n_root)/utils/s2n_prelude.h |
| 13 |
|
| 14 |
goals ?= |
| 15 |
unroll ?= |
| 16 |
looplim ?= |
| 17 |
time ?= |
| 18 |
cflags ?= |
| 19 |
extras ?= |
| 20 |
prereqs ?= |
| 21 |
secure ?= true |
| 22 |
timing ?= |
| 23 |
printModel ?= |
| 24 |
full_self_comp ?= |
| 25 |
shadowingArgs ?= |
| 26 |
|
| 27 |
flags = $(strip \ |
| 28 |
$(if $(strip $(printModel)),--print-model $(printModel)) \ |
| 29 |
$(if $(strip $(full_self_comp)),--full-self-comp $(full_self_comp)) \ |
| 30 |
$(if $(strip $(unroll)),--unroll-limit $(unroll)) \ |
| 31 |
$(if $(strip $(looplim)),--loop-limit $(looplim)) \ |
| 32 |
$(if $(strip $(time)),--time-limit $(time)) \ |
| 33 |
$(if $(strip $(timing)),--timing) \ |
| 34 |
$(if $(strip $(cflags)),--clang-options="$(cflags_prelude) $(cflags)",--clang-options="$(cflags_prelude)") \ |
| 35 |
$(if $(strip $(pruneBefore)),--prune-before) \ |
| 36 |
$(if $(strip $(pruneAfter)),--prune-after) \ |
| 37 |
$(if $(strip $(shadowingArgs)),--shadowingArgs="$(strip $(shadowingArgs))") \ |
| 38 |
) |
| 39 |
|
| 40 |
c = compiled.bpl |
| 41 |
p = product.bpl |
| 42 |
v = verified |
| 43 |
|
| 44 |
.PRECIOUS: %.$(c) %.$(p) |
| 45 |
.PHONY: %.$(v) clean |
| 46 |
|
| 47 |
.SECONDEXPANSION: |
| 48 |
%.$(c): $$(call sourcefile,$$*) $$(extras) $(prereqs) |
| 49 |
@echo |
| 50 |
@echo Compile | figlet |
| 51 |
@echo $* |
| 52 |
@echo |
| 53 |
@mkdir -p $(dir $@) |
| 54 |
@$(ctverif) $(flags) -a $@ --no-product --no-verify -e $(call entrypoint,$*) $(call sourcefile,$*) $(extras) |
| 55 |
|
| 56 |
%.$(p): %.$(c) |
| 57 |
@echo |
| 58 |
@echo Product | figlet |
| 59 |
@echo $* |
| 60 |
@echo |
| 61 |
@$(ctverif) $(flags) -b $@ --no-compile --no-verify $< |
| 62 |
|
| 63 |
%.$(v): %.$(p) |
| 64 |
@echo |
| 65 |
@echo Verify | figlet |
| 66 |
@echo $* |
| 67 |
@echo |
| 68 |
@$(ctverif) $(flags) --no-compile --no-product $< | tee $*.log |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
all: $$(patsubst %,%.$(v),$$(goals)) |
| 73 |
|
| 74 |
clean: |
| 75 |
@echo Removing intermediate files |
| 76 |
@rm -vrf $$(find . -name "*@*") |