| 1 |
#!/usr/bin/make -f |
| 2 |
|
| 3 |
# Exports DEB_{BUILD,HOST}_* flags |
| 4 |
include /usr/share/dpkg/architecture.mk |
| 5 |
|
| 6 |
# Pass this as version-info to dh_makeshlibs |
| 7 |
SHLIBS_MINVER = 1:2.63 |
| 8 |
|
| 9 |
export DEB_BUILD_MAINT_OPTIONS = hardening=+all |
| 10 |
|
| 11 |
# Support cross-compiling |
| 12 |
ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) |
| 13 |
CC := $(DEB_HOST_GNU_TYPE)-gcc |
| 14 |
endif |
| 15 |
|
| 16 |
# One upstream target, "_makenames", requires the BUILD compiler instead of HOST |
| 17 |
BUILD_CC ?= cc |
| 18 |
export BUILD_LDFLAGS = $(shell dpkg-architecture -a$(DEB_BUILD_ARCH) -c dpkg-buildflags --get LDFLAGS) |
| 19 |
export BUILD_CPPFLAGS = $(shell dpkg-architecture -a$(DEB_BUILD_ARCH) -c dpkg-buildflags --get CPPFLAGS) |
| 20 |
|
| 21 |
# Upstream's way of setting optimization |
| 22 |
ifneq (,$(filter noopt, $(DEB_BUILD_OPTIONS))) |
| 23 |
COPTS = COPTS=-O0 |
| 24 |
endif |
| 25 |
|
| 26 |
# See pam_cap/Makefile for FORCELINKPAM |
| 27 |
MAKE_ASSIGNMENTS = \ |
| 28 |
prefix=/usr \ |
| 29 |
FORCELINKPAM=yes \ |
| 30 |
GOLANG=no |
| 31 |
|
| 32 |
%: |
| 33 |
dh ${@} |
| 34 |
|
| 35 |
|
| 36 |
override_dh_auto_clean: |
| 37 |
dh_auto_clean -- $(MAKE_ASSIGNMENTS) |
| 38 |
# The Golang build system does not appear to fully honor -B, so we need |
| 39 |
# two cleans |
| 40 |
set -e; if test -d _build; then \ |
| 41 |
dh_auto_clean -B_build -O--buildsystem=golang; \ |
| 42 |
dh_auto_clean -O--buildsystem=golang; \ |
| 43 |
fi |
| 44 |
# Undo change of lookup (see override_dh_auto_build) |
| 45 |
sed -i -e 's,\./tcapsh-static,../progs/tcapsh-static,g' tests/libcap_launch_test.c |
| 46 |
|
| 47 |
|
| 48 |
override_dh_auto_build: |
| 49 |
# See pam_cap/Makefile for FORCELINKPAM |
| 50 |
dh_auto_build -- \ |
| 51 |
$(MAKE_ASSIGNMENTS) \ |
| 52 |
BUILD_CC=$(BUILD_CC) \ |
| 53 |
CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)- \ |
| 54 |
$(COPTS) \ |
| 55 |
DYNAMIC=yes \ |
| 56 |
SUDO=$(DEB_GAIN_ROOT_CMD) |
| 57 |
# Some of test suite is only invoked when run as real root. Explicitly |
| 58 |
# build all binaries so we can include them in the autopkgtest. |
| 59 |
dh_auto_build -D libcap -- $(MAKE_ASSIGNMENTS) cap_test |
| 60 |
dh_auto_build -D pam_cap -- $(MAKE_ASSIGNMENTS) test_pam_cap |
| 61 |
# Change lookup from sibling dir to current dir |
| 62 |
sed -i -e 's,\.\./progs/tcapsh-static,./tcapsh-static,g' tests/libcap_launch_test.c |
| 63 |
dh_auto_build -D tests -- $(MAKE_ASSIGNMENTS) \ |
| 64 |
psx_test \ |
| 65 |
libcap_psx_test \ |
| 66 |
uns_test \ |
| 67 |
libcap_launch_test \ |
| 68 |
libcap_psx_launch_test \ |
| 69 |
noop \ |
| 70 |
exploit \ |
| 71 |
noexploit |
| 72 |
dh_auto_build -D progs -- $(MAKE_ASSIGNMENTS) tcapsh-static |
| 73 |
|
| 74 |
|
| 75 |
override_dh_installdirs: |
| 76 |
dh_installdirs |
| 77 |
# While the PAM module and the library are in /lib, according to the |
| 78 |
# FHS, development files must go into usr/lib/<triplet>. |
| 79 |
mkdir -p debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH) |
| 80 |
|
| 81 |
|
| 82 |
override_dh_auto_install: |
| 83 |
dh_auto_install -- \ |
| 84 |
$(MAKE_ASSIGNMENTS) \ |
| 85 |
lib=lib/$(DEB_HOST_MULTIARCH) \ |
| 86 |
PKGCONFIGDIR=/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig \ |
| 87 |
RAISE_SETFCAP=no |
| 88 |
|
| 89 |
execute_after_dh_install-arch: |
| 90 |
# Unfortunately, RPATH seems to be needed for the build-time tests |
| 91 |
# (avoiding it and going through LD_LIBRARY_PATH didn't work in all |
| 92 |
# cases). |
| 93 |
# Also, we need to operate on the install result, as the original |
| 94 |
# executable may still be used by a running test process. |
| 95 |
# . |
| 96 |
# List is identical to build above, minus noop (no RPATH) |
| 97 |
cd debian/libcap-dev/usr/lib/$(DEB_HOST_MULTIARCH)/libcap2/tests && \ |
| 98 |
patchelf --remove-rpath \ |
| 99 |
psx_test \ |
| 100 |
libcap_psx_test \ |
| 101 |
uns_test \ |
| 102 |
libcap_launch_test \ |
| 103 |
libcap_psx_launch_test \ |
| 104 |
exploit \ |
| 105 |
noexploit |
| 106 |
|
| 107 |
override_dh_auto_test: |
| 108 |
dh_auto_test -- $(MAKE_ASSIGNMENTS) |
| 109 |
|
| 110 |
override_dh_makeshlibs: |
| 111 |
dh_makeshlibs -V'libcap2 (>= $(SHLIBS_MINVER))' -plibcap2 \ |
| 112 |
--add-udeb=libcap2-udeb -- -c4 |
| 113 |
dh_makeshlibs --remaining-packages -- -c4 |
| 114 |
|
| 115 |
override_dh_gencontrol: |
| 116 |
dh_gencontrol -- -Vmisc:Built-Using="$(shell dpkg-query -f '$${source:Package} (= $${source:Version})' -W libc-dev-bin)" |
| 117 |
|
| 118 |
export DH_GOLANG_BUILDPKG := \ |
| 119 |
kernel.org/pub/linux/libs/security/libcap/cap \ |
| 120 |
kernel.org/pub/linux/libs/security/libcap/psx |
| 121 |
|
| 122 |
execute_after_dh_auto_configure-indep: |
| 123 |
dh_auto_configure -B_build -O--buildsystem=golang |
| 124 |
|
| 125 |
execute_after_dh_auto_install-indep: |
| 126 |
dh_auto_install -B_build -O--buildsystem=golang |
| 127 |
|
| 128 |
execute_after_dh_auto_build-indep: |
| 129 |
dh_auto_build -B_build -O--buildsystem=golang |