Skip to content

Commit

Permalink
Merge pull request #11716 from dilyanpalauzov/makefile_go_ldflags
Browse files Browse the repository at this point in the history
Makefile: use -ldflags/-gccgoflags depending on the go implemenatiton
  • Loading branch information
openshift-merge-robot authored Sep 23, 2021
2 parents e8fc990 + ce080d2 commit f690f78
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
export GOPROXY=https://proxy.golang.org

GO ?= go
GO_LDFLAGS:= $(shell if $(GO) version|grep -q gccgo ; then echo "-gccgoflags"; else echo "-ldflags"; fi)
GOCMD = CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO)
COVERAGE_PATH ?= .coverage
DESTDIR ?=
Expand Down Expand Up @@ -244,19 +245,19 @@ gofmt: ## Verify the source code gofmt

.PHONY: test/checkseccomp/checkseccomp
test/checkseccomp/checkseccomp: .gopathok $(wildcard test/checkseccomp/*.go)
$(GOCMD) build $(BUILDFLAGS) -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS)" -o $@ ./test/checkseccomp
$(GOCMD) build $(BUILDFLAGS) $(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS)" -o $@ ./test/checkseccomp

.PHONY: test/testvol/testvol
test/testvol/testvol: .gopathok $(wildcard test/testvol/*.go)
$(GOCMD) build $(BUILDFLAGS) -ldflags '$(LDFLAGS_PODMAN)' -o $@ ./test/testvol
$(GOCMD) build $(BUILDFLAGS) $(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' -o $@ ./test/testvol

.PHONY: volume-plugin-test-image
volume-plugin-test-img:
podman build -t quay.io/libpod/volume-plugin-test-img -f Containerfile-testvol .

.PHONY: test/goecho/goecho
test/goecho/goecho: .gopathok $(wildcard test/goecho/*.go)
$(GOCMD) build $(BUILDFLAGS) -ldflags '$(LDFLAGS_PODMAN)' -o $@ ./test/goecho
$(GOCMD) build $(BUILDFLAGS) $(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' -o $@ ./test/goecho

test/version/version: .gopathok version/version.go
$(GO) build -o $@ ./test/version/
Expand Down Expand Up @@ -299,7 +300,7 @@ ifeq (,$(findstring systemd,$(BUILDTAGS)))
endif
$(GOCMD) build \
$(BUILDFLAGS) \
-ldflags '$(LDFLAGS_PODMAN)' \
$(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' \
-tags "$(BUILDTAGS)" \
-o $@ ./cmd/podman

Expand All @@ -310,14 +311,14 @@ $(SRCBINDIR):
$(SRCBINDIR)/podman$(BINSFX): $(SRCBINDIR) .gopathok $(SOURCES) go.mod go.sum
$(GOCMD) build \
$(BUILDFLAGS) \
-ldflags '$(LDFLAGS_PODMAN)' \
$(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' \
-tags "${REMOTETAGS}" \
-o $@ ./cmd/podman

$(SRCBINDIR)/podman-remote-static: $(SRCBINDIR) .gopathok $(SOURCES) go.mod go.sum
$(GOCMD) build \
$(BUILDFLAGS) \
-ldflags '$(LDFLAGS_PODMAN_STATIC)' \
$(GO_LDFLAGS) '$(LDFLAGS_PODMAN_STATIC)' \
-tags "${REMOTETAGS}" \
-o $@ ./cmd/podman

Expand Down Expand Up @@ -372,7 +373,7 @@ bin/podman.cross.%: .gopathok
CGO_ENABLED=0 \
$(GO) build \
$(BUILDFLAGS) \
-ldflags '$(LDFLAGS_PODMAN)' \
$(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' \
-tags '$(BUILDTAGS_CROSS)' \
-o "$@" ./cmd/podman

Expand Down

0 comments on commit f690f78

Please sign in to comment.