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 = ../../.. |
| 11 | COMMON_INCLUDE := -I./include -I$(MBEDTLS_ROOT_PATH)/include |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 12 | |
| 13 | TEST_BIN = test/psa_client \ |
| 14 | test/psa_partition |
| 15 | |
| 16 | GENERATED_H_FILES = include/psa_manifest/manifest.h \ |
| 17 | include/psa_manifest/pid.h \ |
| 18 | include/psa_manifest/sid.h |
| 19 | |
| 20 | PSA_CLIENT_SRC = src/psa_ff_client.c \ |
| 21 | src/client.c |
| 22 | |
| 23 | PARTITION_SERVER_BOOTSTRAP = src/psa_ff_bootstrap_TEST_PARTITION.c |
| 24 | |
| 25 | PSA_SERVER_SRC = $(PARTITION_SERVER_BOOTSTRAP) \ |
| 26 | src/psa_ff_server.c |
| 27 | |
Valerio Setti | cd89c1f | 2024-05-10 11:21:04 +0200 | [diff] [blame] | 28 | .PHONY: all clean libpsaclient libpsaserver |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 29 | |
| 30 | all: $(TEST_BIN) |
| 31 | |
Valerio Setti | 87d99fb | 2024-05-14 10:57:35 +0200 | [diff] [blame^] | 32 | test/seedfile: |
| 33 | dd if=/dev/urandom of=./test/seedfile bs=64 count=1 |
| 34 | |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 35 | test/psa_client: $(PSA_CLIENT_SRC) $(GENERATED_H_FILES) |
Valerio Setti | cd89c1f | 2024-05-10 11:21:04 +0200 | [diff] [blame] | 36 | $(CC) $(COMMON_INCLUDE) $(CFLAGS) $(PSA_CLIENT_SRC) $(LIBPSACLIENT) $(LDFLAGS) -o $@ |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 37 | |
Valerio Setti | 87d99fb | 2024-05-14 10:57:35 +0200 | [diff] [blame^] | 38 | test/psa_partition: $(PSA_SERVER_SRC) $(GENERATED_H_FILES) test/seedfile |
Valerio Setti | cd89c1f | 2024-05-10 11:21:04 +0200 | [diff] [blame] | 39 | $(CC) $(COMMON_INCLUDE) $(CFLAGS) $(PSA_SERVER_SRC) $(LIBPSASERVER) $(LDFLAGS) -o $@ |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 40 | |
| 41 | $(PARTITION_SERVER_BOOTSTRAP) $(GENERATED_H_FILES): src/manifest.json src/server.c |
| 42 | tools/psa_autogen.py src/manifest.json |
Valerio Setti | 4f4ade9 | 2024-05-03 17:28:04 +0200 | [diff] [blame] | 43 | |
Valerio Setti | cd89c1f | 2024-05-10 11:21:04 +0200 | [diff] [blame] | 44 | # Build MbedTLS libraries (crypto, x509 and tls) and copy them locally to |
| 45 | # build client/server applications. |
| 46 | # |
| 47 | # Note: these rules assume that mbedtls_config.h is already configured by all.sh. |
| 48 | # If not using all.sh then the user must do it manually. |
| 49 | libpsaclient libpsaserver: |
| 50 | $(MAKE) -C $(MBEDTLS_ROOT_PATH)/library CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" libmbedcrypto.a libmbedx509.a libmbedtls.a |
| 51 | mkdir -p $@ |
| 52 | cp $(MBEDTLS_ROOT_PATH)/library/libmbed*.a $@/ |
| 53 | $(MAKE) -C $(MBEDTLS_ROOT_PATH) clean |
| 54 | |
Valerio Setti | 4f4ade9 | 2024-05-03 17:28:04 +0200 | [diff] [blame] | 55 | clean: |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 56 | rm -f $(TEST_BIN) |
| 57 | rm -f $(PARTITION_SERVER_BOOTSTRAP) |
Valerio Setti | cd89c1f | 2024-05-10 11:21:04 +0200 | [diff] [blame] | 58 | rm -rf libpsaclient libpsaserver |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 59 | rm -rf include/psa_manifest |
| 60 | rm -f test/psa_service_* test/psa_notify_* |
Valerio Setti | 237a64e | 2024-05-10 12:32:10 +0200 | [diff] [blame] | 61 | rm -r test/*.log |
Valerio Setti | 87d99fb | 2024-05-14 10:57:35 +0200 | [diff] [blame^] | 62 | rm test/seedfile |
Valerio Setti | 4f4ade9 | 2024-05-03 17:28:04 +0200 | [diff] [blame] | 63 | |