#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@ --with python2

override_dh_auto_configure:
	dh_auto_configure -- --without-included-ltdl LDFLAGS="$(LDFLAGS) -Wl,--as-needed"

override_dh_auto_build:
	dh_auto_build

	# Build python-wit:
	dh_auto_build --sourcedirectory app/python/wit

	# Build dicoclient python modules:
	dh_auto_build --sourcedirectory dicoweb/dicoclient

	# Make those files executable before installing them:
	chmod +x debian/dicodconfig debian/dicodconfig.alias

override_dh_auto_install:
	dh_auto_install

	# Install python-wit:
	dh_auto_install --sourcedirectory app/python/wit -- --root=$(CURDIR)/debian/python-wit

	# Install dicoclient python modules:
	dh_auto_install --sourcedirectory dicoweb/dicoclient -- --root=$(CURDIR)/debian/python-dicoclient

override_dh_install:
	dh_install
	# Install dicoweb:
	dh_install -pdicoweb dicoweb usr/share -Xdicoclient -XINSTALL -Xtemplates -Xsettings-sample.py -Xstatic
	dh_install -pdicoweb dicoweb/templates etc/dicoweb
	dh_install -pdicoweb dicoweb/static etc/dicoweb
	dh_install -pdicoweb debian/apache2.conf etc/dicoweb
	[ ! -d debian/dicoweb/etc/dicoweb/ ] || install -m 0644 dicoweb/settings-sample.py $(CURDIR)/debian/dicoweb/etc/dicoweb/settings.py

override_dh_auto_clean:
	dh_auto_clean

	# Clean python-wit:
	dh_auto_clean --sourcedirectory app/python/wit

	# Clean dicoclient python modules:
	dh_auto_clean --sourcedirectory dicoweb/dicoclient
