Makefile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. manifests = lighttpd.manifest lighttpd-angel.manifest
  2. SRCDIR = lighttpd-1.4.30
  3. HOST = $(firstword $(shell ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' -m 1 | cut -d: -f2))
  4. PORT = 8000
  5. CORES = 4
  6. conf_files = lighttpd-server.conf lighttpd.conf lighttpd-multithreaded.conf
  7. target = build/sbin/lighttpd $(conf_files) test-data
  8. exec_target = $(manifests)
  9. clean-extra = clean-others
  10. level = ../../
  11. include ../../Makefile
  12. $(manifests): %.manifest: %.manifest.template build/sbin/lighttpd build/sbin/lighttpd-angel
  13. $(MAKE) -C .. lighttpd/$@ appdir=lighttpd/ \
  14. extra_rules="-e 's:\\\$$\$$(HOST):$(HOST):g' -e 's:\\\$$\$$(PORT):$(PORT):g'"
  15. build/sbin/lighttpd: $(SRCDIR)
  16. cd $(SRCDIR) && ./configure --prefix=$(PWD)/build \
  17. --without-openssl --without-pcre --without-zlib --without-bzip2
  18. $(MAKE) -C $(SRCDIR)
  19. $(MAKE) -C $(SRCDIR) install
  20. $(SRCDIR): %: %.tar.gz
  21. tar -xzf $<
  22. lighttpd-server.conf:
  23. rm -rf $@
  24. echo "server.document-root = \"$(PWD)/html\"" >> $@
  25. echo "server.port = $(PORT)" >> $@
  26. echo "server.bind = \"$(HOST)\"" >> $@
  27. lighttpd.conf:
  28. rm -rf $@
  29. echo "include \"lighttpd-server.conf\"" >> $@
  30. echo "include \"lighttpd-generic.conf\"" >> $@
  31. lighttpd-multithreaded.conf:
  32. rm -rf $@
  33. echo "include \"lighttpd-server.conf\"" >> $@
  34. echo "server.max-worker = $(CORES)" >> $@
  35. echo "include \"lighttpd-generic.conf\"" >> $@
  36. start-native-server:
  37. $(PREFIX) build/sbin/lighttpd -D -m build/lib -f \
  38. $(if $(CONF),$(CONF),lighttpd.conf)
  39. start-multithreaded-native-server:
  40. $(PREFIX) build/sbin/lighttpd -D -m build/lib -f \
  41. $(if $(CONF),$(CONF),lighttpd-multithreaded.conf)
  42. start-graphene-server:
  43. $(PREFIX) ./lighttpd.manifest -D -m /lighttpd -f \
  44. $(if $(CONF),$(CONF),lighttpd.conf)
  45. start-multithreaded-graphene-server:
  46. $(PREFIX) ./lighttpd.manifest -D -m /lighttpd -f \
  47. $(if $(CONF),$(CONF),lighttpd-multithreaded.conf)
  48. random-data = $(foreach n,1 2 3 4 5 6 7 8 9 10,2K.$n.html) \
  49. $(foreach n,1 2 3 4 5,10K.$n.html) \
  50. $(foreach n,1 2 3 4 5,100K.$n.html) \
  51. $(foreach n,1 2 3,1M.$n.html) \
  52. $(foreach n,1 2 3,10M.$n.html) \
  53. $(foreach n,1 2 3,100.$n.html)
  54. test-data = html/oscar-web html/oscar-web-static html/random \
  55. $(addprefix html/random/,$(random-data))
  56. try-download:
  57. echo "download random files ($(TESTNAME)):" >> result; \
  58. time -a -o result -p wget $(addprefix http://$(HOST):$(PORT)/random/,$(random-data)) -O wget-out; \
  59. echo "download random files again ($(TESTNAME)):" >> result; \
  60. time -a -o result -p wget $(addprefix http://$(HOST):$(PORT)/random/,$(random-data)) -O wget-out; \
  61. echo "download static oscar-web ($(TESTNAME)):" >> result; \
  62. time -a -o result -p wget -r http://$(HOST):$(PORT)/oscar-web-static/index.php -O wget-out;
  63. test-native: $(test-data)
  64. $(MAKE) start-native-server & serverid=$$!; sleep 1; \
  65. $(MAKE) try-download TESTNAME=native; \
  66. rm wget-out; kill $$serverid
  67. test-multithreaded-native: $(test-data)
  68. $(MAKE) start-multithreaded-native-server & serverid=$$!; sleep 1; \
  69. $(MAKE) try-download TESTNAME=native; \
  70. rm wget-out; kill $$serverid
  71. test-graphene: $(test-data)
  72. $(MAKE) start-graphene-server & serverid=$$!; sleep 1; \
  73. $(MAKE) try-download TESTNAME=graphene; \
  74. rm wget-out; kill $$serverid
  75. test-multithreaded-graphene: $(test-data)
  76. $(MAKE) start-multithreaded-graphene-server & serverid=$$!; sleep 1; \
  77. $(MAKE) try-download TESTNAME=graphene; \
  78. rm wget-out; kill $$serverid
  79. html/%: ../web-data/%.tar.gz
  80. [ -d "$@" ] || (cd html && tar -xzf ../$^)
  81. html/random:
  82. mkdir -p html/random
  83. html/random/%.html: html/random
  84. dd if=/dev/urandom of=$@ count=1 bs=$(basename $(basename $(notdir $@)))
  85. test-data: $(test-data)
  86. distclean: clean
  87. rm -rf build $(SRCDIR)
  88. clean-others:
  89. rm -rf $(conf_files) $(test-data)