From 524b2e9f8a35a73984cc96b5b8677bd2ea19ddca Mon Sep 17 00:00:00 2001 From: Kill Your TV Date: Wed, 29 Oct 2014 21:11:58 +0000 Subject: [PATCH 1/4] check for 64-bit compiler --- Makefile.linux | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile.linux b/Makefile.linux index 77bb2c60fd6..e485b3e248e 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -2,6 +2,9 @@ CC = g++ CFLAGS = -g -Wall CXXVER := $(shell ${CC} -dumpversion) +FGREP = fgrep +IS_64 := $(shell $(CXX) -dumpmachine 2>&1 | $(FGREP) -c "64") + ifeq ($(shell expr match ${CXXVER} "4\.[0-9][0-9]"),4) # >= 4.10 CFLAGS += -std=c++11 else ifeq ($(shell expr match ${CXXVER} "4\.[7-9]"),3) # >= 4.7 @@ -18,8 +21,11 @@ INCFLAGS = LDFLAGS = -lcryptopp -lboost_system -lboost_date_time -lboost_filesystem -lboost_regex -lboost_program_options -lpthread LIBS = + +ifeq ($(IS_64),1) #check if AES-NI is supported by CPU ifneq ($(shell grep -c aes /proc/cpuinfo),0) CPU_FLAGS = -maes -DAESNI endif +endif From 5acbc6a23eef8d65c1a37f350edb2e11448bd875 Mon Sep 17 00:00:00 2001 From: Kill Your TV Date: Wed, 29 Oct 2014 21:54:47 +0000 Subject: [PATCH 2/4] use standard make variables --- Makefile | 4 ++-- Makefile.bsd | 4 ++-- Makefile.linux | 11 +++++------ Makefile.osx | 6 +++--- debian/patches/rename-binary.patch | 8 +++----- debian/rules | 1 - 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 9b9425b1b45..6e6433a1e90 100644 --- a/Makefile +++ b/Makefile @@ -11,13 +11,13 @@ endif all: obj i2p i2p: $(OBJECTS:obj/%=obj/%) - $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) + $(CXX) -o $@ $^ $(LDFLAGS) $(LIBS) .SUFFIXES: .SUFFIXES: .c .cc .C .cpp .o obj/%.o : %.cpp - $(CC) -o $@ $< -c $(CFLAGS) $(INCFLAGS) $(CPU_FLAGS) + $(CXX) -o $@ $< -c $(CXXFLAGS) $(INCFLAGS) $(CPU_FLAGS) obj: mkdir -p obj diff --git a/Makefile.bsd b/Makefile.bsd index 517016ca790..942b555d9a3 100644 --- a/Makefile.bsd +++ b/Makefile.bsd @@ -1,5 +1,5 @@ -CC = g++ -CFLAGS = -std=c++11 -O2 +CXX = g++ +CXXFLAGS = -std=c++11 -O2 include filelist.mk INCFLAGS = -I/usr/include/ -I/usr/local/include/ LDFLAGS = -Wl,-rpath,/usr/local/lib -L/usr/local/lib -lcryptopp -lboost_system -lboost_date_time -lboost_filesystem -lboost_regex -lboost_program_options -lpthread diff --git a/Makefile.linux b/Makefile.linux index e485b3e248e..5ed473dd054 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -1,16 +1,15 @@ -CC = g++ -CFLAGS = -g -Wall -CXXVER := $(shell ${CC} -dumpversion) +CXXFLAGS = -g -Wall +CXXVER := $(shell $(CXX) -dumpversion) FGREP = fgrep IS_64 := $(shell $(CXX) -dumpmachine 2>&1 | $(FGREP) -c "64") ifeq ($(shell expr match ${CXXVER} "4\.[0-9][0-9]"),4) # >= 4.10 -CFLAGS += -std=c++11 +CXXFLAGS += -std=c++11 else ifeq ($(shell expr match ${CXXVER} "4\.[7-9]"),3) # >= 4.7 -CFLAGS += -std=c++11 +CXXFLAGS += -std=c++11 else ifeq ($(shell expr match ${CXXVER} "4\.6"),3) # = 4.6 -CFLAGS += -std=c++0x +CXXFLAGS += -std=c++0x else # not supported $(error Compiler too old) endif diff --git a/Makefile.osx b/Makefile.osx index 56c9d0c701e..180e48becfd 100644 --- a/Makefile.osx +++ b/Makefile.osx @@ -1,5 +1,5 @@ -CC = clang++ -CFLAGS = -g -Wall -std=c++11 -lstdc++ -I/usr/local/include +CXX = clang++ +CXXFLAGS = -g -Wall -std=c++11 -lstdc++ -I/usr/local/include include filelist.mk INCFLAGS = -DCRYPTOPP_DISABLE_ASM LDFLAGS = -Wl,-rpath,/usr/local/lib -L/usr/local/lib -lcryptopp -lboost_system -lboost_date_time -lboost_filesystem -lboost_regex -lboost_program_options -lpthread @@ -9,7 +9,7 @@ LIBS = # http://www.hutsby.net/2011/08/macs-with-aes-ni.html # Seems like all recent Mac's have AES-NI, after firmware upgrade 2.2 # Found no good way to detect it from command line. TODO: Might be some osx sysinfo magic -CFLAGS += -maes -DAESNI +CXXFLAGS += -maes -DAESNI # Apple Mac OSX UNAME_S := $(shell uname -s) diff --git a/debian/patches/rename-binary.patch b/debian/patches/rename-binary.patch index 5c74f388dcf..70973dec53c 100644 --- a/debian/patches/rename-binary.patch +++ b/debian/patches/rename-binary.patch @@ -1,8 +1,6 @@ -diff --git a/Makefile b/Makefile -index 9b9425b..84de72f 100644 --- a/Makefile +++ b/Makefile -@@ -8,9 +8,9 @@ else +@@ -10,9 +10,9 @@ include Makefile.linux endif @@ -11,10 +9,10 @@ index 9b9425b..84de72f 100644 -i2p: $(OBJECTS:obj/%=obj/%) +i2pd: $(OBJECTS:obj/%=obj/%) - $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) + $(CXX) -o $@ $^ $(LDFLAGS) $(LIBS) .SUFFIXES: -@@ -23,7 +23,7 @@ obj: +@@ -25,7 +25,7 @@ mkdir -p obj clean: diff --git a/debian/rules b/debian/rules index 000a1532002..bf31e452508 100755 --- a/debian/rules +++ b/debian/rules @@ -6,7 +6,6 @@ DPKG_EXPORT_BUILDFLAGS = 1 include /usr/share/dpkg/buildflags.mk -CFLAGS+=$(CPPFLAGS) CXXFLAGS+=$(CPPFLAGS) PREFIX=/usr From 6681e25513a6f6891dab2b096086164f0a8a2b68 Mon Sep 17 00:00:00 2001 From: Kill Your TV Date: Thu, 30 Oct 2014 01:42:06 +0000 Subject: [PATCH 3/4] allow CXXFLAGS to be set without overwriting needed flags --- Makefile | 2 +- Makefile.bsd | 3 ++- Makefile.linux | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 6e6433a1e90..4b5832e189a 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ i2p: $(OBJECTS:obj/%=obj/%) .SUFFIXES: .c .cc .C .cpp .o obj/%.o : %.cpp - $(CXX) -o $@ $< -c $(CXXFLAGS) $(INCFLAGS) $(CPU_FLAGS) + $(CXX) -o $@ $< -c $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) $(CPU_FLAGS) obj: mkdir -p obj diff --git a/Makefile.bsd b/Makefile.bsd index 942b555d9a3..d234d3f2795 100644 --- a/Makefile.bsd +++ b/Makefile.bsd @@ -1,5 +1,6 @@ CXX = g++ -CXXFLAGS = -std=c++11 -O2 +CXXFLAGS = -O2 +NEEDED_CXXFLAGS = -std=c++11 include filelist.mk INCFLAGS = -I/usr/include/ -I/usr/local/include/ LDFLAGS = -Wl,-rpath,/usr/local/lib -L/usr/local/lib -lcryptopp -lboost_system -lboost_date_time -lboost_filesystem -lboost_regex -lboost_program_options -lpthread diff --git a/Makefile.linux b/Makefile.linux index 5ed473dd054..c7f3babed3f 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -5,11 +5,11 @@ FGREP = fgrep IS_64 := $(shell $(CXX) -dumpmachine 2>&1 | $(FGREP) -c "64") ifeq ($(shell expr match ${CXXVER} "4\.[0-9][0-9]"),4) # >= 4.10 -CXXFLAGS += -std=c++11 +NEEDED_CXXFLAGS += -std=c++11 else ifeq ($(shell expr match ${CXXVER} "4\.[7-9]"),3) # >= 4.7 -CXXFLAGS += -std=c++11 +NEEDED_CXXFLAGS += -std=c++11 else ifeq ($(shell expr match ${CXXVER} "4\.6"),3) # = 4.6 -CXXFLAGS += -std=c++0x +NEEDED_CXXFLAGS += -std=c++0x else # not supported $(error Compiler too old) endif From 38eaea121fc458d74e3dc3663c144c54936a8a6b Mon Sep 17 00:00:00 2001 From: Kill Your TV Date: Thu, 30 Oct 2014 01:42:55 +0000 Subject: [PATCH 4/4] recognize clang in linux --- Makefile.linux | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.linux b/Makefile.linux index c7f3babed3f..0be317d1d64 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -10,6 +10,8 @@ else ifeq ($(shell expr match ${CXXVER} "4\.[7-9]"),3) # >= 4.7 NEEDED_CXXFLAGS += -std=c++11 else ifeq ($(shell expr match ${CXXVER} "4\.6"),3) # = 4.6 NEEDED_CXXFLAGS += -std=c++0x +else ifeq ($(shell expr match $(CXX) 'clang'),5) +NEEDED_CXXFLAGS += -std=c++11 else # not supported $(error Compiler too old) endif