diff options
Diffstat (limited to 'make-linux.mk')
| -rw-r--r-- | make-linux.mk | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/make-linux.mk b/make-linux.mk index 2a195adf..3704c4ac 100644 --- a/make-linux.mk +++ b/make-linux.mk @@ -26,14 +26,13 @@ ifeq ($(origin CXX),default) CXX=$(shell if [ -e /usr/bin/clang++ ]; then echo clang++; else echo g++; fi) endif -UNAME_M=$(shell $(CC) -dumpmachine | cut -d '-' -f 1) +#UNAME_M=$(shell $(CC) -dumpmachine | cut -d '-' -f 1) -INCLUDES= -DEFS= +INCLUDES?= +DEFS?= LDLIBS?= include objects.mk -OBJS+=osdep/LinuxEthernetTap.o # "make official" is a shortcut for this ifeq ($(ZT_OFFICIAL_RELEASE),1) @@ -63,7 +62,7 @@ ifeq ($(ZT_DEBUG),1) DEFS+=-DZT_TRACE CFLAGS+=-Wall -g -pthread $(INCLUDES) $(DEFS) CXXFLAGS+=-Wall -g -pthread $(INCLUDES) $(DEFS) - LDFLAGS= + LDFLAGS=-ldl STRIP?=echo # The following line enables optimization for the crypto code, since # C25519 in particular is almost UNUSABLE in -O0 even on a 3ghz box! @@ -72,11 +71,12 @@ else CFLAGS?=-O3 -fstack-protector CFLAGS+=-Wall -fPIE -fvisibility=hidden -pthread $(INCLUDES) -DNDEBUG $(DEFS) CXXFLAGS?=-O3 -fstack-protector - CXXFLAGS+=-Wall -fPIE -fvisibility=hidden -fno-rtti -pthread $(INCLUDES) -DNDEBUG $(DEFS) - LDFLAGS=-pie -Wl,-z,relro,-z,now + CXXFLAGS+=-Wall -Wreorder -fPIE -fvisibility=hidden -fno-rtti -pthread $(INCLUDES) -DNDEBUG $(DEFS) + LDFLAGS=-ldl -pie -Wl,-z,relro,-z,now STRIP?=strip STRIP+=--strip-all endif + ifeq ($(ZT_TRACE),1) DEFS+=-DZT_TRACE endif @@ -89,12 +89,24 @@ endif all: one -one: $(OBJS) one.o - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one $(OBJS) one.o $(LDLIBS) +one: $(OBJS) service/OneService.o one.o osdep/LinuxEthernetTap.o + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one $(OBJS) service/OneService.o one.o osdep/LinuxEthernetTap.o $(LDLIBS) $(STRIP) zerotier-one ln -sf zerotier-one zerotier-idtool ln -sf zerotier-one zerotier-cli +netcon: $(OBJS) + rm -f *.o + # Need to selectively rebuild one.cpp and OneService.cpp with ZT_SERVICE_NETCON and ZT_ONE_NO_ROOT_CHECK defined, and also NetconEthernetTap + $(CXX) $(CXXFLAGS) $(LDFLAGS) -DZT_SERVICE_NETCON -DZT_ONE_NO_ROOT_CHECK -Iext/lwip/src/include -Iext/lwip/src/include/ipv4 -Iext/lwip/src/include/ipv6 -o zerotier-netcon-service $(OBJS) service/OneService.cpp netcon/NetconEthernetTap.cpp one.cpp -x c netcon/RPC.c $(LDLIBS) -ldl + # Build netcon/liblwip.so which must be placed in ZT home for zerotier-netcon-service to work + cd netcon ; make -f make-liblwip.mk + # Use gcc not clang to build standalone intercept library since gcc is typically used for libc and we want to ensure maximal ABI compatibility + cd netcon ; gcc -g -O2 -Wall -std=c99 -fPIC -DVERBOSE -D_GNU_SOURCE -DNETCON_INTERCEPT -I. -nostdlib -shared -o libzerotierintercept.so Intercept.c RPC.c -ldl + cp netcon/libzerotierintercept.so libzerotierintercept.so + ln -sf zerotier-netcon-service zerotier-cli + ln -sf zerotier-netcon-service zerotier-idtool + selftest: $(OBJS) selftest.o $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LDLIBS) $(STRIP) zerotier-selftest @@ -102,15 +114,18 @@ selftest: $(OBJS) selftest.o installer: one FORCE ./ext/installfiles/linux/buildinstaller.sh -clean: - rm -rf *.o node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o ext/json-parser/*.o $(OBJS) zerotier-one zerotier-idtool zerotier-cli zerotier-selftest build-* ZeroTierOneInstaller-* *.deb *.rpm +clean: FORCE + rm -rf *.so *.o netcon/*.a node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o ext/json-parser/*.o $(OBJS) zerotier-one zerotier-idtool zerotier-cli zerotier-selftest zerotier-netcon-service build-* ZeroTierOneInstaller-* *.deb *.rpm .depend netcon/.depend + # Remove files from all the funny places we put them for tests + find netcon -type f \( -name '*.o' -o -name '*.so' -o -name '*.1.0' -o -name 'zerotier-one' -o -name 'zerotier-cli' -o -name 'zerotier-netcon-service' \) -delete + find netcon/docker-test -name "zerotier-intercept" -type f -delete debug: FORCE make ZT_DEBUG=1 one make ZT_DEBUG=1 selftest official: FORCE - make -j 4 ZT_OFFICIAL_RELEASE=1 + make -j 4 ZT_OFFICIAL_RELEASE=1 one make ZT_OFFICIAL_RELEASE=1 installer FORCE: |
