#!/usr/bin/make -f

export NOCOLOR=1
PYVERSIONS := $(shell pyversions -s)
WAFFLAGS := --nocache --prefix=/usr

%:
	dh $@

override_dh_auto_clean:
	rm -rf _build_default_ $(PYVERSIONS:%=_build_%_)
	./waf distclean
	# Clean up after waf
	find wafadmin waftools -name '*.pyc' -delete
	rm -f waf-lightc

override_dh_auto_configure:
	./waf configure $(WAFFLAGS) \
		--with-perl-archdir=$(shell /usr/bin/perl -MConfig -le'print $$Config{vendorarch}') \
		--with-perl-binary=/usr/bin/perl \
		--with-ruby-archdir=$(shell ruby1.8 -rrbconfig -e'print Config::CONFIG["archdir"]') \
		--with-ruby-libdir=$(shell ruby1.8 -rrbconfig -e'print Config::CONFIG["rubylibdir"]') \
		--without-optionals=python \
		--with-default-output-plugin=pulse
	mv _build_ _build_default_
	for pyversion in $(PYVERSIONS); do \
		PYTHON=$${pyversion} ./waf configure $(WAFFLAGS) --without-xmms2d --with-optionals=python && \
		mv _build_ _build_$${pyversion}_; \
	done

override_dh_auto_build:
	for pyversion in default $(PYVERSIONS); do \
		mv _build_$${pyversion}_ _build_ && \
		./waf -v && \
		mv _build_ _build_$${pyversion}_; \
	done

override_dh_auto_install:
	for pyversion in default $(PYVERSIONS); do \
		mv _build_$${pyversion}_ _build_ && \
		./waf install --destdir=$(CURDIR)/debian/tmp --without-ldconfig && \
		mv _build_ _build_$${pyversion}_; \
	done
