Makefile 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. # Also see "include/mbedtls/config.h"
  2. CFLAGS ?= -O2
  3. WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement
  4. LDFLAGS ?=
  5. LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64
  6. LOCAL_LDFLAGS =
  7. ifdef DEBUG
  8. LOCAL_CFLAGS += -g3
  9. endif
  10. # MicroBlaze specific options:
  11. # CFLAGS += -mno-xl-soft-mul -mxl-barrel-shift
  12. # To compile on Plan9:
  13. # CFLAGS += -D_BSD_EXTENSION
  14. # if were running on Windows build for Windows
  15. ifdef WINDOWS
  16. WINDOWS_BUILD=1
  17. else ifeq ($(shell uname -s),Darwin)
  18. ifeq ($(AR),ar)
  19. APPLE_BUILD ?= 1
  20. endif
  21. endif
  22. # To compile as a shared library:
  23. ifdef SHARED
  24. # all code is position-indep with mingw, avoid warning about useless flag
  25. ifndef WINDOWS_BUILD
  26. LOCAL_CFLAGS += -fPIC -fpic
  27. endif
  28. endif
  29. SOEXT_TLS=so.12
  30. SOEXT_X509=so.0
  31. SOEXT_CRYPTO=so.3
  32. # Set AR_DASH= (empty string) to use an ar implementation that does not accept
  33. # the - prefix for command line options (e.g. llvm-ar)
  34. AR_DASH ?= -
  35. ARFLAGS = $(AR_DASH)src
  36. ifdef APPLE_BUILD
  37. ifneq ($(APPLE_BUILD),0)
  38. ARFLAGS = $(AR_DASH)Src
  39. RLFLAGS = -no_warning_for_no_symbols -c
  40. RL ?= ranlib
  41. endif
  42. endif
  43. DLEXT ?= so
  44. ifdef WINDOWS_BUILD
  45. # Windows shared library extension:
  46. DLEXT = dll
  47. else ifdef APPLE_BUILD
  48. ifneq ($(APPLE_BUILD),0)
  49. # Mac OS X shared library extension:
  50. DLEXT = dylib
  51. endif
  52. endif
  53. OBJS_CRYPTO= aes.o aesni.o arc4.o \
  54. aria.o asn1parse.o asn1write.o \
  55. base64.o bignum.o blowfish.o \
  56. camellia.o ccm.o chacha20.o \
  57. chachapoly.o cipher.o cipher_wrap.o \
  58. cmac.o ctr_drbg.o des.o \
  59. dhm.o ecdh.o ecdsa.o \
  60. ecjpake.o ecp.o \
  61. ecp_curves.o entropy.o entropy_poll.o \
  62. error.o gcm.o havege.o \
  63. hkdf.o \
  64. hmac_drbg.o md.o md2.o \
  65. md4.o md5.o md_wrap.o \
  66. memory_buffer_alloc.o nist_kw.o \
  67. oid.o padlock.o pem.o \
  68. pk.o pk_wrap.o pkcs12.o \
  69. pkcs5.o pkparse.o pkwrite.o \
  70. platform.o platform_util.o poly1305.o \
  71. ripemd160.o rsa_internal.o rsa.o \
  72. sha1.o sha256.o sha512.o \
  73. threading.o timing.o version.o \
  74. version_features.o xtea.o
  75. OBJS_X509= certs.o pkcs11.o x509.o \
  76. x509_create.o x509_crl.o x509_crt.o \
  77. x509_csr.o x509write_crt.o x509write_csr.o
  78. OBJS_TLS= debug.o net_sockets.o \
  79. ssl_cache.o ssl_ciphersuites.o \
  80. ssl_cli.o ssl_cookie.o \
  81. ssl_srv.o ssl_ticket.o \
  82. ssl_tls.o
  83. .SILENT:
  84. .PHONY: all static shared clean
  85. ifndef SHARED
  86. all: static
  87. else
  88. all: shared static
  89. endif
  90. static: libmbedcrypto.a libmbedx509.a libmbedtls.a
  91. shared: libmbedcrypto.$(DLEXT) libmbedx509.$(DLEXT) libmbedtls.$(DLEXT)
  92. # tls
  93. libmbedtls.a: $(OBJS_TLS)
  94. echo " AR $@"
  95. $(AR) $(ARFLAGS) $@ $(OBJS_TLS)
  96. ifdef APPLE_BUILD
  97. ifneq ($(APPLE_BUILD),0)
  98. echo " RL $@"
  99. $(RL) $(RLFLAGS) $@
  100. endif
  101. endif
  102. libmbedtls.$(SOEXT_TLS): $(OBJS_TLS) libmbedx509.so
  103. echo " LD $@"
  104. $(CC) -shared -Wl,-soname,$@ -L. -lmbedcrypto -lmbedx509 $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_TLS)
  105. libmbedtls.so: libmbedtls.$(SOEXT_TLS)
  106. echo " LN $@ -> $<"
  107. ln -sf $< $@
  108. libmbedtls.dylib: $(OBJS_TLS) libmbedx509.dylib
  109. echo " LD $@"
  110. $(CC) -dynamiclib -L. -lmbedcrypto -lmbedx509 $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_TLS)
  111. libmbedtls.dll: $(OBJS_TLS) libmbedx509.dll
  112. echo " LD $@"
  113. $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_TLS) -lws2_32 -lwinmm -lgdi32 -L. -lmbedcrypto -lmbedx509 -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS)
  114. # x509
  115. libmbedx509.a: $(OBJS_X509)
  116. echo " AR $@"
  117. $(AR) $(ARFLAGS) $@ $(OBJS_X509)
  118. ifdef APPLE_BUILD
  119. ifneq ($(APPLE_BUILD),0)
  120. echo " RL $@"
  121. $(RL) $(RLFLAGS) $@
  122. endif
  123. endif
  124. libmbedx509.$(SOEXT_X509): $(OBJS_X509) libmbedcrypto.so
  125. echo " LD $@"
  126. $(CC) -shared -Wl,-soname,$@ -L. -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_X509)
  127. libmbedx509.so: libmbedx509.$(SOEXT_X509)
  128. echo " LN $@ -> $<"
  129. ln -sf $< $@
  130. libmbedx509.dylib: $(OBJS_X509) libmbedcrypto.dylib
  131. echo " LD $@"
  132. $(CC) -dynamiclib -L. -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_X509)
  133. libmbedx509.dll: $(OBJS_X509) libmbedcrypto.dll
  134. echo " LD $@"
  135. $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_X509) -lws2_32 -lwinmm -lgdi32 -L. -lmbedcrypto -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS)
  136. # crypto
  137. libmbedcrypto.a: $(OBJS_CRYPTO)
  138. echo " AR $@"
  139. $(AR) $(ARFLAGS) $@ $(OBJS_CRYPTO)
  140. ifdef APPLE_BUILD
  141. ifneq ($(APPLE_BUILD),0)
  142. echo " RL $@"
  143. $(RL) $(RLFLAGS) $@
  144. endif
  145. endif
  146. libmbedcrypto.$(SOEXT_CRYPTO): $(OBJS_CRYPTO)
  147. echo " LD $@"
  148. $(CC) -shared -Wl,-soname,$@ $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_CRYPTO)
  149. libmbedcrypto.so: libmbedcrypto.$(SOEXT_CRYPTO)
  150. echo " LN $@ -> $<"
  151. ln -sf $< $@
  152. libmbedcrypto.dylib: $(OBJS_CRYPTO)
  153. echo " LD $@"
  154. $(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_CRYPTO)
  155. libmbedcrypto.dll: $(OBJS_CRYPTO)
  156. echo " LD $@"
  157. $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_CRYPTO) -lws2_32 -lwinmm -lgdi32 -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS)
  158. .c.o:
  159. echo " CC $<"
  160. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c $<
  161. clean:
  162. ifndef WINDOWS
  163. rm -f *.o libmbed*
  164. else
  165. del /Q /F *.o libmbed*
  166. endif