#!/usr/bin/make -f include /usr/share/dpkg/pkg-info.mk export DH_VERBOSE = 1 # https://wiki.debian.org/HardeningWalkthrough export DEB_BUILD_MAINT_OPTIONS = hardening=+all export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed DH_GOPKG := github.com/google/fscrypt ### Set some build flags. ### Partially borrowed from upstream Makefile # As of Go 1.11, -buildmode=pie not supported on linux/mips. # # REMINDER: # On new releases of Go check the release notes to see if we can get # rid of this exclusion. E.g. https://golang.org/doc/go1.11#compiler ifeq ($(filter $(DEB_HOST_ARCH),mips mipsel mips64el),) GO_FLAGS += -buildmode=pie endif GO_LINK_FLAGS := -s -w VERSION_FLAG := -X "main.version=v$(DEB_VERSION_UPSTREAM)" GO_LINK_FLAGS += $(VERSION_FLAG) -extldflags "$(LDFLAGS)" GO_FLAGS += --ldflags '$(GO_LINK_FLAGS)' %: dh $@ --buildsystem=golang --with=golang override_dh_auto_build: # Build the command line tool DH_GOLANG_BUILDPKG=$(DH_GOPKG)/cmd/... dh_auto_build -O--buildsystem=golang -- $(GO_FLAGS) # Build the PAM module (C shared library) DH_GOLANG_BUILDPKG=$(DH_GOPKG)/pam_fscrypt/... dh_auto_build -O--buildsystem=golang -- $(GO_FLAGS) -buildmode=c-shared # Workaround for https://github.com/golang/go/issues/24253 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=903385 # # golang-go calls the library pam_fscrypt.a, while gccgo-go calls it libpam_fscrypt.a. # One thing we (hopefully) now: there is only one .a file. Its path is also difficult # to predict. Let's try to write a command that will always rename it to pam_fscrypt.so. ls -l obj-*/pkg/*/$(DH_GOPKG)/*.a SOPATH=$$(dirname obj-*/pkg/*/$(DH_GOPKG)/*.a) && mv -v $$SOPATH/*.a $$SOPATH/pam_fscrypt.so # Old workaround, for future reference: #rename.ul -v .a .so obj-*/pkg/*/$(DH_GOPKG)/*.a override_dh_auto_test: # Excluded tests: # # crypto: needs a user keyring linked into the session keyring # https://github.com/google/fscrypt/issues/99 # filesystem: requires a filesystem to test upon and root privileges DH_GOLANG_EXCLUDES="crypto filesystem" dh_auto_test