Makefile 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. MAKEF=$(MAKE) -f Makefile.in
  2. TMPDIR=tmp
  3. default: all
  4. all: libhv test timer loop tcp udp nc nmap httpd curl
  5. clean:
  6. $(MAKEF) clean SRCDIRS=". base utils event http http/client http/server protocol examples $(TMPDIR)"
  7. prepare:
  8. -mkdir -p $(TMPDIR) lib bin
  9. -rm base/RAII.o
  10. libhv: prepare
  11. $(MAKEF) TARGET=$@ TARGET_TYPE=SHARED SRCDIRS=". base utils event http http/client http/server protocol"
  12. $(MAKEF) TARGET=$@ TARGET_TYPE=STATIC SRCDIRS=". base utils event http http/client http/server protocol"
  13. test: prepare
  14. -rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
  15. cp main.cpp.tmpl $(TMPDIR)/main.cpp
  16. $(MAKEF) TARGET=$@ SRCDIRS=". base utils $(TMPDIR)"
  17. timer: prepare
  18. -rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
  19. cp examples/timer.c $(TMPDIR)
  20. $(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
  21. loop: prepare
  22. -rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
  23. cp examples/loop.c $(TMPDIR)
  24. $(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
  25. tcp: prepare
  26. -rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
  27. cp examples/tcp.c $(TMPDIR)
  28. $(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
  29. udp: prepare
  30. -rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
  31. cp examples/udp.c $(TMPDIR)
  32. $(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
  33. nc: prepare
  34. -rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
  35. cp examples/nc.c $(TMPDIR)
  36. $(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
  37. nmap: prepare
  38. -rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
  39. cp examples/nmap.cpp $(TMPDIR)
  40. ifeq ($(OS), Windows)
  41. # for nmap on Windows platform, recommand EVENT_POLL, not EVENT_IOCP
  42. $(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)" DEFINES="$(DEFINES) PRINT_DEBUG EVENT_POLL"
  43. else
  44. $(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)" DEFINES="$(DEFINES) PRINT_DEBUG"
  45. endif
  46. httpd: prepare
  47. -rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
  48. cp examples/httpd.cpp examples/http_api_test.h $(TMPDIR)
  49. $(MAKEF) TARGET=$@ SRCDIRS=". base utils event http http/server $(TMPDIR)"
  50. curl: prepare
  51. -rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
  52. cp examples/curl.cpp $(TMPDIR)
  53. $(MAKEF) TARGET=$@ SRCDIRS="$(CURL_SRCDIRS)" SRCDIRS=". base utils http http/client $(TMPDIR)"
  54. #$(MAKEF) TARGET=$@ SRCDIRS="$(CURL_SRCDIRS)" SRCDIRS=". base utils http http/client $(TMPDIR)" DEFINES="$(DEFINES) WITH_CURL CURL_STATICLIB"
  55. unittest: prepare
  56. $(CC) -g -Wall -std=c99 -I. -Ibase -o bin/hmutex unittest/hmutex_test.c -pthread
  57. $(CC) -g -Wall -std=c99 -I. -Ibase -o bin/connect unittest/connect_test.c base/hsocket.c
  58. $(CC) -g -Wall -std=c99 -I. -Ibase -o bin/socketpair unittest/socketpair_test.c base/hsocket.c
  59. $(CXX) -g -Wall -std=c++11 -I. -Ibase -o bin/defer unittest/defer_test.cpp
  60. $(CXX) -g -Wall -std=c++11 -I. -Ibase -o bin/threadpool unittest/threadpool_test.cpp -pthread
  61. $(CXX) -g -Wall -std=c++11 -I. -Ibase -o bin/objectpool unittest/objectpool_test.cpp -pthread
  62. $(CXX) -g -Wall -std=c++11 -I. -Ibase -o bin/ls unittest/listdir_test.cpp base/hdir.cpp base/hbase.c
  63. $(CXX) -g -Wall -std=c++11 -I. -Ibase -Iutils -o bin/ifconfig unittest/ifconfig_test.cpp utils/ifconfig.cpp
  64. $(CC) -g -Wall -std=c99 -I. -Ibase -Iprotocol -o bin/nslookup unittest/nslookup_test.c protocol/dns.c
  65. $(CC) -g -Wall -std=c99 -I. -Ibase -Iprotocol -o bin/ping unittest/ping_test.c protocol/icmp.c base/hsocket.c base/htime.c -DPRINT_DEBUG
  66. $(CC) -g -Wall -std=c99 -I. -Ibase -Iprotocol -o bin/ftp unittest/ftp_test.c protocol/ftp.c base/hsocket.c
  67. $(CC) -g -Wall -std=c99 -I. -Ibase -Iutils -Iprotocol -o bin/sendmail unittest/sendmail_test.c protocol/smtp.c base/hsocket.c utils/base64.c
  68. INSTALL_HEADERS=hv.h\
  69. \
  70. hconfig.h\
  71. base/hplatform.h\
  72. \
  73. base/hdef.h\
  74. base/hversion.h\
  75. base/hbase.h\
  76. base/hsysinfo.h\
  77. base/hproc.h\
  78. base/hmath.h\
  79. base/htime.h\
  80. base/herr.h\
  81. base/hlog.h\
  82. base/hmutex.h\
  83. base/hthread.h\
  84. base/hsocket.h\
  85. base/hbuf.h\
  86. base/hurl.h\
  87. base/hgui.h\
  88. base/ssl_ctx.h\
  89. \
  90. base/hstring.h\
  91. base/hvar.h\
  92. base/hobj.h\
  93. base/hfile.h\
  94. base/hdir.h\
  95. base/hscope.h\
  96. base/hthreadpool.h\
  97. base/hobjectpool.h\
  98. \
  99. utils/base64.h\
  100. utils/md5.h\
  101. utils/json.hpp\
  102. utils/singleton.h\
  103. utils/ifconfig.h\
  104. utils/iniparser.h\
  105. utils/hendian.h\
  106. utils/hmain.h\
  107. \
  108. event/hloop.h\
  109. event/nlog.h\
  110. event/nmap.h\
  111. \
  112. http/httpdef.h\
  113. http/http2def.h\
  114. http/grpcdef.h\
  115. http/http_content.h\
  116. http/HttpMessage.h\
  117. http/client/http_client.h\
  118. http/server/HttpService.h\
  119. http/server/HttpServer.h\
  120. \
  121. protocol/icmp.h\
  122. protocol/dns.h\
  123. protocol/ftp.h\
  124. protocol/smtp.h
  125. install:
  126. -mkdir include
  127. -cp $(INSTALL_HEADERS) include/
  128. # UNIX only
  129. webbench: prepare
  130. $(CC) -o bin/webbench unittest/webbench.c
  131. .PHONY: clean prepare libhv test timer loop tcp udp nc nmap httpd curl unittest webbench install