changelog: mention debian/rules: clean doc files
[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         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
117         dh_auto_clean
118
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)
128
129 override_dh_auto_build-indep:
130 ifeq (y,$(BUILD_DOCS))
131         dh_auto_build -- doc
132         # NINJA DOC INSTALL DOES NOT WORK - .buildinfo present, css missing
133         rm -f obj-$(DEB_HOST_MULTIARCH)/doc/guides/guides/.buildinfo
134 endif
135
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:
139
140 override_dh_auto_install-arch:
141         dh_auto_install
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); \
150           else \
151             PKG=$${LN}$(DPDK_ABI); \
152           fi; \
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}; \
157           fi; \
158         done
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)
165 ifneq (,$(KVERS))
166         # Package: dpdk-modules-<kernel version>
167         dh_install -p dpdk-modules-$(KVERS) lib/modules
168 endif
169
170 override_dh_dkms:
171         dh_dkms -V $(DEB_VERSION_UPSTREAM)
172
173 override_dh_installinit:
174         dh_installinit --no-start --no-stop-on-upgrade
175
176 override_dh_systemd_start:
177         dh_systemd_start --no-start --no-stop-on-upgrade
178
179 override_dh_auto_test:
180
181 override_dh_python3:
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
185
186 override_dh_missing:
187         dh_missing --fail-missing