2016-06-14 16:01:19 -07:00
|
|
|
#
|
|
|
|
|
# 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)
|
|
|
|
|
# doc: builds manpages, requires rst2man somewhere in PATH
|
|
|
|
|
# all: builds 'one'
|
|
|
|
|
# selftest: zerotier-selftest
|
|
|
|
|
# debug: builds 'one' and 'selftest' with tracing and debug flags
|
|
|
|
|
# installer: builds installers and packages (RPM/DEB/etc.) if possible
|
|
|
|
|
# official: cleans and then builds 'one', 'installer', and 'doc'
|
|
|
|
|
# clean: removes all built files, objects, other trash
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
GENERATED_FILES :=
|
|
|
|
|
DOC_DIR = doc
|
|
|
|
|
|
|
|
|
|
# Automagically pick clang or gcc, with preference for clang
|
|
|
|
|
# This is only done if we have not overridden these with an environment or CLI variable
|
|
|
|
|
ifeq ($(origin CC),default)
|
|
|
|
|
CC=$(shell if [ -e /usr/bin/clang ]; then echo clang; else echo gcc; fi)
|
|
|
|
|
endif
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
INCLUDES?=
|
|
|
|
|
DEFS?=
|
|
|
|
|
LDLIBS?=
|
|
|
|
|
|
|
|
|
|
include objects.mk
|
|
|
|
|
|
|
|
|
|
ifeq ($(ZT_DEBUG),1)
|
|
|
|
|
DEFS+=-DZT_TRACE
|
|
|
|
|
CFLAGS+=-Wall -g -pthread $(INCLUDES) $(DEFS)
|
|
|
|
|
CXXFLAGS+=-Wall -g -pthread $(INCLUDES) $(DEFS)
|
|
|
|
|
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!
|
|
|
|
|
ext/lz4/lz4.o node/Salsa20.o node/SHA512.o node/C25519.o node/Poly1305.o: CFLAGS = -Wall -O2 -g -pthread $(INCLUDES) $(DEFS)
|
|
|
|
|
else
|
|
|
|
|
CFLAGS?=-O3 -fstack-protector
|
|
|
|
|
CFLAGS+=-Wall -fPIE -fvisibility=hidden -pthread $(INCLUDES) -DNDEBUG $(DEFS)
|
|
|
|
|
CXXFLAGS?=-O3 -fstack-protector
|
|
|
|
|
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
|
|
|
|
|
|
2016-06-22 16:18:46 -07:00
|
|
|
# Debug output for Network Containers
|
2016-06-14 16:01:19 -07:00
|
|
|
# Specific levels can be controlled in netcon/common.inc.c
|
2016-06-16 11:47:08 -07:00
|
|
|
ifeq ($(SDK_DEBUG),1)
|
|
|
|
|
DEFS+=-DSDK_DEBUG
|
2016-06-14 16:01:19 -07:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
# Uncomment for gprof profile build
|
|
|
|
|
#CFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS)
|
|
|
|
|
#CXXFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS)
|
|
|
|
|
#LDFLAGS=
|
|
|
|
|
#STRIP=echo
|
|
|
|
|
|
2016-06-27 11:43:56 -07:00
|
|
|
all: shared_lib check
|
2016-06-14 16:01:19 -07:00
|
|
|
|
2016-06-27 12:27:51 -07:00
|
|
|
linux_shared_lib: $(OBJS)
|
2016-06-14 16:01:19 -07:00
|
|
|
rm -f *.o
|
2016-06-27 14:15:58 -07:00
|
|
|
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(DEFS) -DZT_SDK -DZT_ONE_NO_ROOT_CHECK -Iext/lwip/src/include -Iext/lwip/src/include/ipv4 -Iext/lwip/src/include/ipv6 -Izerotierone/osdep -Izerotierone/node -Isrc -o build/zerotier-sdk-service $(OBJS) zerotierone/service/OneService.cpp src/SDK_EthernetTap.cpp src/SDK_Proxy.cpp zerotierone/one.cpp -x c src/SDK_RPC.c $(LDLIBS) -ldl
|
2016-06-27 10:54:13 -07:00
|
|
|
# Build liblwip.so which must be placed in ZT home for zerotier-netcon-service to work
|
2016-06-22 14:24:30 -07:00
|
|
|
make -f make-liblwip.mk
|
2016-06-14 16:01:19 -07:00
|
|
|
# Use gcc not clang to build standalone intercept library since gcc is typically used for libc and we want to ensure maximal ABI compatibility
|
2016-06-27 14:15:58 -07:00
|
|
|
cd src ; gcc $(DEFS) -g -O2 -Wall -std=c99 -fPIC -DVERBOSE -D_GNU_SOURCE -DSDK_INTERCEPT -I. -I../zerotierone/node -nostdlib -shared -o libztintercept.so SDK_Sockets.c SDK_Intercept.c SDK_Debug.c SDK_RPC.c -ldl
|
2016-06-27 10:54:13 -07:00
|
|
|
mkdir -p build/linux_shared_lib
|
|
|
|
|
cp src/libztintercept.so build/linux_shared_lib/libztintercept.so
|
2016-06-22 14:24:30 -07:00
|
|
|
ln -sf zerotier-sdk-service zerotier-cli
|
|
|
|
|
ln -sf zerotier-sdk-service zerotier-idtool
|
|
|
|
|
|
2016-06-27 11:43:56 -07:00
|
|
|
check:
|
|
|
|
|
./check.sh build/lwip/liblwip.so
|
|
|
|
|
./check.sh build/linux_shared_lib/libztintercept.so
|
2016-06-27 10:54:13 -07:00
|
|
|
|
2016-06-27 11:43:56 -07:00
|
|
|
clean:
|
|
|
|
|
rm -rf ${GENERATED_FILES}
|
2016-06-22 14:24:30 -07:00
|
|
|
rm -rf zerotier-cli zerotier-idtool
|
|
|
|
|
rm -rf build/*
|
2016-06-27 11:43:56 -07:00
|
|
|
find . -type f -name '*.a' -delete
|
2016-06-22 14:24:30 -07:00
|
|
|
find . -type f -name '*.o' -delete
|
|
|
|
|
find . -type f -name '*.so' -delete
|
|
|
|
|
find . -type f -name '*.o.d' -delete
|
|
|
|
|
# Remove junk generated by Android builds
|
|
|
|
|
cd integrations/Android/proj; ./gradlew clean
|
|
|
|
|
rm -rf integrations/Android/proj/.gradle
|
|
|
|
|
rm -rf integrations/Android/proj/.idea
|
|
|
|
|
rm -rf integrations/Android/proj/build
|