Make selftest build and run on FreeBSD 10 with gmake

This commit is contained in:
Adam Ierymenko 2014-11-04 11:20:38 -08:00
parent 14e4ffd15f
commit 1bd5a1ebcd
5 changed files with 109 additions and 0 deletions

View File

@ -9,3 +9,8 @@ endif
ifeq ($(OSTYPE),Linux)
include make-linux.mk
endif
ifeq ($(OSTYPE),FreeBSD)
include make-freebsd.mk
endif

88
make-freebsd.mk Normal file
View File

@ -0,0 +1,88 @@
CC=cc
CXX=c++
INCLUDES=
DEFS=
LIBS=
include objects.mk
OBJS+=
TESTNET_OBJS=testnet/SimNet.o testnet/SimNetSocketManager.o testnet/TestEthernetTap.o testnet/TestEthernetTapFactory.o testnet/TestRoutingTable.o
# 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
# "make official" is a shortcut for this
ifeq ($(ZT_OFFICIAL_RELEASE),1)
ZT_AUTO_UPDATE=1
DEFS+=-DZT_OFFICIAL_RELEASE
endif
ifeq ($(ZT_AUTO_UPDATE),1)
DEFS+=-DZT_AUTO_UPDATE
endif
# "make debug" is a shortcut for this
ifeq ($(ZT_DEBUG),1)
# DEFS+=-DZT_TRACE -DZT_LOG_STDOUT
CFLAGS=-Wall -g -pthread $(INCLUDES) $(DEFS)
LDFLAGS=
STRIP=echo
# The following line enables optimization for the crypto code, since
# C25519 in particular is almost UNUSABLE in heavy testing without it.
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=-Wall -O3 -fPIE -fvisibility=hidden -fstack-protector -pthread $(INCLUDES) -DNDEBUG $(DEFS)
LDFLAGS=-pie -Wl,-z,relro,-z,now
STRIP=strip --strip-all
endif
CXXFLAGS=$(CFLAGS) -fno-rtti
all: one
one: $(OBJS) main.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one main.o $(OBJS) $(LIBS)
$(STRIP) zerotier-one
ln -sf zerotier-one zerotier-cli
ln -sf zerotier-one zerotier-idtool
selftest: $(OBJS) selftest.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS)
$(STRIP) zerotier-selftest
testnet: $(TESTNET_OBJS) $(OBJS) testnet.o
$(CXX) $(CXXFLAGS) -o zerotier-testnet testnet.o $(OBJS) $(TESTNET_OBJS) $(LIBS)
$(STRIP) zerotier-testnet
installer: one FORCE
./buildinstaller.sh
clean:
rm -rf $(OBJS) $(TESTNET_OBJS) node/*.o osnet/*.o control/*.o testnet/*.o *.o zerotier-* build-* ZeroTierOneInstaller-*
debug: FORCE
make -j 4 ZT_DEBUG=1
official: FORCE
make -j 4 ZT_OFFICIAL_RELEASE=1
./buildinstaller.sh
FORCE:

View File

@ -58,6 +58,21 @@
#include <endian.h>
#endif
#ifdef __FreeBSD__
#ifndef __UNIX_LIKE__
#define __UNIX_LIKE__
#endif
#ifndef __BSD__
#define __BSD__
#endif
#include <machine/endian.h>
#ifndef __BYTE_ORDER
#define __BYTE_ORDER _BYTE_ORDER
#define __LITTLE_ENDIAN _LITTLE_ENDIAN
#define __BIG_ENDIAN _BIG_ENDIAN
#endif
#endif
// TODO: Android is what? Linux technically, but does it define it?
#ifdef __APPLE__

0
node/InetAddress.h Normal file
View File

View File

@ -45,6 +45,7 @@
#else
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#endif
namespace ZeroTier {