Valerio Setti | 4362aae | 2024-05-09 09:15:39 +0200 | [diff] [blame] | 1 | CFLAGS += -Wall -Werror -std=c99 -D_XOPEN_SOURCE=1 -D_POSIX_C_SOURCE=200809L |
Valerio Setti | 4f4ade9 | 2024-05-03 17:28:04 +0200 | [diff] [blame] | 2 | |
| 3 | ifeq ($(DEBUG),1) |
Valerio Setti | c98f8ab | 2024-05-10 15:53:40 +0200 | [diff] [blame] | 4 | CFLAGS += -DDEBUG -O0 -g |
Valerio Setti | 4f4ade9 | 2024-05-03 17:28:04 +0200 | [diff] [blame] | 5 | endif |
| 6 | |
Valerio Setti | cd89c1f | 2024-05-10 11:21:04 +0200 | [diff] [blame] | 7 | LIBPSACLIENT := -Llibpsaclient/ -lmbedcrypto -lmbedx509 -lmbedtls |
| 8 | LIBPSASERVER := -Llibpsaserver/ -lmbedcrypto |
Valerio Setti | 4f4ade9 | 2024-05-03 17:28:04 +0200 | [diff] [blame] | 9 | |
Valerio Setti | cd89c1f | 2024-05-10 11:21:04 +0200 | [diff] [blame] | 10 | MBEDTLS_ROOT_PATH = ../../.. |
Ronald Cron | c7e9e36 | 2024-06-10 09:41:49 +0200 | [diff] [blame] | 11 | COMMON_INCLUDE := -I./include -I$(MBEDTLS_ROOT_PATH)/include -I$(MBEDTLS_ROOT_PATH)/tf-psa-crypto/include |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 12 | |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 13 | GENERATED_H_FILES = include/psa_manifest/manifest.h \ |
| 14 | include/psa_manifest/pid.h \ |
| 15 | include/psa_manifest/sid.h |
| 16 | |
Valerio Setti | 5beb236 | 2024-06-24 13:13:17 +0200 | [diff] [blame] | 17 | PSA_CLIENT_COMMON_SRC = src/psa_ff_client.c \ |
Tom Cosgrove | 3ebb880 | 2024-05-29 10:29:39 +0100 | [diff] [blame] | 18 | src/psa_sim_crypto_client.c \ |
| 19 | src/psa_sim_serialise.c |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 20 | |
Valerio Setti | 5beb236 | 2024-06-24 13:13:17 +0200 | [diff] [blame] | 21 | PSA_CLIENT_BASE_SRC = $(PSA_CLIENT_COMMON_SRC) src/client.c |
| 22 | |
| 23 | PSA_CLIENT_FULL_SRC = $(PSA_CLIENT_COMMON_SRC) \ |
| 24 | $(wildcard src/aut_*.c) |
| 25 | |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 26 | PARTITION_SERVER_BOOTSTRAP = src/psa_ff_bootstrap_TEST_PARTITION.c |
| 27 | |
| 28 | PSA_SERVER_SRC = $(PARTITION_SERVER_BOOTSTRAP) \ |
Tom Cosgrove | 3ebb880 | 2024-05-29 10:29:39 +0100 | [diff] [blame] | 29 | src/psa_ff_server.c \ |
| 30 | src/psa_sim_crypto_server.c \ |
| 31 | src/psa_sim_serialise.c |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 32 | |
Valerio Setti | cd89c1f | 2024-05-10 11:21:04 +0200 | [diff] [blame] | 33 | .PHONY: all clean libpsaclient libpsaserver |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 34 | |
Valerio Setti | f98635c | 2024-06-10 20:13:13 +0200 | [diff] [blame] | 35 | all: |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 36 | |
Valerio Setti | 87d99fb | 2024-05-14 10:57:35 +0200 | [diff] [blame] | 37 | test/seedfile: |
| 38 | dd if=/dev/urandom of=./test/seedfile bs=64 count=1 |
| 39 | |
Valerio Setti | 5beb236 | 2024-06-24 13:13:17 +0200 | [diff] [blame] | 40 | test/psa_client_base: $(PSA_CLIENT_BASE_SRC) $(GENERATED_H_FILES) |
| 41 | $(CC) $(COMMON_INCLUDE) $(CFLAGS) $(PSA_CLIENT_BASE_SRC) $(LIBPSACLIENT) $(LDFLAGS) -o $@ |
| 42 | |
| 43 | test/psa_client_full: $(PSA_CLIENT_FULL_SRC) $(GENERATED_H_FILES) |
| 44 | $(CC) $(COMMON_INCLUDE) $(CFLAGS) $(PSA_CLIENT_FULL_SRC) $(LIBPSACLIENT) $(LDFLAGS) -o $@ |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 45 | |
Valerio Setti | 87d99fb | 2024-05-14 10:57:35 +0200 | [diff] [blame] | 46 | test/psa_partition: $(PSA_SERVER_SRC) $(GENERATED_H_FILES) test/seedfile |
Valerio Setti | cd89c1f | 2024-05-10 11:21:04 +0200 | [diff] [blame] | 47 | $(CC) $(COMMON_INCLUDE) $(CFLAGS) $(PSA_SERVER_SRC) $(LIBPSASERVER) $(LDFLAGS) -o $@ |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 48 | |
| 49 | $(PARTITION_SERVER_BOOTSTRAP) $(GENERATED_H_FILES): src/manifest.json src/server.c |
| 50 | tools/psa_autogen.py src/manifest.json |
Valerio Setti | 4f4ade9 | 2024-05-03 17:28:04 +0200 | [diff] [blame] | 51 | |
Valerio Setti | cd89c1f | 2024-05-10 11:21:04 +0200 | [diff] [blame] | 52 | # Build MbedTLS libraries (crypto, x509 and tls) and copy them locally to |
| 53 | # build client/server applications. |
| 54 | # |
| 55 | # Note: these rules assume that mbedtls_config.h is already configured by all.sh. |
| 56 | # If not using all.sh then the user must do it manually. |
| 57 | libpsaclient libpsaserver: |
| 58 | $(MAKE) -C $(MBEDTLS_ROOT_PATH)/library CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" libmbedcrypto.a libmbedx509.a libmbedtls.a |
| 59 | mkdir -p $@ |
| 60 | cp $(MBEDTLS_ROOT_PATH)/library/libmbed*.a $@/ |
| 61 | $(MAKE) -C $(MBEDTLS_ROOT_PATH) clean |
| 62 | |
Valerio Setti | 4f4ade9 | 2024-05-03 17:28:04 +0200 | [diff] [blame] | 63 | clean: |
Valerio Setti | 5beb236 | 2024-06-24 13:13:17 +0200 | [diff] [blame] | 64 | rm -f test/psa_client_base test/psa_client_full test/psa_partition |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 65 | rm -f $(PARTITION_SERVER_BOOTSTRAP) |
Valerio Setti | cd89c1f | 2024-05-10 11:21:04 +0200 | [diff] [blame] | 66 | rm -rf libpsaclient libpsaserver |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 67 | rm -rf include/psa_manifest |
| 68 | rm -f test/psa_service_* test/psa_notify_* |
Valerio Setti | 1f3c99c | 2024-05-15 07:29:51 +0200 | [diff] [blame] | 69 | rm -f test/*.log |
| 70 | rm -f test/seedfile |