+# LD_LIBRARY_PATH=pwd/debian/tmp/usr/lib dh_shlibdeps -papt
+# dpkg: /home/jgg/work/apt2/debian/tmp/usr/lib/libapt-pkg.so.2.9 not found.
+
+# For the deb builder, you can run 'debian/rules cvs-build', which does all
+# steps nescessary to produce a proper source tarball with the CVS/ removed.
+# It builds in debian/cvs-build/apt-<VER>/, and places files in
+# debian/cvs-build/. Optionally, you can run 'debian/rules cvs-mkul' to
+# create ../upload-<VER>, with all the files needed to be uploaded placed
+# in it.
+
+# See below
+include build/environment.mak
+
+# Default rule
+build:
+
+DEB_BUILD_PROG:=debuild -us -uc
+APT_DEBVER=$(shell dpkg-parsechangelog |sed -n -e '/^Version:/s/^Version: //p')
+APT_CONFVER=$(shell sed -n -e 's/^AC_DEFINE_UNQUOTED(VERSION,"\(.*\)")/\1/p' configure.in)
+
+# Determine the build directory to use
+BASE=.
+ifdef BUILD
+BUILD_POSSIBLE := $(BUILD) $(BASE)/$(BUILD)
+else
+BUILD_POSSIBLE := $(BASE) $(BASE)/build-$(shell uname -m) $(BASE)/build
+endif
+BUILDX:= $(foreach i,$(BUILD_POSSIBLE),$(wildcard $(i)/environment.mak*))
+BUILDX:= $(patsubst %/,%,$(firstword $(dir $(BUILDX))))
+override BLD := $(BUILDX)
+
+ifeq ($(words $(BLD)),0)
+override BLD := ./build
+endif
+
+# Rebuild configure.in to have the correct version from the change log
+ifneq ($(APT_DEBVER),$(APT_CONFVER))
+.PHONY: configure.in
+configure.in:
+ sed -e 's/$(APT_CONFVER)/$(APT_DEBVER)/' $@ > $@.$$$$;mv $@.$$$$ $@
+else
+configure.in:
+endif
+
+# APT Programs in apt-utils
+APT_UTILS=ftparchive sortpkgs