diff --git a/Makefile b/Makefile index af19a7b8..3f2ea602 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,13 @@ export GO15VENDOREXPERIMENT=1 ifeq ($(shell uname),Darwin) PREFIX ?= ${DESTDIR}/usr/local DARWIN_BUILD_TAG=containers_image_ostree_stub +# On macOS, (brew install gpgme) installs it within /usr/local, but /usr/local/include is not in the default search path. +# Rather than hard-code this directory, use gpgme-config. Sadly that must be done at the top-level user +# instead of locally in the gpgme subpackage, because cgo supports only pkg-config, not general shell scripts, +# and gpgme does not install a pkg-config file. +# If gpgme is not installed or gpgme-config can’t be found for other reasons, the error is silently ignored +# (and the user will probably find out because the cgo compilation will fail). +GPGME_ENV := CGO_CFLAGS="$(shell gpgme-config --cflags 2>/dev/null)" CGO_LDFLAGS="$(shell gpgme-config --libs 2>/dev/null)" else PREFIX ?= ${DESTDIR}/usr endif @@ -64,10 +71,10 @@ binary-static: cmd/skopeo # Build w/o using Docker containers binary-local: - $(GO) build -ldflags "-X main.gitCommit=${GIT_COMMIT}" -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o skopeo ./cmd/skopeo + $(GPGME_ENV) $(GO) build -ldflags "-X main.gitCommit=${GIT_COMMIT}" -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o skopeo ./cmd/skopeo binary-local-static: - $(GO) build -ldflags "-extldflags \"-static\" -X main.gitCommit=${GIT_COMMIT}" -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o skopeo ./cmd/skopeo + $(GPGME_ENV) $(GO) build -ldflags "-extldflags \"-static\" -X main.gitCommit=${GIT_COMMIT}" -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o skopeo ./cmd/skopeo build-container: docker build ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)" . @@ -123,4 +130,4 @@ validate-local: hack/make.sh validate-git-marks validate-gofmt validate-lint validate-vet test-unit-local: - $(GO) test -tags "$(BUILDTAGS)" $$($(GO) list -tags "$(BUILDTAGS)" -e ./... | grep -v '^github\.com/projectatomic/skopeo/\(integration\|vendor/.*\)$$') + $(GPGME_ENV) $(GO) test -tags "$(BUILDTAGS)" $$($(GO) list -tags "$(BUILDTAGS)" -e ./... | grep -v '^github\.com/projectatomic/skopeo/\(integration\|vendor/.*\)$$')