diff --git a/Makefile b/Makefile index cc7f9d6a1..bf8b20456 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,18 @@ +PLATFORM ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"') + +ifeq ($(PLATFORM),darwin) +FLAGS_BOOST_THREAD = -lboost_thread-mt +else +FLAGS_BOOST_THREAD = -lboost_thread +FLAGS_DEBUG = -g +endif + binaries=covtest example all: covtest example example: example.cpp settings.h crow.h http_server.h http_connection.h parser.h http_response.h routing.h common.h utility.h json.h datetime.h logging.h - ${CXX} -Wall -g -O3 -std=c++1y -o example example.cpp http-parser/http_parser.c -pthread -lboost_system -lboost_thread -ltcmalloc_minimal -I http-parser/ + ${CXX} -Wall $(FLAGS_DEBUG) -O3 -std=c++1y -o example example.cpp http-parser/http_parser.c -pthread -lboost_system $(FLAGS_BOOST_THREAD) -ltcmalloc_minimal -I http-parser/ test: covtest @@ -14,11 +23,11 @@ runtest: example pkill example unittest: unittest.cpp routing.h utility.h crow.h http_server.h http_connection.h parser.h http_response.h common.h json.h datetime.h logging.h - ${CXX} -Wall -g -std=c++1y -o unittest unittest.cpp http-parser/http_parser.c -pthread -lboost_system -lboost_thread -I http-parser/ + ${CXX} -Wall $(FLAGS_DEBUG) -std=c++1y -o unittest unittest.cpp http-parser/http_parser.c -pthread -lboost_system $(FLAGS_BOOST_THREAD) -I http-parser/ ./unittest covtest: unittest.cpp routing.h utility.h crow.h http_server.h http_connection.h parser.h http_response.h common.h json.h datetime.h logging.h - ${CXX} -Wall -g -std=c++1y -o covtest --coverage unittest.cpp http-parser/http_parser.c -pthread -lboost_system -lboost_thread -I http-parser/ + ${CXX} -Wall $(FLAGS_DEBUG) -std=c++1y -o covtest --coverage unittest.cpp http-parser/http_parser.c -pthread -lboost_system $(FLAGS_BOOST_THREAD) -I http-parser/ ./covtest gcov -r unittest.cpp diff --git a/README.md b/README.md index adc574906..036eb23be 100644 --- a/README.md +++ b/README.md @@ -71,11 +71,18 @@ int main() ## How to Build -### Installing missing dependencies - -#### Ubuntu +### Ubuntu +#### Installing missing dependencies sudo apt-get install build-essential libtcmalloc-minimal4 && sudo ln -s /usr/lib/libtcmalloc_minimal.so.4 /usr/lib/libtcmalloc_minimal.so -### Building +#### Building git submodule init && git submodule update make -j$(($(grep -c '^processor' /proc/cpuinfo)+1)) + +### OSX +#### Installing missing dependencies + brew install boost google-perftools + +#### Building + git submodule init && git submodule update + make -j$(($(sysctl -a | grep machdep.cpu.thread_count | awk -F " " '{print $2}')+1))