Makefile 3.7 KB

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