Clean up and fix minor bugs in DEBUG/GOGCFLAGS handling

* Use “override GOGCFLAGS+=” so that (make GOGCFLAGS=… DEBUG=1)
  does not ignore the appending to GOGCFLAGS
* Move quoting of -gcflags from the variable to its use,
  so that (make GOGCFLAGS=… DEBUG=1) is correctly quoted
* Now that GOGCFLAGS and DEBUG are both handled correctly when
  completely empty, simplify by dropping the DEBUG!=1 branch.
* Beautify the command line by not using DEBUG= if DEBUG is unset.
This commit is contained in:
Miloslav Trmač 2016-08-17 21:31:40 +02:00
parent 2c90120ce6
commit 406ab86104

View File

@ -10,10 +10,7 @@ MANINSTALLDIR=${PREFIX}/share/man
GO_MD2MAN ?= /usr/bin/go-md2man GO_MD2MAN ?= /usr/bin/go-md2man
ifeq ($(DEBUG), 1) ifeq ($(DEBUG), 1)
GOGCFLAGS += "-N -l" override GOGCFLAGS += -N -l
else
GOGCFLAGS ?= ""
DEBUG ?= 0
endif endif
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
@ -44,11 +41,11 @@ all: binary docs
binary: cmd/skopeo binary: cmd/skopeo
docker build ${DOCKER_BUILD_ARGS} -f Dockerfile.build -t skopeobuildimage . docker build ${DOCKER_BUILD_ARGS} -f Dockerfile.build -t skopeobuildimage .
docker run --rm -v ${PWD}:/src/github.com/projectatomic/skopeo \ docker run --rm -v ${PWD}:/src/github.com/projectatomic/skopeo \
skopeobuildimage make binary-local DEBUG=$(DEBUG) skopeobuildimage make binary-local $(if $(DEBUG),DEBUG=$(DEBUG))
# Build w/o using Docker containers # Build w/o using Docker containers
binary-local: binary-local:
go build -ldflags "-X main.gitCommit=${GIT_COMMIT}" -gcflags $(GOGCFLAGS) -o skopeo ./cmd/skopeo go build -ldflags "-X main.gitCommit=${GIT_COMMIT}" -gcflags "$(GOGCFLAGS)" -o skopeo ./cmd/skopeo
build-container: build-container: