Makefile 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. # Also see "include/mbedtls/config.h"
  2. CFLAGS ?= -O2
  3. WARNING_CFLAGS ?= -Wall -Wextra -Wformat=2 -Wno-format-nonliteral
  4. LDFLAGS ?=
  5. # Include ../include for public headers and . for private headers.
  6. # Note that . needs to be included explicitly for the sake of library
  7. # files that are not in the /library directory (which currently means
  8. # under /3rdparty).
  9. LOCAL_CFLAGS = $(WARNING_CFLAGS) -I. -I../include -D_FILE_OFFSET_BITS=64
  10. LOCAL_LDFLAGS =
  11. ifdef DEBUG
  12. LOCAL_CFLAGS += -g3
  13. endif
  14. # MicroBlaze specific options:
  15. # CFLAGS += -mno-xl-soft-mul -mxl-barrel-shift
  16. # To compile on Plan9:
  17. # CFLAGS += -D_BSD_EXTENSION
  18. # if were running on Windows build for Windows
  19. ifdef WINDOWS
  20. WINDOWS_BUILD=1
  21. else ifeq ($(shell uname -s),Darwin)
  22. ifeq ($(AR),ar)
  23. APPLE_BUILD ?= 1
  24. endif
  25. endif
  26. # To compile as a shared library:
  27. ifdef SHARED
  28. # all code is position-indep with mingw, avoid warning about useless flag
  29. ifndef WINDOWS_BUILD
  30. LOCAL_CFLAGS += -fPIC -fpic
  31. endif
  32. endif
  33. SOEXT_TLS=so.14
  34. SOEXT_X509=so.1
  35. SOEXT_CRYPTO=so.7
  36. # Set AR_DASH= (empty string) to use an ar implementation that does not accept
  37. # the - prefix for command line options (e.g. llvm-ar)
  38. AR_DASH ?= -
  39. ARFLAGS = $(AR_DASH)src
  40. ifdef APPLE_BUILD
  41. ifneq ($(APPLE_BUILD),0)
  42. ARFLAGS = $(AR_DASH)Src
  43. RLFLAGS = -no_warning_for_no_symbols -c
  44. RL ?= ranlib
  45. endif
  46. endif
  47. DLEXT ?= so
  48. ifdef WINDOWS_BUILD
  49. # Windows shared library extension:
  50. DLEXT = dll
  51. else ifdef APPLE_BUILD
  52. ifneq ($(APPLE_BUILD),0)
  53. # Mac OS X shared library extension:
  54. DLEXT = dylib
  55. endif
  56. endif
  57. OBJS_CRYPTO= \
  58. aes.o \
  59. aesni.o \
  60. arc4.o \
  61. aria.o \
  62. asn1parse.o \
  63. asn1write.o \
  64. base64.o \
  65. bignum.o \
  66. blowfish.o \
  67. camellia.o \
  68. ccm.o \
  69. chacha20.o \
  70. chachapoly.o \
  71. cipher.o \
  72. cipher_wrap.o \
  73. cmac.o \
  74. constant_time.o \
  75. ctr_drbg.o \
  76. des.o \
  77. dhm.o \
  78. ecdh.o \
  79. ecdsa.o \
  80. ecjpake.o \
  81. ecp.o \
  82. ecp_curves.o \
  83. entropy.o \
  84. entropy_poll.o \
  85. error.o \
  86. gcm.o \
  87. havege.o \
  88. hkdf.o \
  89. hmac_drbg.o \
  90. md.o \
  91. md2.o \
  92. md4.o \
  93. md5.o \
  94. memory_buffer_alloc.o \
  95. mps_reader.o \
  96. mps_trace.o \
  97. nist_kw.o \
  98. oid.o \
  99. padlock.o \
  100. pem.o \
  101. pk.o \
  102. pk_wrap.o \
  103. pkcs12.o \
  104. pkcs5.o \
  105. pkparse.o \
  106. pkwrite.o \
  107. platform.o \
  108. platform_util.o \
  109. poly1305.o \
  110. psa_crypto.o \
  111. psa_crypto_aead.o \
  112. psa_crypto_cipher.o \
  113. psa_crypto_client.o \
  114. psa_crypto_driver_wrappers.o \
  115. psa_crypto_ecp.o \
  116. psa_crypto_hash.o \
  117. psa_crypto_mac.o \
  118. psa_crypto_rsa.o \
  119. psa_crypto_se.o \
  120. psa_crypto_slot_management.o \
  121. psa_crypto_storage.o \
  122. psa_its_file.o \
  123. ripemd160.o \
  124. rsa.o \
  125. rsa_internal.o \
  126. sha1.o \
  127. sha256.o \
  128. sha512.o \
  129. threading.o \
  130. timing.o \
  131. version.o \
  132. version_features.o \
  133. xtea.o \
  134. # This line is intentionally left blank
  135. include ../3rdparty/Makefile.inc
  136. LOCAL_CFLAGS+=$(THIRDPARTY_INCLUDES)
  137. OBJS_CRYPTO+=$(THIRDPARTY_CRYPTO_OBJECTS)
  138. OBJS_X509= \
  139. certs.o \
  140. pkcs11.o \
  141. x509.o \
  142. x509_create.o \
  143. x509_crl.o \
  144. x509_crt.o \
  145. x509_csr.o \
  146. x509write_crt.o \
  147. x509write_csr.o \
  148. # This line is intentionally left blank
  149. OBJS_TLS= \
  150. debug.o \
  151. net_sockets.o \
  152. ssl_cache.o \
  153. ssl_ciphersuites.o \
  154. ssl_cli.o \
  155. ssl_cookie.o \
  156. ssl_msg.o \
  157. ssl_srv.o \
  158. ssl_ticket.o \
  159. ssl_tls.o \
  160. ssl_tls13_keys.o \
  161. # This line is intentionally left blank
  162. .SILENT:
  163. .PHONY: all static shared clean
  164. ifndef SHARED
  165. all: static
  166. else
  167. all: shared static
  168. endif
  169. static: libmbedcrypto.a libmbedx509.a libmbedtls.a
  170. shared: libmbedcrypto.$(DLEXT) libmbedx509.$(DLEXT) libmbedtls.$(DLEXT)
  171. # Windows builds under Mingw can fail if make tries to create archives in the same
  172. # directory at the same time - see https://bugs.launchpad.net/gcc-arm-embedded/+bug/1848002.
  173. # This forces builds of the .a files to be serialised.
  174. ifdef WINDOWS
  175. libmbedtls.a: | libmbedx509.a
  176. libmbedx509.a: | libmbedcrypto.a
  177. endif
  178. # tls
  179. libmbedtls.a: $(OBJS_TLS)
  180. echo " AR $@"
  181. $(AR) $(ARFLAGS) $@ $(OBJS_TLS)
  182. ifdef APPLE_BUILD
  183. ifneq ($(APPLE_BUILD),0)
  184. echo " RL $@"
  185. $(RL) $(RLFLAGS) $@
  186. endif
  187. endif
  188. libmbedtls.$(SOEXT_TLS): $(OBJS_TLS) libmbedx509.so
  189. echo " LD $@"
  190. $(CC) -shared -Wl,-soname,$@ -o $@ $(OBJS_TLS) -L. -lmbedx509 -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS)
  191. libmbedtls.so: libmbedtls.$(SOEXT_TLS)
  192. echo " LN $@ -> $<"
  193. ln -sf $< $@
  194. libmbedtls.dylib: $(OBJS_TLS) libmbedx509.dylib
  195. echo " LD $@"
  196. $(CC) -dynamiclib -o $@ $(OBJS_TLS) -L. -lmbedx509 -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS)
  197. libmbedtls.dll: $(OBJS_TLS) libmbedx509.dll
  198. echo " LD $@"
  199. $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_TLS) -lws2_32 -lwinmm -lgdi32 -L. -lmbedx509 -lmbedcrypto -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS)
  200. # x509
  201. libmbedx509.a: $(OBJS_X509)
  202. echo " AR $@"
  203. $(AR) $(ARFLAGS) $@ $(OBJS_X509)
  204. ifdef APPLE_BUILD
  205. ifneq ($(APPLE_BUILD),0)
  206. echo " RL $@"
  207. $(RL) $(RLFLAGS) $@
  208. endif
  209. endif
  210. libmbedx509.$(SOEXT_X509): $(OBJS_X509) libmbedcrypto.so
  211. echo " LD $@"
  212. $(CC) -shared -Wl,-soname,$@ -o $@ $(OBJS_X509) -L. -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS)
  213. libmbedx509.so: libmbedx509.$(SOEXT_X509)
  214. echo " LN $@ -> $<"
  215. ln -sf $< $@
  216. libmbedx509.dylib: $(OBJS_X509) libmbedcrypto.dylib
  217. echo " LD $@"
  218. $(CC) -dynamiclib -o $@ $(OBJS_X509) -L. -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS)
  219. libmbedx509.dll: $(OBJS_X509) libmbedcrypto.dll
  220. echo " LD $@"
  221. $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_X509) -lws2_32 -lwinmm -lgdi32 -L. -lmbedcrypto -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS)
  222. # crypto
  223. libmbedcrypto.a: $(OBJS_CRYPTO)
  224. echo " AR $@"
  225. $(AR) $(ARFLAGS) $@ $(OBJS_CRYPTO)
  226. ifdef APPLE_BUILD
  227. ifneq ($(APPLE_BUILD),0)
  228. echo " RL $@"
  229. $(RL) $(RLFLAGS) $@
  230. endif
  231. endif
  232. libmbedcrypto.$(SOEXT_CRYPTO): $(OBJS_CRYPTO)
  233. echo " LD $@"
  234. $(CC) -shared -Wl,-soname,$@ -o $@ $(OBJS_CRYPTO) $(LOCAL_LDFLAGS) $(LDFLAGS)
  235. libmbedcrypto.so: libmbedcrypto.$(SOEXT_CRYPTO)
  236. echo " LN $@ -> $<"
  237. ln -sf $< $@
  238. libmbedcrypto.dylib: $(OBJS_CRYPTO)
  239. echo " LD $@"
  240. $(CC) -dynamiclib -o $@ $(OBJS_CRYPTO) $(LOCAL_LDFLAGS) $(LDFLAGS)
  241. libmbedcrypto.dll: $(OBJS_CRYPTO)
  242. echo " LD $@"
  243. $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_CRYPTO) -lws2_32 -lwinmm -lgdi32 -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS)
  244. .c.o:
  245. echo " CC $<"
  246. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $<
  247. clean:
  248. ifndef WINDOWS
  249. rm -f *.o libmbed*
  250. rm -f $(THIRDPARTY_CRYPTO_OBJECTS)
  251. else
  252. if exist *.o del /Q /F *.o
  253. if exist libmbed* del /Q /F libmbed*
  254. del /Q /F del_errors_out_if_the_file_list_is_empty_but_not_if_a_file_does_not_exist $(subst /,\,$(THIRDPARTY_CRYPTO_OBJECTS))
  255. endif