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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@

# The upstream Makefiles do not look at CPPFLAGS. They should, and this should
# be unnecessary
override_dh_auto_build:
	CFLAGS="$(CFLAGS) $(CPPFLAGS)" dh_auto_build

override_dh_installman-arch:
	for langdir in debian/tmp/usr/share/man/*; do								\
		lang=`basename $$langdir`;									\
		test $$lang = "man1" || dh_installman --language $$lang debian/tmp/usr/share/man/$$lang/man1/*;	\
	done
	dh_installman --language C debian/tmp/usr/share/man/man1/* debian/install-notion-cfg.1

# I disable tests because these fail in multiple ways. The previous package
# didn't run the tests anyway
override_dh_auto_test:
	true

override_dh_installmenu-arch:
	dh_installmenu
	install -m644 debian/notion.menu-method.i18n \
		debian/notion/etc/menu-methods/notion-i18n

override_dh_install-indep:
	dh_install

	# install headers
	find . \( -name debian -o -name .pc -o -name config.h -o -name snprintf.h \) \
		-prune -o -name '*.h' -exec install -m644 -D {} \
		debian/notion-dev/usr/include/notion/{} \;

override_dh_fixperms-indep:
	dh_fixperms
	# this needs to be executable
	chmod a+x debian/notion-dev/usr/lib/notion/libextl/libextl-mkexports

override_dh_install-arch:
	dh_install
	# notionflux should go into /usr/bin. The upstream install should probably do this
	mv debian/notion/usr/lib/notion/notionflux debian/notion/usr/bin
