changeset 69:36b9f18509db

Correctly link tweetnacl
author Ivo Smits <Ivo@UFO-Net.nl>
date Mon, 13 Mar 2017 18:17:36 +0100
parents 18e0b8bdeecc
children c34252215268
files build.sh
diffstat 1 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/build.sh	Sun Jan 29 14:09:08 2017 +0100
+++ b/build.sh	Mon Mar 13 18:17:36 2017 +0100
@@ -28,7 +28,7 @@
 	$tar --transform "s,^,quicktun-`cat version`/," -czf "out/quicktun-`cat version`.tgz" build.sh clean.sh deb src version --exclude "debian/data"
 fi
 
-mkdir -p obj tmp tmp/include tmp/lib
+mkdir -p obj tmp tmp/include
 
 export LIBRARY_PATH="/usr/local/lib/:${LIBRARY_PATH}"
 
@@ -39,22 +39,22 @@
 	echo '#include <sodium/crypto_box_curve25519xsalsa20poly1305.h>' > tmp/include/crypto_box_curve25519xsalsa20poly1305.h
 	echo '#include <sodium/crypto_scalarmult_curve25519.h>' > tmp/include/crypto_scalarmult_curve25519.h
 	export CPATH="./tmp/include/:${CPATH}"
-	export CRYPTLIB="sodium"
+	export CRYPTLIB="-lsodium"
 elif $cc -shared -lnacl tmp/libtest2.c -o tmp/libtest 2>/dev/null; then
 	echo Using shared libnacl.
 	echo '#include <nacl/crypto_box_curve25519xsalsa20poly1305.h>' > tmp/include/crypto_box_curve25519xsalsa20poly1305.h
 	echo '#include <nacl/crypto_scalarmult_curve25519.h>' > tmp/include/crypto_scalarmult_curve25519.h
 	export CPATH="./tmp/include/:${CPATH}"
-	export CRYPTLIB="nacl"
+	export CRYPTLIB="-lnacl"
 else
 	echo Building TweetNaCl...
 	echo 'The TweetNaCl cryptography library is not optimized for performance. Please install libsodium or libnacl before building QuickTun for best performance.'
-	$cc $CFLAGS -shared -fPIC src/tweetnacl.c src/randombytes.c -o tmp/lib/libtweetnacl.a
+	$cc $CFLAGS -c src/tweetnacl.c -o obj/tweetnacl.o
+	$cc $CFLAGS -c src/randombytes.c -o obj/randombytes.o
 	echo '#include <src/tweetnacl.h>' > tmp/include/crypto_box_curve25519xsalsa20poly1305.h
 	echo '#include <src/tweetnacl.h>' > tmp/include/crypto_scalarmult_curve25519.h
 	export CPATH="./tmp/include/:${CPATH}"
-	export LIBRARY_PATH="./tmp/lib/:${LIBRARY_PATH}"
-	export CRYPTLIB="tweetnacl"
+	export CRYPTLIB="obj/randombytes.o obj/tweetnacl.o"
 fi
 
 CFLAGS="$CFLAGS -DQT_VERSION=\"`cat version`\""
@@ -66,20 +66,20 @@
 $cc $CFLAGS -c -DCOMBINED_BINARY	src/proto.salty.c	-o obj/proto.salty.o
 $cc $CFLAGS -c -DCOMBINED_BINARY	src/run.combined.c	-o obj/run.combined.o
 $cc $CFLAGS -c				src/common.c		-o obj/common.o
-$cc $CFLAGS -o out/quicktun.combined obj/common.o obj/run.combined.o obj/proto.raw.o obj/proto.nacl0.o obj/proto.nacltai.o obj/proto.salty.o -l$CRYPTLIB $LDFLAGS
+$cc $CFLAGS -o out/quicktun.combined obj/common.o obj/run.combined.o obj/proto.raw.o obj/proto.nacl0.o obj/proto.nacltai.o obj/proto.salty.o $CRYPTLIB $LDFLAGS
 ln out/quicktun.combined out/quicktun
 
 echo Building single protocol binaries...
 $cc $CFLAGS -o out/quicktun.raw		src/proto.raw.c				$LDFLAGS
-$cc $CFLAGS -o out/quicktun.nacl0	src/proto.nacl0.c	-l$CRYPTLIB	$LDFLAGS
-$cc $CFLAGS -o out/quicktun.nacltai	src/proto.nacltai.c	-l$CRYPTLIB	$LDFLAGS
-$cc $CFLAGS -o out/quicktun.salty	src/proto.salty.c	-l$CRYPTLIB	$LDFLAGS
-$cc $CFLAGS -o out/quicktun.keypair	src/keypair.c		-l$CRYPTLIB	$LDFLAGS
+$cc $CFLAGS -o out/quicktun.nacl0	src/proto.nacl0.c	$CRYPTLIB	$LDFLAGS
+$cc $CFLAGS -o out/quicktun.nacltai	src/proto.nacltai.c	$CRYPTLIB	$LDFLAGS
+$cc $CFLAGS -o out/quicktun.salty	src/proto.salty.c	$CRYPTLIB	$LDFLAGS
+$cc $CFLAGS -o out/quicktun.keypair	src/keypair.c		$CRYPTLIB	$LDFLAGS
 
 if [ -f /etc/network/interfaces -o "$1" = "debian" ]; then
 	echo Building debian binary...
 	$cc $CFLAGS -c -DCOMBINED_BINARY -DDEBIAN_BINARY src/run.combined.c -o obj/run.debian.o
-	$cc $CFLAGS -o out/quicktun.debian obj/common.o obj/run.debian.o obj/proto.raw.o obj/proto.nacl0.o obj/proto.nacltai.o obj/proto.salty.o -l$CRYPTLIB $LDFLAGS
+	$cc $CFLAGS -o out/quicktun.debian obj/common.o obj/run.debian.o obj/proto.raw.o obj/proto.nacl0.o obj/proto.nacltai.o obj/proto.salty.o $CRYPTLIB $LDFLAGS
 	if [ "$1" != "debian" -a -x /usr/bin/dpkg-deb -a -x /usr/bin/fakeroot ]; then
 		echo -n Building debian package...
 		cd deb