#!/usr/bin/make -f
# rules
#
# Robert Jordens <jordens@debian.org>
#
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.

include /usr/share/cdbs/1/class/langcore.mk
DEB_UPSTREAM_VERSION := $(shell echo $(DEB_VERSION) | sed 's/-[^-]*//')

include /usr/share/cdbs/1/rules/debhelper.mk

DEB_INSTALL_CHANGELOGS_ALL =
DEB_INSTALL_DOCS_ALL =

common-binary-post-install-arch::
	dh_buildinfo

# This is a cheap hack to make cdbs use all the tarballs' configure
post-patches:: debian/stamp-autotools-maintregen-arch
debian/stamp-autotools-maintregen-arch:
	-@set -e -v; confs=sw*/autogen.sh;\
	for conf in $$confs; do \
	cd `dirname $$conf`; sh `basename $$conf`; cd $(CURDIR);\
	done && touch debian/stamp-autotools-maintregen-arch

common-configure-arch:: debian/stamp-configure-dirs
debian/stamp-configure-dirs:
	-@set -e -v; confs=sw*/configure;\
	for conf in $$confs; do \
	cd `dirname $$conf`;\
	./`basename $$conf` $(DEB_CONFIGURE_NORMAL_ARGS) --disable-maintainer-mode $(cdbs_configure_flags) $(DEB_CONFIGURE_EXTRA_FLAGS) $(DEB_CONFIGURE_USER_FLAGS);\
	cd $(CURDIR);\
	done && touch debian/stamp-configure-dirs

common-build-arch:: debian/stamp-build-dirs
debian/stamp-build-dirs:
	-@set -e -v; confs=sw*/Makefile;\
	for conf in $$confs; do \
	cd `dirname $$conf`;\
	make $(DEB_MAKE_BUILD_TARGET);\
	cd $(CURDIR);\
	done && touch debian/stamp-build-dirs

common-install-arch:: debian/stamp-install-dirs
debian/stamp-install-dirs:
	-@set -e -v; confs=sw*/Makefile;\
	for conf in $$confs; do \
	cd `dirname $$conf`;\
	make $(DEB_MAKE_INSTALL_TARGET);\
	cd $(CURDIR);\
	done && touch debian/stamp-install-dirs

.PHONY: create-orig-tarball
create-orig-tarball:
	mkdir -p tmp-orig-tree/$(DEB_SOURCE_PACKAGE)-$(DEB_UPSTREAM_VERSION).orig
	tar -C tmp-orig-tree -cjvf \
		../$(DEB_SOURCE_PACKAGE)_$(DEB_UPSTREAM_VERSION).orig.tar.bz2 \
		$(DEB_SOURCE_PACKAGE)-$(DEB_UPSTREAM_VERSION).orig

clean::
	-@set -e -v; confs=sw*/Makefile;\
	for conf in $$confs; do \
	cd `dirname $$conf`;\
	make maintainer-clean-generic distclean;\
	cd $(CURDIR);\
	done
	rm -f sw29/config.h.in
	-rm debian/stamp-configure-dirs debian/stamp-build-dirs \
	debian/stamp-install-dirs debian/stamp-autotools-maintregen-arch 
