summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-11-04 11:20:38 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-11-04 11:20:38 -0800
commit1bd5a1ebcd6fb99b6a1c723514a8bf354486a443 (patch)
treee093a73374c19e1acf9681aac2b7b9e3c6437c89
parent14e4ffd15fdef2e5e024b706c7959986570a189a (diff)
downloadinfinitytier-1bd5a1ebcd6fb99b6a1c723514a8bf354486a443.tar.gz
infinitytier-1bd5a1ebcd6fb99b6a1c723514a8bf354486a443.zip
Make selftest build and run on FreeBSD 10 with gmake
-rw-r--r--Makefile5
-rw-r--r--make-freebsd.mk88
-rw-r--r--node/Constants.hpp15
-rw-r--r--node/InetAddress.h0
-rw-r--r--node/InetAddress.hpp1
5 files changed, 109 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index ac50884c..bc094260 100644
--- a/Makefile
+++ b/Makefile
@@ -9,3 +9,8 @@ endif
ifeq ($(OSTYPE),Linux)
include make-linux.mk
endif
+
+ifeq ($(OSTYPE),FreeBSD)
+ include make-freebsd.mk
+endif
+
diff --git a/make-freebsd.mk b/make-freebsd.mk
new file mode 100644
index 00000000..74499972
--- /dev/null
+++ b/make-freebsd.mk
@@ -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:
diff --git a/node/Constants.hpp b/node/Constants.hpp
index 83c98e0f..82d25459 100644
--- a/node/Constants.hpp
+++ b/node/Constants.hpp
@@ -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__
diff --git a/node/InetAddress.h b/node/InetAddress.h
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/node/InetAddress.h
diff --git a/node/InetAddress.hpp b/node/InetAddress.hpp
index 0ddb2cd4..06da9de6 100644
--- a/node/InetAddress.hpp
+++ b/node/InetAddress.hpp
@@ -45,6 +45,7 @@
#else
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <sys/socket.h>
#endif
namespace ZeroTier {