mirror of
https://github.com/henrydcase/pqc.git
synced 2024-11-26 09:21:28 +00:00
165 lines
4.8 KiB
Makefile
165 lines
4.8 KiB
Makefile
# This -Wall was supported by the European Commission through the ERC Starting Grant 805031 (EPOQUE)
|
|
CFLAGS=-Wall -Wextra -Wpedantic -Werror -std=c99 -g $(EXTRAFLAGS)
|
|
|
|
ALL_SCHEMES=$(filter-out crypto_%.c, $(wildcard crypto_*/*))
|
|
COMMON_FILES = common/fips202.c common/sha2.c
|
|
RANDOM_IMPL = common/randombytes.c
|
|
|
|
default: help
|
|
|
|
.PHONY: require_scheme
|
|
require_scheme:
|
|
# assumes a SCHEME variable; e.g. make functest SCHEME=crypto_kem/kyber768
|
|
ifndef SCHEME
|
|
$(error The SCHEME variable is not set. Example: SCHEME=crypto_kem/kyber768)
|
|
endif
|
|
|
|
bin/functest_$(subst /,_,$(SCHEME)): test/$(dir $(SCHEME))functest.c $(wildcard $(SCHEME)/clean/*.c) $(wildcard $(SCHEME)/clean/*.h) | require_scheme
|
|
mkdir -p bin
|
|
$(CC) $(CFLAGS) \
|
|
-DPQCLEAN_NAMESPACE=$(shell echo PQCLEAN_$(subst -,,$(notdir $(SCHEME))) | tr a-z A-Z) \
|
|
-iquote "./common/" \
|
|
-iquote "$(SCHEME)/clean/" \
|
|
-o bin/functest_$(subst /,_,$(SCHEME)) \
|
|
$(SCHEME)/clean/*.c \
|
|
$(COMMON_FILES) \
|
|
$(RANDOM_IMPL) \
|
|
$<
|
|
|
|
.PHONY: functest
|
|
functest: bin/functest_$(subst /,_,$(SCHEME))
|
|
|
|
.PHONY: run-functest
|
|
run-functest: bin/functest_$(subst /,_,$(SCHEME))
|
|
./$<
|
|
|
|
.PHONY: run-valgrind
|
|
run-valgrind: bin/functest_$(subst /,_,$(SCHEME))
|
|
ifeq ($(shell uname -s),Linux)
|
|
valgrind --leak-check=full --error-exitcode=1 $<
|
|
else
|
|
@echo "Valgrind not supported on this platform."
|
|
endif
|
|
|
|
bin/sanitizer_$(subst /,_,$(SCHEME)): test/$(dir $(SCHEME))functest.c $(wildcard $(SCHEME)/clean/*.c) $(wildcard $(SCHEME)/clean/*.h) | require_scheme
|
|
mkdir -p bin
|
|
$(CC) $(CFLAGS) -fsanitize=address,undefined \
|
|
-DPQCLEAN_NAMESPACE=$(shell echo PQCLEAN_$(subst -,,$(notdir $(SCHEME))) | tr a-z A-Z) \
|
|
-iquote "./common/" \
|
|
-iquote "$(SCHEME)/clean/" \
|
|
-o bin/sanitizer_$(subst /,_,$(SCHEME)) \
|
|
$(COMMON_FILES) \
|
|
$(RANDOM_IMPL) \
|
|
$(SCHEME)/clean/*.c \
|
|
$<
|
|
|
|
.PHONY: sanitizer
|
|
sanitizer: bin/sanitizer_$(subst /,_,$(SCHEME))
|
|
|
|
bin/shared_$(subst /,_,$(SCHEME))_clean.so: $(wildcard $(SCHEME)/clean/*.c) | require_scheme
|
|
mkdir -p bin
|
|
$(CC) $(CFLAGS) \
|
|
-DPQCLEAN_NAMESPACE=$(shell echo PQCLEAN_$(subst -,,$(notdir $(SCHEME))) | tr a-z A-Z) \
|
|
-nostdlib \
|
|
-shared \
|
|
-fPIC \
|
|
-iquote "./common/" \
|
|
-iquote "$(SCHEME)/clean/" \
|
|
-o $@ \
|
|
$^
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
rm -rf bin
|
|
|
|
.PHONY: format
|
|
format:
|
|
astyle --project crypto_*/*/*/*.[ch] common/*.[ch]
|
|
|
|
.PHONY: check-format
|
|
check-format:
|
|
astyle --dry-run --project crypto_*/*/*/*.[ch] common/*.[ch] | grep Formatted && exit 1 || exit 0
|
|
|
|
.PHONY: tidy
|
|
tidy:
|
|
$(MAKE) do-tidy
|
|
|
|
do-tidy: require_scheme
|
|
clang-tidy \
|
|
-quiet $(.TIDY_FIX) \
|
|
$(SCHEME)/clean/*.c \
|
|
common/*.c \
|
|
-- -iquote "common/" -iquote "$(SCHEME)/clean"
|
|
|
|
.PHONY: apply-tidy
|
|
apply-tidy:
|
|
$(MAKE) do-tidy .TIDY_FIX=-fix
|
|
|
|
# The below should be outlined with ts=8
|
|
.PHONY: help
|
|
help:
|
|
@echo "make test-all Run all tests"
|
|
@echo "make functest SCHEME=scheme Build functional tests for SCHEME"
|
|
@echo "make functest-all Build functional tests for all schemes"
|
|
@echo "make run-functest SCHEME=scheme Run functional tests for SCHEME"
|
|
@echo "make run-functest-all Run all functests"
|
|
@echo "make run-sanitizer-all Run address sanitizer for all schemes"
|
|
@echo "make run-valgrind SCHEME=scheme Run valgrind checks for SCHEME"
|
|
@echo "make run-valgrind-all Run valgrind checks all schemes"
|
|
@echo "make clean Clean up the bin/ folder"
|
|
@echo "make format Automatically formats all the source code"
|
|
@echo "make tidy SCHEME=scheme Runs the clang-tidy linter against SCHEME"
|
|
@echo "make apply-tidy SCHEME=scheme Tries to automatically fix the issues found by clang-tidy in SCHEME"
|
|
@echo "make tidy-all Runs the clang-tidy linter against all schemes"
|
|
@echo "make apply-tidy-all Tidy up all schemes"
|
|
@echo "make help Displays this message"
|
|
|
|
.PHONY: functest-all
|
|
functest-all:
|
|
@for scheme in $(ALL_SCHEMES); do \
|
|
$(MAKE) functest SCHEME=$$scheme || exit 1; \
|
|
done
|
|
|
|
.PHONY: sanitizer-all
|
|
sanitizer-all:
|
|
@for scheme in $(ALL_SCHEMES); do \
|
|
$(MAKE) sanitizer SCHEME=$$scheme || exit 1; \
|
|
done
|
|
|
|
.PHONY: run-valgrind-all
|
|
run-valgrind-all:
|
|
@for scheme in $(ALL_SCHEMES); do \
|
|
$(MAKE) run-valgrind SCHEME=$$scheme || exit 1; \
|
|
done
|
|
|
|
.PHONY: run-functest-all
|
|
run-functest-all: functest-all
|
|
@for functest in $$(find bin/ -maxdepth 1 -name 'functest_*' -not -type d) ; do \
|
|
echo ./$$functest ; \
|
|
./$$functest || exit 1 ;\
|
|
done
|
|
@echo Tests completed
|
|
|
|
.PHONY: run-sanitizer-all
|
|
run-sanitizer-all: sanitizer-all
|
|
@for sanitizer in $$(find bin/ -maxdepth 1 -name 'sanitizer_*' -not -type d) ; do \
|
|
echo ./$$sanitizer ; \
|
|
./$$sanitizer || exit 1 ;\
|
|
done
|
|
@echo Tests completed
|
|
|
|
.PHONY: test-all
|
|
test-all: run-functest-all run-valgrind-all run-sanitizer-all
|
|
|
|
.PHONY: tidy-all
|
|
tidy-all:
|
|
@for scheme in $(ALL_SCHEMES); do \
|
|
$(MAKE) tidy SCHEME=$$scheme || exit 1 ; \
|
|
done
|
|
|
|
.PHONY: apply-tidy-all
|
|
apply-tidy-all:
|
|
@for scheme in $(ALL_SCHEMES); do \
|
|
$(MAKE) apply-tidy SCHEME=$$scheme; \
|
|
done
|