Merge pull request #108 from bnrjee/master
Add go ldflags using LDFLAGS at the time of compilation
This commit is contained in:
commit
22c0395c9c
|
|
@ -69,12 +69,17 @@ endif
|
||||||
# toolchain.
|
# toolchain.
|
||||||
BUILD_PLATFORMS =
|
BUILD_PLATFORMS =
|
||||||
|
|
||||||
|
# Add go ldflags using LDFLAGS at the time of compilation.
|
||||||
|
IMPORTPATH_LDFLAGS = -X main.version=$(REV)
|
||||||
|
EXT_LDFLAGS = -extldflags "-static"
|
||||||
|
LDFLAGS =
|
||||||
|
FULL_LDFLAGS = $(LDFLAGS) $(IMPORTPATH_LDFLAGS) $(EXT_LDFLAGS)
|
||||||
# This builds each command (= the sub-directories of ./cmd) for the target platform(s)
|
# This builds each command (= the sub-directories of ./cmd) for the target platform(s)
|
||||||
# defined by BUILD_PLATFORMS.
|
# defined by BUILD_PLATFORMS.
|
||||||
$(CMDS:%=build-%): build-%: check-go-version-go
|
$(CMDS:%=build-%): build-%: check-go-version-go
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
echo '$(BUILD_PLATFORMS)' | tr ';' '\n' | while read -r os arch suffix; do \
|
echo '$(BUILD_PLATFORMS)' | tr ';' '\n' | while read -r os arch suffix; do \
|
||||||
if ! (set -x; CGO_ENABLED=0 GOOS="$$os" GOARCH="$$arch" go build $(GOFLAGS_VENDOR) -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o "./bin/$*$$suffix" ./cmd/$*); then \
|
if ! (set -x; CGO_ENABLED=0 GOOS="$$os" GOARCH="$$arch" go build $(GOFLAGS_VENDOR) -a -ldflags '$(FULL_LDFLAGS)' -o "./bin/$*$$suffix" ./cmd/$*); then \
|
||||||
echo "Building $* for GOOS=$$os GOARCH=$$arch failed, see error(s) above."; \
|
echo "Building $* for GOOS=$$os GOARCH=$$arch failed, see error(s) above."; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi; \
|
fi; \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue