Makefile 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. MAKEF=$(MAKE) -f Makefile.in
  2. TMPDIR=tmp
  3. default: all
  4. all: libhw test ping timer loop tcp udp nc nmap httpd
  5. clean:
  6. $(MAKEF) clean SRCDIRS=". base utils event http http/client http/server examples $(TMPDIR)"
  7. prepare:
  8. -mkdir -p $(TMPDIR)
  9. libhw:
  10. $(MAKEF) TARGET=$@ TARGET_TYPE=STATIC SRCDIRS=". base utils event http http/client http/server"
  11. test: prepare
  12. -rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
  13. cp main.cpp.tmpl $(TMPDIR)/main.cpp
  14. $(MAKEF) TARGET=$@ SRCDIRS=". base utils $(TMPDIR)"
  15. ping:
  16. -rm base/hsocket.o
  17. $(MAKEF) TARGET=$@ SRCDIRS="" SRCS="examples/ping.c base/hsocket.c base/htime.c base/RAII.cpp" INCDIRS=". base" DEFINES="PRINT_DEBUG"
  18. timer: prepare
  19. -rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
  20. cp examples/timer.c $(TMPDIR)
  21. $(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
  22. loop: prepare
  23. -rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
  24. cp examples/loop.c $(TMPDIR)
  25. $(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
  26. tcp: prepare
  27. -rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
  28. cp examples/tcp.c $(TMPDIR)
  29. $(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
  30. udp: prepare
  31. -rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
  32. cp examples/udp.c $(TMPDIR)
  33. $(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
  34. nc: prepare
  35. -rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
  36. cp examples/nc.c $(TMPDIR)
  37. $(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
  38. nmap: prepare
  39. -rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
  40. cp examples/nmap.cpp $(TMPDIR)
  41. ifeq ($(OS), Windows)
  42. # for nmap, on Windows platform, we suggest EVENT_POLL, not EVENT_IOCP
  43. $(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)" DEFINES="PRINT_DEBUG EVENT_POLL"
  44. else
  45. $(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)" DEFINES="PRINT_DEBUG"
  46. endif
  47. httpd: prepare
  48. -rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
  49. cp examples/httpd.cpp examples/httpd_conf.h examples/http_api_test.h $(TMPDIR)
  50. $(MAKEF) TARGET=$@ SRCDIRS=". base utils event http http/server $(TMPDIR)"
  51. webbench:
  52. $(MAKEF) TARGET=$@ SRCDIRS="" SRCS="examples/webbench.c"
  53. # curl
  54. CURL_SRCDIRS := http http/client
  55. CURL_INCDIRS += base utils http http/client
  56. CURL_SRCS += examples/curl.cpp base/hstring.cpp base/hbase.c
  57. curl:
  58. $(MAKEF) TARGET=$@ SRCDIRS="$(CURL_SRCDIRS)" INCDIRS="$(CURL_INCDIRS)" SRCS="$(CURL_SRCS)" DEFINES="CURL_STATICLIB" LIBS="curl"
  59. .PHONY: clean prepare libhw test ping timer loop tcp udp nc nmap httpd webbench curl