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

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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export PYTHON_SKIP_SWAGGERDOC=1

%:
	dh $@

override_dh_auto_configure:
	./autogen.sh
	dh_auto_configure

override_dh_auto_build:
	# Make sure we rebuild the minified files from the upstream tarball.
	$(MAKE) -C httpdocs/js clean
	$(MAKE) -C httpdocs/js minify UGLIFY_VERSION=3
	dh_auto_build
	mkdir -p debian/generated-code/
	coffee -c -o debian/generated-code/ debian/missing-sources/gauge.coffee
	$(MAKE) -C doc/src release

override_dh_auto_install:

override_dh_installdocs:
	dh_installdocs -pntopng
	dh_installdocs -pntopng-data
	dh_installdocs -pntopng-doc --doc-main-package=ntopng --exclude=fonts

override_dh_install-indep:
	dh_install --indep \
	    --exclude=.source-map.js \
	    --exclude=EtherOUI.txt \
	    --exclude=Makefile \
	    --exclude=README.gauge \
	    --exclude=font-awesome \
	    --exclude=redis.lua \
	    --exclude=scripts/lua/modules/i18n \
	    --exclude=scripts/lua/modules/resty
	rm -fr $(CURDIR)/debian/ntopng-data/usr/share/ntopng/httpdocs/bootstrap
	find $(CURDIR)/debian/ntopng-data/usr/share -type f -exec chmod a-x {} \;
	rm -fr $(CURDIR)/debian/ntopng-data/usr/share/ntopng/httpdocs/ssl
	chmod +x $(CURDIR)/debian/ntopng-data/usr/share/ntopng/httpdocs/misc/ntopng-add-user.sh
	rm -f $(CURDIR)/debian/ntopng-data/usr/share/ntopng/httpdocs/geoip/README
	chmod +x $(CURDIR)/debian/ntopng-data/usr/share/ntopng/httpdocs/misc/ntopng-utils-manage-config

override_dh_install-arch:
	dh_install --arch

override_dh_auto_clean:
	dh_auto_clean
	rm -fr debian/generated-code/


.PHONY: override_dh_auto_install override_dh_strip override_dh_install-indep
.PHONY: override_dh_install-arch get-orig-source
