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)
diff --git a/library/Makefile b/library/Makefile
index a291250..3058a31 100644
--- a/library/Makefile
+++ b/library/Makefile
@@ -73,7 +73,7 @@
 		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 @@
 		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	\