Makefile 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. include config.mk
  2. include Makefile.vars
  3. MAKEF=$(MAKE) -f Makefile.in
  4. ALL_SRCDIRS=. base util event protocol cpputil evpp http http/client http/server consul
  5. LIBHV_SRCDIRS = . base util event
  6. LIBHV_HEADERS = hv.h hconfig.h hexport.h
  7. LIBHV_HEADERS += $(BASE_HEADERS) $(UTIL_HEADERS) $(EVENT_HEADERS)
  8. ifeq ($(WITH_PROTOCOL), yes)
  9. LIBHV_HEADERS += $(PROTOCOL_HEADERS)
  10. LIBHV_SRCDIRS += protocol
  11. endif
  12. ifeq ($(WITH_EVPP), yes)
  13. LIBHV_HEADERS += $(CPPUTIL_HEADERS) $(EVPP_HEADERS)
  14. LIBHV_SRCDIRS += cpputil evpp
  15. ifeq ($(WITH_HTTP), yes)
  16. LIBHV_HEADERS += $(HTTP_HEADERS)
  17. LIBHV_SRCDIRS += http
  18. ifeq ($(WITH_HTTP_SERVER), yes)
  19. LIBHV_HEADERS += $(HTTP_SERVER_HEADERS)
  20. LIBHV_SRCDIRS += http/server
  21. endif
  22. ifeq ($(WITH_HTTP_CLIENT), yes)
  23. LIBHV_HEADERS += $(HTTP_CLIENT_HEADERS)
  24. LIBHV_SRCDIRS += http/client
  25. ifeq ($(WITH_CONSUL), yes)
  26. LIBHV_HEADERS += $(CONSUL_HEADERS)
  27. LIBHV_SRCDIRS += consul
  28. endif
  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 \
  36. tcp_echo_server \
  37. tcp_chat_server \
  38. tcp_proxy_server \
  39. udp_echo_server \
  40. udp_proxy_server \
  41. http_server_test http_client_test \
  42. websocket_server_test \
  43. websocket_client_test \
  44. consul_cli
  45. clean:
  46. $(MAKEF) clean SRCDIRS="$(ALL_SRCDIRS)"
  47. $(RM) examples/*.o examples/httpd/*.o examples/nmap/*.o
  48. $(RM) include/hv
  49. prepare:
  50. $(MKDIR) bin
  51. libhv:
  52. $(MKDIR) lib
  53. $(MAKEF) TARGET=$@ TARGET_TYPE="SHARED|STATIC" SRCDIRS="$(LIBHV_SRCDIRS)"
  54. $(MKDIR) include/hv
  55. $(CP) $(LIBHV_HEADERS) include/hv
  56. install:
  57. $(MKDIR) $(INSTALL_INCDIR)
  58. $(MKDIR) $(INSTALL_LIBDIR)
  59. $(CP) include/hv/* $(INSTALL_INCDIR)
  60. $(CP) lib/libhv.* $(INSTALL_LIBDIR)
  61. hmain_test: prepare
  62. $(MAKEF) TARGET=$@ SRCDIRS=". base cpputil" SRCS="examples/hmain_test.cpp"
  63. htimer_test: prepare
  64. $(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/htimer_test.c"
  65. hloop_test: prepare
  66. $(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/hloop_test.c"
  67. tcp_echo_server: prepare
  68. $(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/tcp_echo_server.c"
  69. tcp_chat_server: prepare
  70. $(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/tcp_chat_server.c"
  71. tcp_proxy_server: prepare
  72. $(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/tcp_proxy_server.c"
  73. udp_echo_server: prepare
  74. $(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/udp_echo_server.c"
  75. udp_proxy_server: prepare
  76. $(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/udp_proxy_server.c"
  77. nc: prepare
  78. $(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/nc.c"
  79. nmap: prepare
  80. $(MAKEF) TARGET=$@ SRCDIRS=". base event cpputil examples/nmap" SRCS="examples/nmap/nmap_test.cpp" DEFINES="PRINT_DEBUG"
  81. httpd: prepare
  82. $(MAKEF) TARGET=$@ SRCDIRS=". base event util cpputil evpp http http/server examples/httpd"
  83. curl: prepare
  84. $(MAKEF) TARGET=$@ SRCDIRS=". base event util cpputil evpp http http/client" SRCS="examples/curl.cpp"
  85. # $(MAKEF) TARGET=$@ SRCDIRS=". base event util cpputil evpp http http/client" SRCS="examples/curl.cpp" WITH_CURL=yes
  86. wget: prepare
  87. $(MAKEF) TARGET=$@ SRCDIRS=". base event util cpputil evpp http http/client" SRCS="examples/wget.cpp"
  88. http_server_test: prepare
  89. $(MAKEF) TARGET=$@ SRCDIRS=". base event util cpputil evpp http http/server" SRCS="examples/http_server_test.cpp"
  90. http_client_test: prepare
  91. $(MAKEF) TARGET=$@ SRCDIRS=". base event util cpputil evpp http http/client" SRCS="examples/http_client_test.cpp"
  92. websocket_server_test: prepare
  93. $(MAKEF) TARGET=$@ SRCDIRS=". base event util cpputil evpp http http/server" SRCS="examples/websocket_server_test.cpp"
  94. websocket_client_test: prepare
  95. $(MAKEF) TARGET=$@ SRCDIRS=". base event util cpputil evpp http http/client" SRCS="examples/websocket_client_test.cpp"
  96. consul_cli: prepare
  97. $(MAKEF) TARGET=$@ SRCDIRS=". base event util cpputil evpp http http/client consul" SRCS="examples/consul_cli.cpp" DEFINES="PRINT_DEBUG"
  98. unittest: prepare
  99. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -o bin/mkdir_p unittest/mkdir_test.c base/hbase.c
  100. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -o bin/rmdir_p unittest/rmdir_test.c base/hbase.c
  101. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -o bin/date unittest/date_test.c base/htime.c
  102. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -o bin/hatomic_test unittest/hatomic_test.c -pthread
  103. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -o bin/hatomic_cpp_test unittest/hatomic_test.cpp -pthread
  104. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -o bin/hthread_test unittest/hthread_test.cpp -pthread
  105. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -o bin/hmutex_test unittest/hmutex_test.c base/htime.c -pthread
  106. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -o bin/connect_test unittest/connect_test.c base/hsocket.c base/htime.c
  107. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -o bin/socketpair_test unittest/socketpair_test.c base/hsocket.c
  108. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Icpputil -o bin/hstring_test unittest/hstring_test.cpp cpputil/hstring.cpp
  109. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Icpputil -o bin/ls unittest/listdir_test.cpp cpputil/hdir.cpp
  110. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Icpputil -o bin/ifconfig unittest/ifconfig_test.cpp cpputil/ifconfig.cpp
  111. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Icpputil -o bin/defer_test unittest/defer_test.cpp
  112. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Icpputil -o bin/synchronized_test unittest/synchronized_test.cpp -pthread
  113. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Icpputil -o bin/threadpool_test unittest/threadpool_test.cpp -pthread
  114. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Icpputil -o bin/objectpool_test unittest/objectpool_test.cpp -pthread
  115. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -Iprotocol -o bin/nslookup unittest/nslookup_test.c protocol/dns.c
  116. $(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
  117. $(CC) -g -Wall -O0 -std=c99 -I. -Ibase -Iprotocol -o bin/ftp unittest/ftp_test.c protocol/ftp.c base/hsocket.c
  118. $(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
  119. evpp: prepare libhv
  120. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Ievent -Icpputil -Ievpp -o bin/EventLoop_test evpp/EventLoop_test.cpp -Llib -lhv -lpthread
  121. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Ievent -Icpputil -Ievpp -o bin/EventLoopThread_test evpp/EventLoopThread_test.cpp -Llib -lhv -lpthread
  122. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Ievent -Icpputil -Ievpp -o bin/EventLoopThreadPool_test evpp/EventLoopThreadPool_test.cpp -Llib -lhv -lpthread
  123. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Ievent -Icpputil -Ievpp -o bin/TcpServer_test evpp/TcpServer_test.cpp -Llib -lhv -lpthread
  124. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Ievent -Icpputil -Ievpp -o bin/TcpClient_test evpp/TcpClient_test.cpp -Llib -lhv -lpthread
  125. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Ievent -Icpputil -Ievpp -o bin/UdpServer_test evpp/UdpServer_test.cpp -Llib -lhv -lpthread
  126. $(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Ievent -Icpputil -Ievpp -o bin/UdpClient_test evpp/UdpClient_test.cpp -Llib -lhv -lpthread
  127. # UNIX only
  128. webbench: prepare
  129. $(CC) -o bin/webbench unittest/webbench.c
  130. echo-servers:
  131. $(CXX) -g -Wall -std=c++11 -o bin/pingpong_client echo-servers/pingpong_client.cpp -lhv -lpthread
  132. $(CC) -g -Wall -std=c99 -o bin/libevent_echo echo-servers/libevent_echo.c -levent
  133. $(CC) -g -Wall -std=c99 -o bin/libev_echo echo-servers/libev_echo.c -lev
  134. $(CC) -g -Wall -std=c99 -o bin/libuv_echo echo-servers/libuv_echo.c -luv
  135. $(CC) -g -Wall -std=c99 -o bin/libhv_echo echo-servers/libhv_echo.c -lhv
  136. $(CXX) -g -Wall -std=c++11 -o bin/asio_echo echo-servers/asio_echo.cpp -lboost_system -lpthread
  137. $(CXX) -g -Wall -std=c++11 -o bin/poco_echo echo-servers/poco_echo.cpp -lPocoNet -lPocoUtil -lPocoFoundation
  138. # $(CXX) -g -Wall -std=c++11 -o bin/muduo_echo echo-servers/muduo_echo.cpp -lmuduo_net -lmuduo_base -lpthread
  139. .PHONY: clean prepare install libhv examples unittest evpp echo-servers