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 # People rebuilding this package can overwrite RTE_MACHINE
16 # via DEB_BUILD_OPTIONS if they like
17 ifneq (,$(filter rte_machine=%,$(DEB_BUILD_OPTIONS)))
18 RTE_MACHINE ?= $(patsubst rte_machine=%,%,$(filter rte_machine=%,$(DEB_BUILD_OPTIONS)))
20 # default to minimal base, without setting this it would build
21 # -march=native which is a non portable invariant
22 RTE_MACHINE ?= "default"
24 # now stable with parallel comilation, so support -j
25 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
26 PAR := $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
30 ifneq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
33 ifneq (,$(findstring nodoc,$(DEB_BUILD_OPTIONS)))
35 # to stop dh_installdoc from running
36 export DEB_BUILD_PROFILES += nodoc
42 # Allow to pass specific configure flags to meson as a comma separated list
43 ifneq (,$(filter dpdk_config_options=%,$(DEB_BUILD_OPTIONS)))
44 # GNU Makefile hack: can't directly escape comma and spaces, so use variables
48 DPDK_CONFIG_OPTIONS ?= $(subst $(comma),$(space),$(patsubst dpdk_config_options=%,%,$(filter dpdk_config_options=%,$(DEB_BUILD_OPTIONS))))
51 # kernel_modules can be passed via DEB_BUILD_OPTIONS to enable building the
52 # optional binary kernel modules package. By default it will be built against
53 # the current kernel, or ksrc can be passed with a path to the target kernel
55 ifeq (,$(findstring kernel_modules,$(DEB_BUILD_OPTIONS)))
56 DPDK_CONFIG_BUILD_KMOD=false
59 ifneq (,$(filter ksrc=%,$(DEB_BUILD_OPTIONS)))
60 KSRC := $(patsubst ksrc=%,%,$(filter ksrc=%,$(DEB_BUILD_OPTIONS)))
62 KSRC := /lib/modules/$(shell LIST=$$(ls /lib/modules/); for dir in $$LIST; do test -d /lib/modules/$$dir/build && echo $$dir; done | sort -V | tail -n1)/build
65 KVERS := $(shell perl debian/kernel-version $(KSRC))
67 export MODULE_CFLAGS=-fno-PIE
69 DPDK_CONFIG_BUILD_KMOD=true
71 # Since the binary module package is generated at build time depending on the
72 # local kernel version, we have to append the new package in d/control.
73 # We cannot use a separate control file since that wouldn't work with
74 # dpkg-genchanges, and also would require a lot of overrides for debhelpers.
75 get_built_using ?= $(filter-out (=),$(shell dpkg-query -f='$${source:Package} (=$${source:Version})' -W $1))
78 @if [ x"$(KVERS)" = x ] ; then \
79 echo 'No version in $(KSRC)/include/linux/version.h' >&2; \
82 sh debian/prep-modules $(KSRC)
83 cat debian/control.modules >> debian/control
84 dh $@ --with python3,dkms,systemd --buildsystem=meson
88 dh $@ --with python3,dkms,systemd --buildsystem=meson
90 override_dh_gencontrol:
92 # debian/files will not exist until dh_gencontrol has ran at least once,
93 # so we need to run gencontrol for libdpdk-dev after.
94 # The list of libraries and PMDs is everchanging, so generate the dependency
95 # list for libdpdk-dev to avoid having to maintain it manually.
96 # Same for the recommends list for dpdk, were we want the PMDs and the mempools.
97 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'`"
98 dh_gencontrol -p dpdk -- -V"librte:Suggests=`grep -E 'librte-(pmd|mempool).*' ./debian/files | grep -v dbgsym | tr '_' ' ' | awk '{ print $$1,"(=",$$2 ")" }' | paste -sd ',' - | sed -e 's/,/, /g'`"
99 ifneq (,$(findstring kernel_modules,$(DEB_BUILD_OPTIONS)))
100 dh_gencontrol -p dpdk-modules-$(KVERS) -- \
101 -v`cat debian/VERSION` \
102 -V'built:using:kernel=$(call get_built_using,linux-headers-$(KVERS))'
105 override_dh_auto_clean:
106 rm -rf debian/build debian/tmp debian/dpdk-modules-* \
107 debian/control.modules debian/VERSION
108 sed -i '/Package: dpdk-modules-/,/`tail -n1 debian/control.modules.in`/d' debian/control
109 rm -f debian/dpdk-igb-uio-dkms.dkms debian/dpdk-rte-kni-dkms.dkms
110 rm -f doc/guides/compressdevs/overview_feature_table.txt \
111 doc/guides/cryptodevs/overview_aead_table.txt \
112 doc/guides/cryptodevs/overview_asym_table.txt \
113 doc/guides/cryptodevs/overview_auth_table.txt \
114 doc/guides/cryptodevs/overview_cipher_table.txt \
115 doc/guides/cryptodevs/overview_feature_table.txt \
116 doc/guides/nics/overview_table.txt
119 override_dh_auto_configure:
120 dh_auto_configure -- $(DPDK_CONFIG_OPTIONS) \
121 --includedir=include/dpdk \
122 --default-library=shared \
123 -Dper_library_versions=false \
124 -Dinclude_subdir_arch=../$(DEB_HOST_MULTIARCH)/dpdk \
125 -Dmachine=$(RTE_MACHINE) \
126 -Dkernel_dir=$(KSRC) \
127 -Denable_kmods=$(DPDK_CONFIG_BUILD_KMOD)
129 override_dh_auto_build-indep:
130 ifeq (y,$(BUILD_DOCS))
132 # NINJA DOC INSTALL DOES NOT WORK - .buildinfo present, css missing
133 rm -f obj-$(DEB_HOST_MULTIARCH)/doc/guides/guides/.buildinfo
136 # ninja install doc does not work, will rebuild everything,
137 # only dpdk-doc as arch: all so just skip it
138 override_dh_auto_install-indep:
140 override_dh_auto_install-arch:
142 # have the DKMS build include the correct per-arch directory
143 sed "s/@@DEB_HOST_MULTIARCH@@/$(DEB_HOST_MULTIARCH)/g" debian/dpdk-igb-uio-dkms.dkms.in > debian/dpdk-igb-uio-dkms.dkms
144 sed "s/@@DEB_HOST_MULTIARCH@@/$(DEB_HOST_MULTIARCH)/g" debian/dpdk-rte-kni-dkms.dkms.in > debian/dpdk-rte-kni-dkms.dkms
145 # Package(s): libdpdk-<NAME><VER> (bare runtime libs and PMDs)
146 for lib in $$(ls -1 debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/*.so.*); do \
147 LN=$$(basename $${lib} | sed -e 's/\.so\.[0-9\.]*$$//' | tr '_' '-'); \
148 if echo $${LN} | grep -q ".*[0-9]$$"; then \
149 PKG=$${LN}-$(DPDK_ABI); \
151 PKG=$${LN}$(DPDK_ABI); \
153 LIBF="$$(basename $${lib})"; \
154 dh_install -p $${PKG} usr/lib/$(DEB_HOST_MULTIARCH)/$${LIBF}; \
155 if [ -f debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/*/*/$${LIBF} ]; then \
156 dh_install -p $${PKG} usr/lib/$(DEB_HOST_MULTIARCH)/*/*/$${LIBF}; \
159 # Package: dpdk-igb-uio-dkms
160 dh_install -p dpdk-igb-uio-dkms kernel/linux/igb_uio/* \
161 usr/src/dpdk-igb-uio-$(DEB_VERSION_UPSTREAM)
162 # Package: dpdk-rte-kni-dkms
163 dh_install -p dpdk-rte-kni-dkms kernel/linux/kni/* \
164 usr/src/dpdk-rte-kni-$(DEB_VERSION_UPSTREAM)
166 # Package: dpdk-modules-<kernel version>
167 dh_install -p dpdk-modules-$(KVERS) lib/modules
171 dh_dkms -V $(DEB_VERSION_UPSTREAM)
173 override_dh_installinit:
174 dh_installinit --no-start --no-stop-on-upgrade
176 override_dh_systemd_start:
177 dh_systemd_start --no-start --no-stop-on-upgrade
179 override_dh_auto_test:
182 # dh_python only looks in /usr/share/package_name but dpdk-doc installs in
183 # /usr/share/dpdk, so pass /usr to catch all
184 dh_python3 --shebang=/usr/bin/python3 /usr
187 dh_missing --fail-missing