Skip to content

Commit 334c7a2

Browse files
authored
Merge pull request #390 from pq-code-package/shasum
Makefile: Detect suitable sha256sum tool and set -o pipefail
2 parents 5070d3b + 35b3e1e commit 334c7a2

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,19 @@
1717
build test all \
1818
clean quickcheck check-defined-CYCLES
1919

20+
SHELL := /bin/bash
2021
.DEFAULT_GOAL := build
22+
2123
all: build
2224

2325
W := $(EXEC_WRAPPER)
2426

27+
# Detect available SHA256 command
28+
SHA256SUM := $(shell command -v shasum >/dev/null 2>&1 && echo "shasum -a 256" || (command -v sha256sum >/dev/null 2>&1 && echo "sha256sum" || echo ""))
29+
ifeq ($(SHA256SUM),)
30+
$(error Neither 'shasum' nor 'sha256sum' found. Please install one of these tools.)
31+
endif
32+
2533
include test/mk/config.mk
2634
include test/mk/components.mk
2735
include test/mk/rules.mk
@@ -35,11 +43,11 @@ test: run_kat run_func run_acvp
3543
$(Q)echo " Everything checks fine!"
3644

3745
run_kat_44: kat_44
38-
$(W) $(MLDSA44_DIR)/bin/gen_KAT44 | sha256sum | cut -d " " -f 1 | xargs ./META.sh ML-DSA-44 kat-sha256
46+
set -o pipefail; $(W) $(MLDSA44_DIR)/bin/gen_KAT44 | $(SHA256SUM) | cut -d " " -f 1 | xargs ./META.sh ML-DSA-44 kat-sha256
3947
run_kat_65: kat_65
40-
$(W) $(MLDSA65_DIR)/bin/gen_KAT65 | sha256sum | cut -d " " -f 1 | xargs ./META.sh ML-DSA-65 kat-sha256
48+
set -o pipefail; $(W) $(MLDSA65_DIR)/bin/gen_KAT65 | $(SHA256SUM) | cut -d " " -f 1 | xargs ./META.sh ML-DSA-65 kat-sha256
4149
run_kat_87: kat_87
42-
$(W) $(MLDSA87_DIR)/bin/gen_KAT87 | sha256sum | cut -d " " -f 1 | xargs ./META.sh ML-DSA-87 kat-sha256
50+
set -o pipefail; $(W) $(MLDSA87_DIR)/bin/gen_KAT87 | $(SHA256SUM) | cut -d " " -f 1 | xargs ./META.sh ML-DSA-87 kat-sha256
4351
run_kat: run_kat_44 run_kat_65 run_kat_87
4452

4553
run_func_44: func_44

0 commit comments

Comments
 (0)