Browse Source

Don't build with system installed static libax25

A new debian policy restricts the use of fPIC compiled static libraries,
which is (apparently) required by cgo. libax25 in Debian Stretch is
built without fPIC, so we can't use it anymore.

I've included a function in make.bash that downloads and compiles
libax25 to use when building the static Pat binary. Users can use the
env variable CGO_LDFLAGS to specify a custom libax25.a path.
Martin Hebnes Pedersen 2 years ago
parent
commit
a1cb232f98
4 changed files with 26 additions and 5 deletions
  1. 1 0
      .gitignore
  2. 1 1
      .travis.yml
  3. 23 3
      make.bash
  4. 1 1
      vendor/github.com/la5nta/wl2k-go

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+.build/

+ 1 - 1
.travis.yml

@@ -14,8 +14,8 @@ matrix:
     go: 1.6
 
 install:
-  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -y libax25-dev; fi
   - git submodule update --init --recursive
+  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./make.bash libax25; fi
 
 script:
   - ./make.bash

+ 23 - 3
make.bash

@@ -10,12 +10,32 @@ VERSION=$(grep Version VERSION.go|cut -d '"' -f2)
 GO_POINT_VERSION=$(go version| perl -ne 'm/go1\.(\d)/; print $1;')
 [ "$GO_POINT_VERSION" -lt "5" ] && echo "Go 1.5 or later required" && exit 1;
 
+AX25DIST="libax25-0.0.12-rc4"
+function install_libax25 {
+	mkdir -p .build && cd .build
+	[[ -f "${AX25DIST}.tar.gz" ]] || curl -Ssf "http://www.linux-ax25.org/pub/libax25/${AX25DIST}.tar.gz" | tar zx
+	cd "${AX25DIST}" && ./configure --prefix=/ && make && cd ../../
+}
+
+[[ "$1" == "libax25" ]] && install_libax25 && exit 0;
+
 # Link against libax25 (statically) on Linux
 if [[ "$OSTYPE" == "linux"* ]]; then
-	if [[ -f "/usr/lib/libax25.a" ]]; then
-		TAGS="libax25 static"
+	TAGS="libax25 $TAGS"
+	LIB=".build/${AX25DIST}/.libs/libax25.a"
+	if [[ -z "$CGO_LDFLAGS" ]] && [[ -f "$LIB" ]]; then
+		export CGO_CFLAGS="-I$(pwd)/.build/${AX25DIST}"
+		export CGO_LDFLAGS="$(pwd)/${LIB}"
+	fi
+	if [[ -z "$CGO_LDFLAGS" ]]; then
+		echo "WARNING: No static libax25 library available."
+		echo "  Linking against shared library instead. To fix"
+		echo "  this issue, set CGO_LDFLAGS to the full path of"
+		echo "  libax25.a, or run 'make.bash libax25' to download"
+		echo "  and compile ${AX25DIST} in .build/"
+		sleep 3;
 	else
-		echo "WARNING: Not linking with libax25 - /usr/lib/libax25.a not found."
+		TAGS="static $TAGS"
 	fi
 fi
 

+ 1 - 1
vendor/github.com/la5nta/wl2k-go

@@ -1 +1 @@
-Subproject commit d736fafcc35d388c65af7e42fd3197ed95d08d2a
+Subproject commit 88b1c68d041b2026bb51a04f97eb2fe54df65835