make.bash 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/env bash
  2. set -e
  3. export GO15VENDOREXPERIMENT=1
  4. if [ -d $GOOS ]; then OS=$(go env GOOS); else OS=$GOOS; fi
  5. GITREV=$(git rev-parse --short HEAD)
  6. VERSION=$(grep Version VERSION.go|cut -d '"' -f2)
  7. # Go 1.5 or later is required
  8. GO_POINT_VERSION=$(go version| perl -ne 'm/go1\.(\d+)/; print $1;')
  9. [ "$GO_POINT_VERSION" -lt "5" ] && echo "Go 1.5 or later required" && exit 1;
  10. AX25VERSION="0.0.12-rc4"
  11. AX25DIST="libax25-${AX25VERSION}"
  12. AX25DIST_URL="http://http.debian.net/debian/pool/main/liba/libax25/libax25_${AX25VERSION}.orig.tar.gz"
  13. function install_libax25 {
  14. mkdir -p .build && cd .build
  15. [[ -f "${AX25DIST}" ]] || curl -LSsf "${AX25DIST_URL}" | tar zx
  16. cd "${AX25DIST}/" && ./configure --prefix=/ && make && cd ../../
  17. }
  18. [[ "$1" == "libax25" ]] && install_libax25 && exit 0;
  19. # Link against libax25 (statically) on Linux
  20. if [[ "$OS" == "linux"* ]]; then
  21. TAGS="libax25 $TAGS"
  22. LIB=".build/${AX25DIST}/.libs/libax25.a"
  23. if [[ -z "$CGO_LDFLAGS" ]] && [[ -f "$LIB" ]]; then
  24. export CGO_CFLAGS="-I$(pwd)/.build/${AX25DIST}"
  25. export CGO_LDFLAGS="$(pwd)/${LIB}"
  26. fi
  27. if [[ -z "$CGO_LDFLAGS" ]]; then
  28. echo "WARNING: No static libax25 library available."
  29. echo " Linking against shared library instead. To fix"
  30. echo " this issue, set CGO_LDFLAGS to the full path of"
  31. echo " libax25.a, or run 'make.bash libax25' to download"
  32. echo " and compile ${AX25DIST} in .build/"
  33. sleep 3;
  34. else
  35. TAGS="static $TAGS"
  36. fi
  37. fi
  38. # Update submodules (dependencies)
  39. echo -e "Updating git submodules..."
  40. git submodule update --init --recursive
  41. echo "Running tests..."
  42. go test -tags "$TAGS" `go list ./...|grep -v vendor` `go list ./...|grep wl2k-go|egrep -v '/vendor/.*/vendor/'`
  43. echo
  44. echo "Building Pat v$VERSION..."
  45. go build -tags "$TAGS" -ldflags "-X \"main.GitRev=$GITREV\"" $(go list .)
  46. # Build macOS pkg (amd64)
  47. if [[ "$OS" == "darwin"* ]] && command -v packagesbuild >/dev/null 2>&1; then
  48. echo "Generating macOS installer package..."
  49. packagesbuild osx/pat.pkgproj
  50. mv 'Pat :: A Modern Winlink Client.pkg' "pat_${VERSION}_darwin_amd64_unsigned.pkg"
  51. fi
  52. echo -e "Enjoy!"