# Special Makefile for `recode' tables.			-*- Makefile -*-
# Copyright  1997, 1998, 1999 Free Software Foundation, Inc.
# Franois Pinard <pinard@iro.umontreal.ca>, 1997.

# 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, 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.

#essai:
#	$(PERL) $(srcdir)/tables.pl -n \
#	  $(srcdir)/$(MNEMONICS_DS) $(srcdir)/$(ISO10646_DEF)

include Makefile

## Some files in the `recode' distribution are mechanically derived
## from data files while is available from the net using FTP or HTTP.
## These original files are not distributed.  From the *distribution*
## standpoint, one might consider those derived files just as sources,
## forgetting there is some hidden magic behind them.  But the magic
## is revealed here! :-).  The distribution already contains all
## non-trivial derivation tools I made.  For completeness, this
## special Makefile holds the accompanying derivation recipes.

## For activating the included recipes, it suffices to link this
## `Makemore' file as `GNUmakefile' in the `doc/' directory of your
## *build* hierarchy.  You need GNU make, GNU wget, Perl and Internet
## connectivity for all this to work.  However, be warned that if
## external files changed, you may be hit.  I am interested in hearing
## about such problems (maybe at `recode-bugs@iro.umontreal.ca'), but
## I do not want to commit myself at maintaining the derivation stuff
## at the same level as for the the remainder of `recode'.

MNEMONICS_DS = mnemonic,ds
CHSET = chset32a
ISO10646_DEF = $(CHSET)/iso10646.def
CHARSETS_DEF = $(CHSET)/charsets.def
MNEMONICS_DS = keld-email/mnemonics,ds
CHARSETS_DEF = keld-email/charsets.def
NOMS_CARACS = noms_juc_19981216.txt

MAPURL = ftp://ftp.unicode.org/MAPPINGS
PERL = perl -w
SURF = netscape

# Merely add our things to standard `all' goal.
all: $(srcdir)/charset.texi $(srcdir)/fr-charset.texi \
$(top_srcdir)/src/charname.h $(top_srcdir)/src/fr-charname.h \
$(top_srcdir)/src/rfc1345.h

# The next rule, when written:
#charset.texi pool.c tables.c: ...
# may launch many parallel occurrences of the action.  This is bad.
# Any idea, someone?  For now, just list one of them.

$(srcdir)/charset.texi: tables.pl $(MNEMONICS_DS) $(CHARSETS_DEF)
	$(PERL) $(srcdir)/tables.pl -p -t \
	  $(srcdir)/$(MNEMONICS_DS) $(srcdir)/$(CHARSETS_DEF)
	test $(srcdir) = . || mv charset.texi $@
	mv strip-pool.c $(top_srcdir)/src/strip-pool.c
	mv strip-data.c $(top_srcdir)/src/strip-data.c

$(top_srcdir)/src/charname.h: tables.pl $(MNEMONICS_DS) rfc1345.txt
	$(PERL) $(srcdir)/tables.pl -n \
	  $(srcdir)/$(MNEMONICS_DS) $(srcdir)/rfc1345.txt
	mv charname.h $@

$(top_srcdir)/src/rfc1345.h: tables.pl $(MNEMONICS_DS)
	$(PERL) $(srcdir)/tables.pl -m $(srcdir)/$(MNEMONICS_DS)
	mv rfc1345.h $@

$(srcdir)/fr-charset.texi: tables.pl $(CHARSETS_DEF)
	$(PERL) $(srcdir)/tables.pl -F -t $(srcdir)/$(CHARSETS_DEF)
	test $(srcdir) = . || mv fr-charset.texi $@

$(top_srcdir)/src/fr-charname.h: tables.pl $(NOMS_CARACS)
	$(PERL) $(srcdir)/tables.pl -F -n $(srcdir)/$(NOMS_CARACS)
	mv fr-charname.h $@

# -----------------------------------#
# External files built into recode.  #
# -----------------------------------#

$(srcdir)/rfc1345.txt:
	wget ftp://nic.ddn.mil/rfc/rfc1345.txt
	test $(srcdir) = . || mv rfc1345.txt $@

$(srcdir)/$(CHSET)/charsets.def: $(srcdir)/$(CHSET)

$(srcdir)/$(CHSET):
	mkdir $@-tmp
	wget ftp://dkuug.dk/pub/$(CHSET).tar
	tar xfC $(CHSET).tar $@-tmp
	rm $(CHSET).tar
	mv $@-tmp $@

# Also look in `ftp://dkuug.dk/i18n/WG15-collection/charmaps/iso10646'.
$(srcdir)/mnemonic,ds:
	wget ftp://dkuug.dk/i18n/WG15-collection/repertoiremaps/mnemonic,ds
	test $(srcdir) = . || mv mnemonic,ds $@

# -------------------------------------------------#
# Useful external files, but unbuilt into recode.  #
# -------------------------------------------------#

$(srcdir)/cp1250.txt:
	wget $(MAPURL)/VENDORS/MICSFT/WINDOWS/CP1250.TXT
	mv CP1250.TXT $@

$(srcdir)/cp1251.txt:
	wget $(MAPURL)/VENDORS/MICSFT/WINDOWS/CP1251.TXT
	mv CP1251.TXT $@

$(srcdir)/cp1252.txt:
	wget $(MAPURL)/VENDORS/MICSFT/WINDOWS/CP1252.TXT
	mv CP1252.TXT $@

# Index at `http://www.dkuug.dk/jtc1/sc22/wg20/docs/projects.html.en'.
i18n.txt:
	wget http://www.dkuug.dk/jtc1/sc22/wg20/docs/i18n.txt
i18nrep.txt:
	wget http://www.dkuug.dk/jtc1/sc22/wg20/docs/i18nrep.txt

# Various files.
iso2375reg.txt:
	wget ftp://dkuug.dk/i18n/iso2375reg.txt

# Online documentation.
# Index at `http://osiris.dkuug.dk/jtc1/sc2/wg3'.
character-sets:
	$(SURF) http://www.ewos.be/tg-cs/gtop.htm
