+
+# 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.
+#
+# for etch:
+#DEBIAN_WX_DEFAULT_VERSION = 2.6
+
+
+# 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))
+
+pytoolkit := gtk2
+pydir := usr/lib/$(python_ver)/site-packages
+wxpydir := $(pydir)/wx-$(compatible_release)-$(pytoolkit)
+
+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 \
+ --with-gnomeprint \
+ --enable-mediactrl \
+ --enable-sound \
+ --with-sdl \
+ --enable-display \
+ --enable-geometry \
+ --enable-graphics_ctx \
+ --with-libjpeg=sys \
+ --with-libpng=sys \
+ --with-libtiff=sys \
+
+
+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 := $(pydir)/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
+endif
+
+ifeq ($(WX_OPENGL),1)
+ GTK_CONFIGURE_OPTIONS += --with-opengl
+else
+ GTK_CONFIGURE_OPTIONS += --without-opengl
+endif
+
+# Packages to build:
+package_wxbase_lib := libwxbase$(release)$(unicode_suffix)
+package_wxbase_dev := libwxbase$(release)$(unicode_suffix)-dev
+package_wxbase_dbg := libwxbase$(release)$(unicode_suffix)-dbg
+
+package_gtk_lib := libwxgtk$(release)$(unicode_suffix)
+package_gtk_dev := libwxgtk$(release)$(unicode_suffix)-dev
+package_gtk_dbg := libwxgtk$(release)$(unicode_suffix)-dbg
+
+
+
+
+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_headers := wx$(release)-headers
+package_i18n := wx$(release)-i18n
+package_doc := wx$(release)-doc
+package_examples := wx$(release)-examples
+package_common = wx-common
+
+# 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_gtk_dbg_py := python-wxgtk$(release)$(unicode_suffix)-dbg
+
+
+
+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_gtk_dbg_py) \
+ $(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)
+
+# 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 stamps:
+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_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
+
+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)
+
+
+# wxPython uses this to build in-tree
+wxconfig := $(shell pwd)/$(objdir_gtk_shared)/wx-config --no_rpath
+wxconfig-dbg := $(shell pwd)/$(objdir_gtk_debug)/wx-config --no_rpath
+
+# and this after it is installed.
+py_wxconfig := wx-config $(PY_WX_CONFIG_OPTIONS) --debug=no
+pyd_wxconfig := wx-config $(PY_WX_CONFIG_OPTIONS) --debug
+
+
+#contrib_libs := $(subst CVS,,$(notdir $(wildcard contrib/include/wx/*)))
+
+
+# The Rules:
+
+debian/python-version:
+ echo python_ver := python$(shell python -c "import sys;print sys.version[:3]") > $@
+
+debian/control: $(addprefix debian/,control.in python-version)
+ sed -e 's/=V/$(release)/g;s/=SOV/$(release)/g;s/=PY/$(python_ver)/g;s/=U/$(unicode_suffix)/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; \
+ done;
+ @for f in postinst prerm; do \
+ echo "generating control file $(package_wxbase_dbg).$$f"; \
+ sed -e 's/=V/$(release)/g; '\
+' s/=PRIO/$(alt_prio)/g' \
+ < debian/libwxbase-dbg.$$f \
+ > debian/$(package_wxbase_dbg).$$f; \
+ done;
+ @for f in postinst prerm; do \
+ echo "generating control file $(package_gtk_dev).$$f"; \
+ sed -e 's/=V/$(release)/g; '\
+' s/=PRIO/$(alt_prio)/g' \
+ < debian/libwxgtk-dev.$$f \
+ > debian/$(package_gtk_dev).$$f; \
+ done;
+ @for f in postinst prerm; do \
+ echo "generating control file $(package_gtk_dbg).$$f"; \
+ sed -e 's/=V/$(release)/g; '\
+' s/=PRIO/$(alt_prio)/g' \
+ < debian/libwxgtk-dbg.$$f \
+ > debian/$(package_gtk_dbg).$$f; \
+ done;
+ @for f in docs postinst prerm; do \
+ echo "generating control file $(package_gtk_py_lib).$$f"; \
+ sed -e 's/=PY/$(python_ver)/g; '\
+' s|=WXPYDIR|$(wxpydir)|g; '\
+' s/=V/$(release)/g; '\
+' s/=PRIO/$(alt_prio)/g' \
+ < debian/python-wxgtk.$$f \
+ > debian/$(package_gtk_py_lib).$$f; \
+ done;
+ @for f in postinst prerm; do \
+ echo "generating control file $(package_gtk_dbg_py).$$f"; \
+ sed -e 's/=PY/$(python_ver)/g; '\
+' s/=V/$(release)/g; '\
+' s/=PRIO/$(alt_prio)/g' \
+ < debian/python-wxgtk-dbg.$$f \
+ > debian/$(package_gtk_dbg_py).$$f; \
+ done;
+ @echo "generating control file $(package_gtk_dbg_py).docs";
+ @cp debian/python-wxgtk.docs debian/$(package_gtk_dbg_py).docs;
+ @for f in docs doc-base; do \
+ echo "generating control file $(package_doc).$$f"; \
+ sed -e 's/=V/$(release)/g' < debian/wx-doc.$$f \
+ > debian/$(package_doc).$$f; \
+ done;
+ @for f in examples; do \
+ echo "generating control file $(package_examples).$$f"; \
+ cp debian/wx-examples.$$f debian/$(package_examples).$$f; \
+ done;
+ @for f in postinst prerm; do \
+ echo "generating control file $(package_msw_dev).$$f"; \
+ sed -e 's/=V/$(release)/g; '\
+' s/=H/$(cross_host)/g; '\
+' s/=PRIO/$(alt_prio)/g' \
+ < debian/libwxmsw-dev.$$f \
+ > debian/$(package_msw_dev).$$f; \
+ done;
+ @for f in postinst prerm; do \
+ echo "generating control file $(package_msw_dbg).$$f"; \
+ sed -e 's/=V/$(release)/g; '\
+' s/=H/$(cross_host)/g; '\
+' s/=PRIO/$(alt_prio)/g' \
+ < debian/libwxmsw-dbg.$$f \
+ > debian/$(package_msw_dbg).$$f; \
+ done;
+# @echo "generating control file $(package_common).menu"; \
+# sed -e 's/=V/$(release)/g' < debian/wx-common.menu \
+# > debian/$(package_common).menu;
+ @echo "generating control file lintian-override"; \
+ sed -e 's/=V/$(release)/g; '\
+' s/=SOV/$(release)/g' \
+ < debian/lintian-override.in \
+ > debian/lintian-override; \
+ touch $@
+
+build_arch: control-files-stamp $(build_arch_stamps)
+build_all: control-files-stamp $(build_stamps_native)
+
+# Really we should probably do nothing here until we know which
+# binary target is being called, but alpha builds were exploding
+# (compiler segfaults) in random places when building under fakeroot
+# from the binary-arch target. Build all -arch files here then, and
+# let the -indep stuff fend for itself later.
+
+build: build_arch
+
+
+# The wx2.6 build system makes us run around in circles to get a separate
+# libwxbase. We need to configure it here in order to get the correct
+# config files to use it alone, but there is no point building it as the
+# wxgtk build is going to do that again anyway. We'll move the relevant
+# files out when that is done.
+
+configure-wxbase-shared-stamp:
+ dh_testdir
+ mkdir -p $(objdir_wxbase_shared)
+ cd $(objdir_wxbase_shared) \
+ && ../configure $(BASE_CONFIGURE_OPTIONS)
+ touch $@
+
+build-wxbase-shared-stamp: configure-wxbase-shared-stamp
+ dh_testdir
+ # Nothing to build here, move along...
+ #cd $(objdir_wxbase_shared) && $(FAST_MAKE)
+ touch $@
+
+configure-wxbase-debug-stamp: