Makefile 11 KB

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