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)
@@ -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 \
