#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk

ifeq ($(DEB_BUILD_ARCH),m68k)
	CFLAGS=-g -O1 $(DEB_OPT_FLAG)
endif

# Workaround for compiler/binutils bug on mips and mipsel, see #519006.
ifneq (,$(filter mips mipsel, $(DEB_HOST_ARCH)))
	CFLAGS = -Wall -g0 $(DEB_OPT_FLAG)
endif

DEB_CONFIGURE_EXTRA_FLAGS := --enable-grace-home=/usr/share/grace \
	--with-editor="xterm -e sensible-editor" \
	--with-helpviewer="sensible-browser %s" \
	--with-f77=gfortran \
	--disable-pdfdrv

DEB_DESTDIR = $(CURDIR)/debian/tmp/
DEB_DH_INSTALL_SOURCEDIR = $(DEB_DESTDIR)

# this prevents cdbs from creating a symlink to debian/patches
DEB_QUILT_PATCHDIR_LINK=
export QUILT_PATCHES=debian/patches

binary-post-install/grace::
	# 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_gconf -pgrace

get-orig-source::
	-uscan --upstream-version 0 --rename
