Browse Source

allow debug & release builds of Rust

Grant Limberg 3 years ago
parent
commit
1375e3e2f5
2 changed files with 18 additions and 6 deletions
  1. 11 3
      make-linux.mk
  2. 7 3
      make-mac.mk

+ 11 - 3
make-linux.mk

@@ -11,14 +11,14 @@ endif
 
 
 INCLUDES?=-Izeroidc/target
 INCLUDES?=-Izeroidc/target
 DEFS?=
 DEFS?=
-LDLIBS?=zeroidc/target/release/libzeroidc.a -ldl
+LDLIBS?=
 DESTDIR?=
 DESTDIR?=
 
 
 include objects.mk
 include objects.mk
 ONE_OBJS+=osdep/LinuxEthernetTap.o
 ONE_OBJS+=osdep/LinuxEthernetTap.o
 ONE_OBJS+=osdep/LinuxNetLink.o
 ONE_OBJS+=osdep/LinuxNetLink.o
 
 
-# for central controller builds
+# for central controller buildsk
 TIMESTAMP=$(shell date +"%Y%m%d%H%M")
 TIMESTAMP=$(shell date +"%Y%m%d%H%M")
 
 
 # Auto-detect miniupnpc and nat-pmp as well and use system libs if present,
 # Auto-detect miniupnpc and nat-pmp as well and use system libs if present,
@@ -41,6 +41,12 @@ else
 	override DEFS+=-DZT_USE_SYSTEM_NATPMP
 	override DEFS+=-DZT_USE_SYSTEM_NATPMP
 endif
 endif
 
 
+ifeq ($(ZT_DEBUG),1)
+	LDLIBS+=zeroidc/target/debug/libzeroidc.a -ldl
+else
+	LDLIBS+=zeroidc/target/release/libzeroidc.a -ldl
+endif
+
 # Use bundled http-parser since distribution versions are NOT API-stable or compatible!
 # Use bundled http-parser since distribution versions are NOT API-stable or compatible!
 # Trying to use dynamically linked libhttp-parser causes tons of compatibility problems.
 # Trying to use dynamically linked libhttp-parser causes tons of compatibility problems.
 ONE_OBJS+=ext/http-parser/http_parser.o
 ONE_OBJS+=ext/http-parser/http_parser.o
@@ -64,6 +70,7 @@ ifeq ($(ZT_DEBUG),1)
 	override CFLAGS+=-Wall -Wno-deprecated -g -O -pthread $(INCLUDES) $(DEFS)
 	override CFLAGS+=-Wall -Wno-deprecated -g -O -pthread $(INCLUDES) $(DEFS)
 	override CXXFLAGS+=-Wall -Wno-deprecated -g -O -std=c++11 -pthread $(INCLUDES) $(DEFS)
 	override CXXFLAGS+=-Wall -Wno-deprecated -g -O -std=c++11 -pthread $(INCLUDES) $(DEFS)
 	ZT_TRACE=1
 	ZT_TRACE=1
+	RUSTFLAGS=
 	# The following line enables optimization for the crypto code, since
 	# The following line enables optimization for the crypto code, since
 	# C25519 in particular is almost UNUSABLE in -O0 even on a 3ghz box!
 	# C25519 in particular is almost UNUSABLE in -O0 even on a 3ghz box!
 node/Salsa20.o node/SHA512.o node/C25519.o node/Poly1305.o: CXXFLAGS=-Wall -O2 -g -pthread $(INCLUDES) $(DEFS)
 node/Salsa20.o node/SHA512.o node/C25519.o node/Poly1305.o: CXXFLAGS=-Wall -O2 -g -pthread $(INCLUDES) $(DEFS)
@@ -73,6 +80,7 @@ else
 	CXXFLAGS?=-O3 -fstack-protector -fPIE
 	CXXFLAGS?=-O3 -fstack-protector -fPIE
 	override CXXFLAGS+=-Wall -Wno-deprecated -std=c++11 -pthread $(INCLUDES) -DNDEBUG $(DEFS)
 	override CXXFLAGS+=-Wall -Wno-deprecated -std=c++11 -pthread $(INCLUDES) -DNDEBUG $(DEFS)
 	LDFLAGS=-pie -Wl,-z,relro,-z,now
 	LDFLAGS=-pie -Wl,-z,relro,-z,now
+	RUSTFLAGS=--release
 endif
 endif
 
 
 ifeq ($(ZT_QNAP), 1)
 ifeq ($(ZT_QNAP), 1)
@@ -364,7 +372,7 @@ debug:	FORCE
 	make ZT_DEBUG=1 selftest
 	make ZT_DEBUG=1 selftest
 
 
 zeroidc:	FORCE
 zeroidc:	FORCE
-	cd zeroidc && cargo build --release
+	cd zeroidc && cargo build $(RUSTFLAGS)
 
 
 # Note: keep the symlinks in /var/lib/zerotier-one to the binaries since these
 # Note: keep the symlinks in /var/lib/zerotier-one to the binaries since these
 # provide backward compatibility with old releases where the binaries actually
 # provide backward compatibility with old releases where the binaries actually

+ 7 - 3
make-mac.mk

@@ -75,6 +75,8 @@ ifeq ($(ZT_DEBUG),1)
 	ARCH_FLAGS=
 	ARCH_FLAGS=
 	CFLAGS+=-Wall -g $(INCLUDES) $(DEFS) $(ARCH_FLAGS)
 	CFLAGS+=-Wall -g $(INCLUDES) $(DEFS) $(ARCH_FLAGS)
 	STRIP=echo
 	STRIP=echo
+	RUSTFLAGS=
+	RUST_VARIANT=debug
 	# The following line enables optimization for the crypto code, since
 	# The following line enables optimization for the crypto code, since
 	# C25519 in particular is almost UNUSABLE in heavy testing without it.
 	# C25519 in particular is almost UNUSABLE in heavy testing without it.
 node/Salsa20.o node/SHA512.o node/C25519.o node/Poly1305.o: CFLAGS = -Wall -O2 -g $(INCLUDES) $(DEFS)
 node/Salsa20.o node/SHA512.o node/C25519.o node/Poly1305.o: CFLAGS = -Wall -O2 -g $(INCLUDES) $(DEFS)
@@ -82,6 +84,8 @@ else
 	CFLAGS?=-Ofast -fstack-protector-strong
 	CFLAGS?=-Ofast -fstack-protector-strong
 	CFLAGS+=$(ARCH_FLAGS) -Wall -flto -fPIE -mmacosx-version-min=$(MACOS_VERSION_MIN) -DNDEBUG -Wno-unused-private-field $(INCLUDES) $(DEFS)
 	CFLAGS+=$(ARCH_FLAGS) -Wall -flto -fPIE -mmacosx-version-min=$(MACOS_VERSION_MIN) -DNDEBUG -Wno-unused-private-field $(INCLUDES) $(DEFS)
 	STRIP=strip
 	STRIP=strip
+	RUSTFLAGS=--release
+	RUST_VARIANT=release
 endif
 endif
 
 
 ifeq ($(ZT_TRACE),1)
 ifeq ($(ZT_TRACE),1)
@@ -117,9 +121,9 @@ zerotier-one: one
 zeroidc: zeroidc/target/libzeroidc.a
 zeroidc: zeroidc/target/libzeroidc.a
 
 
 zeroidc/target/libzeroidc.a:	FORCE
 zeroidc/target/libzeroidc.a:	FORCE
-	cd zeroidc && MACOSX_DEPLOYMENT_TARGET=$(MACOS_VERSION_MIN) cargo build --target=x86_64-apple-darwin --release
-	cd zeroidc && MACOSX_DEPLOYMENT_TARGET=$(MACOS_VERSION_MIN) cargo build --target=aarch64-apple-darwin --release
-	cd zeroidc && lipo -create target/x86_64-apple-darwin/release/libzeroidc.a target/aarch64-apple-darwin/release/libzeroidc.a -output target/libzeroidc.a
+	cd zeroidc && MACOSX_DEPLOYMENT_TARGET=$(MACOS_VERSION_MIN) cargo build --target=x86_64-apple-darwin $(RUSTFLAGS)
+	cd zeroidc && MACOSX_DEPLOYMENT_TARGET=$(MACOS_VERSION_MIN) cargo build --target=aarch64-apple-darwin $(RUSTFLAGS)
+	cd zeroidc && lipo -create target/x86_64-apple-darwin/$(RUST_VARIANT)/libzeroidc.a target/aarch64-apple-darwin/$(RUST_VARIANT)/libzeroidc.a -output target/libzeroidc.a
 
 
 central-controller:
 central-controller:
 	make ARCH_FLAGS="-arch x86_64" ZT_CONTROLLER=1 one
 	make ARCH_FLAGS="-arch x86_64" ZT_CONTROLLER=1 one