Browse Source

Security improvements to Linux build flags mirroring OSX improvements.

Adam Ierymenko 11 years ago
parent
commit
ce09d00679
1 changed files with 8 additions and 9 deletions
  1. 8 9
      make-linux.mk

+ 8 - 9
make-linux.mk

@@ -18,15 +18,18 @@ endif
 #DEFS+=-DZT_TRACE -DZT_LOG_STDOUT 
 #DEFS+=-DZT_TRACE -DZT_LOG_STDOUT 
 
 
 # Uncomment for a release optimized build
 # Uncomment for a release optimized build
-CFLAGS=-Wall -O3 -fvisibility=hidden -fstack-protector -pthread $(INCLUDES) -DNDEBUG $(DEFS)
+CFLAGS=-Wall -O3 -fPIE -fvisibility=hidden -fstack-protector -pthread $(INCLUDES) -DNDEBUG $(DEFS)
+LDFLAGS=-pie -Wl,-z,relro,-z,now
 STRIP=strip --strip-all
 STRIP=strip --strip-all
 
 
 # Uncomment for a debug build
 # Uncomment for a debug build
 #CFLAGS=-Wall -g -pthread $(INCLUDES) -DZT_TRACE $(DEFS)
 #CFLAGS=-Wall -g -pthread $(INCLUDES) -DZT_TRACE $(DEFS)
+#LDFLAGS=
 #STRIP=echo
 #STRIP=echo
 
 
 # Uncomment for gprof profile build
 # Uncomment for gprof profile build
 #CFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS)
 #CFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS)
+#LDFLAGS=
 #STRIP=echo
 #STRIP=echo
 
 
 CXXFLAGS=$(CFLAGS) -fno-rtti
 CXXFLAGS=$(CFLAGS) -fno-rtti
@@ -35,20 +38,16 @@ include objects.mk
 
 
 all:	one
 all:	one
 
 
-one:	$(OBJS)
-	$(CXX) $(CXXFLAGS) -o zerotier-one main.cpp $(OBJS) $(LIBS)
+one:	$(OBJS) main.o
+	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one main.o $(OBJS) $(LIBS)
 	$(STRIP) zerotier-one
 	$(STRIP) zerotier-one
 	ln -sf zerotier-one zerotier-cli
 	ln -sf zerotier-one zerotier-cli
 	ln -sf zerotier-one zerotier-idtool
 	ln -sf zerotier-one zerotier-idtool
 
 
-selftest:	$(OBJS)
-	$(CXX) $(CXXFLAGS) -o zerotier-selftest selftest.cpp $(OBJS) $(LIBS)
+selftest:	$(OBJS) selftest.o
+	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS)
 	$(STRIP) zerotier-selftest
 	$(STRIP) zerotier-selftest
 
 
-idtool:	$(OBJS)
-	$(CXX) $(CXXFLAGS) -o zerotier-idtool idtool.cpp $(OBJS) $(LIBS)
-	$(STRIP) zerotier-idtool
-
 installer: one FORCE
 installer: one FORCE
 	./buildinstaller.sh
 	./buildinstaller.sh