summaryrefslogtreecommitdiff
path: root/build.bash
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-12-16 21:34:41 +0100
committerJakob Unterwurzacher2018-12-16 21:34:41 +0100
commit3cba378ad5a996a28a012147539cc8721a1133cc (patch)
tree8e61643fc976cf501da1b7cb8427fd7485a5f93c /build.bash
parentbf241ce77e838ec714a3b40be3c66cfd225f3e93 (diff)
build.bash: support user-set LDFLAGS
As requested at https://github.com/rfjakob/gocryptfs/pull/280
Diffstat (limited to 'build.bash')
-rwxr-xr-xbuild.bash15
1 files changed, 12 insertions, 3 deletions
diff --git a/build.bash b/build.bash
index 900010c..2f2d1dd 100755
--- a/build.bash
+++ b/build.bash
@@ -5,7 +5,10 @@
#
# If you want to fake a build date to reproduce a specific build,
# you can use:
-# BUILDDATE=2017-02-03 ./build.bash
+# BUILDDATE=2017-02-03 ./build.bash
+# or
+# SOURCE_DATE_EPOCH=1544192417 ./build.bash
+# .
cd "$(dirname "$0")"
MYDIR=$PWD
@@ -77,9 +80,15 @@ else
TRIM="all=-trimpath=${GOPATH1}/src"
fi
-LDFLAGS="-X main.GitVersion=$GITVERSION -X main.GitVersionFuse=$GITVERSIONFUSE -X main.BuildDate=$BUILDDATE"
+GO_LDFLAGS="-X main.GitVersion=$GITVERSION -X main.GitVersionFuse=$GITVERSIONFUSE -X main.BuildDate=$BUILDDATE"
-go build "-ldflags=$LDFLAGS" "-gcflags=$TRIM" "-asmflags=$TRIM" "$@"
+# If LDFLAGS is set, add it as "-extldflags".
+if [[ -n ${LDFLAGS:-} ]] ; then
+ GO_LDFLAGS="-extldflags=$LDFLAGS $GO_LDFLAGS"
+fi
+
+# Actual "go build" call
+go build "-ldflags=$GO_LDFLAGS" "-gcflags=$TRIM" "-asmflags=$TRIM" "$@"
(cd gocryptfs-xray; go build "-gcflags=$TRIM" "-asmflags=$TRIM" "$@")