3 # see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
4 DPKG_EXPORT_BUILDFLAGS = 1
5 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
6 include /usr/share/dpkg/default.mk
8 DPDK_ABI := $(shell echo $(DEB_VERSION_UPSTREAM) | cut -d '-' -f1 | cut -d '.' -f1-2 | cut -d '~' -f1)
10 ifeq (,$(findstring terse,$(DEB_BUILD_OPTIONS)))
15 # now stable with parallel comilation, so support -j
16 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
17 PAR := $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
21 ifneq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
24 ifneq (,$(findstring nodoc,$(DEB_BUILD_OPTIONS)))
26 # to stop dh_installdoc from running
27 export DEB_BUILD_PROFILES += nodoc
33 # kernel_modules can be passed via DEB_BUILD_OPTIONS to enable building the
34 # optional binary kernel modules package. By default it will be built against
35 # the current kernel, or ksrc can be passed with a path to the target kernel
37 ifeq (,$(findstring kernel_modules,$(DEB_BUILD_OPTIONS)))
38 DPDK_CONFIG_BUILD_KMOD=false
41 ifneq (,$(filter ksrc=%,$(DEB_BUILD_OPTIONS)))
42 KSRC := $(patsubst ksrc=%,%,$(filter ksrc=%,$(DEB_BUILD_OPTIONS)))
44 KSRC := /lib/modules/$(shell uname -r)/build
47 KVERS := $(shell perl debian/kernel-version $(KSRC))
49 export MODULE_CFLAGS=-fno-PIE
51 DPDK_CONFIG_BUILD_KMOD=true
53 # Since the binary module package is generated at build time depending on the
54 # local kernel version, we have to append the new package in d/control.
55 # We cannot use a separate control file since that wouldn't work with
56 # dpkg-genchanges, and also would require a lot of overrides for debhelpers.
57 get_built_using ?= $(filter-out (=),$(shell dpkg-query -f='$${source:Package} (=$${source:Version})' -W $1))
60 @if [ x"$(KVERS)" = x ] ; then \
61 echo 'No version in $(KSRC)/include/linux/version.h' >&2; \
64 sh debian/prep-modules $(KSRC)
65 cat debian/control.modules >> debian/control
66 dh $@ --with python3,dkms,systemd --buildsystem=meson
70 dh $@ --with python3,dkms,systemd --buildsystem=meson
72 override_dh_gencontrol:
74 # debian/files will not exist until dh_gencontrol has ran at least once,
75 # so we need to run gencontrol for libdpdk-dev after.
76 # The list of libraries and PMDs is everchanging, so generate the dependency
77 # list for libdpdk-dev to avoid having to maintain it manually.
78 # Same for the recommends list for dpdk, were we want the PMDs and the mempools.
79 dh_gencontrol -p libdpdk-dev -- -V"librte:Depends=`grep -E 'librte-*' ./debian/files | grep -v dbgsym | tr '_' ' ' | awk '{ print $$1,"(=",$$2 ")" }' | paste -sd ',' - | sed -e 's/,/, /g'`"
80 dh_gencontrol -p dpdk -- -V"librte:Recommends=`grep -E 'librte-(pmd|mempool).*' ./debian/files | grep -v dbgsym | tr '_' ' ' | awk '{ print $$1,"(=",$$2 ")" }' | paste -sd ',' - | sed -e 's/,/, /g'`"
81 ifneq (,$(findstring kernel_modules,$(DEB_BUILD_OPTIONS)))
82 dh_gencontrol -p dpdk-modules-$(KVERS) -- \
83 -v`cat debian/VERSION` \
84 -V'built:using:kernel=$(call get_built_using,linux-headers-$(KVERS))'
87 override_dh_auto_clean:
88 rm -rf debian/build debian/tmp debian/dpdk-modules-* \
89 debian/control.modules debian/VERSION
90 sed -i '/Package: dpdk-modules-/,/`tail -n1 debian/control.modules.in`/d' debian/control
91 rm -f debian/dpdk-igb-uio-dkms.dkms debian/dpdk-rte-kni-dkms.dkms
94 override_dh_auto_configure:
95 dh_auto_configure -- \
96 --includedir=include/dpdk \
97 -Dper_library_versions=false \
98 -Dinclude_subdir_arch=../$(DEB_HOST_MULTIARCH)/dpdk \
100 -Dkernel_dir=$(KSRC) \
101 -Denable_kmods=$(DPDK_CONFIG_BUILD_KMOD)
103 override_dh_auto_build-indep:
104 ifeq (y,$(BUILD_DOCS))
106 # NINJA DOC INSTALL DOES NOT WORK - .buildinfo present, css missing
107 rm -f obj-$(DEB_HOST_MULTIARCH)/doc/guides/guides/.buildinfo
110 # ninja install doc does not work, will rebuild everything,
111 # only dpdk-doc as arch: all so just skip it
112 override_dh_auto_install-indep:
114 override_dh_auto_install-arch:
116 # have the DKMS build include the correct per-arch directory
117 sed "s/@@DEB_HOST_MULTIARCH@@/$(DEB_HOST_MULTIARCH)/g" debian/dpdk-igb-uio-dkms.dkms.in > debian/dpdk-igb-uio-dkms.dkms
118 sed "s/@@DEB_HOST_MULTIARCH@@/$(DEB_HOST_MULTIARCH)/g" debian/dpdk-rte-kni-dkms.dkms.in > debian/dpdk-rte-kni-dkms.dkms
119 # Package(s): libdpdk-<NAME><VER> (bare runtime libs and PMDs)
120 for lib in $$(ls -1 debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/*.so.*); do \
121 LN=$$(basename $${lib} | sed -e 's/\.so\.[0-9\.]*$$//' | tr '_' '-'); \
122 if echo $${LN} | grep -q ".*[0-9]$$"; then \
123 PKG=$${LN}-$(DPDK_ABI); \
125 PKG=$${LN}$(DPDK_ABI); \
127 LIBF="$$(basename $${lib})"; \
128 dh_install -p $${PKG} usr/lib/$(DEB_HOST_MULTIARCH)/$${LIBF}; \
129 if [ -f debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/*/*/$${LIBF} ]; then \
130 dh_install -p $${PKG} usr/lib/$(DEB_HOST_MULTIARCH)/*/*/$${LIBF}; \
133 # Package: dpdk-igb-uio-dkms
134 dh_install -p dpdk-igb-uio-dkms kernel/linux/igb_uio/* \
135 usr/src/dpdk-igb-uio-$(DEB_VERSION_UPSTREAM)
136 # Package: dpdk-rte-kni-dkms
137 dh_install -p dpdk-rte-kni-dkms kernel/linux/kni/* \
138 usr/src/dpdk-rte-kni-$(DEB_VERSION_UPSTREAM)
140 # Package: dpdk-modules-<kernel version>
141 dh_install -p dpdk-modules-$(KVERS) lib/modules
145 dh_dkms -V $(DEB_VERSION_UPSTREAM)
147 override_dh_installinit:
148 dh_installinit --no-start --no-stop-on-upgrade
150 override_dh_systemd_start:
151 dh_systemd_start --no-start --no-stop-on-upgrade
153 override_dh_auto_test:
156 # dh_python only looks in /usr/share/package_name but dpdk-doc installs in
157 # /usr/share/dpdk, so pass /usr to catch all
158 dh_python3 --shebang=/usr/bin/python3 /usr
161 dh_missing --fail-missing