#!/usr/bin/make -f
export DH_VERBOSE=1

PERLARCHLIB := $(shell perl -MConfig -e 'print substr($$Config{vendorarch}, 1);')
PYTHONARCHLIB := $(shell python3 -c "import sysconfig; print(sysconfig.get_path('platlib', vars={'platbase':'usr'}) + '/*')")

BUILDOPTS= --with-cluster --without-forester --with-kinwalker --disable-silent-rules

ifeq ($(shell lsb_release --short --codename),wheezy)
BUILDOPTS+= --disable-lto --without-rnalocmin
endif

ifeq ($(shell lsb_release --short --codename),precise)
BUILDOPTS+= --disable-lto --without-rnalocmin
endif

%:
	dh $@ --parallel --with python3

override_dh_auto_configure:
	dh_auto_configure --  $(BUILDOPTS) INSTALLDIRS=vendor
	sed -e 's,@PERLARCHLIB@,$(PERLARCHLIB),g' debian/perl-rna.install.in > debian/perl-rna.install
	sed -e 's,@PYTHONARCHLIB@,$(PYTHONARCHLIB),g' debian/python3-rna.install.in > debian/python3-rna.install

override_dh_strip:
	dh_strip --exclude=libRNA.a

override_dh_auto_clean:
	dh_auto_clean
	rm -rf build .*egg-info

override_dh_clean:
	rm -f debian/perl-rna.install
	dh_clean
 
