1- # (SPDX-License-Identifier: CC-BY-4.0)
1+ # Copyright (c) The mlkem-native project authors
2+ # Copyright (c) The mldsa-native project authors
3+ # SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
24
3- .PHONY : build run clean size
5+ .PHONY : build run clean
46.DEFAULT_GOAL := all
57
6- # Append cross-prefix for cross compilation
7- # Remove or ignore for native builds
88CC ?= gcc
9- SIZE ?= size
9+
10+ # Adjust CFLAGS if needed
11+ CFLAGS := \
12+ -Wall \
13+ -Wextra \
14+ -Werror=unused-result \
15+ -Wpedantic \
16+ -Werror \
17+ -Wmissing-prototypes \
18+ -Wshadow \
19+ -Wpointer-arith \
20+ -Wredundant-decls \
21+ -Wconversion \
22+ -Wsign-conversion \
23+ -Wno-long-long \
24+ -Wno-unknown-pragmas \
25+ -Wno-unused-command-line-argument \
26+ -O3 \
27+ -fomit-frame-pointer \
28+ -std=c99 \
29+ -pedantic \
30+ -MMD \
31+ $(CFLAGS )
32+
33+ # If you want to use the native backends, the compiler needs to know about
34+ # the target architecture. Here, we import the default host detection from
35+ # mldsa-native's tests, but you can write your own or specialize accordingly.
36+ AUTO ?= 1
37+ include auto.mk
38+
39+ # The following only concerns the cross-compilation tests.
40+ # You can likely ignore the following for your application.
41+ #
42+ # Append cross-prefix for cross compilation
1043# When called from the root Makefile, CROSS_PREFIX has already been added here
1144ifeq (,$(findstring $(CROSS_PREFIX ) ,$(CC ) ) )
1245CC := $(CROSS_PREFIX )$(CC )
1346endif
1447
15- ifeq (,$(findstring $(CROSS_PREFIX ) ,$(SIZE ) ) )
16- SIZE := $(CROSS_PREFIX )$(SIZE )
17- endif
18-
1948# Part A:
2049#
2150# mldsa-native source and header files
2251#
2352# If you are not concerned about minimizing for a specific backend,
2453# you can just include _all_ source files into your build.
25- MLD_SOURCE =$(wildcard \
26- ../../mldsa/* .c \
27- ../../mldsa/** /* .c \
28- ../../mldsa/** /** /* .c \
29- ../../mldsa/** /** /** /* .c)
54+ #
55+ # In this example, we compile the individual mldsa-native source files directly.
56+ # Alternatively, you can compile the 'monobuild' source file mldsa_native.c.
57+ # See examples/monolithic_build for that.
58+ MLD_SOURCE =$(wildcard \
59+ mldsa_native/mldsa/* .c \
60+ mldsa_native/mldsa/** /* .c \
61+ mldsa_native/mldsa/** /** /* .c \
62+ mldsa_native/mldsa/** /** /** /* .c)
3063
3164# Part B:
3265#
@@ -50,29 +83,12 @@ ALL_SOURCE=$(MLD_SOURCE) $(RNG_SOURCE) $(APP_SOURCE)
5083BUILD_DIR =build
5184BIN =test_binary
5285
53- CFLAGS := \
54- -Wall \
55- -Wextra \
56- -Werror \
57- -Wmissing-prototypes \
58- -Wshadow \
59- -Werror \
60- -Wpointer-arith \
61- -Wredundant-decls \
62- -Wconversion \
63- -Wsign-conversion \
64- -Wno-long-long \
65- -Wno-unknown-pragmas \
66- -Wno-unused-command-line-argument \
67- -fomit-frame-pointer \
68- -std=c99 \
69- -pedantic \
70- -MMD \
71- -O3 \
72- $(CFLAGS )
86+ #
87+ # Configuration adjustments
88+ #
7389
74- # Use the default namespace prefix from config.h
75- # CFLAGS += -DMLD_CONFIG_NAMESPACE_PREFIX=mldsa
90+ # Pick prefix
91+ CFLAGS += -DMLD_CONFIG_NAMESPACE_PREFIX=mldsa
7692
7793BINARY_NAME_FULL_44 =$(BUILD_DIR ) /$(BIN ) 44
7894BINARY_NAME_FULL_65 =$(BUILD_DIR ) /$(BIN ) 65
@@ -88,7 +104,7 @@ $(BINARIES_FULL): $(ALL_SOURCE)
88104 mkdir -p $(BUILD_DIR )
89105 $(CC ) $(CFLAGS ) $^ -o $@
90106
91- all : build size
107+ all : build
92108
93109build : $(BINARIES_FULL )
94110
@@ -97,13 +113,5 @@ run: $(BINARIES_FULL)
97113 $(EXEC_WRAPPER ) ./$(BINARY_NAME_FULL_65 )
98114 $(EXEC_WRAPPER ) ./$(BINARY_NAME_FULL_87 )
99115
100- size : build
101- @echo " === Size info for $( BINARY_NAME_FULL_44) ==="
102- @$(SIZE ) $(BINARY_NAME_FULL_44 )
103- @echo " === Size info for $( BINARY_NAME_FULL_65) ==="
104- @$(SIZE ) $(BINARY_NAME_FULL_65 )
105- @echo " === Size info for $( BINARY_NAME_FULL_87) ==="
106- @$(SIZE ) $(BINARY_NAME_FULL_87 )
107-
108116clean :
109117 rm -rf $(BUILD_DIR )
0 commit comments