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 | 0917265 | 2024-06-27 08:00:54 +0200 | [diff] [blame] | 4 | override CFLAGS += -DDEBUG -O0 -g |
Valerio Setti | 4f4ade9 | 2024-05-03 17:28:04 +0200 | [diff] [blame] | 5 | endif |
| 6 | |
Valerio Setti | 0917265 | 2024-06-27 08:00:54 +0200 | [diff] [blame] | 7 | CLIENT_LIBS := -Lclient_libs -lpsaclient -lmbedtls -lmbedx509 -lmbedcrypto |
| 8 | SERVER_LIBS := -Lserver_libs -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 | 3d817ad | 2024-06-14 08:43:28 +0200 | [diff] [blame] | 11 | COMMON_INCLUDE := -I./include -I$(MBEDTLS_ROOT_PATH)/include \ |
| 12 | -I$(MBEDTLS_ROOT_PATH)/tf-psa-crypto/include \ |
| 13 | -I$(MBEDTLS_ROOT_PATH)/tf-psa-crypto/drivers/builtin/include |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 14 | |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 15 | GENERATED_H_FILES = include/psa_manifest/manifest.h \ |
| 16 | include/psa_manifest/pid.h \ |
| 17 | include/psa_manifest/sid.h |
| 18 | |
Valerio Setti | 0917265 | 2024-06-27 08:00:54 +0200 | [diff] [blame] | 19 | LIBPSACLIENT_SRC = src/psa_ff_client.c \ |
| 20 | src/psa_sim_crypto_client.c \ |
| 21 | src/psa_sim_serialise.c |
| 22 | LIBPSACLIENT_OBJS=$(LIBPSACLIENT_SRC:.c=.o) |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 23 | |
Valerio Setti | 0917265 | 2024-06-27 08:00:54 +0200 | [diff] [blame] | 24 | PSA_CLIENT_BASE_SRC = $(LIBPSACLIENT_SRC) src/client.c |
Valerio Setti | 5beb236 | 2024-06-24 13:13:17 +0200 | [diff] [blame] | 25 | |
Valerio Setti | 0917265 | 2024-06-27 08:00:54 +0200 | [diff] [blame] | 26 | PSA_CLIENT_FULL_SRC = $(LIBPSACLIENT_SRC) \ |
Valerio Setti | 5beb236 | 2024-06-24 13:13:17 +0200 | [diff] [blame] | 27 | $(wildcard src/aut_*.c) |
| 28 | |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 29 | PARTITION_SERVER_BOOTSTRAP = src/psa_ff_bootstrap_TEST_PARTITION.c |
| 30 | |
| 31 | PSA_SERVER_SRC = $(PARTITION_SERVER_BOOTSTRAP) \ |
Tom Cosgrove | 3ebb880 | 2024-05-29 10:29:39 +0100 | [diff] [blame] | 32 | src/psa_ff_server.c \ |
| 33 | src/psa_sim_crypto_server.c \ |
| 34 | src/psa_sim_serialise.c |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 35 | |
Valerio Setti | 0917265 | 2024-06-27 08:00:54 +0200 | [diff] [blame] | 36 | .PHONY: all clean client_libs server_libs |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 37 | |
Valerio Setti | f98635c | 2024-06-10 20:13:13 +0200 | [diff] [blame] | 38 | all: |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 39 | |
Valerio Setti | 87d99fb | 2024-05-14 10:57:35 +0200 | [diff] [blame] | 40 | test/seedfile: |
| 41 | dd if=/dev/urandom of=./test/seedfile bs=64 count=1 |
| 42 | |
Valerio Setti | 0917265 | 2024-06-27 08:00:54 +0200 | [diff] [blame] | 43 | src/%.o: src/%.c $(GENERATED_H_FILES) |
| 44 | $(CC) $(COMMON_INCLUDE) $(CFLAGS) -c $< $(LDFLAGS) -o $@ |
Valerio Setti | 5beb236 | 2024-06-24 13:13:17 +0200 | [diff] [blame] | 45 | |
Valerio Setti | 0917265 | 2024-06-27 08:00:54 +0200 | [diff] [blame] | 46 | client_libs/libpsaclient: $(LIBPSACLIENT_OBJS) |
| 47 | mkdir -p client_libs |
| 48 | $(AR) -src client_libs/libpsaclient.a $(LIBPSACLIENT_OBJS) |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 49 | |
Valerio Setti | 0917265 | 2024-06-27 08:00:54 +0200 | [diff] [blame] | 50 | test/psa_client_base: $(PSA_CLIENT_BASE_SRC) $(GENERATED_H_FILES) test/seedfile |
| 51 | $(CC) $(COMMON_INCLUDE) $(CFLAGS) $(PSA_CLIENT_BASE_SRC) $(CLIENT_LIBS) $(LDFLAGS) -o $@ |
| 52 | |
| 53 | test/psa_client_full: $(PSA_CLIENT_FULL_SRC) $(GENERATED_H_FILES) test/seedfile |
| 54 | $(CC) $(COMMON_INCLUDE) $(CFLAGS) $(PSA_CLIENT_FULL_SRC) $(CLIENT_LIBS) $(LDFLAGS) -o $@ |
| 55 | |
| 56 | test/psa_server: $(PSA_SERVER_SRC) $(GENERATED_H_FILES) |
| 57 | $(CC) $(COMMON_INCLUDE) $(CFLAGS) $(PSA_SERVER_SRC) $(SERVER_LIBS) $(LDFLAGS) -o $@ |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 58 | |
| 59 | $(PARTITION_SERVER_BOOTSTRAP) $(GENERATED_H_FILES): src/manifest.json src/server.c |
| 60 | tools/psa_autogen.py src/manifest.json |
Valerio Setti | 4f4ade9 | 2024-05-03 17:28:04 +0200 | [diff] [blame] | 61 | |
Valerio Setti | cd89c1f | 2024-05-10 11:21:04 +0200 | [diff] [blame] | 62 | # Build MbedTLS libraries (crypto, x509 and tls) and copy them locally to |
| 63 | # build client/server applications. |
| 64 | # |
| 65 | # Note: these rules assume that mbedtls_config.h is already configured by all.sh. |
| 66 | # If not using all.sh then the user must do it manually. |
Valerio Setti | 0917265 | 2024-06-27 08:00:54 +0200 | [diff] [blame] | 67 | client_libs: client_libs/libpsaclient |
| 68 | client_libs server_libs: |
Valerio Setti | cd89c1f | 2024-05-10 11:21:04 +0200 | [diff] [blame] | 69 | $(MAKE) -C $(MBEDTLS_ROOT_PATH)/library CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" libmbedcrypto.a libmbedx509.a libmbedtls.a |
| 70 | mkdir -p $@ |
| 71 | cp $(MBEDTLS_ROOT_PATH)/library/libmbed*.a $@/ |
Valerio Setti | cd89c1f | 2024-05-10 11:21:04 +0200 | [diff] [blame] | 72 | |
Valerio Setti | 0917265 | 2024-06-27 08:00:54 +0200 | [diff] [blame] | 73 | clean_server_intermediate_files: |
Valerio Setti | 66fb1c1 | 2024-05-10 06:51:16 +0200 | [diff] [blame] | 74 | rm -f $(PARTITION_SERVER_BOOTSTRAP) |
| 75 | rm -rf include/psa_manifest |
Valerio Setti | 0917265 | 2024-06-27 08:00:54 +0200 | [diff] [blame] | 76 | |
| 77 | clean: clean_server_intermediate_files |
| 78 | rm -f test/psa_client_base test/psa_client_full test/psa_server |
| 79 | rm -rf client_libs server_libs |
| 80 | rm -f test/psa_service_* test/psa_notify_* test/*.log |
Valerio Setti | 1f3c99c | 2024-05-15 07:29:51 +0200 | [diff] [blame] | 81 | rm -f test/seedfile |