#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# default is first version
DEFAULTPY=$(shell pyversions -v -d)
PYVERSIONS=$(shell pyversions -v -r)
ALLPY=$(PYVERSIONS:%=%-dbg) $(PYVERSIONS)

CMAKE_PARAMS=-DBUILD_SHARED_LIBS=ON -DINSTALL_GNAPPLET=OFF -DCMAKE_INSTALL_PREFIX=/usr
override_dh_strip:
	dh_strip --dbg-package=libgammu-dbg

override_dh_auto_configure-%:
	mkdir build-$*
	set -e -x; cd build-$* ; cmake .. $(CMAKE_PARAMS) -DBUILD_PYTHON=/usr/bin/python$*

override_dh_auto_configure: $(ALLPY:%=override_dh_auto_configure-%)

override_dh_auto_build-$(DEFAULTPY):
	dh_auto_build -- -C build-$(DEFAULTPY)
	make -C build-$(DEFAULTPY) pydoc

override_dh_auto_build-%:	
	dh_auto_build -- -C build-$*

override_dh_auto_build: $(ALLPY:%=override_dh_auto_build-%)

# We do all test just once
override_dh_auto_test-$(DEFAULTPY):
	set -e -x; cd build-$(DEFAULTPY) ; ctest -V

override_dh_auto_test-%:
	set -e -x; cd build-$* ; ctest -V -R py-

override_dh_auto_test: $(ALLPY:%=override_dh_auto_test-%)

override_dh_auto_install-%:
	dh_auto_install -- -C build-$*

override_dh_auto_install: $(ALLPY:%=override_dh_auto_install-%)

override_dh_auto_clean:
	rm -rf build-*

build: build-stamp

build-stamp:
	dh build
	touch $@

clean:
	dh $@

install: build install-stamp
install-stamp:
	dh install
	touch $@

# Build architecture-independent files here.
binary-indep: build install
	dh $@

# Build architecture-dependent files here.
binary-arch: build install
	dh $@

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install 
