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)))
21 # Use default for arm* where there is a defined list.
22 # x86 and power would just use "native", which is an invariant, so set
23 # power8 and corei7 to keep it stable.
24 ifneq (,$(filter $(DEB_HOST_ARCH), arm64))
25 RTE_MACHINE ?= "default"
27 ifneq (,$(filter $(DEB_HOST_ARCH), armhf))
28 RTE_MACHINE ?= "armv7a"
30 ifneq (,$(filter $(DEB_HOST_ARCH), ppc64el))
31 RTE_MACHINE ?= "power8"
33 RTE_MACHINE ?= "corei7"
38 # now stable with parallel comilation, so support -j
39 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
40 PAR := $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
44 ifneq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
47 ifneq (,$(findstring nodoc,$(DEB_BUILD_OPTIONS)))
49 # to stop dh_installdoc from running
50 export DEB_BUILD_PROFILES += nodoc
56 # kernel_modules can be passed via DEB_BUILD_OPTIONS to enable building the
57 # optional binary kernel modules package. By default it will be built against
58 # the current kernel, or ksrc can be passed with a path to the target kernel
60 ifeq (,$(findstring kernel_modules,$(DEB_BUILD_OPTIONS)))
61 DPDK_CONFIG_BUILD_KMOD=false
64 ifneq (,$(filter ksrc=%,$(DEB_BUILD_OPTIONS)))
65 KSRC := $(patsubst ksrc=%,%,$(filter ksrc=%,$(DEB_BUILD_OPTIONS)))
67 KSRC := /lib/modules/$(shell uname -r)/build
70 KVERS := $(shell perl debian/kernel-version $(KSRC))
72 export MODULE_CFLAGS=-fno-PIE
74 DPDK_CONFIG_BUILD_KMOD=true
76 # Since the binary module package is generated at build time depending on the
77 # local kernel version, we have to append the new package in d/control.
78 # We cannot use a separate control file since that wouldn't work with
79 # dpkg-genchanges, and also would require a lot of overrides for debhelpers.
80 get_built_using ?= $(filter-out (=),$(shell dpkg-query -f='$${source:Package} (=$${source:Version})' -W $1))
83 @if [ x"$(KVERS)" = x ] ; then \
84 echo 'No version in $(KSRC)/include/linux/version.h' >&2; \
87 sh debian/prep-modules $(KSRC)
88 cat debian/control.modules >> debian/control
89 dh $@ --with python3,dkms,systemd --buildsystem=meson
93 dh $@ --with python3,dkms,systemd --buildsystem=meson
95 override_dh_gencontrol:
97 # debian/files will not exist until dh_gencontrol has ran at least once,
98 # so we need to run gencontrol for libdpdk-dev after.
99 # The list of libraries and PMDs is everchanging, so generate the dependency
100 # list for libdpdk-dev to avoid having to maintain it manually.
101 # Same for the recommends list for dpdk, were we want the PMDs and the mempools.
102 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'`"
103 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'`"
104 ifneq (,$(findstring kernel_modules,$(DEB_BUILD_OPTIONS)))
105 dh_gencontrol -p dpdk-modules-$(KVERS) -- \
106 -v`cat debian/VERSION` \
107 -V'built:using:kernel=$(call get_built_using,linux-headers-$(KVERS))'
110 override_dh_auto_clean:
111 rm -rf debian/build debian/tmp debian/dpdk-modules-* \
112 debian/control.modules debian/VERSION
113 sed -i '/Package: dpdk-modules-/,/`tail -n1 debian/control.modules.in`/d' debian/control
114 rm -f debian/dpdk-igb-uio-dkms.dkms debian/dpdk-rte-kni-dkms.dkms
117 override_dh_auto_configure:
118 dh_auto_configure -- \
119 --includedir=include/dpdk \
120 -Dper_library_versions=false \
121 -Dinclude_subdir_arch=../$(DEB_HOST_MULTIARCH)/dpdk \
122 -Dmachine=$(RTE_MACHINE) \
123 -Dkernel_dir=$(KSRC) \
124 -Denable_kmods=$(DPDK_CONFIG_BUILD_KMOD)
126 override_dh_auto_build-indep:
127 ifeq (y,$(BUILD_DOCS))
129 # NINJA DOC INSTALL DOES NOT WORK - .buildinfo present, css missing
130 rm -f obj-$(DEB_HOST_MULTIARCH)/doc/guides/guides/.buildinfo
133 # ninja install doc does not work, will rebuild everything,
134 # only dpdk-doc as arch: all so just skip it
135 override_dh_auto_install-indep:
137 override_dh_auto_install-arch:
139 # have the DKMS build include the correct per-arch directory
140 sed "s/@@DEB_HOST_MULTIARCH@@/$(DEB_HOST_MULTIARCH)/g" debian/dpdk-igb-uio-dkms.dkms.in > debian/dpdk-igb-uio-dkms.dkms
141 sed "s/@@DEB_HOST_MULTIARCH@@/$(DEB_HOST_MULTIARCH)/g" debian/dpdk-rte-kni-dkms.dkms.in > debian/dpdk-rte-kni-dkms.dkms
142 # Package(s): libdpdk-<NAME><VER> (bare runtime libs and PMDs)
143 for lib in $$(ls -1 debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/*.so.*); do \
144 LN=$$(basename $${lib} | sed -e 's/\.so\.[0-9\.]*$$//' | tr '_' '-'); \
145 if echo $${LN} | grep -q ".*[0-9]$$"; then \
146 PKG=$${LN}-$(DPDK_ABI); \
148 PKG=$${LN}$(DPDK_ABI); \
150 LIBF="$$(basename $${lib})"; \
151 dh_install -p $${PKG} usr/lib/$(DEB_HOST_MULTIARCH)/$${LIBF}; \
152 if [ -f debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/*/*/$${LIBF} ]; then \
153 dh_install -p $${PKG} usr/lib/$(DEB_HOST_MULTIARCH)/*/*/$${LIBF}; \
156 # Package: dpdk-igb-uio-dkms
157 dh_install -p dpdk-igb-uio-dkms kernel/linux/igb_uio/* \
158 usr/src/dpdk-igb-uio-$(DEB_VERSION_UPSTREAM)
159 # Package: dpdk-rte-kni-dkms
160 dh_install -p dpdk-rte-kni-dkms kernel/linux/kni/* \
161 usr/src/dpdk-rte-kni-$(DEB_VERSION_UPSTREAM)
163 # Package: dpdk-modules-<kernel version>
164 dh_install -p dpdk-modules-$(KVERS) lib/modules
168 dh_dkms -V $(DEB_VERSION_UPSTREAM)
170 override_dh_installinit:
171 dh_installinit --no-start --no-stop-on-upgrade
173 override_dh_systemd_start:
174 dh_systemd_start --no-start --no-stop-on-upgrade
176 override_dh_auto_test:
179 # dh_python only looks in /usr/share/package_name but dpdk-doc installs in
180 # /usr/share/dpdk, so pass /usr to catch all
181 dh_python3 --shebang=/usr/bin/python3 /usr
184 dh_missing --fail-missing