From 4ba7d5017419cfc592e4915a81f2a4e2e7cd3fb1 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Thu, 24 Sep 2020 11:13:06 -0400 Subject: [PATCH] Makefile: add a local-cross target Add a make target that cross-compiles for a handful of the possible targets that `go tool dist list` can tell us about. Signed-off-by: Nalin Dahyabhai --- .travis.yml | 2 +- Makefile | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bb349078..d8392a8f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,4 +24,4 @@ install: script: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then hack/travis_osx.sh ; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make vendor && ./hack/tree_status.sh && make check ; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make vendor && ./hack/tree_status.sh && make local-cross && make check ; fi diff --git a/Makefile b/Makefile index 0460b995..8e4028ae 100644 --- a/Makefile +++ b/Makefile @@ -126,6 +126,9 @@ static: .PHONY: bin/skopeo bin/skopeo: $(GPGME_ENV) $(GO) build $(MOD_VENDOR) ${GO_DYN_FLAGS} ${LDFLAGS} -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o $@ ./cmd/skopeo +bin/skopeo.%: + GOOS=$(word 2,$(subst ., ,$@)) GOARCH=$(word 3,$(subst ., ,$@)) $(GO) build $(MOD_VENDOR) ${LDFLAGS} -tags "containers_image_openpgp $(BUILDTAGS)" -o $@ ./cmd/skopeo +local-cross: bin/skopeo.darwin.amd64 bin/skopeo.linux.arm bin/skopeo.linux.arm64 bin/skopeo.windows.386.exe bin/skopeo.windows.amd64.exe build-container: ${CONTAINER_RUNTIME} build ${BUILD_ARGS} -t "$(IMAGE)" .