#!/usr/bin/make -f

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


# CMake doesn't use CPPFLAGS, pass them to CFLAGS/CXXFLAGS instead (bug #662833)
export DEB_BUILD_MAINT_OPTIONS   := hardening=+all
export DEB_CFLAGS_MAINT_APPEND   := -pipe -Wall $(shell dpkg-buildflags --get CPPFLAGS)
export DEB_CXXFLAGS_MAINT_APPEND := -pipe -Wall $(shell dpkg-buildflags --get CPPFLAGS)
export DEB_LDFLAGS_MAINT_APPEND  := -Wl,-Bsymbolic -Wl,--as-needed


AQSIS_CHANGELOG = release-notes/1.8/summary-1.8.0.txt


%:
	dh $@ --buildsystem=cmake

override_dh_auto_configure:
	dh_auto_configure -- \
		-DSYSCONFDIR=/etc/aqsis \
		-DAQSIS_USE_EXTERNAL_TINYXML:BOOL=ON \
		-DAQSIS_USE_PDIFF:BOOL=OFF \
		-DAQSIS_USE_RPATH:BOOL=OFF

override_dh_auto_install:
	dh_auto_install

#	Remove houdini script, not interesting for Debian (it's intended as
#	plugin for 3rd party proprietary software, to use Aqsis as renderer),
#	and also has poor licensing terms (not well explained, not for all
#	files, etc).
	rm -frv debian/tmp/usr/share/aqsis/plugins/houdini

#	Remove empty directory (valid until/unless there are more plugins than
#	houdini), otherwise dh_install fails with --list-missing
	rmdir debian/tmp/usr/share/aqsis/plugins

#	Add exec permissions to several example scripts
	find debian/tmp/usr/ \( -name \*.sh -o -name \*.py \) -exec chmod a+x {} \;

override_dh_install:
	dh_install -Xeqsl.desktop -Xpiqsl.desktop

override_dh_installchangelogs:
	dh_installchangelogs $(AQSIS_CHANGELOG)
