#!/usr/bin/make -f

MODULE := ipl
DEBDIR := debian/icingaweb2-module-$(MODULE)

%:
	dh ${@}

override_dh_auto_install:
	mkdir -p $(DEBDIR)/usr/share/icingaweb2/modules/$(MODULE)
	find . -maxdepth 1 -mindepth 1 -and -not -name debian -and -not -name ".git*" -exec cp -a {} $(DEBDIR)/usr/share/icingaweb2/modules/$(MODULE) \;

	# remove useless files
	rm -rf $(DEBDIR)/usr/share/icingaweb2/modules/$(MODULE)/bin
	rm -f $(DEBDIR)/usr/share/icingaweb2/modules/$(MODULE)/README.md
	find $(DEBDIR)/usr/share/icingaweb2/modules/$(MODULE) -name LICENSE -exec rm -f {} \;

	# enable module
	mkdir -p $(DEBDIR)/etc/icingweb2/enabledModules
	ln -s /usr/share/icingaweb2/modules/$(MODULE) $(DEBDIR)/etc/icingweb2/enabledModules/$(MODULE)
