1
0

Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. include config.mk
  2. include Makefile.vars
  3. MAKEF=$(MAKE) -f Makefile.in
  4. ALL_SRCDIRS=. base ssl event event/kcp util cpputil evpp protocol http http/client http/server
  5. CORE_SRCDIRS=. base ssl event
  6. ifeq ($(WITH_KCP), yes)
  7. CORE_SRCDIRS += event/kcp
  8. endif
  9. LIBHV_SRCDIRS = $(CORE_SRCDIRS) util
  10. LIBHV_HEADERS = hv.h hconfig.h hexport.h
  11. LIBHV_HEADERS += $(BASE_HEADERS) $(SSL_HEADERS) $(EVENT_HEADERS) $(UTIL_HEADERS)
  12. ifeq ($(WITH_PROTOCOL), yes)
  13. LIBHV_HEADERS += $(PROTOCOL_HEADERS)
  14. LIBHV_SRCDIRS += protocol
  15. endif
  16. ifeq ($(WITH_EVPP), yes)
  17. LIBHV_HEADERS += $(CPPUTIL_HEADERS) $(EVPP_HEADERS)
  18. LIBHV_SRCDIRS += cpputil evpp
  19. ifeq ($(WITH_HTTP), yes)
  20. LIBHV_HEADERS += $(HTTP_HEADERS)
  21. LIBHV_SRCDIRS += http
  22. ifeq ($(WITH_HTTP_SERVER), yes)
  23. LIBHV_HEADERS += $(HTTP_SERVER_HEADERS)
  24. LIBHV_SRCDIRS += http/server
  25. endif
  26. ifeq ($(WITH_HTTP_CLIENT), yes)
  27. LIBHV_HEADERS += $(HTTP_CLIENT_HEADERS)
  28. LIBHV_SRCDIRS += http/client
  29. endif
  30. endif
  31. endif
  32. default: all
  33. all: libhv examples
  34. examples: hmain_test htimer_test hloop_test \
  35. nc nmap httpd curl wget wrk consul \
  36. tcp_echo_server \
  37. tcp_chat_server \
  38. tcp_proxy_server \
  39. udp_echo_server \
  40. udp_proxy_server \
  41. multi-acceptor-processes \
  42. multi-acceptor-threads \
  43. one-acceptor-multi-workers \
  44. http_server_test http_client_test \
  45. websocket_server_test \
  46. websocket_client_test \
  47. jsonrpc \
  48. clean:
  49. $(MAKEF) clean SRCDIRS="$(ALL_SRCDIRS)"
  50. $(RM) examples/*.o examples/*/*.o
  51. $(RM) include/hv
  52. prepare:
  53. $(MKDIR) bin
  54. libhv:
  55. $(MKDIR) lib
  56. $(MAKEF) TARGET=$@ TARGET_TYPE="SHARED|STATIC" SRCDIRS="$(LIBHV_SRCDIRS)"
  57. $(MKDIR) include/hv
  58. $(CP) $(LIBHV_HEADERS) include/hv
  59. install:
  60. $(MKDIR) $(INSTALL_INCDIR)
  61. $(MKDIR) $(INSTALL_LIBDIR)
  62. $(CP) include/hv/* $(INSTALL_INCDIR)
  63. $(CP) lib/libhv.* $(INSTALL_LIBDIR)
  64. hmain_test: prepare
  65. $(MAKEF) TARGET=$@ SRCDIRS=". base cpputil" SRCS="examples/hmain_test.cpp"
  66. htimer_test: prepare
  67. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS)" SRCS="examples/htimer_test.c"
  68. hloop_test: prepare
  69. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS)" SRCS="examples/hloop_test.c"
  70. tcp_echo_server: prepare
  71. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS)" SRCS="examples/tcp_echo_server.c"
  72. tcp_chat_server: prepare
  73. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS)" SRCS="examples/tcp_chat_server.c"
  74. tcp_proxy_server: prepare
  75. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS)" SRCS="examples/tcp_proxy_server.c"
  76. udp_echo_server: prepare
  77. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS)" SRCS="examples/udp_echo_server.c"
  78. udp_proxy_server: prepare
  79. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS)" SRCS="examples/udp_proxy_server.c"
  80. multi-acceptor-processes: prepare
  81. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS)" SRCS="examples/multi-thread/multi-acceptor-processes.c"
  82. multi-acceptor-threads: prepare
  83. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS)" SRCS="examples/multi-thread/multi-acceptor-threads.c"
  84. one-acceptor-multi-workers: prepare
  85. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS)" SRCS="examples/multi-thread/one-acceptor-multi-workers.c"
  86. nc: prepare
  87. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS)" SRCS="examples/nc.c"
  88. nmap: prepare
  89. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS) cpputil examples/nmap" DEFINES="PRINT_DEBUG"
  90. wrk: prepare
  91. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS) util cpputil evpp http" SRCS="examples/wrk.cpp"
  92. httpd: prepare
  93. $(RM) examples/httpd/*.o
  94. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS) util cpputil evpp http http/client http/server examples/httpd"
  95. consul: prepare
  96. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS) util cpputil evpp http http/client examples/consul" DEFINES="PRINT_DEBUG"
  97. curl: prepare
  98. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS) util cpputil evpp http http/client" SRCS="examples/curl.cpp"
  99. # $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS) util cpputil evpp http http/client" SRCS="examples/curl.cpp" WITH_CURL=yes
  100. wget: prepare
  101. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS) util cpputil evpp http http/client" SRCS="examples/wget.cpp"
  102. http_server_test: prepare
  103. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS) util cpputil evpp http http/server" SRCS="examples/http_server_test.cpp"
  104. http_client_test: prepare
  105. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS) util cpputil evpp http http/client" SRCS="examples/http_client_test.cpp"
  106. websocket_server_test: prepare
  107. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS) util cpputil evpp http http/server" SRCS="examples/websocket_server_test.cpp"
  108. websocket_client_test: prepare
  109. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS) util cpputil evpp http http/client" SRCS="examples/websocket_client_test.cpp"
  110. jsonrpc: jsonrpc_client jsonrpc_server
  111. jsonrpc_client: prepare
  112. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS)" SRCS="examples/jsonrpc/jsonrpc_client.c examples/jsonrpc/jsonrpc.c examples/jsonrpc/cJSON.c"
  113. jsonrpc_server: prepare
  114. $(RM) examples/jsonrpc/*.o
  115. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS)" SRCS="examples/jsonrpc/jsonrpc_server.c examples/jsonrpc/jsonrpc.c examples/jsonrpc/cJSON.c"
  116. protorpc: protorpc_client protorpc_server
  117. protorpc_protoc:
  118. bash examples/protorpc/proto/protoc.sh
  119. protorpc_client: prepare protorpc_protoc
  120. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS) cpputil evpp examples/protorpc/generated" \
  121. SRCS="examples/protorpc/protorpc_client.cpp examples/protorpc/protorpc.c" \
  122. LIBS="protobuf"
  123. protorpc_server: prepare protorpc_protoc
  124. $(RM) examples/protorpc/*.o
  125. $(MAKEF) TARGET=$@ SRCDIRS="$(CORE_SRCDIRS) cpputil evpp examples/protorpc/generated" \
  126. SRCS="examples/protorpc/protorpc_server.cpp examples/protorpc/protorpc.c" \
  127. LIBS="protobuf"
  128. unittest: prepare
  129. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -o bin/rbtree_test unittest/rbtree_test.c base/rbtree.c
  130. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -o bin/mkdir_p unittest/mkdir_test.c base/hbase.c
  131. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -o bin/rmdir_p unittest/rmdir_test.c base/hbase.c
  132. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -o bin/date unittest/date_test.c base/htime.c
  133. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -o bin/hatomic_test unittest/hatomic_test.c -pthread
  134. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -o bin/hatomic_cpp_test unittest/hatomic_test.cpp -pthread
  135. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -o bin/hthread_test unittest/hthread_test.cpp -pthread
  136. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -o bin/hmutex_test unittest/hmutex_test.c base/htime.c -pthread
  137. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -o bin/connect_test unittest/connect_test.c base/hsocket.c base/htime.c
  138. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -o bin/socketpair_test unittest/socketpair_test.c base/hsocket.c
  139. $(CC) -g -Wall -O0 -std=c99 -I. -Iutil -o bin/base64 unittest/base64_test.c util/base64.c
  140. $(CC) -g -Wall -O0 -std=c99 -I. -Iutil -o bin/md5 unittest/md5_test.c util/md5.c
  141. $(CC) -g -Wall -O0 -std=c99 -I. -Iutil -o bin/sha1 unittest/sha1_test.c util/sha1.c
  142. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Icpputil -o bin/hstring_test unittest/hstring_test.cpp cpputil/hstring.cpp
  143. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Icpputil -o bin/hpath_test unittest/hpath_test.cpp cpputil/hpath.cpp
  144. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Icpputil -o bin/ls unittest/listdir_test.cpp cpputil/hdir.cpp
  145. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Icpputil -o bin/ifconfig unittest/ifconfig_test.cpp cpputil/ifconfig.cpp
  146. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Icpputil -o bin/defer_test unittest/defer_test.cpp
  147. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Icpputil -o bin/synchronized_test unittest/synchronized_test.cpp -pthread
  148. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Icpputil -o bin/threadpool_test unittest/threadpool_test.cpp -pthread
  149. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Icpputil -o bin/objectpool_test unittest/objectpool_test.cpp -pthread
  150. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Issl -Ievent -Ievpp -Icpputil -Ihttp -Ihttp/client -Ihttp/server -o bin/sizeof_test unittest/sizeof_test.cpp
  151. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -Iprotocol -o bin/nslookup unittest/nslookup_test.c protocol/dns.c
  152. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -Iprotocol -o bin/ping unittest/ping_test.c protocol/icmp.c base/hsocket.c base/htime.c -DPRINT_DEBUG
  153. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -Iprotocol -o bin/ftp unittest/ftp_test.c protocol/ftp.c base/hsocket.c
  154. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -Iprotocol -Iutil -o bin/sendmail unittest/sendmail_test.c protocol/smtp.c base/hsocket.c util/base64.c
  155. run-unittest: unittest
  156. bash scripts/unittest.sh
  157. check: examples
  158. bash scripts/check.sh
  159. evpp: prepare libhv
  160. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Issl -Ievent -Icpputil -Ievpp -o bin/EventLoop_test evpp/EventLoop_test.cpp -Llib -lhv -pthread
  161. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Issl -Ievent -Icpputil -Ievpp -o bin/EventLoopThread_test evpp/EventLoopThread_test.cpp -Llib -lhv -pthread
  162. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Issl -Ievent -Icpputil -Ievpp -o bin/EventLoopThreadPool_test evpp/EventLoopThreadPool_test.cpp -Llib -lhv -pthread
  163. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Issl -Ievent -Icpputil -Ievpp -o bin/TcpServer_test evpp/TcpServer_test.cpp -Llib -lhv -pthread
  164. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Issl -Ievent -Icpputil -Ievpp -o bin/TcpClient_test evpp/TcpClient_test.cpp -Llib -lhv -pthread
  165. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Issl -Ievent -Icpputil -Ievpp -o bin/UdpServer_test evpp/UdpServer_test.cpp -Llib -lhv -pthread
  166. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Issl -Ievent -Icpputil -Ievpp -o bin/UdpClient_test evpp/UdpClient_test.cpp -Llib -lhv -pthread
  167. # UNIX only
  168. webbench: prepare
  169. $(CC) -o bin/webbench unittest/webbench.c
  170. echo-servers:
  171. $(CXX) -g -Wall -std=c++11 -o bin/pingpong_client echo-servers/pingpong_client.cpp -lhv -pthread
  172. $(CC) -g -Wall -std=c99 -o bin/libevent_echo echo-servers/libevent_echo.c -levent
  173. $(CC) -g -Wall -std=c99 -o bin/libev_echo echo-servers/libev_echo.c -lev
  174. $(CC) -g -Wall -std=c99 -o bin/libuv_echo echo-servers/libuv_echo.c -luv
  175. $(CC) -g -Wall -std=c99 -o bin/libhv_echo echo-servers/libhv_echo.c -lhv
  176. $(CXX) -g -Wall -std=c++11 -o bin/asio_echo echo-servers/asio_echo.cpp -lboost_system -pthread
  177. $(CXX) -g -Wall -std=c++11 -o bin/poco_echo echo-servers/poco_echo.cpp -lPocoNet -lPocoUtil -lPocoFoundation
  178. # $(CXX) -g -Wall -std=c++11 -o bin/muduo_echo echo-servers/muduo_echo.cpp -lmuduo_net -lmuduo_base -pthread
  179. echo-benchmark: echo-servers
  180. bash echo-servers/benchmark.sh
  181. .PHONY: clean prepare install libhv examples unittest evpp echo-servers