# GNU Makefile for the SECS table (Simple European Character Set)
# Markus Kuhn <mkuhn@acm.org>

# Command to get source packages over the network

#RETRIEVE=@echo Please get over the Internet the file ; echo 
RETRIEVE=netget

# character set files loadable from various Internet servers

REMOTE_CHARFILES = UnicodeData-Latest.txt \
8859-1.TXT 8859-2.TXT 8859-3.TXT 8859-4.TXT 8859-5.TXT 8859-6.TXT \
8859-7.TXT 8859-8.TXT 8859-9.TXT 8859-14.TXT 8859-15.TXT \
CP1250.TXT CP1251.TXT CP1252.TXT CP1253.TXT CP1254.TXT CP1255.TXT \
CP1256.TXT CP1257.TXT CP1258.TXT \
CP437.TXT CP737.TXT CP775.TXT CP850.TXT CP852.TXT CP855.TXT CP857.TXT \
CP860.TXT CP861.TXT CP862.TXT CP863.TXT CP864.TXT CP865.TXT CP866.TXT \
CP869.TXT CP874.TXT \
CYRILLIC.TXT GREEK.TXT ICELAND.TXT LATIN2.TXT ROMAN.TXT TURKISH.TXT \
CP037.TXT CP1026.TXT CP500.TXT CP875.TXT \
NEXTSTEP.TXT IBMGRAPH.TXT \
SAMI CP437 CP850

# character set files original in this package

LOCAL_CHARFILES = MES-1 MES-2 MES-3 \
MES-4 MES-1.980709 MES-2.980709 MES-3.980709 \
MES EES EES-COLLECTIONS MATH MATH-SMALL MIT VAUX VAUX-9 AUX WGL4 IPA-MINI \
8859-10.TXT 8859-11.TXT 8859-13.TXT IR-143.TXT IR-155.TXT IR-158.TXT \
IR-182.TXT \
WIDTH-[AFHNWX] GREEK-BAD GREEK-POLYTONIC OBSOLETE

# repertoires to be constructed

SETTARGETS=SECS-B SECS-I SECS-G SECS-C SECS-O SECS-W SECS-P SECS-S SECS-X11 SECS-MES

TARGETS=$(SETTARGETS) $(SETTARGETS:%=%.gif) secs-all.html

# files to be packed into the secs.zip distribution package

PACKAGE_FILES = README uniset gen-wgl4 Makefile rationale $(TARGETS) \
$(LOCAL_CHARFILES) secs-template.html vsecs-template.html secs-all-template.html end.html $(REMOTE_CHARFILES)

all: $(TARGETS)

$(SETTARGETS:%=%.gif): %.gif: %
	./uniset +$* giftable16 ; mv table.gif $*.gif

gifs: $(SETTARGETS:%=%.gif)
	for i in $(SETTARGETS:%=%.gif) ; do (xv $$i &) ; done

install: secs.tar.gz secs.zip secs-all.html # secs.html vsecs.html
	perl -i -p -e 's/^<!--BASE /<BASE /;' secs-all.html # secs.html vsecs.html
	mv secs.tar.gz secs.zip secs-all.html $(HOME)/.www/ucs/

clean:
	rm -f $(TARGETS) *~ W.log secs.zip *.gif core *.o

allclean: clean
	rm -f $(REMOTE_CHARFILES)

SECS-B: uniset 8859-1.TXT 8859-2.TXT 8859-3.TXT 8859-4.TXT 8859-9.TXT 8859-10.TXT 8859-14.TXT 8859-15.TXT \
	AUX-B CP1252.TXT
	echo "# Simple European Character Set - Basic Latin" >$@
	./uniset +8859-1.TXT +8859-2.TXT +8859-3.TXT +8859-4.TXT +8859-9.TXT \
	+8859-10.TXT +8859-14.TXT +8859-15.TXT +CP1252.TXT +AUX-B compact nr >>$@

SECS-I: uniset SECS-B CP437 CP850 IBMGRAPH.TXT
	echo "# Simple European Character Set - IBM PC compatibility extension" >$@
	./uniset +CP437 +CP850 +IBMGRAPH.TXT -SECS-B compact nr >>$@

SECS-G: uniset SECS-B 8859-7.TXT AUX-G
	echo "# Simple European Character Set - Basic Greek extension" >$@
	./uniset +8859-7.TXT +AUX-G -SECS-B compact nr >>$@

SECS-C: uniset SECS-B 8859-5.TXT AUX-C
	echo "# Simple European Character Set - Cyrillic extension" >$@
	./uniset +8859-5.TXT +AUX-C -SECS-B compact nr >>$@

SECS-O: uniset SECS-B SAMI AUX-O
	echo "# Simple European Character Set - old or rarely used Latin extension" >$@
	./uniset +SAMI +AUX-O -SECS-B compact nr >>$@

SECS-W: uniset WGL4 ROMAN.TXT SECS-B SECS-I SECS-G SECS-C SECS-O
	echo "# Simple European Character Set - Windows/Mac compatibility extensions" >$@
	./uniset +WGL4 +ROMAN.TXT -SECS-B -SECS-I -SECS-G -SECS-C -SECS-O clean compact nr >>$@

SECS-P: uniset
	echo "# Simple European Character Set - Polytonic Greek extension" >$@
	./uniset +1F00-1FFF clean compact nr >>$@

SECS-S: uniset MATH AUX-S SECS-B SECS-G
	echo "# Simple European Character Set - Symbol extension" >$@
	./uniset +MATH +AUX-S -SECS-B -SECS-G compact nr >>$@

SECS-X11: SECS-B SECS-I SECS-G SECS-C SECS-S SECS-W SECS-O
	echo "# Target Repertoire for low-res X11 fonts" >$@
	./uniset +SECS-B +SECS-I +SECS-G +SECS-C +SECS-S +SECS-W +SECS-O compact nr >>$@

SECS-MES: SECS-B SECS-I SECS-G SECS-C SECS-O SECS-W SECS-P
	echo "# SECS-derived CEN MES-1 Repertoire " >$@
	./uniset +SECS-B +SECS-I +SECS-G +SECS-C +SECS-W +SECS-O +SECS-P compact nr >>$@

secs-all.html: uniset Makefile secs-all-template.html AUX-B AUX-C AUX-G AUX-O AUX-S \
		$(SETTARGETS)
	./uniset template secs-all-template.html >$@ || { rm -f $@ && false ; }

secs.tar.gz: $(PACKAGE_FILES)
	tar cvf secs.tar $(PACKAGE_FILES)
	gzip -f9 secs.tar

secs.zip: $(PACKAGE_FILES)
	rm -f secs.zip
	zip -9 secs.zip $(PACKAGE_FILES)

glyphs.zip:
	zip -r glyphs.zip Small.Glyphs

##########################################################################
#
# Places from where the packages can be retrieved
#
##########################################################################

CP437 CP850 SAMI KOI8-R:
	$(RETRIEVE) ftp://dkuug.dk/i18n/WG15-collection/charmaps/$@

UnicodeData-Latest.txt:
	$(RETRIEVE) ftp://ftp.unicode.org/Public/UNIDATA/$@

8859-1.TXT 8859-2.TXT 8859-3.TXT 8859-4.TXT 8859-5.TXT 8859-6.TXT \
8859-7.TXT 8859-8.TXT 8859-9.TXT 8859-14.TXT 8859-15.TXT:
	$(RETRIEVE) ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/$@

CP1250.TXT CP1251.TXT CP1252.TXT CP1253.TXT CP1254.TXT CP1255.TXT \
CP1256.TXT CP1257.TXT CP1258.TXT CP932.TXT CP936.TXT CP949.TXT CP950.TXT:
	$(RETRIEVE) ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/$@

CP437.TXT CP737.TXT CP775.TXT CP850.TXT CP852.TXT CP855.TXT CP857.TXT \
CP860.TXT CP861.TXT CP862.TXT CP863.TXT CP864.TXT CP865.TXT CP866.TXT \
CP869.TXT CP874.TXT:
	$(RETRIEVE) ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/$@

CYRILLIC.TXT GREEK.TXT ICELAND.TXT LATIN2.TXT ROMAN.TXT TURKISH.TXT:
	$(RETRIEVE) ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/$@

CP037.TXT CP1026.TXT CP500.TXT CP875.TXT:
	$(RETRIEVE) ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/EBCDIC/$@

NEXTSTEP.TXT:
	$(RETRIEVE) ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/NEXT/$@

IBMGRAPH.TXT SGML.TXT:
	$(RETRIEVE) ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/$@

WGL4: UnicodeData-Latest.txt gen-wgl4
	./gen-wgl4 >WGL4


##########################################################################
#
# old stuff
#
##########################################################################

VSECS_CHARSETS = CP1252.TXT 8859-2.TXT 8859-3.TXT 8859-4.TXT 8859-14.TXT VAUX

VSECS-9_CHARSETS = 8859-1.TXT 8859-2.TXT 8859-3.TXT 8859-4.TXT \
                   8859-5.TXT 8859-7.TXT VAUX-9

SECS_CHARSETS  = $(VSECS_CHARSETS) 8859-5.TXT 8859-7.TXT CP437.TXT CP850.TXT MATH AUX

OTHER_CHARSETS = MES-1 \
8859-1.TXT 8859-2.TXT 8859-3.TXT 8859-4.TXT 8859-9.TXT 8859-10.TXT \
8859-13.TXT 8859-14.TXT 8859-15.TXT \
CP037.TXT CP500.TXT CP1026.TXT CP1250.TXT CP1252.TXT CP1254.TXT CP1257.TXT \
CP1258.TXT \
NEXTSTEP.TXT ICELAND.TXT LATIN2.TXT ROMAN.TXT TURKISH.TXT

MANY_OTHER_CHARSETS = $(OTHER_CHARSETS) \
8859-7.TXT CP737.TXT CP869.TXT CP875.TXT CP1253.TXT GREEK.TXT \
8859-5.TXT CP855.TXT CP866.TXT CP1251.TXT CYRILLIC.TXT \
CP775.TXT CP850.TXT CP852.TXT CP857.TXT CP860.TXT CP861.TXT CP863.TXT \
CP865.TXT \
WGL4 IBMGRAPH.TXT IR-143.TXT IR-155.TXT IR-182.TXT IPA-MINI

UOPT=img table sources compact nr

SECS: uniset $(SECS_CHARSETS)
	echo "# Simple European Character Set (SECS) proposal -- Markus Kuhn <mkuhn@acm.org>" >SECS
	./uniset $(patsubst %,+%,$(SECS_CHARSETS)) compact nr >>SECS

VSECS: uniset $(VSECS_CHARSETS)
	echo "# Very Simple European Character Set (VSECS) proposal -- Markus Kuhn <mkuhn@acm.org>" >VSECS
	./uniset $(patsubst %,+%,$(VSECS_CHARSETS)) compact nr >>VSECS

VSECS-9: uniset $(VSECS-9_CHARSETS)
	echo "# Very Simple European Character Set with 512 characters (VSECS-9) proposal\n# Markus Kuhn <mkuhn@acm.org>" >VSECS-9
	./uniset $(patsubst %,+%,$(VSECS-9_CHARSETS)) compact nr >>VSECS-9

secs.html: uniset Makefile secs-template.html end.html $(SECS_CHARSETS) $(MANY_OTHER_CHARSETS)
	./uniset template secs-template.html $(patsubst %,+%,$(SECS_CHARSETS)) $(UOPT) >secs.html
	echo "<A NAME=snm1><H2>Characters in SECS but not in MES-1</H2></A>"	>>secs.html
	./uniset $(patsubst %,+%,$(SECS_CHARSETS)) -MES-1 $(UOPT)		>>secs.html
	echo "<A NAME=snm2><H2>Characters in SECS but not in MES-2</H2></A>"	>>secs.html
	./uniset $(patsubst %,+%,$(SECS_CHARSETS)) -MES-2 $(UOPT)		>>secs.html
	echo "<A NAME=snm3><H2>Characters in SECS but not in MES-3</H2></A>"	>>secs.html
	./uniset $(patsubst %,+%,$(SECS_CHARSETS)) -MES-3 $(UOPT)		>>secs.html
	echo "<A NAME=snm4><H2>Characters in SECS but not in MES-4</H2></A>"	>>secs.html
	./uniset $(patsubst %,+%,$(SECS_CHARSETS)) -MES-4 $(UOPT)		>>secs.html
	echo "<A NAME=snw4><H2>Characters in SECS but not in WGL4</H2></A>"	>>secs.html
	./uniset $(patsubst %,+%,$(SECS_CHARSETS)) -WGL4 $(UOPT)		>>secs.html
	echo "<A NAME=m1ns><H2>Characters in MES-1 but not in SECS</H2></A>"	>>secs.html
	./uniset +MES-1 $(patsubst %,-%,$(SECS_CHARSETS)) $(UOPT)		>>secs.html
	echo "<A NAME=m2ns><H2>Characters in MES-2 but not in SECS</H2></A>"	>>secs.html
	./uniset +MES-2 $(patsubst %,-%,$(SECS_CHARSETS)) $(UOPT)		>>secs.html
	echo "<A NAME=m3ns><H2>Characters in MES-3 but not in SECS</H2></A>"	>>secs.html
	./uniset +MES-3 $(patsubst %,-%,$(SECS_CHARSETS)) $(UOPT)		>>secs.html
	echo "<A NAME=ons><H2>Characters in other character sets but not in SECS</H2></A>"	>>secs.html
	echo "<P>List of other character sets: $(patsubst %.TXT,%,$(MANY_OTHER_CHARSETS))"	>>secs.html
	./uniset $(patsubst %,+%,$(MANY_OTHER_CHARSETS)) $(patsubst %,-%,$(SECS_CHARSETS)) $(UOPT) >>secs.html
	cat end.html >>secs.html

vsecs.html: uniset Makefile VSECS vsecs-template.html end.html $(VSECS_CHARSETS) $(OTHER_CHARSETS)
	./uniset template vsecs-template.html $(patsubst %,+%,$(VSECS_CHARSETS)) $(UOPT) >vsecs.html
	echo "<A NAME=snm1><H2>Characters in VSECS but not in MES-1</H2></A>"	>>vsecs.html
	./uniset $(patsubst %,+%,$(VSECS_CHARSETS)) -MES-1 $(UOPT)		>>vsecs.html
	echo "<A NAME=ons><H2>Characters in other character sets but not in VSECS</H2></A>"	>>vsecs.html
	echo "<P>List of other character sets: $(patsubst %.TXT,%,$(OTHER_CHARSETS))"		>>vsecs.html
	./uniset $(patsubst %,+%,$(OTHER_CHARSETS)) $(patsubst %,-%,$(VSECS_CHARSETS)) $(UOPT)	>>vsecs.html
	cat end.html >>vsecs.html

MES-1.gif: MES-1
	./uniset +$< giftable ; mv table.gif $@

MES-2.gif: MES-2
	./uniset +$< giftable ; mv table.gif $@

MES-3.gif: MES-3
	./uniset +$< giftable ; mv table.gif $@

MES-4.gif: MES-4
	./uniset +$< giftable ; mv table.gif $@

mes-tables.pdf: Makefile MES-1.gif MES-2.gif MES-3.gif MES-4.gif
	giftopnm MES-1.gif | pnmtops -width 8.27 -height 11.7 >tables.ps
	giftopnm MES-2.gif | pnmtops -width 8.27 -height 11.7 >>tables.ps
	giftopnm MES-3.gif | pnmtops -width 8.27 -height 11.7 >>tables.ps
	giftopnm MES-4.gif | pnmtops -width 8.27 -height 11.7 >>tables.ps
	distill <tables.ps >mes-tables.pdf
	rm tables.ps

