#!/usr/bin/make -f
# You must remove unused comment lines for the released package.
export DH_VERBOSE = 1
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

%:
	dh $@
# --with autoreconf

override_dh_auto_install:
	touch include_dev

	#modify also where include_dev flag is
	echo usr/include/actionswf/oadbgdatas.oh usr/include/actionswf/ > debian/libactionswf-dev.install
	echo usr/include/actionswf/oadbgdata.oh usr/include/actionswf/ >> debian/libactionswf-dev.install
	echo usr/include/actionswf/oadbgdatas.h usr/include/actionswf/ >> debian/libactionswf-dev.install
	echo usr/include/actionswf/oadbgdata.h usr/include/actionswf/ >> debian/libactionswf-dev.install
	#
	#yes otoc
	echo usr/include/actionswf/flags.oh usr/include/actionswf/ >> debian/libactionswf-dev.install
	echo usr/include/actionswf/flagss.oh usr/include/actionswf/ >> debian/libactionswf-dev.install
	#no otoc
	echo usr/include/actionswf/importf.oh usr/include/actionswf/ >> debian/libactionswf-dev.install
	echo usr/include/actionswf/import.oh usr/include/actionswf/ >> debian/libactionswf-dev.install
	#from otoc
	echo usr/include/actionswf/flags.h usr/include/actionswf/ >> debian/libactionswf-dev.install
	echo usr/include/actionswf/flagss.h usr/include/actionswf/ >> debian/libactionswf-dev.install
	#not from otoc
	echo usr/include/actionswf/actionswf.oh usr/include/actionswf/ >> debian/libactionswf-dev.install
	echo usr/include/actionswf/actionswf.h usr/include/actionswf/ >> debian/libactionswf-dev.install

	#same as ocompiler, when adding another one, make install are useless or another test
	echo usr/bin/oaalternative.sh usr/bin/ > debian/actionswf.install
	echo usr/bin/oaalternative.py usr/bin/ >> debian/actionswf.install
	echo usr/bin/oaalternativer.py usr/bin/ >> debian/actionswf.install
	echo usr/bin/oaas3 usr/bin/ >> debian/actionswf.install
	echo usr/lib/libactionswf.so usr/lib/ >> debian/actionswf.install
	echo usr/lib/liboadbgdata.so usr/lib/ >> debian/actionswf.install
	echo usr/lib/liboaas.so usr/lib/ >> debian/actionswf.install

	dh_auto_install -- prefix=/usr

	rm include_dev

ifeq ($(shell dpkg-architecture -qDEB_HOST_ARCH), amd64)
override_dh_gencontrol:
	dh_gencontrol
	echo -n "Depends: actionswf (= " >> debian/libactionswf-dev/DEBIAN/control
	echo -n `cat debian/changelog | head -1 | grep -Poe "[^(]*(?=\))"` >> debian/libactionswf-dev/DEBIAN/control
	echo ")" >> debian/libactionswf-dev/DEBIAN/control
endif
