-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-# This has to be exported to make some magic below work.
-export DH_OPTIONS
-
-# prefix of the target package name
-PACKAGE=openvswitch-datapath-module
-# modifieable for experiments or debugging m-a
-MA_DIR ?= /usr/share/modass
-# load generic variable handling
--include $(MA_DIR)/include/generic.make
-# load default rules
--include $(MA_DIR)/include/common-rules.make
-
-DATAPATH_CONFIGURE_OPTS =
-
-# Official build number. Leave set to 0 if not an official build.
-BUILD_NUMBER = 0
+PACKAGE=openvswitch
+pdkms=openvswitch-datapath-dkms
+DEB_UPSTREAM_VERSION=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([0-9]:)*([^-]+).*,\2,p')
+srcfiles := $(filter-out debian, $(wildcard * .[^.]*))
+
+ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
+PARALLEL = -j$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
+else
+PARALLEL =
+endif
+MAKEFLAGS += $(PARALLEL)
+
+CFLAGS += -g
+ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
+CFLAGS += -O0
+else
+CFLAGS += -O2
+endif
+
+# Old versions of dpkg-buildflags do not understand --export=configure.
+# When dpkg-buildflags does not understand an option, it prints its full
+# --help output on stdout, so we have to avoid that here.
+buildflags := $(shell if dpkg-buildflags --export=configure >/dev/null 2>&1; \
+ then dpkg-buildflags --export=configure; fi)