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