| 1 |
#!/usr/bin/make -f |
| 2 |
|
| 3 |
export KDIR = $(shell find /usr/lib/modules/ -maxdepth 2 -mindepth 2 -type l -name build | sort | tail -1) |
| 4 |
|
| 5 |
# Disable the test suite if the kernel headers are not available |
| 6 |
ifeq (,$(KDIR)) |
| 7 |
DEB_BUILD_OPTIONS+=nocheck |
| 8 |
endif |
| 9 |
|
| 10 |
ifeq ($(filter noudeb,$(DEB_BUILD_PROFILES)),) |
| 11 |
BUILD_UDEB := 1 |
| 12 |
endif |
| 13 |
|
| 14 |
KMOD_ENABLE_DOCS=$(if $(filter nodoc,$(DEB_BUILD_PROFILES)),false,true) |
| 15 |
KMOD_ENABLE_TESTS=$(if $(filter nocheck,$(DEB_BUILD_PROFILES)),false,true) |
| 16 |
|
| 17 |
D := $(CURDIR)/debian/kmod |
| 18 |
DK := $(CURDIR)/debian/libkmod2 |
| 19 |
DD := $(CURDIR)/debian/libkmod-dev |
| 20 |
DU := $(CURDIR)/debian/kmod-udeb |
| 21 |
DKU := $(CURDIR)/debian/libkmod2-udeb |
| 22 |
TU := $(CURDIR)/debian/tmp-udeb |
| 23 |
|
| 24 |
CONFFLAGS = |
| 25 |
CONFFLAGS_deb = $(CONFFLAGS) \ |
| 26 |
-D build-tests=$(KMOD_ENABLE_TESTS) \ |
| 27 |
-D docs=$(KMOD_ENABLE_DOCS) \ |
| 28 |
-D openssl=enabled \ |
| 29 |
-D dlopen=all \ |
| 30 |
-D zlib=disabled \ |
| 31 |
-D xz=enabled \ |
| 32 |
-D zstd=enabled |
| 33 |
CONFFLAGS_udeb = $(CONFFLAGS) \ |
| 34 |
-D docs=false \ |
| 35 |
-D openssl=disabled \ |
| 36 |
-D zlib=disabled \ |
| 37 |
-D xz=enabled \ |
| 38 |
-D zstd=disabled |
| 39 |
|
| 40 |
############################################################################## |
| 41 |
ifdef BUILD_UDEB |
| 42 |
BUILD_UDEB_TARGET := build-udeb/.stamp-build |
| 43 |
endif |
| 44 |
|
| 45 |
############################################################################## |
| 46 |
%: |
| 47 |
dh $@ --buildsystem=meson |
| 48 |
|
| 49 |
execute_before_dh_clean: |
| 50 |
rm -rf build-*deb $(TU) |
| 51 |
|
| 52 |
# ignore dh_autoreconf until the autoconf-based build system will be removed |
| 53 |
override_dh_autoreconf: |
| 54 |
|
| 55 |
build-deb/build.ninja: |
| 56 |
$(shell DEB_BUILD_MAINT_OPTIONS="hardening=+bindnow" \ |
| 57 |
dpkg-buildflags --export=configure || true) \ |
| 58 |
dh_auto_configure --builddir=build-deb -- $(CONFFLAGS_deb) |
| 59 |
|
| 60 |
build-udeb/build.ninja: |
| 61 |
$(subst -O2,-Os -fomit-frame-pointer,$(shell DEB_BUILD_MAINT_OPTIONS="hardening=-all" \ |
| 62 |
dpkg-buildflags --export=configure || true)) \ |
| 63 |
dh_auto_configure --builddir=build-udeb -- $(CONFFLAGS_udeb) |
| 64 |
|
| 65 |
override_dh_auto_configure: |
| 66 |
|
| 67 |
build-deb/.stamp-build: build-deb/build.ninja |
| 68 |
dh_auto_build --builddir=build-deb |
| 69 |
touch $@ |
| 70 |
|
| 71 |
build-udeb/.stamp-build: build-udeb/build.ninja |
| 72 |
# ignore the blhc false positives (see CONFFLAGS_udeb) |
| 73 |
@echo 'blhc: ignore-line-regexp: .* [^ ]*cc .+ -Os -fomit-frame-pointer .+' |
| 74 |
@echo 'blhc: ignore-line-regexp: *(LD|CC) .+/build-deb/testsuite/.+' |
| 75 |
dh_auto_build --builddir=build-udeb |
| 76 |
touch $@ |
| 77 |
|
| 78 |
override_dh_auto_build: build-deb/.stamp-build $(BUILD_UDEB_TARGET) |
| 79 |
|
| 80 |
override_dh_auto_test: |
| 81 |
dh_auto_test --builddir=build-deb |
| 82 |
|
| 83 |
override_dh_auto_install: |
| 84 |
dh_auto_install --builddir=build-deb |
| 85 |
ifdef BUILD_UDEB |
| 86 |
cd build-udeb && DESTDIR=$(TU) meson install --tags runtime |
| 87 |
endif |
| 88 |
|
| 89 |
override_dh_install: |
| 90 |
ifneq (,$(filter nodoc, $(DEB_BUILD_OPTIONS))) |
| 91 |
# create an empty directory which will be installed by dh_install |
| 92 |
mkdir debian/tmp/usr/share/gtk-doc/ |
| 93 |
endif |
| 94 |
dh_install -Nkmod-udeb -Nlibkmod2-udeb |
| 95 |
sed -i -re '/^Requires.private:/d' \ |
| 96 |
$(DD)/usr/lib/*/pkgconfig/libkmod.pc |
| 97 |
ifdef BUILD_UDEB |
| 98 |
dh_install --sourcedir=$(TU) -pkmod-udeb -plibkmod2-udeb |
| 99 |
egrep -i '^[a-z]' debian/extra/aliases.conf > $(DU)/usr/lib/modprobe.d/aliases.conf |
| 100 |
endif |
| 101 |
|
| 102 |
override_dh_installdocs: |
| 103 |
dh_installdocs -pkmod -plibkmod-dev --link-doc=libkmod2 |
| 104 |
dh_installdocs -plibkmod2 |
| 105 |
cp libkmod/README $(DD)/usr/share/doc/libkmod2/README.libkmod |
| 106 |
|
| 107 |
override_dh_installchangelogs: |
| 108 |
dh_installchangelogs NEWS |
| 109 |
|
| 110 |
override_dh_makeshlibs: |
| 111 |
dh_makeshlibs -V'libkmod2 (>= $(shell perl debian/highest_symbol_version debian/libkmod2.symbols))' -- -c4 |
| 112 |
|
| 113 |
override_dh_shlibdeps: |
| 114 |
dh_shlibdeps -- --warnings=7 |
| 115 |
|