#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
#
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
#
# Modified to make a template file for a multi-binary package with separated
# build-arch and build-indep targets  by Bill Allombert 2001

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

# This has to be exported to make some magic below work.

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

DEB_CONFIGURE_NORMAL_ARGS := --build=x86_64-linux-gnu --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libexecdir=${prefix}/lib/ghostscript --with-ijs --with-jbig2dec --without-system-libtiff --without-x --disable-gtk --enable-dynamic --disable-compile-inits --with-drivers=ALL --with-fontpath=/var/lib/ghostscript/fonts:/usr/share/cups/fonts:/usr/share/ghostscript/fonts:/usr/local/lib/ghostscript/fonts:/usr/share/fonts --enable-openjpeg --enable-freetype --enable-cups --enable-dbus

DEB_MAKE_BUILD_TARGET = so gs.a $(gs_opts)
DEB_MAKE_INSTALL_TARGET = soinstall DESTDIR=$(DEB_DESTDIR) $(gs_opts)

abi = $(shell echo $(DEB_UPSTREAM_TARBALL_VERSION) | sed 's/[\~\+].*$$//')

clean::
	[ ! -f Makefile ] || $(MAKE) soclean
	[ ! -f Makefile ] || $(MAKE) distclean
	# These are somehow left...
	rm -rf sobin soobj gs.a

install/ghostscript::
	# Do not include the Ghostscript loader executable with GTK support
	rm -f $(DEB_DESTDIR)/usr/bin/gsx

	# Rename /usr/bin/gsc, to not conflict with gambc
	mv $(DEB_DESTDIR)/usr/bin/gsc $(DEB_DESTDIR)/usr/bin/gs
	install -m 755 debian/update-gsfontmap $(DEB_DESTDIR)/usr/bin
	install -D -m 644 debian/apport-hook.py $(CURDIR)/debian/ghostscript/usr/share/apport/package-hooks/source_ghostscript.py

install/libgs-dev::
	mkdir -p $(DEB_DESTDIR)/usr/lib/
	install -m 644 gs.a $(DEB_DESTDIR)/usr/lib/libgs.a

install/libgs9-common::
	rm -f $(DEB_DESTDIR)/usr/share/ghostscript/$(abi)/Resource/CIDFSubst/DroidSansFallback.ttf
