Makefile 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. include config.mk
  2. include Makefile.vars
  3. MAKEF=$(MAKE) -f Makefile.in
  4. ALL_SRCDIRS=. base utils event protocol http http/client http/server consul examples
  5. LIBHV_SRCDIRS = . base utils event
  6. LIBHV_HEADERS = hv.h hconfig.h hexport.h
  7. LIBHV_HEADERS += $(BASE_HEADERS) $(UTILS_HEADERS) $(EVENT_HEADERS)
  8. ifeq ($(WITH_PROTOCOL), yes)
  9. LIBHV_HEADERS += $(PROTOCOL_HEADERS)
  10. LIBHV_SRCDIRS += protocol
  11. endif
  12. ifeq ($(WITH_HTTP), yes)
  13. LIBHV_HEADERS += $(HTTP_HEADERS)
  14. LIBHV_SRCDIRS += http
  15. ifeq ($(WITH_HTTP_SERVER), yes)
  16. LIBHV_HEADERS += $(HTTP_SERVER_HEADERS)
  17. LIBHV_SRCDIRS += http/server
  18. endif
  19. ifeq ($(WITH_HTTP_CLIENT), yes)
  20. LIBHV_HEADERS += $(HTTP_CLIENT_HEADERS)
  21. LIBHV_SRCDIRS += http/client
  22. ifeq ($(WITH_CONSUL), yes)
  23. LIBHV_HEADERS += $(CONSUL_HEADERS)
  24. LIBHV_SRCDIRS += consul
  25. endif
  26. endif
  27. endif
  28. default: all
  29. all: libhv examples
  30. examples: hmain_test htimer_test hloop_test \
  31. nc nmap httpd curl \
  32. udp_echo_server \
  33. tcp_echo_server \
  34. tcp_chat_server \
  35. tcp_proxy_server \
  36. http_server_test http_client_test \
  37. consul_cli
  38. clean:
  39. $(MAKEF) clean SRCDIRS="$(ALL_SRCDIRS)"
  40. $(RM) include/hv
  41. prepare:
  42. $(MKDIR) bin
  43. libhv:
  44. $(MKDIR) lib
  45. $(MAKEF) TARGET=$@ TARGET_TYPE="SHARED|STATIC" SRCDIRS="$(LIBHV_SRCDIRS)"
  46. $(MKDIR) include/hv
  47. $(CP) $(LIBHV_HEADERS) include/hv
  48. install:
  49. $(MKDIR) $(INSTALL_INCDIR)
  50. $(CP) include/hv/* $(INSTALL_INCDIR)
  51. $(CP) lib/libhv.a lib/libhv.so $(INSTALL_LIBDIR)
  52. hmain_test: prepare
  53. $(MAKEF) TARGET=$@ SRCDIRS=". base utils" SRCS="examples/hmain_test.cpp"
  54. htimer_test: prepare
  55. $(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/htimer_test.c"
  56. hloop_test: prepare
  57. $(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/hloop_test.c"
  58. udp_echo_server: prepare
  59. $(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/udp_echo_server.c"
  60. tcp_echo_server: prepare
  61. $(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/tcp_echo_server.c"
  62. tcp_chat_server: prepare
  63. $(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/tcp_chat_server.c"
  64. tcp_proxy_server: prepare
  65. $(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/tcp_proxy_server.c"
  66. nc: prepare
  67. $(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/nc.c"
  68. nmap: prepare
  69. ifeq ($(OS), Windows)
  70. # for nmap on Windows platform, recommand EVENT_POLL, not EVENT_IOCP
  71. $(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/nmap.cpp" DEFINES="PRINT_DEBUG EVENT_POLL"
  72. else
  73. $(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/nmap.cpp" DEFINES="PRINT_DEBUG"
  74. endif
  75. httpd: prepare
  76. $(RM) examples/httpd/*.o
  77. $(MAKEF) TARGET=$@ SRCDIRS=". base utils event http http/server examples/httpd"
  78. curl: prepare
  79. $(MAKEF) TARGET=$@ SRCDIRS=". base utils event http http/client" SRCS="examples/curl.cpp"
  80. # $(MAKEF) TARGET=$@ SRCDIRS=". base utils event http http/client" SRCS="examples/curl.cpp" WITH_CURL=yes DEFINES="CURL_STATICLIB"
  81. http_server_test: prepare
  82. $(MAKEF) TARGET=$@ SRCDIRS=". base utils event http http/server" SRCS="examples/http_server_test.cpp"
  83. http_client_test: prepare
  84. $(MAKEF) TARGET=$@ SRCDIRS=". base utils event http http/client" SRCS="examples/http_client_test.cpp"
  85. consul_cli: prepare
  86. $(MAKEF) TARGET=$@ SRCDIRS=". base utils event http http/client consul" SRCS="examples/consul_cli.cpp" DEFINES="PRINT_DEBUG"
  87. unittest: prepare
  88. $(CC) -g -Wall -std=c99 -I. -Ibase -o bin/mkdir_p unittest/mkdir_test.c base/hbase.c
  89. $(CC) -g -Wall -std=c99 -I. -Ibase -o bin/rmdir_p unittest/rmdir_test.c base/hbase.c
  90. $(CC) -g -Wall -std=c99 -I. -Ibase -o bin/date unittest/date_test.c base/htime.c
  91. $(CC) -g -Wall -std=c99 -I. -Ibase -o bin/hatomic_test unittest/hatomic_test.c -pthread
  92. $(CXX) -g -Wall -std=c++11 -I. -Ibase -o bin/hatomic_cpp_test unittest/hatomic_test.cpp -pthread
  93. $(CXX) -g -Wall -std=c++11 -I. -Ibase -o bin/hthread_test unittest/hthread_test.cpp -pthread
  94. $(CC) -g -Wall -std=c99 -I. -Ibase -o bin/hmutex_test unittest/hmutex_test.c base/htime.c -pthread
  95. $(CC) -g -Wall -std=c99 -I. -Ibase -o bin/connect_test unittest/connect_test.c base/hsocket.c base/htime.c
  96. $(CC) -g -Wall -std=c99 -I. -Ibase -o bin/socketpair_test unittest/socketpair_test.c base/hsocket.c
  97. $(CXX) -g -Wall -std=c++11 -I. -Ibase -o bin/defer_test unittest/defer_test.cpp
  98. $(CXX) -g -Wall -std=c++11 -I. -Ibase -o bin/synchronized_test unittest/synchronized_test.cpp -pthread
  99. $(CXX) -g -Wall -std=c++11 -I. -Ibase -o bin/hstring_test unittest/hstring_test.cpp base/hstring.cpp
  100. $(CXX) -g -Wall -std=c++11 -I. -Ibase -o bin/threadpool_test unittest/threadpool_test.cpp -pthread
  101. $(CXX) -g -Wall -std=c++11 -I. -Ibase -o bin/objectpool_test unittest/objectpool_test.cpp -pthread
  102. $(CXX) -g -Wall -std=c++11 -I. -Ibase -o bin/ls unittest/listdir_test.cpp base/hdir.cpp
  103. $(CXX) -g -Wall -std=c++11 -I. -Ibase -o bin/ifconfig unittest/ifconfig_test.cpp base/ifconfig.cpp
  104. $(CC) -g -Wall -std=c99 -I. -Ibase -Iprotocol -o bin/nslookup unittest/nslookup_test.c protocol/dns.c
  105. $(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
  106. $(CC) -g -Wall -std=c99 -I. -Ibase -Iprotocol -o bin/ftp unittest/ftp_test.c protocol/ftp.c base/hsocket.c
  107. $(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
  108. # UNIX only
  109. webbench: prepare
  110. $(CC) -o bin/webbench unittest/webbench.c
  111. echo-servers:
  112. $(CC) -g -Wall -std=c99 -o bin/libevent_echo echo-servers/libevent_echo.c -levent
  113. $(CC) -g -Wall -std=c99 -o bin/libev_echo echo-servers/libev_echo.c -lev
  114. $(CC) -g -Wall -std=c99 -o bin/libuv_echo echo-servers/libuv_echo.c -luv
  115. $(CC) -g -Wall -std=c99 -o bin/libhv_echo echo-servers/libhv_echo.c -lhv
  116. $(CXX) -g -Wall -std=c++11 -o bin/asio_echo echo-servers/asio_echo.cpp -lboost_system
  117. $(CXX) -g -Wall -std=c++11 -o bin/poco_echo echo-servers/poco_echo.cpp -lPocoNet -lPocoUtil -lPocoFoundation
  118. $(CXX) -g -Wall -std=c++11 -o bin/muduo_echo echo-servers/muduo_echo.cpp -lmuduo_net -lmuduo_base -lpthread
  119. .PHONY: clean prepare libhv install examples nc nmap httpd curl consul_cli unittest webbench echo-servers