2024-05-09 07:15:39 +00:00
|
|
|
CFLAGS += -Wall -Werror -std=c99 -D_XOPEN_SOURCE=1 -D_POSIX_C_SOURCE=200809L
|
2024-05-03 15:28:04 +00:00
|
|
|
|
|
|
|
ifeq ($(DEBUG),1)
|
2024-06-27 06:00:54 +00:00
|
|
|
override CFLAGS += -DDEBUG -O0 -g
|
2024-05-03 15:28:04 +00:00
|
|
|
endif
|
|
|
|
|
2024-06-27 06:00:54 +00:00
|
|
|
CLIENT_LIBS := -Lclient_libs -lpsaclient -lmbedtls -lmbedx509 -lmbedcrypto
|
|
|
|
SERVER_LIBS := -Lserver_libs -lmbedcrypto
|
2024-05-03 15:28:04 +00:00
|
|
|
|
2024-05-10 09:21:04 +00:00
|
|
|
MBEDTLS_ROOT_PATH = ../../..
|
2024-06-14 06:43:28 +00:00
|
|
|
COMMON_INCLUDE := -I./include -I$(MBEDTLS_ROOT_PATH)/include \
|
|
|
|
-I$(MBEDTLS_ROOT_PATH)/tf-psa-crypto/include \
|
|
|
|
-I$(MBEDTLS_ROOT_PATH)/tf-psa-crypto/drivers/builtin/include
|
2024-05-10 04:51:16 +00:00
|
|
|
|
|
|
|
GENERATED_H_FILES = include/psa_manifest/manifest.h \
|
|
|
|
include/psa_manifest/pid.h \
|
|
|
|
include/psa_manifest/sid.h
|
|
|
|
|
2024-06-27 06:00:54 +00:00
|
|
|
LIBPSACLIENT_SRC = src/psa_ff_client.c \
|
|
|
|
src/psa_sim_crypto_client.c \
|
|
|
|
src/psa_sim_serialise.c
|
|
|
|
LIBPSACLIENT_OBJS=$(LIBPSACLIENT_SRC:.c=.o)
|
2024-05-10 04:51:16 +00:00
|
|
|
|
2024-06-27 06:00:54 +00:00
|
|
|
PSA_CLIENT_BASE_SRC = $(LIBPSACLIENT_SRC) src/client.c
|
2024-06-24 11:13:17 +00:00
|
|
|
|
2024-06-27 06:00:54 +00:00
|
|
|
PSA_CLIENT_FULL_SRC = $(LIBPSACLIENT_SRC) \
|
2024-06-24 11:13:17 +00:00
|
|
|
$(wildcard src/aut_*.c)
|
|
|
|
|
2024-05-10 04:51:16 +00:00
|
|
|
PARTITION_SERVER_BOOTSTRAP = src/psa_ff_bootstrap_TEST_PARTITION.c
|
|
|
|
|
|
|
|
PSA_SERVER_SRC = $(PARTITION_SERVER_BOOTSTRAP) \
|
2024-05-29 09:29:39 +00:00
|
|
|
src/psa_ff_server.c \
|
|
|
|
src/psa_sim_crypto_server.c \
|
|
|
|
src/psa_sim_serialise.c
|
2024-05-10 04:51:16 +00:00
|
|
|
|
2024-06-27 06:00:54 +00:00
|
|
|
.PHONY: all clean client_libs server_libs
|
2024-05-10 04:51:16 +00:00
|
|
|
|
2024-06-10 18:13:13 +00:00
|
|
|
all:
|
2024-05-10 04:51:16 +00:00
|
|
|
|
2024-05-14 08:57:35 +00:00
|
|
|
test/seedfile:
|
|
|
|
dd if=/dev/urandom of=./test/seedfile bs=64 count=1
|
|
|
|
|
2024-06-27 06:00:54 +00:00
|
|
|
src/%.o: src/%.c $(GENERATED_H_FILES)
|
|
|
|
$(CC) $(COMMON_INCLUDE) $(CFLAGS) -c $< $(LDFLAGS) -o $@
|
2024-06-24 11:13:17 +00:00
|
|
|
|
2024-06-27 06:00:54 +00:00
|
|
|
client_libs/libpsaclient: $(LIBPSACLIENT_OBJS)
|
|
|
|
mkdir -p client_libs
|
|
|
|
$(AR) -src client_libs/libpsaclient.a $(LIBPSACLIENT_OBJS)
|
2024-05-10 04:51:16 +00:00
|
|
|
|
2024-06-27 06:00:54 +00:00
|
|
|
test/psa_client_base: $(PSA_CLIENT_BASE_SRC) $(GENERATED_H_FILES) test/seedfile
|
|
|
|
$(CC) $(COMMON_INCLUDE) $(CFLAGS) $(PSA_CLIENT_BASE_SRC) $(CLIENT_LIBS) $(LDFLAGS) -o $@
|
|
|
|
|
|
|
|
test/psa_client_full: $(PSA_CLIENT_FULL_SRC) $(GENERATED_H_FILES) test/seedfile
|
|
|
|
$(CC) $(COMMON_INCLUDE) $(CFLAGS) $(PSA_CLIENT_FULL_SRC) $(CLIENT_LIBS) $(LDFLAGS) -o $@
|
|
|
|
|
|
|
|
test/psa_server: $(PSA_SERVER_SRC) $(GENERATED_H_FILES)
|
|
|
|
$(CC) $(COMMON_INCLUDE) $(CFLAGS) $(PSA_SERVER_SRC) $(SERVER_LIBS) $(LDFLAGS) -o $@
|
2024-05-10 04:51:16 +00:00
|
|
|
|
|
|
|
$(PARTITION_SERVER_BOOTSTRAP) $(GENERATED_H_FILES): src/manifest.json src/server.c
|
|
|
|
tools/psa_autogen.py src/manifest.json
|
2024-05-03 15:28:04 +00:00
|
|
|
|
2024-05-10 09:21:04 +00:00
|
|
|
# Build MbedTLS libraries (crypto, x509 and tls) and copy them locally to
|
|
|
|
# build client/server applications.
|
|
|
|
#
|
|
|
|
# Note: these rules assume that mbedtls_config.h is already configured by all.sh.
|
|
|
|
# If not using all.sh then the user must do it manually.
|
2024-06-27 06:00:54 +00:00
|
|
|
client_libs: client_libs/libpsaclient
|
|
|
|
client_libs server_libs:
|
2024-05-10 09:21:04 +00:00
|
|
|
$(MAKE) -C $(MBEDTLS_ROOT_PATH)/library CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" libmbedcrypto.a libmbedx509.a libmbedtls.a
|
|
|
|
mkdir -p $@
|
|
|
|
cp $(MBEDTLS_ROOT_PATH)/library/libmbed*.a $@/
|
|
|
|
|
2024-06-27 06:00:54 +00:00
|
|
|
clean_server_intermediate_files:
|
2024-05-10 04:51:16 +00:00
|
|
|
rm -f $(PARTITION_SERVER_BOOTSTRAP)
|
|
|
|
rm -rf include/psa_manifest
|
2024-06-27 06:00:54 +00:00
|
|
|
|
|
|
|
clean: clean_server_intermediate_files
|
|
|
|
rm -f test/psa_client_base test/psa_client_full test/psa_server
|
|
|
|
rm -rf client_libs server_libs
|
|
|
|
rm -f test/psa_service_* test/psa_notify_* test/*.log
|
2024-05-15 05:29:51 +00:00
|
|
|
rm -f test/seedfile
|