From 3cba378ad5a996a28a012147539cc8721a1133cc Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 16 Dec 2018 21:34:41 +0100 Subject: [PATCH] build.bash: support user-set LDFLAGS As requested at https://github.com/rfjakob/gocryptfs/pull/280 --- build.bash | 15 ++++++++++++--- 1 file 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" "$@")