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 # kernel_modules can be passed via DEB_BUILD_OPTIONS to enable building the
43 # optional binary kernel modules package. By default it will be built against
44 # the current kernel, or ksrc can be passed with a path to the target kernel
46 ifeq (,$(findstring kernel_modules,$(DEB_BUILD_OPTIONS)))
47 DPDK_CONFIG_BUILD_KMOD=false
50 ifneq (,$(filter ksrc=%,$(DEB_BUILD_OPTIONS)))
51 KSRC := $(patsubst ksrc=%,%,$(filter ksrc=%,$(DEB_BUILD_OPTIONS)))
53 KSRC := /lib/modules/$(shell uname -r)/build
56 KVERS := $(shell perl debian/kernel-version $(KSRC))
58 export MODULE_CFLAGS=-fno-PIE
60 DPDK_CONFIG_BUILD_KMOD=true
62 # Since the binary module package is generated at build time depending on the
63 # local kernel version, we have to append the new package in d/control.
64 # We cannot use a separate control file since that wouldn't work with
65 # dpkg-genchanges, and also would require a lot of overrides for debhelpers.
66 get_built_using ?= $(filter-out (=),$(shell dpkg-query -f='$${source:Package} (=$${source:Version})' -W $1))
69 @if [ x"$(KVERS)" = x ] ; then \
70 echo 'No version in $(KSRC)/include/linux/version.h' >&2; \
73 sh debian/prep-modules $(KSRC)
74 cat debian/control.modules >> debian/control
75 dh $@ --with python3,dkms,systemd --buildsystem=meson
79 dh $@ --with python3,dkms,systemd --buildsystem=meson
81 override_dh_gencontrol:
83 # debian/files will not exist until dh_gencontrol has ran at least once,
84 # so we need to run gencontrol for libdpdk-dev after.
85 # The list of libraries and PMDs is everchanging, so generate the dependency
86 # list for libdpdk-dev to avoid having to maintain it manually.
87 # Same for the recommends list for dpdk, were we want the PMDs and the mempools.
88 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'`"
89 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'`"
90 ifneq (,$(findstring kernel_modules,$(DEB_BUILD_OPTIONS)))
91 dh_gencontrol -p dpdk-modules-$(KVERS) -- \
92 -v`cat debian/VERSION` \
93 -V'built:using:kernel=$(call get_built_using,linux-headers-$(KVERS))'
96 override_dh_auto_clean:
97 rm -rf debian/build debian/tmp debian/dpdk-modules-* \
98 debian/control.modules debian/VERSION
99 sed -i '/Package: dpdk-modules-/,/`tail -n1 debian/control.modules.in`/d' debian/control
100 rm -f debian/dpdk-igb-uio-dkms.dkms debian/dpdk-rte-kni-dkms.dkms
103 override_dh_auto_configure:
104 dh_auto_configure -- \
105 --includedir=include/dpdk \
106 -Dper_library_versions=false \
107 -Dinclude_subdir_arch=../$(DEB_HOST_MULTIARCH)/dpdk \
108 -Dmachine=$(RTE_MACHINE) \
109 -Dkernel_dir=$(KSRC) \
110 -Denable_kmods=$(DPDK_CONFIG_BUILD_KMOD)
112 override_dh_auto_build-indep:
113 ifeq (y,$(BUILD_DOCS))
115 # NINJA DOC INSTALL DOES NOT WORK - .buildinfo present, css missing
116 rm -f obj-$(DEB_HOST_MULTIARCH)/doc/guides/guides/.buildinfo
119 # ninja install doc does not work, will rebuild everything,
120 # only dpdk-doc as arch: all so just skip it
121 override_dh_auto_install-indep:
123 override_dh_auto_install-arch:
125 # have the DKMS build include the correct per-arch directory
126 sed "s/@@DEB_HOST_MULTIARCH@@/$(DEB_HOST_MULTIARCH)/g" debian/dpdk-igb-uio-dkms.dkms.in > debian/dpdk-igb-uio-dkms.dkms
127 sed "s/@@DEB_HOST_MULTIARCH@@/$(DEB_HOST_MULTIARCH)/g" debian/dpdk-rte-kni-dkms.dkms.in > debian/dpdk-rte-kni-dkms.dkms
128 # Package(s): libdpdk-<NAME><VER> (bare runtime libs and PMDs)
129 for lib in $$(ls -1 debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/*.so.*); do \
130 LN=$$(basename $${lib} | sed -e 's/\.so\.[0-9\.]*$$//' | tr '_' '-'); \
131 if echo $${LN} | grep -q ".*[0-9]$$"; then \
132 PKG=$${LN}-$(DPDK_ABI); \
134 PKG=$${LN}$(DPDK_ABI); \
136 LIBF="$$(basename $${lib})"; \
137 dh_install -p $${PKG} usr/lib/$(DEB_HOST_MULTIARCH)/$${LIBF}; \
138 if [ -f debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/*/*/$${LIBF} ]; then \
139 dh_install -p $${PKG} usr/lib/$(DEB_HOST_MULTIARCH)/*/*/$${LIBF}; \
142 # Package: dpdk-igb-uio-dkms
143 dh_install -p dpdk-igb-uio-dkms kernel/linux/igb_uio/* \
144 usr/src/dpdk-igb-uio-$(DEB_VERSION_UPSTREAM)
145 # Package: dpdk-rte-kni-dkms
146 dh_install -p dpdk-rte-kni-dkms kernel/linux/kni/* \
147 usr/src/dpdk-rte-kni-$(DEB_VERSION_UPSTREAM)
149 # Package: dpdk-modules-<kernel version>
150 dh_install -p dpdk-modules-$(KVERS) lib/modules
154 dh_dkms -V $(DEB_VERSION_UPSTREAM)
156 override_dh_installinit:
157 dh_installinit --no-start --no-stop-on-upgrade
159 override_dh_systemd_start:
160 dh_systemd_start --no-start --no-stop-on-upgrade
162 override_dh_auto_test:
165 # dh_python only looks in /usr/share/package_name but dpdk-doc installs in
166 # /usr/share/dpdk, so pass /usr to catch all
167 dh_python3 --shebang=/usr/bin/python3 /usr
170 dh_missing --fail-missing