mirror of
https://github.com/containers/skopeo.git
synced 2025-06-30 16:42:24 +00:00
Automatically use the right CFLAGS and LDFLAGS for gpgme
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); this is so that users can use the containers_image_openpgp build tag without seeing ugly errors (and without the Makefile having to detect that build tag in even more shell scripts).
This commit is contained in:
parent
aa6df53779
commit
37e34aaff2
13
Makefile
13
Makefile
@ -5,6 +5,13 @@ export GO15VENDOREXPERIMENT=1
|
|||||||
ifeq ($(shell uname),Darwin)
|
ifeq ($(shell uname),Darwin)
|
||||||
PREFIX ?= ${DESTDIR}/usr/local
|
PREFIX ?= ${DESTDIR}/usr/local
|
||||||
DARWIN_BUILD_TAG=containers_image_ostree_stub
|
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
|
else
|
||||||
PREFIX ?= ${DESTDIR}/usr
|
PREFIX ?= ${DESTDIR}/usr
|
||||||
endif
|
endif
|
||||||
@ -64,10 +71,10 @@ binary-static: cmd/skopeo
|
|||||||
|
|
||||||
# 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)" -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:
|
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:
|
build-container:
|
||||||
docker build ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)" .
|
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
|
hack/make.sh validate-git-marks validate-gofmt validate-lint validate-vet
|
||||||
|
|
||||||
test-unit-local:
|
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/.*\)$$')
|
||||||
|
Loading…
Reference in New Issue
Block a user