-release:=$(shell dpkg-parsechangelog | sed -n 's/^Source: wxwindows//p')
-
-# Packages to build:
-package_wxbase_lib=libwxbase$(release)
-package_wxbase_dev=libwxbase$(release)-dev
-package_wxbase_dbg=libwxbase$(release)-dbg
-package_gtk_lib=libwxgtk$(release)
-package_gtk_dev=libwxgtk$(release)-dev
-package_gtk_dbg=libwxgtk$(release)-dbg
-package_gtk_py=libwxgtk$(release)-python
-package_gtk_contrib=libwxgtk$(release)-contrib
-package_gtk_contrib_dev=libwxgtk$(release)-contrib-dev
-package_headers=wxwin$(release)-headers
-package_doc=wxwin$(release)-doc
-package_examples=wxwin$(release)-examples
-
-# Build directories:
-objdir_wxbase_shared=objs_wxbase_sh
-objdir_wxbase_static=objs_wxbase_st
-objdir_wxbase_debug=objs_wxbase_d
-objdir_gtk_shared=objs_gtk_sh
-objdir_gtk_static=objs_gtk_st
-objdir_gtk_debug=objs_gtk_d
-objdir_doc_cruft=objs_doc_con
-objdir_doc=docs/wxWindows-manual.html
-objdir_examples=docs/examples
-objdirs=$(objdir_wxbase_shared) $(objdir_wxbase_static) $(objdir_wxbase_debug) \
- $(objdir_gtk_shared) $(objdir_gtk_static) $(objdir_gtk_debug) \
- $(objdir_doc) $(objdir_examples)
-
-build_stamps=build-wxbase-shared-stamp build-wxbase-static-stamp \
- build-wxbase-debug-stamp build-gtk-shared-stamp \
- build-gtk-static-stamp build-gtk-debug-stamp \
- build-contrib-shared-stamp build-contrib-static-stamp \
- build-gtk-python-stamp build-examples-stamp build-doc-stamp
-
-install_all=install-wxbase-lib install-wxbase-dev install-wxbase-dbg \
- install-gtk-lib install-gtk-dev install-gtk-dbg \
- install-gtk-contrib install-gtk-contrib-dev install-gtk-py \
- install-headers install-doc install-examples
-
-wxconfig:=$(shell pwd)/$(objdir_gtk_shared)/wx-config \
- --prefix=$(shell pwd) \
- --exec-prefix=$(shell pwd)/$(objdir_gtk_shared)
-
-
-# The Rules:
-
-debian/control: debian/control.in
- sed -e 's/=V/$(release)/g' < debian/control.in > debian/control
-
-debian/wxwin-doc.doc-base: debian/wxwin-doc.doc-base.in
- sed -e 's/=V/$(release)/g' < debian/wxwin-doc.doc-base.in > debian/wxwin-doc.doc-base
-
-control-files-stamp: debian/control debian/wxwin-doc.doc-base
- dh_testdir
- @for f in dirs docs postinst; do \
- echo "generating control file $(package_wxbase_lib).$$f"; \
- cp debian/libwxbase.$$f debian/$(package_wxbase_lib).$$f; \
- done;
- @for f in dirs docs files links postinst prerm; do \
- echo "generating control file $(package_wxbase_dev).$$f"; \
- cp debian/libwxbase-dev.$$f debian/$(package_wxbase_dev).$$f; \
- done;
- @for f in dirs docs links postinst prerm; do \
- echo "generating control file $(package_wxbase_dbg).$$f"; \
- cp debian/libwxbase-dbg.$$f debian/$(package_wxbase_dbg).$$f; \
- done;
- @for f in dirs docs postinst; do \
- echo "generating control file $(package_gtk_lib).$$f"; \
- cp debian/libwxgtk.$$f debian/$(package_gtk_lib).$$f; \
+ifdef CONCURRENCY_LEVEL
+ # A user who knows what they want, that's like gold...
+ # respect their precious opinion of how much blue smoke to use.
+ JOB_COUNT := $(CONCURRENCY_LEVEL)
+else ifdef DISTCC_HOSTS
+ # Otherwise, if they have a cluster, try to put it to good use.
+ JOB_COUNT := $(shell set $${DISTCC_HOSTS} > /dev/null 2>&1 ; echo $$\#)
+endif
+
+ifdef JOB_COUNT
+ FAST_MAKE = $(MAKE) -j $(JOB_COUNT)
+else
+ FAST_MAKE = $(MAKE)
+endif
+
+
+# Find the python version(s) to build for
+PYVERS := $(shell pyversions -vr || pyversions -vs)
+ifeq ($(strip $(PYVERS)),)
+ PYVERS := $(shell python -c 'import sys; print sys.version[:3]')
+ NO_PYCENTRAL = 1
+ PY_BUILD_DEPS = python$(PYVERS), python$(PYVERS)-dbg, python$(PYVERS)-dev
+else
+ DEB_PYTHON_SYSTEM=pycentral
+ PY_BUILD_DEPS = python-all, python-all-dbg, python-all-dev, python-central
+endif
+
+# If another source package is to supply the common binary packages
+# for a particular Debian release, then define this variable to indicate
+# the $(release) that is expected to provide it. Do not define it at
+# all if this is to be the default (or only) wx source package for the
+# target release.
+#
+#DEBIAN_WX_DEFAULT_VERSION = 2.8
+
+
+# This will extract a flavour out of the name of the source directory
+# and flavour the packages and binaries with it. 'Official' builds
+# should use a source dir of the form wxwidgets$RELEASE-$VERSION.
+# Flavoured builds may use wxwidgets$RELEASE-$FLAVOUR-$VERSION, where
+# any descriptive alphanumeric name will do for FLAVOUR. This will
+# allow a custom build to be installed alongside the mainline ones
+# without conflict. You will also need to make a corresponding
+# changelog entry for your flavour source package using:
+# wxwidget$RELEASE-$FLAVOUR ($VERSION) to satify dpkg-source and
+# to correctly set the release below.
+DEBIAN_WXFLAVOUR := $(shell pwd | sed -e 's@.*/wxwidgets[0-9.]\+-\?\(.*\)-[0-9.]\+-\?.*@\1@')
+
+
+wx_major_version_number := $(shell sed -n 's/^wx_major_version_number=//p' configure.in)
+wx_minor_version_number := $(shell sed -n 's/^wx_minor_version_number=//p' configure.in)
+wx_release_number := $(shell sed -n 's/^wx_release_number=//p' configure.in)
+wx_subrelease_number := $(shell sed -n 's/^wx_subrelease_number=//p' configure.in)
+
+##release := $(shell dpkg-parsechangelog | sed -n 's/^Source: wxwidgets//p' | sed 's/-ansi//')
+release := $(wx_major_version_number).$(wx_minor_version_number)
+
+# This is broken completely now by bakefiles changes. Until we add
+# some hocus pocus to the main tree, to export these values from it
+# again, we approximate its behaviour (fairly precisely fwiw) to
+# specify $soversion below. Re-automate if incompatible changes
+# result in it actually changing.
+#soversion := $(shell grep '^WX_CURRENT=' configure.in | sed 's/WX_CURRENT=\([0-9]\+\).*/\1/')
+soversion := 0
+sorelease := $(release:%-$(DEBIAN_WXFLAVOUR)=%)-$(soversion)$(addprefix -,$(DEBIAN_WXFLAVOUR))
+
+# In some places we use the full version number, including the micro version,
+# for the development releases (which can be incompatible for the same major
+# and minor version) but just the major.minor for the stable releases (which
+# are supposed to be compatible), this variable contains the appropriate value
+ifeq ($(shell echo `echo $(release) | sed 's/.\+\.\(.\+\)/\1/'`%2 | bc),1)
+ # development release
+ compatible_release := $(release).$(wx_release_number)
+else
+ compatible_release := $(release)
+endif
+
+# Base value for alternative priorities.
+alt_prio := $(subst .,,$(release))
+
+cross_host := i586-mingw32msvc
+cross_build := $(shell ./config.guess)
+
+config_cache = ../config_deb.cache
+config_cache_cross = ../config_deb_cross.cache
+
+
+# build options
+COMMON_CONFIGURE_OPTIONS = \
+ --prefix=/usr \
+ --cache-file=$(config_cache) \
+ --with-flavour=$(DEBIAN_WXFLAVOUR) \
+ --with-zlib=sys \
+ --disable-reserved_virtual \
+
+BASE_CONFIGURE_OPTIONS = $(COMMON_CONFIGURE_OPTIONS) \
+ --disable-gui \
+
+GTK_CONFIGURE_OPTIONS = $(COMMON_CONFIGURE_OPTIONS) \
+ --with-gtk \
+ --enable-mediactrl \
+ --enable-sound \
+ --with-sdl \
+ --enable-display \
+ --enable-geometry \
+ --enable-graphics_ctx \
+ --with-libjpeg=sys \
+ --with-libpng=sys \
+ --with-libtiff=sys \
+
+
+pytoolkit := gtk2
+PY_WX_CONFIG_OPTIONS = --version=$(release) --toolkit=$(pytoolkit) --static=no
+
+WX_UNICODE := 1
+WX_OPENGL := 1
+
+ifeq ($(WX_UNICODE),1)
+ COMMON_CONFIGURE_OPTIONS += --enable-unicode
+ PY_WX_CONFIG_OPTIONS += --unicode
+ PY_UNICODE = UNICODE=1
+ wxpydir := wx-$(compatible_release)-$(pytoolkit)-unicode
+
+ # for compatibility with the existing 2.6 packages, we don't use "u" in
+ # the Unicode (default) package names
+ unicode_suffix :=
+else
+ # but we do need to use something for non-Unicode packages to distinguish
+ # them
+ unicode_suffix := -ansi
+ PY_UNICODE = UNICODE=0
+ wxpydir := wx-$(compatible_release)-$(pytoolkit)
+endif
+
+ifeq ($(WX_OPENGL),1)
+ GTK_CONFIGURE_OPTIONS += --with-opengl
+else
+ GTK_CONFIGURE_OPTIONS += --without-opengl
+endif
+
+#---------------------------------------------------------------------------
+# Packages to build
+
+package_wxbase_lib := libwxbase$(sorelease)$(unicode_suffix)
+package_wxbase_dev := libwxbase$(release)$(unicode_suffix)-dev
+package_wxbase_dbg := libwxbase$(release)$(unicode_suffix)-dbg
+
+package_gtk_lib := libwxgtk$(sorelease)$(unicode_suffix)
+package_gtk_dev := libwxgtk$(release)$(unicode_suffix)-dev
+package_gtk_dbg := libwxgtk$(release)$(unicode_suffix)-dbg
+
+package_headers := wx$(release)-headers
+package_i18n := wx$(release)-i18n
+package_doc := wx$(release)-doc
+package_examples := wx$(release)-examples
+package_common = wx-common
+
+package_gtk_py_lib := python-wxgtk$(release)$(unicode_suffix)
+package_gtk_py_ver = python-wxversion
+package_gtk_py_tools = python-wxtools
+package_gtk_py_addons = python-wxaddons
+package_gtk_dbg_py := python-wxgtk$(release)$(unicode_suffix)-dbg
+
+
+# The packages listed here are common to all wx versions, and may be provided
+# by another source package if more than one is in the release simultaneously.
+common_packages := $(package_common) $(package_gtk_py_ver) $(package_gtk_py_tools) $(package_gtk_py_addons)
+
+
+package_msw_dev := libwxmsw$(release)$(unicode_suffix)-dev
+package_msw_dbg := libwxmsw$(release)$(unicode_suffix)-dbg
+package_headers_msw := wx$(release)-headers-msw
+
+# The packages listed here will not be built by default.
+extra_packages := $(package_msw_dev) $(package_msw_dbg) $(package_headers_msw)
+
+ifdef DEBIAN_WX_DEFAULT_VERSION
+ extra_packages += $(common_packages)
+endif
+
+
+#---------------------------------------------------------------------------
+# Build directories
+
+objdir_wxbase_shared = objs_wxbase_sh
+objdir_wxbase_debug = objs_wxbase_d
+objdir_gtk_shared = objs_gtk_sh
+objdir_gtk_debug = objs_gtk_d
+objdir_gtk_install = objs_gtk_install
+objdir_doc_cruft = objs_doc_con
+objdir_doc = docs/wx-manual.html
+objdir_examples = docs/examples
+objdir_i18n = locale
+
+objdir_msw_shared = objs_msw_sh
+objdir_msw_static = objs_msw_st
+objdir_msw_dbg = objs_msw_d
+objdir_msw_install = objs_msw_install
+
+objdirs := $(objdir_wxbase_shared) $(objdir_wxbase_debug) \
+ $(objdir_gtk_shared) $(objdir_gtk_debug) $(objdir_gtk_install) \
+ $(objdir_doc_cruft) $(objdir_doc) $(objdir_examples) \
+ $(objdir_msw_shared) $(objdir_msw_static) $(objdir_msw_dbg) \
+ $(objdir_msw_install)
+
+#---------------------------------------------------------------------------
+# Build stamps:
+
+# note that the i18n package is actually arch indep (once built)
+# but must be built (and installed) during the arch any phase as
+# it's pulled out of the wxGTK shared lib package.
+#
+# similarly some of the wxpython packages are arch indep too, but
+# all files for it are installed during the arch any phase.
+
+
+build_arch_stamps = build-wxbase-shared-stamp build-wxbase-debug-stamp \
+ build-gtk-shared-stamp build-gtk-shared-contrib-stamp \
+ build-gtk-debug-stamp build-gtk-debug-contrib-stamp \
+ build-i18n-stamp build-gtk-py-stamp build-gtk-dbg-py-stamp
+
+build_indep_stamps = build-examples-stamp build-doc-stamp
+
+build_cross_stamps = build-msw-shared-stamp build-msw-static-stamp build-msw-dbg-stamp
+
+build_stamps_native := $(build_arch_stamps) $(build_indep_stamps)
+
+build_stamps := $(build_stamps_native) $(build_cross_stamps)
+
+
+#---------------------------------------------------------------------------
+# Install targets:
+install_all_arch = install-wxbase-lib install-wxbase-dev install-wxbase-dbg \
+ install-gtk-lib install-gtk-dev install-gtk-dbg \
+ install-headers install-i18n install-gtk-py install-gtk-dbg-py
+
+ifndef DEBIAN_WX_DEFAULT_VERSION
+ install_all_arch += install-common
+endif
+
+install_all_indep = install-examples install-doc
+
+install_all_cross = install-msw-dev install-msw-dbg install-headers-msw
+
+install_all_native := $(install_all_arch) $(install_all_indep)
+
+install_all := $(install_all_native) $(install_all_cross)
+
+
+
+#---------------------------------------------------------------------------
+# Setup Rules:
+
+debian/control: debian/control.in debian/rules
+ sed -e 's/=V/$(release)/g; '\
+' s/=SOV/$(sorelease)/g; '\
+' s/=U/$(unicode_suffix)/g; '\
+' s/=PY_BUILD_DEPS/$(PY_BUILD_DEPS)/g '\
+ < debian/control.in > debian/control
+
+control-files-stamp: debian/control
+ dh_testdir
+ @for f in postinst prerm; do \
+ echo "generating control file $(package_wxbase_dev).$$f"; \
+ sed -e 's/=V/$(release)/g; '\
+' s/=PRIO/$(alt_prio)/g' \
+ < debian/libwxbase-dev.$$f \
+ > debian/$(package_wxbase_dev).$$f; \