a simple multithreaded webserver
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.8KB

  1. # this ifeq is not optional, because otherwise local.conf would always be built
  2. ifeq ($(wildcard local.conf),local.conf)
  3. -include local.conf
  4. endif
  5. PREFIX?=$(HOME)/local/
  6. BOOST_INCLUDE?=$(PREFIX)/include/
  7. BOOST_LIB?=$(PREFIX)/lib/
  8. AR?=ar
  9. CC?=cc
  10. CXX?=c++
  11. CFLAGS+=-std=c11
  12. CXXFLAGS+=-I$(BOOST_INCLUDE) -std=c++11
  13. LDFLAGS+=$(BOOST_LIB)/libboost_regex.a $(BOOST_LIB)/libboost_filesystem.a
  14. ifdef NDEBUG
  15. CFLAGS+=-O3 -DNDEBUG -fvisibility=hidden
  16. CXXFLAGS+=-O3 -DNDEBUG -fvisibility=hidden
  17. else
  18. CFLAGS+=-O0 -g -fvisibility=hidden
  19. CXXFLAGS+=-O0 -g -fvisibility=hidden
  20. endif
  21. TARGET=libpEpwebserver.a
  22. ALL_SOURCE=$(filter-out test_%.cc,$(wildcard *.cc))
  23. DEPENDS=$(subst .cc,.d,$(ALL_SOURCE))
  24. ALL_OBJECTS=$(subst .d,.o,$(DEPENDS))
  25. TEST_SOURCE=$(wildcard test_*.cc)
  26. TEST_OBJECTS=$(subst .cc,.o,$(TEST_SOURCE))
  27. TESTS=$(subst .cc,,$(TEST_SOURCE))
  28. all: $(TARGET)
  29. %.d: %.cc
  30. @set -e; rm -f $@; \
  31. $(CC) -MM $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
  32. sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
  33. rm -f $@.$$$$
  34. # If only the goal 'clean' is given, do not generate and include the '%.d' files.
  35. ifneq ($(MAKECMDGOALS),clean)
  36. -include $(DEPENDS)
  37. endif
  38. $(TARGET): $(ALL_OBJECTS)
  39. $(AR) -cr $@ $^
  40. %.o: %.cc
  41. $(CXX) $(CXXFLAGS) -c -o $@ $^
  42. test_%: test_%.o $(TARGET)
  43. $(CXX) $(LDFLAGS) $(TARGET) -o $@ $<
  44. test: $(TESTS)
  45. for i in $(TESTS) ; do ./$$i ; done
  46. .PHONY: clean uninstall install
  47. install: $(TARGET)
  48. mkdir -p $(PREFIX)/include/pEp
  49. cp -v *.hh $(PREFIX)/include/pEp
  50. cp -v libpEpwebserver.a $(PREFIX)/lib/
  51. uninstall:
  52. for i in *.hh; do rm -f $(PREFIX)/include/pEp/\$i ; done
  53. clean:
  54. rm -vf *.a *.o *.d *.d.* $(TARGET) $(TESTS)
  55. local.conf:
  56. @echo writing local.conf
  57. @echo 'PREFIX=$$(HOME)' > local.conf
  58. @echo 'BOOST_INCLUDE=$(BOOST_INCLUDE)' >> local.conf
  59. @echo 'BOOST_LIB=$(BOOST_LIB)' >> local.conf