#!/bin/make
# Copyright 2005 Paul Martin <pm@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA


all: jargon.txt
.PHONY: all

jargsrc.tar.gz:
	wget http://www.catb.org/~esr/jargon/jargsrc.tar.gz

jargon.xml: jargsrc.tar.gz
	tar xvfz jargsrc.tar.gz jargon.xml

jargon-text.xsl: jargsrc.tar.gz
	tar xvfz jargsrc.tar.gz jargon-text.xsl
	patch -p0 <jargon-text.xsl.patch

jargon.xsl: jargsrc.tar.gz
	tar xvfz jargsrc.tar.gz jargon.xsl
	patch -p0 <jargon.xsl.patch

jargon-web.xml:
	# esr wrote xmlif, but jargon.xml uses the old syntax
	perl -pe 's/<\?(if|else|fi)\b/<?xmlif \1/' <jargon.xml | \
	xmlif condition='web' >jargon-web.xml

jargon-web.html: jargon-web.xml
	# Convert XML to HTML
	xmlto -m jargon-text.xsl html-nochunks jargon-web.xml
	# Change acute accents to apostrophes. iso_8859-15 shows them badly
	sed -i "s/\o264/'/" jargon-web.html

jargon.txt: jargon-web.html
	# Turn into plain text
	elinks -dump -dump-width 79 -no-numbering 1 -no-references 1 \
		jargon-web.html >jargon.txt

clean:
	rm -f jargon-web.xml
	rm -f jargon-web.html
	rm -f jargon.txt
	rm -f jargsrc.tar.gz
	rm -f *~

force-update: superclean jargon.xsl jargon-text.xsl jargon.xml jargsrc.tar.gz
.PHONY: force-update

superclean:
	rm -f jargon.xml
	rm -f jargon-text.xsl
	rm -f jargon.xsl
