libdpdk-dev: depend on libipsec-mb-dev
[deb_dpdk.git] / debian / rules
1 #!/usr/bin/make -f
2
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
7
8 DPDK_ABI := $(shell echo $(DEB_VERSION_UPSTREAM) | cut -d '-' -f1 | cut -d '.'  -f1-2 | cut -d '~' -f1)
9
10 ifeq (,$(findstring terse,$(DEB_BUILD_OPTIONS)))
11         export DH_VERBOSE=1
12         export DH_OPTIONS=-v
13 endif
14
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)))
19 endif
20 # default to minimal base, without setting this it would build
21 # -march=native which is a non portable invariant
22 RTE_MACHINE ?= "default"
23
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)))
27     MAKEFLAGS += -j$(PAR)
28 endif
29
30 ifneq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
31 BUILD_DOCS=n
32 else
33 ifneq (,$(findstring nodoc,$(DEB_BUILD_OPTIONS)))
34 BUILD_DOCS=n
35 # to stop dh_installdoc from running
36 export DEB_BUILD_PROFILES += nodoc
37 else
38 BUILD_DOCS=y
39 endif
40 endif
41
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
45     comma := ,
46     space :=
47     space +=
48     DPDK_CONFIG_OPTIONS ?= $(subst $(comma),$(space),$(patsubst dpdk_config_options=%,%,$(filter dpdk_config_options=%,$(DEB_BUILD_OPTIONS))))
49 endif
50
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
54 # sources instead.
55 ifeq (,$(findstring kernel_modules,$(DEB_BUILD_OPTIONS)))
56 DPDK_CONFIG_BUILD_KMOD=false
57 KSRC=""
58 else
59 ifneq (,$(filter ksrc=%,$(DEB_BUILD_OPTIONS)))
60     KSRC := $(patsubst ksrc=%,%,$(filter ksrc=%,$(DEB_BUILD_OPTIONS)))
61 else
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
63 endif
64
65 KVERS := $(shell perl debian/kernel-version $(KSRC))
66 export KVERS
67 export MODULE_CFLAGS=-fno-PIE
68
69 DPDK_CONFIG_BUILD_KMOD=true
70
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))
76
77 build:
78         @if [ x"$(KVERS)" = x ] ; then \
79             echo 'No version in $(KSRC)/include/linux/version.h' >&2; \
80             exit 1; \
81         fi
82         sh debian/prep-modules $(KSRC)
83         cat debian/control.modules >> debian/control
84         dh $@ --with python3,dkms,systemd --buildsystem=meson
85 endif
86
87 %:
88         dh $@ --with python3,dkms,systemd --buildsystem=meson
89
90 override_dh_gencontrol:
91         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))'
103 endif
104
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         dh_auto_clean
111
112 override_dh_auto_configure:
113         dh_auto_configure -- $(DPDK_CONFIG_OPTIONS) \
114                 --includedir=include/dpdk \
115                 --default-library=shared \
116                 -Dper_library_versions=false \
117                 -Dinclude_subdir_arch=../$(DEB_HOST_MULTIARCH)/dpdk \
118                 -Dmachine=$(RTE_MACHINE) \
119                 -Dkernel_dir=$(KSRC) \
120                 -Denable_kmods=$(DPDK_CONFIG_BUILD_KMOD)
121
122 override_dh_auto_build-indep:
123 ifeq (y,$(BUILD_DOCS))
124         dh_auto_build -- doc
125         # NINJA DOC INSTALL DOES NOT WORK - .buildinfo present, css missing
126         rm -f obj-$(DEB_HOST_MULTIARCH)/doc/guides/guides/.buildinfo
127 endif
128
129 # ninja install doc does not work, will rebuild everything,
130 # only dpdk-doc as arch: all so just skip it
131 override_dh_auto_install-indep:
132
133 override_dh_auto_install-arch:
134         dh_auto_install
135         # have the DKMS build include the correct per-arch directory
136         sed "s/@@DEB_HOST_MULTIARCH@@/$(DEB_HOST_MULTIARCH)/g" debian/dpdk-igb-uio-dkms.dkms.in > debian/dpdk-igb-uio-dkms.dkms
137         sed "s/@@DEB_HOST_MULTIARCH@@/$(DEB_HOST_MULTIARCH)/g" debian/dpdk-rte-kni-dkms.dkms.in > debian/dpdk-rte-kni-dkms.dkms
138         # Package(s): libdpdk-<NAME><VER> (bare runtime libs and PMDs)
139         for lib in $$(ls -1 debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/*.so.*); do \
140           LN=$$(basename $${lib} | sed -e 's/\.so\.[0-9\.]*$$//' | tr '_' '-'); \
141           if echo $${LN} | grep -q ".*[0-9]$$"; then \
142             PKG=$${LN}-$(DPDK_ABI); \
143           else \
144             PKG=$${LN}$(DPDK_ABI); \
145           fi; \
146           LIBF="$$(basename $${lib})"; \
147           dh_install -p $${PKG} usr/lib/$(DEB_HOST_MULTIARCH)/$${LIBF}; \
148           if [ -f debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/*/*/$${LIBF} ]; then \
149             dh_install -p $${PKG} usr/lib/$(DEB_HOST_MULTIARCH)/*/*/$${LIBF}; \
150           fi; \
151         done
152         # Package: dpdk-igb-uio-dkms
153         dh_install -p dpdk-igb-uio-dkms kernel/linux/igb_uio/* \
154                 usr/src/dpdk-igb-uio-$(DEB_VERSION_UPSTREAM)
155         # Package: dpdk-rte-kni-dkms
156         dh_install -p dpdk-rte-kni-dkms kernel/linux/kni/* \
157                 usr/src/dpdk-rte-kni-$(DEB_VERSION_UPSTREAM)
158 ifneq (,$(KVERS))
159         # Package: dpdk-modules-<kernel version>
160         dh_install -p dpdk-modules-$(KVERS) lib/modules
161 endif
162
163 override_dh_dkms:
164         dh_dkms -V $(DEB_VERSION_UPSTREAM)
165
166 override_dh_installinit:
167         dh_installinit --no-start --no-stop-on-upgrade
168
169 override_dh_systemd_start:
170         dh_systemd_start --no-start --no-stop-on-upgrade
171
172 override_dh_auto_test:
173
174 override_dh_python3:
175         # dh_python only looks in /usr/share/package_name but dpdk-doc installs in
176         # /usr/share/dpdk, so pass /usr to catch all
177         dh_python3 --shebang=/usr/bin/python3 /usr
178
179 override_dh_missing:
180         dh_missing --fail-missing