#!/usr/bin/make -f

export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
export DEB_BUILD_MAINT_OPTIONS  = hardening=+bindnow

%:
	dh $@ --with autotools_dev

override_dh_auto_configure:
	dh_auto_configure -- \
	--enable-grace-home=/usr/share/grace \
	--with-editor="xterm -e sensible-editor" \
	--with-helpviewer="sensible-browser %s" \
	--with-f77=gfortran \
	--with-bundled-t1lib \
	--disable-pdfdrv \
	--without-bundled-xbae

# "make check" is more of a series of demos, requires X
override_dh_auto_test:

override_dh_auto_install:
	dh_auto_install --destdir debian/tmp

override_dh_install:
	# install the icons
	themedir=$(CURDIR)/debian/grace/usr/share/icons/hicolor;\
	for x in 16 22 24 32; do \
		install -D -m 644 -o root -g root debian/icons/grace$${x}.png \
			$${themedir}/$${x}x$${x}/apps/grace.png; \
	done
	install -m 755 -o root -g root debian/update-grace-fonts \
		$(CURDIR)/debian/grace/usr/sbin/update-grace-fonts
	dh_install

# Optional component that will not fail if gconf is missing, so a hard
# Depends: is not desirable.
override_dh_gconf:

# Upstream Makefile needs configure run even for clean target.  Override it,
# and ignore errors if they occur -- they come from the configure-check, not
# from the missing Makefile that is the common case.
override_dh_auto_clean:
	$(MAKE) --keep-going --ignore distclean
