Makefile 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. endif
  18. # To compile as a shared library:
  19. ifdef SHARED
  20. # all code is position-indep with mingw, avoid warning about useless flag
  21. ifndef WINDOWS_BUILD
  22. LOCAL_CFLAGS += -fPIC -fpic
  23. endif
  24. endif
  25. SOEXT_TLS=so.10
  26. SOEXT_X509=so.0
  27. SOEXT_CRYPTO=so.0
  28. DLEXT=so
  29. # OSX shared library extension:
  30. # DLEXT=dylib
  31. # Windows shared library extension:
  32. ifdef WINDOWS_BUILD
  33. DLEXT=dll
  34. endif
  35. OBJS_CRYPTO= aes.o aesni.o arc4.o \
  36. asn1parse.o asn1write.o base64.o \
  37. bignum.o blowfish.o camellia.o \
  38. ccm.o cipher.o cipher_wrap.o \
  39. cmac.o ctr_drbg.o des.o \
  40. dhm.o ecdh.o ecdsa.o \
  41. ecjpake.o ecp.o \
  42. ecp_curves.o entropy.o entropy_poll.o \
  43. error.o gcm.o havege.o \
  44. hmac_drbg.o md.o md2.o \
  45. md4.o md5.o md_wrap.o \
  46. memory_buffer_alloc.o oid.o \
  47. padlock.o pem.o pk.o \
  48. pk_wrap.o pkcs12.o pkcs5.o \
  49. pkparse.o pkwrite.o platform.o \
  50. ripemd160.o rsa.o sha1.o \
  51. sha256.o sha512.o threading.o \
  52. timing.o version.o \
  53. version_features.o xtea.o
  54. OBJS_X509= certs.o pkcs11.o x509.o \
  55. x509_create.o x509_crl.o x509_crt.o \
  56. x509_csr.o x509write_crt.o x509write_csr.o
  57. OBJS_TLS= debug.o net_sockets.o \
  58. ssl_cache.o ssl_ciphersuites.o \
  59. ssl_cli.o ssl_cookie.o \
  60. ssl_srv.o ssl_ticket.o \
  61. ssl_tls.o
  62. .SILENT:
  63. .PHONY: all static shared clean
  64. ifndef SHARED
  65. all: static
  66. else
  67. all: shared static
  68. endif
  69. static: libmbedcrypto.a libmbedx509.a libmbedtls.a
  70. shared: libmbedcrypto.$(DLEXT) libmbedx509.$(DLEXT) libmbedtls.$(DLEXT)
  71. # tls
  72. libmbedtls.a: $(OBJS_TLS)
  73. echo " AR $@"
  74. $(AR) -rc $@ $(OBJS_TLS)
  75. echo " RL $@"
  76. $(AR) -s $@
  77. libmbedtls.$(SOEXT_TLS): $(OBJS_TLS) libmbedx509.so
  78. echo " LD $@"
  79. $(CC) -shared -Wl,-soname,$@ -L. -lmbedcrypto -lmbedx509 $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_TLS)
  80. libmbedtls.so: libmbedtls.$(SOEXT_TLS)
  81. echo " LN $@ -> $<"
  82. ln -sf $< $@
  83. libmbedtls.dylib: $(OBJS_TLS)
  84. echo " LD $@"
  85. $(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_TLS)
  86. libmbedtls.dll: $(OBJS_TLS) libmbedx509.dll
  87. echo " LD $@"
  88. $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_TLS) -lws2_32 -lwinmm -lgdi32 -L. -lmbedcrypto -lmbedx509 -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS)
  89. # x509
  90. libmbedx509.a: $(OBJS_X509)
  91. echo " AR $@"
  92. $(AR) -rc $@ $(OBJS_X509)
  93. echo " RL $@"
  94. $(AR) -s $@
  95. libmbedx509.$(SOEXT_X509): $(OBJS_X509) libmbedcrypto.so
  96. echo " LD $@"
  97. $(CC) -shared -Wl,-soname,$@ -L. -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_X509)
  98. libmbedx509.so: libmbedx509.$(SOEXT_X509)
  99. echo " LN $@ -> $<"
  100. ln -sf $< $@
  101. libmbedx509.dylib: $(OBJS_X509)
  102. echo " LD $@"
  103. $(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_X509)
  104. libmbedx509.dll: $(OBJS_X509) libmbedcrypto.dll
  105. echo " LD $@"
  106. $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_X509) -lws2_32 -lwinmm -lgdi32 -L. -lmbedcrypto -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS)
  107. # crypto
  108. libmbedcrypto.a: $(OBJS_CRYPTO)
  109. echo " AR $@"
  110. $(AR) -rc $@ $(OBJS_CRYPTO)
  111. echo " RL $@"
  112. $(AR) -s $@
  113. libmbedcrypto.$(SOEXT_CRYPTO): $(OBJS_CRYPTO)
  114. echo " LD $@"
  115. $(CC) -shared -Wl,-soname,$@ $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_CRYPTO)
  116. libmbedcrypto.so: libmbedcrypto.$(SOEXT_CRYPTO)
  117. echo " LN $@ -> $<"
  118. ln -sf $< $@
  119. libmbedcrypto.dylib: $(OBJS_CRYPTO)
  120. echo " LD $@"
  121. $(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_CRYPTO)
  122. libmbedcrypto.dll: $(OBJS_CRYPTO)
  123. echo " LD $@"
  124. $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_CRYPTO) -lws2_32 -lwinmm -lgdi32 -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS)
  125. .c.o:
  126. echo " CC $<"
  127. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c $<
  128. clean:
  129. ifndef WINDOWS
  130. rm -f *.o libmbed*
  131. else
  132. del /Q /F *.o libmbed*
  133. endif