2 # See debhelper(7) (uncomment to enable)
3 # output every command that modifies files on the build system.
7 VERSION := $(shell dpkg-parsechangelog | sed -nr '/^Version:/s/Version: (.*:)?(.*)-(.*)/\2/p')
9 # see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
10 include /usr/share/dpkg/default.mk
12 DEB_HOST_GNU_CPU := $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
14 # see FEATURE AREAS in dpkg-buildflags(1)
15 export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-pie
17 # see ENVIRONMENT in dpkg-buildflags(1)
18 # package maintainers to append CFLAGS
19 export DEB_CFLAGS_MAINT_APPEND = -fPIC
20 # package maintainers to append LDFLAGS
21 #export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
23 include /usr/share/dpkg/buildflags.mk
24 export EXTRA_CFLAGS=$(CFLAGS)
25 export EXTRA_CPPFLAGS=$(CPPFLAGS)
26 export HOST_EXTRA_CFLAGS=$(CFLAGS)
27 export HOST_EXTRA_CPPFLAGS=$(CPPFLAGS)
28 # need to be stripped as DPDK build system adds them and it would be -Wl,-Wl,opt
29 export EXTRA_LDFLAGS=$(shell echo $(LDFLAGS) | sed 's/-Wl,//g')
30 # HOST_CC build system does not add -Wl ...
31 export EXTRA_HOST_LDFLAGS=$(LDFLAGS)
33 export RTE_DEVEL_BUILD=n
35 # People rebuilding this package can overwrite DPDK_CONFIG, RTE_MACHINE and
36 # RTE_TARGET via DEB_BUILD_OPTIONS if they like
37 ifneq (,$(filter dpdk_config=%,$(DEB_BUILD_OPTIONS)))
38 DPDK_CONFIG ?= $(patsubst dpdk_config=%,%,$(filter dpdk_config=%,$(DEB_BUILD_OPTIONS)))
40 ifneq (,$(filter rte_machine=%,$(DEB_BUILD_OPTIONS)))
41 RTE_MACHINE ?= $(patsubst rte_machine=%,%,$(filter rte_machine=%,$(DEB_BUILD_OPTIONS)))
43 ifneq (,$(filter rte_target=%,$(DEB_BUILD_OPTIONS)))
44 RTE_TARGET ?= $(patsubst rte_target=%,%,$(filter rte_target=%,$(DEB_BUILD_OPTIONS)))
47 ifneq (,$(filter $(DEB_HOST_ARCH), arm64))
48 DPDK_CONFIG ?= "arm64-armv8a-linuxapp-gcc"
49 RTE_MACHINE ?= "armv8a"
50 RTE_TARGET ?= "arm64-armv8a-linuxapp-gcc"
52 ifneq (,$(filter $(DEB_HOST_ARCH), ppc64el))
53 DPDK_CONFIG ?= "ppc_64-power8-linuxapp-gcc"
54 RTE_MACHINE ?= "power8"
55 RTE_TARGET ?= "ppc_64-power8-linuxapp-gcc"
57 DPDK_CONFIG ?= "$(DEB_HOST_GNU_CPU)-native-linuxapp-gcc"
58 RTE_MACHINE ?= "default"
59 RTE_TARGET ?= "$(DEB_HOST_GNU_CPU)-default-linuxapp-gcc"
62 DPDK_STATIC_DIR = "debian/build/static-root"
63 DPDK_SHARED_DIR = "debian/build/shared-root"
65 # kernel_modules can be passed via DEB_BUILD_OPTIONS to enable building the
66 # optional binary kernel modules package. By default it will be built against
67 # the current kernel, or ksrc can be passed with a path to the target kernel
69 ifeq (,$(findstring kernel_modules,$(DEB_BUILD_OPTIONS)))
70 DPDK_CONFIG_BUILD_KMOD=n
73 ifneq (,$(filter ksrc=%,$(DEB_BUILD_OPTIONS)))
74 KSRC := $(patsubst ksrc=%,%,$(filter ksrc=%,$(DEB_BUILD_OPTIONS)))
76 KSRC := /lib/modules/$(shell uname -r)/build
79 KVERS := $(shell perl debian/kernel-version $(KSRC))
82 DPDK_CONFIG_BUILD_KMOD=y
84 # Since the binary module package is generated at build time depending on the
85 # local kernel version, we have to append the new package in d/control.
86 # We cannot use a separate control file since that wouldn't work with
87 # dpkg-genchanges, and also would require a lot of overrides for debhelpers.
88 get_built_using ?= $(filter-out (=),$(shell dpkg-query -f='$${source:Package} (=$${source:Version})' -W $1))
90 override_dh_gencontrol:
92 dh_gencontrol -p dpdk-modules-$(KVERS) -- \
93 -v`cat debian/VERSION` \
94 -V'built:using:kernel=$(call get_built_using,linux-headers-$(KVERS))'
97 @if [ x"$(KVERS)" = x ] ; then \
98 echo 'No version in $(KSRC)/include/linux/version.h' >&2; \
101 sh debian/prep-modules $(KSRC)
102 cat debian/control.modules >> debian/control
103 dh $@ --with python2,dkms
107 dh $@ --with python2,dkms
109 override_dh_auto_clean:
110 rm -rf debian/build debian/tmp debian/dpdk-modules-* \
111 debian/control.modules debian/VERSION
112 sed -i '/Package: dpdk-modules-/,/`tail -n1 debian/control.modules.in`/d' debian/control
113 test -L config/defconfig_$(DPDK_CONFIG) && rm -f config/defconfig_$(DPDK_CONFIG) || true
115 override_dh_auto_configure:
116 # Add support for a custom defconfig file in the debian directory.
117 ifneq (,$(filter dpdk_config=%,$(DEB_BUILD_OPTIONS)))
118 test -e config/defconfig_$(DPDK_CONFIG) || ln -fs ../debian/defconfig_$(DPDK_CONFIG) config/defconfig_$(DPDK_CONFIG)
120 # report dpkg-buildflags status to build log
121 dpkg-buildflags --status
122 echo EXTRA_CFLAGS $$EXTRA_CFLAGS
123 echo EXTRA_LDFLAGS: $$EXTRA_LDFLAGS
124 $(MAKE) V=$(DH_VERBOSE) O=$(DPDK_STATIC_DIR) T=$(DPDK_CONFIG) config
125 ifeq (,$(filter dpdk_config=%,$(DEB_BUILD_OPTIONS)))
126 sed -ri -e 's,(RTE_MACHINE=).*,\1$(RTE_MACHINE),' \
127 -e 's,(RTE_NEXT_ABI=).*,\1n,' \
128 -e 's,(CONFIG_RTE_EAL_IGB_UIO=).*,\1$(DPDK_CONFIG_BUILD_KMOD),' \
129 -e 's,(CONFIG_RTE_KNI_KMOD=).*,\1$(DPDK_CONFIG_BUILD_KMOD),' \
130 -e 's,(LIBRTE_PMD_PCAP=).*,\1y,' \
131 -e 's,(LIBRTE_PMD_XENVIRT=).*,\1y,' \
132 $(DPDK_STATIC_DIR)/.config
133 # xen not available on ppc64el
134 ifneq (,$(filter $(DEB_HOST_ARCH), ppc64el))
135 sed -ri -e 's,(LIBRTE_PMD_XENVIRT=).*,\1n,' $(DPDK_STATIC_DIR)/.config
140 override_dh_auto_build-indep:
141 $(MAKE) V=$(DH_VERBOSE) O=$(DPDK_STATIC_DIR) doc-api-html doc-guides-html \
144 override_dh_auto_install-indep:
146 # All files based on the install-doc rule (includes examples)
147 $(MAKE) V=$(DH_VERBOSE) O=$(DPDK_STATIC_DIR) prefix=/usr \
148 DESTDIR=debian/dpdk-doc install-doc
150 override_dh_auto_build-arch:
151 $(MAKE) V=$(DH_VERBOSE) O=$(DPDK_STATIC_DIR) RTE_KERNELDIR=$(KSRC) build
152 # Unfortunately the decision about having static or shared libraries is
153 # made for the whole build, which then produces only .a or .so files
155 # And the target layout for target selection has no field for the
157 # Right now I hack this by doing a second build which only differs in
158 # the selection of shared libs.
159 # Shared libs should be default, so the previous static build is only
160 # used to get static libraries.
161 cp -a $(DPDK_STATIC_DIR) $(DPDK_SHARED_DIR)
162 sed -ri 's,(RTE_BUILD_SHARED_LIB=).*,\1y,' \
163 $(DPDK_SHARED_DIR)/.config
164 $(MAKE) V=$(DH_VERBOSE) O=$(DPDK_SHARED_DIR) RTE_KERNELDIR=$(KSRC) build
166 override_dh_auto_install-arch: LIBDIR=usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
167 override_dh_auto_install-arch:
168 # Package: dpdk (runtime)
169 $(MAKE) V=$(DH_VERBOSE) O=$(DPDK_STATIC_DIR) prefix=/usr \
170 DESTDIR=debian/dpdk install-runtime
171 $(MAKE) V=$(DH_VERBOSE) O=$(DPDK_SHARED_DIR) prefix=/usr \
172 DESTDIR=debian/dpdk install-runtime
173 mkdir -p debian/dpdk/etc/dpdk
174 cp debian/dpdk.interfaces debian/dpdk/etc/dpdk/interfaces
175 rm debian/dpdk/usr/sbin/dpdk-devbind
176 mkdir -p debian/dpdk/sbin
177 ln -s /usr/share/dpdk/tools/dpdk-devbind.py \
178 debian/dpdk/sbin/dpdk-devbind
179 # Package: dpdk-dev (build environment)
180 $(MAKE) V=$(DH_VERBOSE) O=$(DPDK_SHARED_DIR) prefix=/usr \
181 DESTDIR=debian/dpdk-dev install-sdk
182 cp $(DPDK_SHARED_DIR)/.config debian/dpdk-dev/usr/share/dpdk/config
183 sed -e 's/SDK_TARGET/$(RTE_TARGET)/' debian/dpdk-sdk-env.sh.in > \
184 debian/dpdk-dev/usr/share/dpdk/dpdk-sdk-env.sh
185 # Package: libdpdk-dev (bare headers, static devel libs and linker
187 mkdir -p debian/libdpdk-dev/$(LIBDIR)
189 mv debian/dpdk/usr/lib/libdpdk.so debian/libdpdk-dev/$(LIBDIR)/
191 mkdir -p debian/libdpdk-dev/usr/include
192 mv debian/dpdk-dev/usr/include/dpdk debian/libdpdk-dev/usr/include/
193 # all static libs are in the dev package
194 mv debian/dpdk/usr/lib/lib*.a debian/libdpdk-dev/$(LIBDIR)/
195 # symlinks to last .so's are in the non versioned libdpdk-dev as well
196 # this allows multiple libdpdk-<NAME><VER> at different VER concurrently
197 # libdpdk-dev depends on all sublibs so symlinks are never broken
198 mv debian/dpdk/usr/lib/*.so debian/libdpdk-dev/$(LIBDIR)/
199 # Package(s): libdpdk-<NAME><VER> (bare runtime libs)
200 for lib in $$(ls -1 debian/dpdk/usr/lib/*.so.*); do \
201 BN=$$(basename $${lib}); \
202 VER=$$(echo $${BN} | sed -e 's/^.*\.so\.//'); \
203 LN=$$(echo $${BN} | sed -e 's/\.so\.[0-9]*$$//' | tr '_' '-'); \
204 if echo $${LN} | grep -q ".*[0-9]$$"; then \
205 PKG=$${LN}-$${VER}; \
209 echo "moving $${lib} for library $${PKG}"; \
210 mkdir -p debian/$${PKG}/$(LIBDIR); \
211 mv $${lib} debian/$${PKG}/$(LIBDIR); \
214 mkdir -p debian/libdpdk-dev/$(LIBDIR)/pkgconfig
215 LIBS=$$(sed -e 's/GROUP ( \(.*\) )/\1/' -e 's/lib/-l/g' -e 's/\.so//g' \
216 $(CURDIR)/debian/libdpdk-dev/$(LIBDIR)/libdpdk.so); \
217 sed -e "s/@DPDK_LIBS@/$${LIBS}/" -e "s/@VERSION@/$(VERSION)/" \
218 debian/libdpdk.pc.in > debian/libdpdk-dev/$(LIBDIR)/pkgconfig/libdpdk.pc
219 # Package: dpdk-igb-uio-dkms
220 mkdir -p debian/dpdk-igb-uio-dkms/usr/src/dpdk-igb-uio-$(VERSION)
221 cp lib/librte_eal/linuxapp/igb_uio/* \
222 debian/dpdk-igb-uio-dkms/usr/src/dpdk-igb-uio-$(VERSION)
223 # Package: dpdk-rte-kni-dkms
224 mkdir -p debian/dpdk-rte-kni-dkms/usr/src/dpdk-rte-kni-$(VERSION)
225 cp -a lib/librte_eal/linuxapp/kni/* \
226 debian/dpdk-rte-kni-dkms/usr/src/dpdk-rte-kni-$(VERSION)
228 # Package: dpdk-modules-<kernel version>
229 mkdir -p debian/dpdk-modules-$(KVERS)/lib/modules/$(KVERS)/kernel/drivers/net
230 cp -a debian/build/shared-root/kmod/* \
231 debian/dpdk-modules-$(KVERS)/lib/modules/$(KVERS)/kernel/drivers/net
235 dh_dkms -V $(VERSION)
237 override_dh_installinit:
238 dh_installinit --no-start --no-restart-on-upgrade
240 override_dh_systemd_start:
241 dh_systemd_start --no-start --no-restart-on-upgrade
243 override_dh_auto_test: