From 8df5de42e2e094c5250686d4e5582d8630098703 Mon Sep 17 00:00:00 2001 From: Jaeden Amero Date: Fri, 26 Apr 2019 12:24:48 +0100 Subject: [PATCH 1/3] Makefile: Output to explicit target Don't depend on the C compiler's default output file name and path. Make knows what it wants to build and where it should go, and this may not always align with the C compiler default, so tell the C compilter to output to the Make target explicitly. --- library/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Makefile b/library/Makefile index 6ed5e68613..a2912507da 100644 --- a/library/Makefile +++ b/library/Makefile @@ -198,7 +198,7 @@ libmbedcrypto.dll: $(OBJS_CRYPTO) .c.o: echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c $< + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c $< -o $@ clean: ifndef WINDOWS From 92da0bd86237adf8ce3ddf966abdd668f039806e Mon Sep 17 00:00:00 2001 From: Jaeden Amero Date: Fri, 26 Apr 2019 11:59:31 +0100 Subject: [PATCH 2/3] Makefile: Use generated source files from parent When building as a submodule of a parent project, like Mbed TLS, use the parent projects generated source files (error.c, version.c, version_features.c) --- library/Makefile | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/library/Makefile b/library/Makefile index a2912507da..3058a31c96 100644 --- a/library/Makefile +++ b/library/Makefile @@ -73,7 +73,7 @@ OBJS_CRYPTO= aes.o aesni.o arc4.o \ dhm.o ecdh.o ecdsa.o \ ecjpake.o ecp.o \ ecp_curves.o entropy.o entropy_poll.o \ - error.o gcm.o havege.o \ + gcm.o havege.o \ hkdf.o \ hmac_drbg.o md.o md2.o \ md4.o md5.o md_wrap.o \ @@ -88,8 +88,22 @@ OBJS_CRYPTO= aes.o aesni.o arc4.o \ psa_its_file.o \ ripemd160.o rsa_internal.o rsa.o \ sha1.o sha256.o sha512.o \ - threading.o timing.o version.o \ - version_features.o xtea.o + threading.o timing.o \ + xtea.o + +# For files generated by the parent project (Mbed TLS) when building Mbed +# Crypto as a submodule, ensure that the parent project instance is used. +ifeq ($(USE_CRYPTO_SUBMODULE), 1) +OBJS_CRYPTO += ../../library/error.o +OBJS_CRYPTO += ../../library/version.o +OBJS_CRYPTO += ../../library/version_features.o +else +OBJS_CRYPTO += error.o +OBJS_CRYPTO += version.o +OBJS_CRYPTO += version_features.o +endif + +$(info $(OBJS_CRYPTO)) OBJS_X509= certs.o pkcs11.o x509.o \ x509_create.o x509_crl.o x509_crt.o \ From 18d47899471bc023ee4ace185c7d9a17aaa67519 Mon Sep 17 00:00:00 2001 From: Jaeden Amero Date: Fri, 26 Apr 2019 12:53:02 +0100 Subject: [PATCH 3/3] CMake: Use generated source files from parent When building as a submodule of a parent project, like Mbed TLS, use the parent projects generated source files (error.c, version.c, version_features.c) --- library/CMakeLists.txt | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 903921677d..072e74aff9 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -29,7 +29,6 @@ set(src_crypto ecp_curves.c entropy.c entropy_poll.c - error.c gcm.c havege.c hkdf.c @@ -65,11 +64,27 @@ set(src_crypto sha512.c threading.c timing.c - version.c - version_features.c xtea.c ) +# For files generated by the parent project (Mbed TLS) when building Mbed +# Crypto as a submodule, ensure that the parent project instance is used. +if(USE_CRYPTO_SUBMODULE) +set(src_crypto + ${src_crypto} + ${CMAKE_SOURCE_DIR}/library/version.c + ${CMAKE_SOURCE_DIR}/library/version_features.c + ${CMAKE_SOURCE_DIR}/library/error.c +) +else() +set(src_crypto + ${src_crypto} + version.c + version_features.c + error.c +) +endif() + set(src_x509 certs.c pkcs11.c