Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. # To compile on SunOS: add "-lsocket -lnsl" to LDFLAGS
  2. # To compile with PKCS11: add "-lpkcs11-helper" to LDFLAGS
  3. CFLAGS ?= -O2
  4. WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement
  5. WARNING_CXXFLAGS ?= -Wall -W
  6. LDFLAGS ?=
  7. LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64
  8. LOCAL_CXXFLAGS = $(WARNING_CXXFLAGS) -I../include -D_FILE_OFFSET_BITS=64
  9. LOCAL_LDFLAGS = -L../library \
  10. -lmbedtls$(SHARED_SUFFIX) \
  11. -lmbedx509$(SHARED_SUFFIX) \
  12. -lmbedcrypto$(SHARED_SUFFIX)
  13. ifndef SHARED
  14. DEP=../library/libmbedcrypto.a ../library/libmbedx509.a ../library/libmbedtls.a
  15. else
  16. DEP=../library/libmbedcrypto.$(DLEXT) ../library/libmbedx509.$(DLEXT) ../library/libmbedtls.$(DLEXT)
  17. endif
  18. ifdef DEBUG
  19. LOCAL_CFLAGS += -g3
  20. endif
  21. # if we're running on Windows, build for Windows
  22. ifdef WINDOWS
  23. WINDOWS_BUILD=1
  24. endif
  25. ifdef WINDOWS_BUILD
  26. DLEXT=dll
  27. EXEXT=.exe
  28. LOCAL_LDFLAGS += -lws2_32
  29. ifdef SHARED
  30. SHARED_SUFFIX=.$(DLEXT)
  31. endif
  32. else
  33. DLEXT ?= so
  34. EXEXT=
  35. SHARED_SUFFIX=
  36. endif
  37. # Zlib shared library extensions:
  38. ifdef ZLIB
  39. LOCAL_LDFLAGS += -lz
  40. endif
  41. APPS = aes/aescrypt2$(EXEXT) aes/crypt_and_hash$(EXEXT) \
  42. hash/hello$(EXEXT) hash/generic_sum$(EXEXT) \
  43. pkey/dh_client$(EXEXT) \
  44. pkey/dh_genprime$(EXEXT) pkey/dh_server$(EXEXT) \
  45. pkey/ecdh_curve25519$(EXEXT) \
  46. pkey/ecdsa$(EXEXT) pkey/gen_key$(EXEXT) \
  47. pkey/key_app$(EXEXT) pkey/key_app_writer$(EXEXT) \
  48. pkey/mpi_demo$(EXEXT) pkey/pk_decrypt$(EXEXT) \
  49. pkey/pk_encrypt$(EXEXT) pkey/pk_sign$(EXEXT) \
  50. pkey/pk_verify$(EXEXT) pkey/rsa_genkey$(EXEXT) \
  51. pkey/rsa_decrypt$(EXEXT) pkey/rsa_encrypt$(EXEXT) \
  52. pkey/rsa_sign$(EXEXT) pkey/rsa_verify$(EXEXT) \
  53. pkey/rsa_sign_pss$(EXEXT) pkey/rsa_verify_pss$(EXEXT) \
  54. ssl/dtls_client$(EXEXT) ssl/dtls_server$(EXEXT) \
  55. ssl/ssl_client1$(EXEXT) ssl/ssl_client2$(EXEXT) \
  56. ssl/ssl_server$(EXEXT) ssl/ssl_server2$(EXEXT) \
  57. ssl/ssl_fork_server$(EXEXT) ssl/mini_client$(EXEXT) \
  58. ssl/ssl_mail_client$(EXEXT) random/gen_entropy$(EXEXT) \
  59. random/gen_random_havege$(EXEXT) \
  60. random/gen_random_ctr_drbg$(EXEXT) \
  61. test/benchmark$(EXEXT) \
  62. test/selftest$(EXEXT) test/udp_proxy$(EXEXT) \
  63. test/zeroize$(EXEXT) \
  64. test/query_compile_time_config$(EXEXT) \
  65. util/pem2der$(EXEXT) util/strerror$(EXEXT) \
  66. x509/cert_app$(EXEXT) x509/crl_app$(EXEXT) \
  67. x509/cert_req$(EXEXT) x509/cert_write$(EXEXT) \
  68. x509/req_app$(EXEXT)
  69. ifdef PTHREAD
  70. APPS += ssl/ssl_pthread_server$(EXEXT)
  71. endif
  72. ifdef TEST_CPP
  73. APPS += test/cpp_dummy_build$(EXEXT)
  74. endif
  75. .SILENT:
  76. .PHONY: all clean list
  77. all: $(APPS)
  78. $(DEP):
  79. $(MAKE) -C ../library
  80. aes/aescrypt2$(EXEXT): aes/aescrypt2.c $(DEP)
  81. echo " CC aes/aescrypt2.c"
  82. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) aes/aescrypt2.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  83. aes/crypt_and_hash$(EXEXT): aes/crypt_and_hash.c $(DEP)
  84. echo " CC aes/crypt_and_hash.c"
  85. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) aes/crypt_and_hash.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  86. hash/hello$(EXEXT): hash/hello.c $(DEP)
  87. echo " CC hash/hello.c"
  88. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) hash/hello.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  89. hash/generic_sum$(EXEXT): hash/generic_sum.c $(DEP)
  90. echo " CC hash/generic_sum.c"
  91. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) hash/generic_sum.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  92. pkey/dh_client$(EXEXT): pkey/dh_client.c $(DEP)
  93. echo " CC pkey/dh_client.c"
  94. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/dh_client.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  95. pkey/dh_genprime$(EXEXT): pkey/dh_genprime.c $(DEP)
  96. echo " CC pkey/dh_genprime.c"
  97. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/dh_genprime.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  98. pkey/dh_server$(EXEXT): pkey/dh_server.c $(DEP)
  99. echo " CC pkey/dh_server.c"
  100. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/dh_server.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  101. pkey/ecdh_curve25519$(EXEXT): pkey/ecdh_curve25519.c $(DEP)
  102. echo " CC pkey/ecdh_curve25519.c"
  103. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/ecdh_curve25519.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  104. pkey/ecdsa$(EXEXT): pkey/ecdsa.c $(DEP)
  105. echo " CC pkey/ecdsa.c"
  106. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/ecdsa.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  107. pkey/gen_key$(EXEXT): pkey/gen_key.c $(DEP)
  108. echo " CC pkey/gen_key.c"
  109. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/gen_key.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  110. pkey/key_app$(EXEXT): pkey/key_app.c $(DEP)
  111. echo " CC pkey/key_app.c"
  112. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/key_app.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  113. pkey/key_app_writer$(EXEXT): pkey/key_app_writer.c $(DEP)
  114. echo " CC pkey/key_app_writer.c"
  115. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/key_app_writer.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  116. pkey/mpi_demo$(EXEXT): pkey/mpi_demo.c $(DEP)
  117. echo " CC pkey/mpi_demo.c"
  118. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/mpi_demo.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  119. pkey/pk_decrypt$(EXEXT): pkey/pk_decrypt.c $(DEP)
  120. echo " CC pkey/pk_decrypt.c"
  121. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/pk_decrypt.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  122. pkey/pk_encrypt$(EXEXT): pkey/pk_encrypt.c $(DEP)
  123. echo " CC pkey/pk_encrypt.c"
  124. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/pk_encrypt.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  125. pkey/pk_sign$(EXEXT): pkey/pk_sign.c $(DEP)
  126. echo " CC pkey/pk_sign.c"
  127. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/pk_sign.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  128. pkey/pk_verify$(EXEXT): pkey/pk_verify.c $(DEP)
  129. echo " CC pkey/pk_verify.c"
  130. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/pk_verify.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  131. pkey/rsa_genkey$(EXEXT): pkey/rsa_genkey.c $(DEP)
  132. echo " CC pkey/rsa_genkey.c"
  133. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/rsa_genkey.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  134. pkey/rsa_sign$(EXEXT): pkey/rsa_sign.c $(DEP)
  135. echo " CC pkey/rsa_sign.c"
  136. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/rsa_sign.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  137. pkey/rsa_verify$(EXEXT): pkey/rsa_verify.c $(DEP)
  138. echo " CC pkey/rsa_verify.c"
  139. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/rsa_verify.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  140. pkey/rsa_sign_pss$(EXEXT): pkey/rsa_sign_pss.c $(DEP)
  141. echo " CC pkey/rsa_sign_pss.c"
  142. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/rsa_sign_pss.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  143. pkey/rsa_verify_pss$(EXEXT): pkey/rsa_verify_pss.c $(DEP)
  144. echo " CC pkey/rsa_verify_pss.c"
  145. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/rsa_verify_pss.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  146. pkey/rsa_decrypt$(EXEXT): pkey/rsa_decrypt.c $(DEP)
  147. echo " CC pkey/rsa_decrypt.c"
  148. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/rsa_decrypt.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  149. pkey/rsa_encrypt$(EXEXT): pkey/rsa_encrypt.c $(DEP)
  150. echo " CC pkey/rsa_encrypt.c"
  151. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/rsa_encrypt.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  152. random/gen_entropy$(EXEXT): random/gen_entropy.c $(DEP)
  153. echo " CC random/gen_entropy.c"
  154. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) random/gen_entropy.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  155. random/gen_random_havege$(EXEXT): random/gen_random_havege.c $(DEP)
  156. echo " CC random/gen_random_havege.c"
  157. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) random/gen_random_havege.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  158. random/gen_random_ctr_drbg$(EXEXT): random/gen_random_ctr_drbg.c $(DEP)
  159. echo " CC random/gen_random_ctr_drbg.c"
  160. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) random/gen_random_ctr_drbg.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  161. ssl/dtls_client$(EXEXT): ssl/dtls_client.c $(DEP)
  162. echo " CC ssl/dtls_client.c"
  163. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/dtls_client.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  164. ssl/dtls_server$(EXEXT): ssl/dtls_server.c $(DEP)
  165. echo " CC ssl/dtls_server.c"
  166. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/dtls_server.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  167. ssl/ssl_client1$(EXEXT): ssl/ssl_client1.c $(DEP)
  168. echo " CC ssl/ssl_client1.c"
  169. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_client1.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  170. ssl/ssl_client2$(EXEXT): ssl/ssl_client2.c ssl/query_config.c $(DEP)
  171. echo " CC ssl/ssl_client2.c"
  172. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_client2.c ssl/query_config.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  173. ssl/ssl_server$(EXEXT): ssl/ssl_server.c $(DEP)
  174. echo " CC ssl/ssl_server.c"
  175. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_server.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  176. ssl/ssl_server2$(EXEXT): ssl/ssl_server2.c ssl/query_config.c $(DEP)
  177. echo " CC ssl/ssl_server2.c"
  178. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_server2.c ssl/query_config.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  179. ssl/ssl_fork_server$(EXEXT): ssl/ssl_fork_server.c $(DEP)
  180. echo " CC ssl/ssl_fork_server.c"
  181. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_fork_server.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  182. ssl/ssl_pthread_server$(EXEXT): ssl/ssl_pthread_server.c $(DEP)
  183. echo " CC ssl/ssl_pthread_server.c"
  184. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_pthread_server.c $(LOCAL_LDFLAGS) -lpthread $(LDFLAGS) -o $@
  185. ssl/ssl_mail_client$(EXEXT): ssl/ssl_mail_client.c $(DEP)
  186. echo " CC ssl/ssl_mail_client.c"
  187. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_mail_client.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  188. ssl/mini_client$(EXEXT): ssl/mini_client.c $(DEP)
  189. echo " CC ssl/mini_client.c"
  190. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/mini_client.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  191. test/benchmark$(EXEXT): test/benchmark.c $(DEP)
  192. echo " CC test/benchmark.c"
  193. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/benchmark.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  194. test/cpp_dummy_build$(EXEXT): test/cpp_dummy_build.cpp $(DEP)
  195. echo " CXX test/cpp_dummy_build.cpp"
  196. $(CXX) $(LOCAL_CXXFLAGS) $(CXXFLAGS) test/cpp_dummy_build.cpp $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  197. test/selftest$(EXEXT): test/selftest.c $(DEP)
  198. echo " CC test/selftest.c"
  199. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/selftest.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  200. test/udp_proxy$(EXEXT): test/udp_proxy.c $(DEP)
  201. echo " CC test/udp_proxy.c"
  202. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/udp_proxy.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  203. test/zeroize$(EXEXT): test/zeroize.c $(DEP)
  204. echo " CC test/zeroize.c"
  205. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/zeroize.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  206. test/query_compile_time_config$(EXEXT): test/query_compile_time_config.c ssl/query_config.c $(DEP)
  207. echo " CC test/query_compile_time_config.c"
  208. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/query_compile_time_config.c ssl/query_config.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  209. util/pem2der$(EXEXT): util/pem2der.c $(DEP)
  210. echo " CC util/pem2der.c"
  211. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) util/pem2der.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  212. util/strerror$(EXEXT): util/strerror.c $(DEP)
  213. echo " CC util/strerror.c"
  214. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) util/strerror.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  215. x509/cert_app$(EXEXT): x509/cert_app.c $(DEP)
  216. echo " CC x509/cert_app.c"
  217. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) x509/cert_app.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  218. x509/cert_write$(EXEXT): x509/cert_write.c $(DEP)
  219. echo " CC x509/cert_write.c"
  220. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) x509/cert_write.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  221. x509/crl_app$(EXEXT): x509/crl_app.c $(DEP)
  222. echo " CC x509/crl_app.c"
  223. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) x509/crl_app.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  224. x509/cert_req$(EXEXT): x509/cert_req.c $(DEP)
  225. echo " CC x509/cert_req.c"
  226. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) x509/cert_req.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  227. x509/req_app$(EXEXT): x509/req_app.c $(DEP)
  228. echo " CC x509/req_app.c"
  229. $(CC) $(LOCAL_CFLAGS) $(CFLAGS) x509/req_app.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
  230. clean:
  231. ifndef WINDOWS
  232. rm -f $(APPS)
  233. -rm -f ssl/ssl_pthread_server$(EXEXT)
  234. -rm -f test/cpp_dummy_build$(EXEXT)
  235. else
  236. del /S /Q /F *.o *.exe
  237. endif
  238. list:
  239. echo $(APPS)