Browse Source

GitHub issue #171 -- separate CFLAGS and CXXFLAGS in Linux makefile

Adam Ierymenko 10 years ago
parent
commit
cfdf4e3a49
1 changed files with 26 additions and 5 deletions
  1. 26 5
      make-linux.mk

+ 26 - 5
make-linux.mk

@@ -1,4 +1,23 @@
-# Pick clang or gcc, with preference for clang
+#
+# Makefile for ZeroTier One on Linux
+#
+# This is confirmed to work on distributions newer than CentOS 6 (the
+# one used for reference builds) and on 32 and 64 bit x86 and ARM
+# machines. It should also work on other 'normal' machines and recent
+# distributions. Editing might be required for tiny devices or weird
+# distros.
+#
+# Targets
+#   one: zerotier-one and symlinks (cli and idtool)
+#   all: builds 'one'
+#   selftest: zerotier-selftest
+#   debug: builds 'one' and 'selftest' with tracing and debug flags
+#   installer: ZeroTierOneInstaller-... and packages (if possible)
+#   official: builds 'one' and 'installer'
+#   clean: removes all built files, objects, other trash
+#
+
+# Automagically pick clang or gcc, with preference for clang
 CC=$(shell if [ -e /usr/bin/clang ]; then echo clang; else echo gcc; fi)
 CC=$(shell if [ -e /usr/bin/clang ]; then echo clang; else echo gcc; fi)
 CXX=$(shell if [ -e /usr/bin/clang++ ]; then echo clang++; else echo g++; fi)
 CXX=$(shell if [ -e /usr/bin/clang++ ]; then echo clang++; else echo g++; fi)
 
 
@@ -25,24 +44,25 @@ endif
 ifeq ($(ZT_DEBUG),1)
 ifeq ($(ZT_DEBUG),1)
 	DEFS+=-DZT_TRACE 
 	DEFS+=-DZT_TRACE 
 	CFLAGS=-Wall -g -pthread $(INCLUDES) $(DEFS)
 	CFLAGS=-Wall -g -pthread $(INCLUDES) $(DEFS)
+	CXXFLAGS=-Wall -g -pthread $(INCLUDES) $(DEFS)
 	LDFLAGS=
 	LDFLAGS=
 	STRIP=echo
 	STRIP=echo
 	# The following line enables optimization for the crypto code, since
 	# The following line enables optimization for the crypto code, since
-	# C25519 in particular is almost UNUSABLE in heavy testing without it.
+	# C25519 in particular is almost UNUSABLE in -O0 even on a 3ghz box!
 ext/lz4/lz4.o node/Salsa20.o node/SHA512.o node/C25519.o node/Poly1305.o: CFLAGS = -Wall -O2 -g -pthread $(INCLUDES) $(DEFS)
 ext/lz4/lz4.o node/Salsa20.o node/SHA512.o node/C25519.o node/Poly1305.o: CFLAGS = -Wall -O2 -g -pthread $(INCLUDES) $(DEFS)
 else
 else
 	CFLAGS=-Wall -O3 -fPIE -fvisibility=hidden -fstack-protector -pthread $(INCLUDES) -DNDEBUG $(DEFS)
 	CFLAGS=-Wall -O3 -fPIE -fvisibility=hidden -fstack-protector -pthread $(INCLUDES) -DNDEBUG $(DEFS)
+	CXXFLAGS=-Wall -O3 -fPIE -fvisibility=hidden -fstack-protector -fno-rtti -pthread $(INCLUDES) -DNDEBUG $(DEFS)
 	LDFLAGS=-pie -Wl,-z,relro,-z,now
 	LDFLAGS=-pie -Wl,-z,relro,-z,now
 	STRIP=strip --strip-all
 	STRIP=strip --strip-all
 endif
 endif
 
 
 # Uncomment for gprof profile build
 # Uncomment for gprof profile build
 #CFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS)
 #CFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS)
+#CXXFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS)
 #LDFLAGS=
 #LDFLAGS=
 #STRIP=echo
 #STRIP=echo
 
 
-CXXFLAGS=$(CFLAGS) -fno-rtti
-
 all:	one
 all:	one
 
 
 one:	$(OBJS) one.o
 one:	$(OBJS) one.o
@@ -62,7 +82,8 @@ clean:
 	rm -rf *.o node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o ext/json-parser/*.o zerotier-one zerotier-idtool zerotier-cli zerotier-selftest build-* ZeroTierOneInstaller-* *.deb *.rpm
 	rm -rf *.o node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o ext/json-parser/*.o zerotier-one zerotier-idtool zerotier-cli zerotier-selftest build-* ZeroTierOneInstaller-* *.deb *.rpm
 
 
 debug:	FORCE
 debug:	FORCE
-	make -j 4 ZT_DEBUG=1
+	make ZT_DEBUG=1 one
+	make ZT_DEBUG=1 selftest
 
 
 official: FORCE
 official: FORCE
 	make -j 4 ZT_OFFICIAL_RELEASE=1
 	make -j 4 ZT_OFFICIAL_RELEASE=1