From 82af922b406ea4b7220791672cd3686201b0ecb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20Bj=C3=B8rnson-Langen?= Date: Mon, 29 Dec 2014 17:12:05 +0100 Subject: [PATCH] Fixed building on OS X. I got it to work on OS X 10.10.2 using clang. Note: I'm an OS noob :) --- Makefile | 9 +++++---- Makefile.osx | 11 +++++++---- README.md | 2 +- filelist.mk | 10 ++++++++++ 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 6f55bcff..019b3649 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,10 @@ else # win32 DAEMON_SRC += DaemonWin32.cpp endif -all: $(SHLIB) $(I2PD) +all: mk_build_dir $(SHLIB) $(I2PD) + +mk_build_dir: + test -d obj || mkdir obj api: $(SHLIB) @@ -34,12 +37,10 @@ api: $(SHLIB) ## custom FLAGS to work at build-time. deps: - @test -d obj || mkdir obj $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) -MM *.cpp > $(DEPS) @sed -i -e '/\.o:/ s/^/obj\//' $(DEPS) obj/%.o : %.cpp - @test -d obj || mkdir obj $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) $(CPU_FLAGS) -c -o $@ $< # '-' is 'ignore if missing' on first run @@ -50,7 +51,7 @@ $(I2PD): $(patsubst %.cpp,obj/%.o,$(DAEMON_SRC)) $(SHLIB): $(patsubst %.cpp,obj/%.o,$(LIB_SRC)) ifneq ($(USE_STATIC),yes) - $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) $(CPU_FLAGS) -shared -o $@ $^ + $(CXX) $(LDFLAGS) $(LDLIBS) -shared -o $@ $^ endif clean: diff --git a/Makefile.osx b/Makefile.osx index ca5fabaf..9d3d2e46 100644 --- a/Makefile.osx +++ b/Makefile.osx @@ -1,5 +1,6 @@ CXX = clang++ -CXXFLAGS = -g -Wall -std=c++11 -lstdc++ -DCRYPTOPP_DISABLE_ASM +CXXFLAGS = -g -Wall -std=c++11 -DCRYPTOPP_DISABLE_ASM +#CXXFLAGS = -g -O2 -Wall -std=c++11 -DCRYPTOPP_DISABLE_ASM INCFLAGS = -I/usr/local/include LDFLAGS = -Wl,-rpath,/usr/local/lib -L/usr/local/lib LDLIBS = -lcryptopp -lboost_system -lboost_date_time -lboost_filesystem -lboost_regex -lboost_program_options -lpthread @@ -12,6 +13,8 @@ ifeq ($(USE_AESNI),yes) CXXFLAGS += -maes -DAESNI endif -install: all - mkdir -p ${PREFIX}/ - cp -r i2p ${PREFIX}/ +# Disabled, since it will be the default make rule. I think its better +# to define the default rule in Makefile and not Makefile. - torkel +#install: all +# test -d ${PREFIX} || mkdir -p ${PREFIX}/ +# cp -r i2p ${PREFIX}/ diff --git a/README.md b/README.md index 91a5cca1..2f55ca5f 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Build Statuses - Linux x64 - [![Build Status](https://jenkins.nordcloud.no/buildStatus/icon?job=i2pd-linux)](https://jenkins.nordcloud.no/job/i2pd-linux/) - Linux ARM - To be added -- Mac OS X - To be added +- Mac OS X - Got it working, but not well tested. (Only works with clang, not GCC.) - Microsoft VC13 - To be added diff --git a/filelist.mk b/filelist.mk index ccb79854..08ba2885 100644 --- a/filelist.mk +++ b/filelist.mk @@ -5,6 +5,16 @@ COMMON_SRC = \ TransitTunnel.cpp Transports.cpp Tunnel.cpp TunnelEndpoint.cpp TunnelPool.cpp \ TunnelGateway.cpp Destination.cpp util.cpp aes.cpp base64.cpp + +ifeq ($(UNAME),Darwin) +# This is needed on OS X for some reason I don't understand (yet). +# Else will get linker error about unknown symbols. - torkel + COMMON_SRC += \ + BOB.cpp ClientContext.cpp Daemon.cpp I2PTunnel.cpp SAM.cpp SOCKS.cpp \ + UPnP.cpp HTTPServer.cpp HTTPProxy.cpp i2p.cpp DaemonLinux.cpp +endif + + # also: Daemon{Linux,Win32}.cpp will be added later DAEMON_SRC = $(COMMON_SRC) \ BOB.cpp ClientContext.cpp Daemon.cpp I2PTunnel.cpp SAM.cpp SOCKS.cpp UPnP.cpp \