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.
 
 
 

78 lines
1.8 KiB

# this ifeq is not optional, because otherwise local.conf would always be built
ifeq ($(wildcard local.conf),local.conf)
-include local.conf
endif
PREFIX?=$(HOME)/local/
BOOST_INCLUDE?=$(PREFIX)/include/
BOOST_LIB?=$(PREFIX)/lib/
AR?=ar
CC?=cc
CXX?=c++
CFLAGS+=-std=c11
CXXFLAGS+=-I$(BOOST_INCLUDE) -std=c++11
LDFLAGS+=$(BOOST_LIB)/libboost_regex.a $(BOOST_LIB)/libboost_filesystem.a
ifdef NDEBUG
CFLAGS+=-O3 -DNDEBUG -fvisibility=hidden
CXXFLAGS+=-O3 -DNDEBUG -fvisibility=hidden
else
CFLAGS+=-O0 -g -fvisibility=hidden
CXXFLAGS+=-O0 -g -fvisibility=hidden
endif
TARGET=libpEpwebserver.a
ALL_SOURCE=$(filter-out test_%.cc,$(wildcard *.cc))
DEPENDS=$(subst .cc,.d,$(ALL_SOURCE))
ALL_OBJECTS=$(subst .d,.o,$(DEPENDS))
TEST_SOURCE=$(wildcard test_*.cc)
TEST_OBJECTS=$(subst .cc,.o,$(TEST_SOURCE))
TESTS=$(subst .cc,,$(TEST_SOURCE))
all: $(TARGET)
%.d: %.cc
@set -e; rm -f $@; \
$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
# If only the goal 'clean' is given, do not generate and include the '%.d' files.
ifneq ($(MAKECMDGOALS),clean)
-include $(DEPENDS)
endif
$(TARGET): $(ALL_OBJECTS)
$(AR) -cr $@ $^
%.o: %.cc
$(CXX) $(CXXFLAGS) -c -o $@ $^
test_%: test_%.o $(TARGET)
$(CXX) $(LDFLAGS) $(TARGET) -o $@ $<
test: $(TESTS)
for i in $(TESTS) ; do ./$$i ; done
.PHONY: clean uninstall install
install: $(TARGET)
mkdir -p $(PREFIX)/include/pEp
cp -v *.hh $(PREFIX)/include/pEp
cp -v libpEpwebserver.a $(PREFIX)/lib/
uninstall:
for i in *.hh; do rm -f $(PREFIX)/include/pEp/\$i ; done
clean:
rm -vf *.a *.o *.d *.d.* $(TARGET) $(TESTS)
local.conf:
@echo writing local.conf
@echo 'PREFIX=$$(HOME)' > local.conf
@echo 'BOOST_INCLUDE=$(BOOST_INCLUDE)' >> local.conf
@echo 'BOOST_LIB=$(BOOST_LIB)' >> local.conf