Debian Codegraph @

others/mbedtls/tf-psa-crypto/drivers/pqcp/mldsa-native/examples/basic_deterministic/Makefile

raw
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
4
5 .PHONY: build run clean
6 .DEFAULT_GOAL := all
7
8 CC ?= gcc
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
43 # When called from the root Makefile, CROSS_PREFIX has already been added here
44 ifeq (,$(findstring $(CROSS_PREFIX),$(CC)))
45 CC := $(CROSS_PREFIX)$(CC)
46 endif
47
48 # Part A:
49 #
50 # mldsa-native source and header files
51 #
52 # If you are not concerned about minimizing for a specific backend,
53 # you can just include _all_ source files into your build.
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/src/*.c \
60 mldsa_native/src/**/*.c \
61 mldsa_native/src/**/**/*.c \
62 mldsa_native/src/**/**/**/*.c)
63
64 INC=-Imldsa_native
65
66 # Part B:
67 #
68 # Your application source code
69 APP_SOURCE=$(wildcard *.c)
70
71 ALL_SOURCE=$(MLD_SOURCE) $(APP_SOURCE)
72
73 BUILD_DIR=build
74 BIN=test_binary
75
76 BINARY_NAME_FULL_44=$(BUILD_DIR)/$(BIN)44
77 BINARY_NAME_FULL_65=$(BUILD_DIR)/$(BIN)65
78 BINARY_NAME_FULL_87=$(BUILD_DIR)/$(BIN)87
79 BINARIES_FULL=$(BINARY_NAME_FULL_44) $(BINARY_NAME_FULL_65) $(BINARY_NAME_FULL_87)
80
81 $(BINARY_NAME_FULL_44): CFLAGS += -DMLD_CONFIG_PARAMETER_SET=44
82 $(BINARY_NAME_FULL_65): CFLAGS += -DMLD_CONFIG_PARAMETER_SET=65
83 $(BINARY_NAME_FULL_87): CFLAGS += -DMLD_CONFIG_PARAMETER_SET=87
84
85 $(BINARIES_FULL): $(ALL_SOURCE)
86 echo "$@"
87 mkdir -p $(BUILD_DIR)
88 $(CC) $(CFLAGS) $(INC) $^ -o $@
89
90 all: build
91
92 build: $(BINARIES_FULL)
93
94 run: $(BINARIES_FULL)
95 $(EXEC_WRAPPER) ./$(BINARY_NAME_FULL_44)
96 $(EXEC_WRAPPER) ./$(BINARY_NAME_FULL_65)
97 $(EXEC_WRAPPER) ./$(BINARY_NAME_FULL_87)
98
99 clean:
100 rm -rf $(BUILD_DIR)