#!/usr/bin/make -f
# -*- makefile -*-
# debian/rules for the Praat

# Author: Rafael Laboissiere <rafael@debian.org>
# Licence: GPL

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/patchsys-quilt.mk

DEBDIR = $(CURDIR)/debian
INSTDIR = $(DEBDIR)/praat

DB2MAN = $(DEBDIR)/manpage.xsl
XP = xsltproc -''-nonet

PIXDIR = usr/share/pixmaps
BINDIR = usr/bin
APPDIR = usr/share/applications

SUBSTCMD = sed 's:@BINDIR@:$(BINDIR):g;s:@PIXDIR@:$(PIXDIR):g;	\
		s:@APPDIR@:$(APPDIR):g'

get-upstream-changelog:
	# Get upstream changelog (in HTML format) and replace some characters
	# for correct display in the final ASCII file
	( cd debian ;							    \
	  wget -N http://www.fon.hum.uva.nl/praat/manual/What_s_new_.html ; \
	  perl -pi -e "s/&#712;/'/g;s/&#716;/,/g;" What_s_new_.html )

praat.1: $(DEBDIR)/praat.dbk $(DEBDIR)/manpage.xsl
	$(XP) $(DB2MAN) $<

build/praat:: praat.1
	for i in dirs install menu ; do 				\
		$(SUBSTCMD) < $(DEBDIR)/$$i.in > $(DEBDIR)/praat.$$i ;	\
	done
	# Build against GTK instead of lesstif2
	# ln -fs makefiles/makefile.defs.linux.dynamic makefile.defs
	ln -fs makefiles/makefile.defs.linux.gtk makefile.defs
	$(MAKE)

clean::
	rm -f `find . -name \*.a -o -name \*.o` praat makefile.defs praat.1 \
	  $(DEBDIR)/praat.dirs $(DEBDIR)/praat.install $(DEBDIR)/praat.menu

install/praat::
	dh_installchangelogs debian/What_s_new_.html
	rm -f $(INSTDIR)/usr/share/doc/praat/changelog.html
