Makefile 4.1 KB

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