File: rules

package info (click to toggle)
fscrypt 0.2.4-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 620 kB
  • sloc: makefile: 135; ansic: 79; sh: 25
file content (59 lines) | stat: -rwxr-xr-x 2,088 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/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