2019-01-15 15:34:01 +00:00
|
|
|
# This -Wall was supported by the European Commission through the ERC Starting Grant 805031 (EPOQUE)
|
2019-01-23 11:11:09 +00:00
|
|
|
CFLAGS=-Wall -Wextra -Wpedantic -Werror -std=c99 -g $(EXTRAFLAGS)
|
2019-01-15 15:09:32 +00:00
|
|
|
|
2019-01-16 12:02:57 +00:00
|
|
|
ALL_SCHEMES=$(filter-out crypto_%.c, $(wildcard crypto_*/*))
|
2019-02-06 16:20:31 +00:00
|
|
|
COMMON_FILES = common/fips202.c common/sha2.c
|
|
|
|
RANDOM_IMPL = common/randombytes.c
|
2019-01-16 12:52:53 +00:00
|
|
|
|
|
|
|
default: help
|
|
|
|
|
|
|
|
.PHONY: require_scheme
|
|
|
|
require_scheme:
|
2019-01-17 16:44:55 +00:00
|
|
|
# assumes a SCHEME variable; e.g. make functest SCHEME=crypto_kem/kyber768
|
2019-01-16 12:52:53 +00:00
|
|
|
ifndef SCHEME
|
|
|
|
$(error The SCHEME variable is not set. Example: SCHEME=crypto_kem/kyber768)
|
|
|
|
endif
|
|
|
|
|
2019-01-17 16:44:55 +00:00
|
|
|
bin/functest_$(subst /,_,$(SCHEME)): test/$(dir $(SCHEME))functest.c $(wildcard $(SCHEME)/clean/*.c) $(wildcard $(SCHEME)/clean/*.h) | require_scheme
|
2019-01-15 15:03:38 +00:00
|
|
|
mkdir -p bin
|
2019-01-16 07:18:33 +00:00
|
|
|
$(CC) $(CFLAGS) \
|
2019-01-22 16:37:58 +00:00
|
|
|
-DPQCLEAN_NAMESPACE=$(shell echo PQCLEAN_$(subst -,,$(notdir $(SCHEME))) | tr a-z A-Z) \
|
2019-01-16 07:18:33 +00:00
|
|
|
-iquote "./common/" \
|
|
|
|
-iquote "$(SCHEME)/clean/" \
|
|
|
|
-o bin/functest_$(subst /,_,$(SCHEME)) \
|
2019-02-07 08:59:28 +00:00
|
|
|
$(SCHEME)/clean/*.c \
|
2019-02-06 16:20:31 +00:00
|
|
|
$(COMMON_FILES) \
|
|
|
|
$(RANDOM_IMPL) \
|
2019-01-15 15:22:15 +00:00
|
|
|
$<
|
2019-01-15 15:03:38 +00:00
|
|
|
|
2019-01-16 12:02:35 +00:00
|
|
|
.PHONY: functest
|
|
|
|
functest: bin/functest_$(subst /,_,$(SCHEME))
|
|
|
|
|
|
|
|
.PHONY: run-functest
|
|
|
|
run-functest: bin/functest_$(subst /,_,$(SCHEME))
|
|
|
|
./$<
|
|
|
|
|
2019-01-22 15:56:22 +00:00
|
|
|
.PHONY: run-valgrind
|
|
|
|
run-valgrind: bin/functest_$(subst /,_,$(SCHEME))
|
2019-01-23 11:20:23 +00:00
|
|
|
ifeq ($(shell uname -s),Linux)
|
2019-01-22 15:56:22 +00:00
|
|
|
valgrind --leak-check=full --error-exitcode=1 $<
|
2019-01-23 11:20:23 +00:00
|
|
|
else
|
2019-01-23 11:36:23 +00:00
|
|
|
@echo "Valgrind not supported on this platform."
|
2019-01-23 11:20:23 +00:00
|
|
|
endif
|
2019-01-22 15:56:22 +00:00
|
|
|
|
2019-01-22 16:22:18 +00:00
|
|
|
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 \
|
2019-01-23 09:32:13 +00:00
|
|
|
-DPQCLEAN_NAMESPACE=$(shell echo PQCLEAN_$(subst -,,$(notdir $(SCHEME))) | tr a-z A-Z) \
|
2019-01-22 16:22:18 +00:00
|
|
|
-iquote "./common/" \
|
|
|
|
-iquote "$(SCHEME)/clean/" \
|
|
|
|
-o bin/sanitizer_$(subst /,_,$(SCHEME)) \
|
2019-02-06 16:20:31 +00:00
|
|
|
$(COMMON_FILES) \
|
|
|
|
$(RANDOM_IMPL) \
|
2019-01-22 16:22:18 +00:00
|
|
|
$(SCHEME)/clean/*.c \
|
|
|
|
$<
|
|
|
|
|
|
|
|
.PHONY: sanitizer
|
|
|
|
sanitizer: bin/sanitizer_$(subst /,_,$(SCHEME))
|
2019-01-22 15:56:22 +00:00
|
|
|
|
2019-01-17 16:44:55 +00:00
|
|
|
bin/testvectors_$(subst /,_,$(SCHEME)): test/$(dir $(SCHEME))testvectors.c $(wildcard $(SCHEME)/clean/*.c) $(wildcard $(SCHEME)/clean/*.h) | require_scheme
|
2019-01-16 13:21:52 +00:00
|
|
|
mkdir -p bin
|
|
|
|
$(CC) $(CFLAGS) \
|
2019-01-22 16:37:58 +00:00
|
|
|
-DPQCLEAN_NAMESPACE=$(shell echo PQCLEAN_$(subst -,,$(notdir $(SCHEME))) | tr a-z A-Z) \
|
2019-01-16 13:21:52 +00:00
|
|
|
-iquote "./common/" \
|
|
|
|
-iquote "$(SCHEME)/clean/" \
|
|
|
|
-o bin/testvectors_$(subst /,_,$(SCHEME)) \
|
2019-02-06 16:20:31 +00:00
|
|
|
$(COMMON_FILES) \
|
|
|
|
common/notrandombytes.c \
|
2019-01-16 13:21:52 +00:00
|
|
|
$(SCHEME)/clean/*.c \
|
|
|
|
$<
|
|
|
|
|
|
|
|
.PHONY: testvectors
|
|
|
|
testvectors: bin/testvectors_$(subst /,_,$(SCHEME))
|
|
|
|
|
2019-01-18 12:41:07 +00:00
|
|
|
bin/shared_$(subst /,_,$(SCHEME))_clean.so: $(wildcard $(SCHEME)/clean/*.c) | require_scheme
|
|
|
|
mkdir -p bin
|
2019-01-23 11:36:23 +00:00
|
|
|
$(CC) $(CFLAGS) \
|
2019-01-22 16:37:58 +00:00
|
|
|
-DPQCLEAN_NAMESPACE=$(shell echo PQCLEAN_$(subst -,,$(notdir $(SCHEME))) | tr a-z A-Z) \
|
2019-01-23 10:52:53 +00:00
|
|
|
-nostdlib \
|
2019-01-18 12:41:07 +00:00
|
|
|
-shared \
|
|
|
|
-fPIC \
|
|
|
|
-iquote "./common/" \
|
|
|
|
-iquote "$(SCHEME)/clean/" \
|
|
|
|
-o $@ \
|
|
|
|
$^
|
|
|
|
|
2019-01-15 15:03:38 +00:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
rm -rf bin
|
2019-01-15 15:34:01 +00:00
|
|
|
|
2019-01-16 07:18:33 +00:00
|
|
|
.PHONY: format
|
2019-01-15 15:34:01 +00:00
|
|
|
format:
|
|
|
|
find . -iname *.h -o -iname *.c | xargs clang-format -i -style=file
|
2019-01-16 07:18:33 +00:00
|
|
|
|
2019-01-16 12:52:53 +00:00
|
|
|
.PHONY: check-format
|
|
|
|
check-format:
|
|
|
|
@for src in $(SOURCES) ; do \
|
|
|
|
var=`clang-format "$(SRC_DIR)/$$src" | diff "$(SRC_DIR)/$$src" - | wc -l` ; \
|
|
|
|
if [ $$var -ne 0 ] ; then \
|
|
|
|
echo "$$src does not respect the coding style (diff: $$var lines)" ; \
|
|
|
|
exit 1 ; \
|
|
|
|
fi ; \
|
|
|
|
done
|
|
|
|
@echo "Style check passed"
|
|
|
|
|
2019-01-16 07:18:33 +00:00
|
|
|
.PHONY: tidy
|
2019-01-16 12:52:53 +00:00
|
|
|
tidy:
|
|
|
|
$(MAKE) do-tidy
|
|
|
|
|
|
|
|
do-tidy: require_scheme
|
2019-01-16 07:18:33 +00:00
|
|
|
clang-tidy \
|
2019-01-16 12:52:53 +00:00
|
|
|
-quiet $(.TIDY_FIX) \
|
2019-01-16 07:18:33 +00:00
|
|
|
$(SCHEME)/clean/*.c \
|
|
|
|
common/*.c \
|
|
|
|
-- -iquote "common/" -iquote "$(SCHEME)/clean"
|
|
|
|
|
2019-01-16 12:52:53 +00:00
|
|
|
.PHONY: apply-tidy
|
|
|
|
apply-tidy:
|
|
|
|
$(MAKE) do-tidy .TIDY_FIX=-fix
|
2019-01-16 07:18:33 +00:00
|
|
|
|
2019-01-16 12:52:53 +00:00
|
|
|
# The below should be outlined with ts=8
|
2019-01-16 07:18:33 +00:00
|
|
|
.PHONY: help
|
|
|
|
help:
|
2019-01-16 12:02:57 +00:00
|
|
|
@echo "make test-all Run all tests"
|
2019-01-16 12:52:53 +00:00
|
|
|
@echo "make functest SCHEME=scheme Build functional tests for SCHEME"
|
2019-01-16 12:02:57 +00:00
|
|
|
@echo "make functest-all Build functional tests for all schemes"
|
2019-01-16 12:52:53 +00:00
|
|
|
@echo "make run-functest SCHEME=scheme Run functional tests for SCHEME"
|
|
|
|
@echo "make run-functest-all Run all functests"
|
2019-01-22 14:05:48 +00:00
|
|
|
@echo "make run-testvectors SCHEME=scheme Run testvector checks for SCHEME"
|
|
|
|
@echo "make run-testvectors-all Run all testvector checks"
|
2019-01-22 16:22:18 +00:00
|
|
|
@echo "make run-sanitizer-all Run address sanitizer for all schemes"
|
2019-01-22 14:05:48 +00:00
|
|
|
@echo "make run-symbol-namespace SCHEME=scheme Run symbol namespace checks for SCHEME"
|
|
|
|
@echo "make run-symbol-namespace-all Run all symbol namespace checks"
|
2019-01-22 15:56:22 +00:00
|
|
|
@echo "make run-valgrind SCHEME=scheme Run valgrind checks for SCHEME"
|
|
|
|
@echo "make run-valgrind-all Run valgrind checks all schemes"
|
2019-01-16 12:52:53 +00:00
|
|
|
@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"
|
2019-01-16 12:02:35 +00:00
|
|
|
|
2019-01-16 12:52:53 +00:00
|
|
|
.PHONY: functest-all
|
2019-01-16 12:02:57 +00:00
|
|
|
functest-all:
|
|
|
|
@for scheme in $(ALL_SCHEMES); do \
|
|
|
|
$(MAKE) functest SCHEME=$$scheme || exit 1; \
|
|
|
|
done
|
2019-01-16 12:02:35 +00:00
|
|
|
|
2019-01-22 16:22:18 +00:00
|
|
|
.PHONY: sanitizer-all
|
|
|
|
sanitizer-all:
|
|
|
|
@for scheme in $(ALL_SCHEMES); do \
|
|
|
|
$(MAKE) sanitizer SCHEME=$$scheme || exit 1; \
|
|
|
|
done
|
|
|
|
|
2019-01-22 15:56:22 +00:00
|
|
|
.PHONY: run-valgrind-all
|
|
|
|
run-valgrind-all:
|
|
|
|
@for scheme in $(ALL_SCHEMES); do \
|
|
|
|
$(MAKE) run-valgrind SCHEME=$$scheme || exit 1; \
|
|
|
|
done
|
|
|
|
|
2019-01-22 14:05:48 +00:00
|
|
|
.PHONY: run-testvectors
|
|
|
|
run-testvectors: test/check_testvectors.py | require_scheme
|
2019-01-23 10:27:43 +00:00
|
|
|
python3 test/check_testvectors.py $(SCHEME) || exit 1; \
|
2019-01-22 14:05:48 +00:00
|
|
|
|
|
|
|
.PHONY: run-symbol-namespace
|
|
|
|
run-symbol-namespace: test/check_symbol_namespace.py | require_scheme
|
2019-01-23 10:27:43 +00:00
|
|
|
python3 test/check_symbol_namespace.py $(SCHEME) || exit 1; \
|
2019-01-22 14:05:48 +00:00
|
|
|
|
|
|
|
.PHONY: run-testvectors-all
|
|
|
|
run-testvectors-all: test/check_testvectors.py
|
2019-01-23 11:36:23 +00:00
|
|
|
@for scheme in $(ALL_SCHEMES); do \
|
2019-01-23 10:27:43 +00:00
|
|
|
python3 test/check_testvectors.py $$scheme || exit 1; \
|
2019-01-22 14:05:48 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
.PHONY: run-symbol-namespace-all
|
|
|
|
run-symbol-namespace-all:
|
|
|
|
@for scheme in $(ALL_SCHEMES); do \
|
2019-01-23 10:27:43 +00:00
|
|
|
python3 test/check_symbol_namespace.py $$scheme || exit 1; \
|
2019-01-22 14:05:48 +00:00
|
|
|
done
|
|
|
|
|
2019-01-16 12:52:53 +00:00
|
|
|
.PHONY: run-functest-all
|
2019-01-16 12:02:57 +00:00
|
|
|
run-functest-all: functest-all
|
2019-01-23 11:11:09 +00:00
|
|
|
@for functest in $$(find bin/ -maxdepth 1 -name 'functest_*' -not -type d) ; do \
|
2019-01-16 12:52:53 +00:00
|
|
|
echo ./$$functest ; \
|
2019-01-16 12:02:57 +00:00
|
|
|
./$$functest || exit 1 ;\
|
2019-01-16 12:52:53 +00:00
|
|
|
done
|
|
|
|
@echo Tests completed
|
2019-01-16 12:02:35 +00:00
|
|
|
|
2019-01-22 16:22:18 +00:00
|
|
|
.PHONY: run-sanitizer-all
|
|
|
|
run-sanitizer-all: sanitizer-all
|
2019-01-23 11:11:09 +00:00
|
|
|
@for sanitizer in $$(find bin/ -maxdepth 1 -name 'sanitizer_*' -not -type d) ; do \
|
2019-01-22 16:22:18 +00:00
|
|
|
echo ./$$sanitizer ; \
|
|
|
|
./$$sanitizer || exit 1 ;\
|
|
|
|
done
|
|
|
|
@echo Tests completed
|
|
|
|
|
2019-01-29 16:45:26 +00:00
|
|
|
.PHONY: check-license-files
|
|
|
|
check-license-files:
|
|
|
|
@echo Checking that LICENSE files exist
|
|
|
|
@for scheme in $(ALL_SCHEMES); do \
|
|
|
|
echo Checking for $$scheme/clean/LICENSE;\
|
|
|
|
test -f $$scheme/clean/LICENSE || exit 1 ;\
|
|
|
|
done
|
|
|
|
|
2019-01-16 12:02:35 +00:00
|
|
|
.PHONY: test-all
|
2019-01-22 16:22:18 +00:00
|
|
|
test-all: run-functest-all run-valgrind-all run-sanitizer-all run-testvectors-all run-symbol-namespace-all
|
2019-01-16 12:02:35 +00:00
|
|
|
|
|
|
|
.PHONY: tidy-all
|
|
|
|
tidy-all:
|
2019-01-16 12:52:53 +00:00
|
|
|
@for scheme in $(ALL_SCHEMES); do \
|
2019-01-16 12:02:57 +00:00
|
|
|
$(MAKE) tidy SCHEME=$$scheme || exit 1 ; \
|
2019-01-16 12:52:53 +00:00
|
|
|
done
|
2019-01-16 12:02:35 +00:00
|
|
|
|
2019-01-16 12:52:53 +00:00
|
|
|
.PHONY: apply-tidy-all
|
2019-01-16 12:02:35 +00:00
|
|
|
apply-tidy-all:
|
2019-01-16 12:52:53 +00:00
|
|
|
@for scheme in $(ALL_SCHEMES); do \
|
|
|
|
$(MAKE) apply-tidy SCHEME=$$scheme; \
|
|
|
|
done
|
2019-01-29 16:25:29 +00:00
|
|
|
|
|
|
|
.PHONY: check-metadata
|
|
|
|
check-metadata:
|
2019-01-29 16:38:19 +00:00
|
|
|
python3 test/check_metadata.py
|