+# Since the binary module package is generated at build time depending on the
+# local kernel version, we have to append the new package in d/control.
+# We cannot use a separate control file since that wouldn't work with
+# dpkg-genchanges, and also would require a lot of overrides for debhelpers.
+get_built_using ?= $(filter-out (=),$(shell dpkg-query -f='$${source:Package} (=$${source:Version})' -W $1))
+
+override_dh_gencontrol:
+ dh_gencontrol
+ dh_gencontrol -p dpdk-modules-$(KVERS) -- \
+ -v`cat debian/VERSION` \
+ -V'built:using:kernel=$(call get_built_using,linux-headers-$(KVERS))'
+
+build:
+ @if [ x"$(KVERS)" = x ] ; then \
+ echo 'No version in $(KSRC)/include/linux/version.h' >&2; \
+ exit 1; \
+ fi
+ sh debian/prep-modules $(KSRC)
+ cat debian/control.modules >> debian/control
+ dh $@ --with python2,dkms
+endif
+
+%:
+ dh $@ --with python2,dkms
+
+override_dh_auto_clean:
+ rm -rf debian/build debian/tmp debian/dpdk-modules-* \
+ debian/control.modules debian/VERSION
+ sed -i '/Package: dpdk-modules-/,/`tail -n1 debian/control.modules.in`/d' debian/control
+
+override_dh_auto_configure:
+ # report dpkg-buildflags status to build log
+ dpkg-buildflags --status
+ echo EXTRA_CFLAGS $$EXTRA_CFLAGS
+ echo EXTRA_LDFLAGS: $$EXTRA_LDFLAGS
+ $(MAKE) V=$(DH_VERBOSE) O=$(DPDK_STATIC_DIR) T=$(DPDK_CONFIG) config