2013-12-16 22:24:41 +00:00
|
|
|
# Pick clang or gcc, with preference for clang
|
|
|
|
CC=$(shell which clang gcc cc 2>/dev/null | head -n 1)
|
|
|
|
CXX=$(shell which clang++ g++ c++ 2>/dev/null | head -n 1)
|
2013-07-04 20:56:19 +00:00
|
|
|
|
2013-09-16 13:20:59 +00:00
|
|
|
INCLUDES=
|
2013-10-21 18:12:00 +00:00
|
|
|
DEFS=
|
2013-10-01 21:19:24 +00:00
|
|
|
LIBS=
|
2013-07-04 20:56:19 +00:00
|
|
|
|
2014-10-29 23:32:24 +00:00
|
|
|
include objects.mk
|
2015-04-09 01:47:06 +00:00
|
|
|
OBJS+=osdep/LinuxEthernetTap.o
|
|
|
|
TESTNET_OBJS=testnet/SimNet.o testnet/SimNetSocketManager.o testnet/TestEthernetTap.o
|
2014-10-29 23:32:24 +00:00
|
|
|
|
2014-08-28 00:01:24 +00:00
|
|
|
# Enable SSE-optimized Salsa20 on x86 and x86_64 machines
|
|
|
|
MACHINE=$(shell uname -m)
|
|
|
|
ifeq ($(MACHINE),x86_64)
|
|
|
|
DEFS+=-DZT_SALSA20_SSE
|
|
|
|
endif
|
|
|
|
ifeq ($(MACHINE),amd64)
|
|
|
|
DEFS+=-DZT_SALSA20_SSE
|
|
|
|
endif
|
|
|
|
ifeq ($(MACHINE),i686)
|
|
|
|
DEFS+=-DZT_SALSA20_SSE
|
|
|
|
endif
|
|
|
|
ifeq ($(MACHINE),i586)
|
|
|
|
DEFS+=-DZT_SALSA20_SSE
|
|
|
|
endif
|
|
|
|
ifeq ($(MACHINE),i386)
|
|
|
|
DEFS+=-DZT_SALSA20_SSE
|
|
|
|
endif
|
|
|
|
ifeq ($(MACHINE),x86)
|
|
|
|
DEFS+=-DZT_SALSA20_SSE
|
|
|
|
endif
|
2014-08-18 14:07:03 +00:00
|
|
|
|
2015-01-08 23:17:02 +00:00
|
|
|
# Build with ZT_ENABLE_NETCONF_MASTER=1 to build with NetworkConfigMaster enabled
|
|
|
|
ifeq ($(ZT_ENABLE_NETCONF_MASTER),1)
|
|
|
|
DEFS+=-DZT_ENABLE_NETCONF_MASTER
|
2015-03-12 21:03:53 +00:00
|
|
|
LIBS+=-lsqlite3
|
|
|
|
OBJS+=netconf/SqliteNetworkConfigMaster.o
|
2015-01-08 23:17:02 +00:00
|
|
|
endif
|
|
|
|
|
2014-08-18 14:07:03 +00:00
|
|
|
# "make official" is a shortcut for this
|
2014-01-07 22:48:56 +00:00
|
|
|
ifeq ($(ZT_OFFICIAL_RELEASE),1)
|
|
|
|
ZT_AUTO_UPDATE=1
|
2014-02-24 21:23:03 +00:00
|
|
|
DEFS+=-DZT_OFFICIAL_RELEASE
|
2014-01-07 22:48:56 +00:00
|
|
|
endif
|
2013-12-11 21:14:10 +00:00
|
|
|
ifeq ($(ZT_AUTO_UPDATE),1)
|
2013-12-31 19:21:53 +00:00
|
|
|
DEFS+=-DZT_AUTO_UPDATE
|
2013-12-11 21:14:10 +00:00
|
|
|
endif
|
|
|
|
|
2014-08-18 14:07:03 +00:00
|
|
|
# "make debug" is a shortcut for this
|
|
|
|
ifeq ($(ZT_DEBUG),1)
|
2015-04-10 18:42:02 +00:00
|
|
|
DEFS+=-DZT_TRACE
|
2014-10-12 18:42:49 +00:00
|
|
|
CFLAGS=-Wall -g -pthread $(INCLUDES) $(DEFS)
|
2014-08-18 14:07:03 +00:00
|
|
|
LDFLAGS=
|
|
|
|
STRIP=echo
|
2014-10-12 18:42:49 +00:00
|
|
|
# The following line enables optimization for the crypto code, since
|
|
|
|
# C25519 in particular is almost UNUSABLE in heavy testing without it.
|
2014-10-14 17:22:27 +00:00
|
|
|
ext/lz4/lz4.o node/Salsa20.o node/SHA512.o node/C25519.o node/Poly1305.o: CFLAGS = -Wall -O2 -g -pthread $(INCLUDES) $(DEFS)
|
2014-08-18 14:07:03 +00:00
|
|
|
else
|
|
|
|
CFLAGS=-Wall -O3 -fPIE -fvisibility=hidden -fstack-protector -pthread $(INCLUDES) -DNDEBUG $(DEFS)
|
|
|
|
LDFLAGS=-pie -Wl,-z,relro,-z,now
|
|
|
|
STRIP=strip --strip-all
|
|
|
|
endif
|
2013-07-04 20:56:19 +00:00
|
|
|
|
2013-10-18 20:51:05 +00:00
|
|
|
# Uncomment for gprof profile build
|
|
|
|
#CFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS)
|
2014-03-11 18:50:04 +00:00
|
|
|
#LDFLAGS=
|
2013-10-18 20:51:05 +00:00
|
|
|
#STRIP=echo
|
|
|
|
|
2013-07-04 20:56:19 +00:00
|
|
|
CXXFLAGS=$(CFLAGS) -fno-rtti
|
|
|
|
|
2013-11-08 20:23:48 +00:00
|
|
|
all: one
|
2013-07-04 20:56:19 +00:00
|
|
|
|
2014-08-19 21:11:02 +00:00
|
|
|
one: $(OBJS) main.o
|
|
|
|
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one main.o $(OBJS) $(LIBS)
|
2013-07-04 20:56:19 +00:00
|
|
|
$(STRIP) zerotier-one
|
2013-11-19 20:05:14 +00:00
|
|
|
ln -sf zerotier-one zerotier-cli
|
2013-12-04 22:44:28 +00:00
|
|
|
ln -sf zerotier-one zerotier-idtool
|
2013-07-04 20:56:19 +00:00
|
|
|
|
2014-03-11 18:50:04 +00:00
|
|
|
selftest: $(OBJS) selftest.o
|
|
|
|
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS)
|
2013-07-04 20:56:19 +00:00
|
|
|
$(STRIP) zerotier-selftest
|
|
|
|
|
2014-10-29 23:32:24 +00:00
|
|
|
testnet: $(TESTNET_OBJS) $(OBJS) testnet.o
|
|
|
|
$(CXX) $(CXXFLAGS) -o zerotier-testnet testnet.o $(OBJS) $(TESTNET_OBJS) $(LIBS)
|
|
|
|
$(STRIP) zerotier-testnet
|
|
|
|
|
2013-11-08 22:37:47 +00:00
|
|
|
installer: one FORCE
|
|
|
|
./buildinstaller.sh
|
|
|
|
|
2013-07-04 20:56:19 +00:00
|
|
|
clean:
|
2015-04-11 00:07:06 +00:00
|
|
|
rm -rf *.o netconf/*.o node/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o zerotier-* build-* ZeroTierOneInstaller-* *.deb *.rpm
|
2014-08-18 14:07:03 +00:00
|
|
|
|
|
|
|
debug: FORCE
|
|
|
|
make -j 4 ZT_DEBUG=1
|
2013-11-06 17:06:42 +00:00
|
|
|
|
2014-01-07 22:48:56 +00:00
|
|
|
official: FORCE
|
|
|
|
make -j 4 ZT_OFFICIAL_RELEASE=1
|
|
|
|
./buildinstaller.sh
|
|
|
|
|
2013-11-06 17:06:42 +00:00
|
|
|
FORCE:
|