#!/usr/bin/make -f
# -*- makefile -*-

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

%:
	dh $@ --sourcedirectory=Apache --with=apache2

override_dh_install:
	dh_install -XChanges
	# Remove embedded copy of qrcode
	rm -rf $(CURDIR)/debian/ocsinventory-reports/usr/share/ocsinventory-reports/libraries/qrcode
	# Remove embedded copy of php-cas
	rm -rf $(CURDIR)/debian/ocsinventory-reports/usr/share/ocsinventory-reports/backend/require/lib/phpcas/*
	# Remove a few empty dirs generated by dh_install:
	# Don't remove plugins/main_sections/conf/old_conf/
	rmdir $(CURDIR)/debian/ocsinventory-reports/usr/share/ocsinventory-reports/plugins/main_sections/ms_ipdiscover/require ||:
	rmdir $(CURDIR)/debian/ocsinventory-reports/usr/share/ocsinventory-reports/plugins/snmp_detail/img ||:
	rmdir $(CURDIR)/debian/ocsinventory-reports/usr/share/ocsinventory-reports/plugins/snmp_detail/require ||:

override_dh_installchangelogs:
	dh_installchangelogs -p ocsinventory-reports ocsreports/Changes
	dh_installchangelogs -p ocsinventory-server Apache/Changes

override_dh_fixperms:
	dh_fixperms
	# fix permissions for scripts and images
	find $(CURDIR)/debian/ocsinventory-reports/usr/share/ocsinventory-reports -type f -exec chmod a-x {} \;
	# fix the permissions for the .pl scripts
	find $(CURDIR)/debian/ocsinventory-server/usr/share/ocsinventory-server -name '*.pl' -exec chmod +x {} \;
	chmod -x $(CURDIR)/debian/ocsinventory-server/usr/share/ocsinventory-server/binutils/ocs-errors
