# $Header:Makefile 12.0$
# $ACIS:Makefile 12.0$
# $Source: /ibm/acis/usr/src/usr.lib/font/dev3812/fixedfonts/RCS/Makefile,v $
#
#	Build the fonts.
#
DESTDIR=

FCP = fcp 
ACP = acp
SCP = symcp
TBL = fontnameTBL
CVT20to12 = /usr/ibm/cvt20to12
WIDTH3812 = /usr/ibm/width3812
INSTALL   = /usr/bin/install
IFLAGS    = -c -m 644

# Where to install the fonts, and directories that that's dependent on
DEVDIR= ${DESTDIR}/usr/lib/font/dev3812
FONTDIR=${DEVDIR}/fonts
DEPDIRS=${DESTDIR}/usr/lib/font	${DEVDIR} ${FONTDIR}

FIXEDFONTS= AP BR Bb Bi CW Ci Cw Cb Cc Cd Ce Cf Du  E EB EI EL F G GI GB GP \
	    KT Lr Lb RA RB O  OB PP PB PI RM SC Sf Sb Si SH SY TX
OTHERFONTS= R I B BI H HI HB HY S SB HS HZ L LI LB LY K KI KB KY D SP 

DESCFILE=${DEVDIR}/DESC

# Since it is too painful to explicitly list the real dependencies for
# every font, we have the dummy targets depend on all the sources.
PDS=	c0d0gb10.pds c0d0gb12.pds c0d0gi12.pds c0d0gp12.pds \
	c0d0gt10.pds c0d0gt12.pds c0d0gt15.pds c0d0gt20.pds \
	c0d0gt24.pds c0d0rt10.pds c0d0sb12.pds c0d0si10.pds \
	c0d0si12.pds c0d0st10.pds c0d0st12.pds c0d0st15.pds \
	c0l00aoa.pds c0l00boa.pds c0l00t11.pds c0l0fm10.pds \
	c0l0fm12.pds c0l0fm15.pds c0l0kata.pds c0s0ae10.pds \
	c0s0ae20.pds c0s0bitr.pds c0s0brtr.pds c0s0ce12.pds \
	c0s0ci10.pds c0s0cr10.pds c0s0dotr.pds c0s0ebtr.pds \
	c0s0eitr.pds c0s0eltr.pds c0s0estr.pds c0s0lb12.pds \
	c0s0lr12.pds c0s0ob10.pds c0s0or10.pds c0s0pb12.pds \
	c0s0pi12.pds c0s0pr10.pds c0s0pr12.pds c0s0s193.pds \
	c0s0s198.pds c0s0sr12.pds

PDS3820=	c0accm90.pds3820 c0accm91.pds3820 c0h0brk2.pds3820 \
		c0h0hb10.pds3820 c0h0hb12.pds3820 c0h0hb15.pds3820 \
		c0rc5590.pds3820 c0rc5591.pds3820 c0rccm40.pds3820 \
		c0rcdw90.pds3820 c0rcdw91.pds3820

all: dat_and_ndx special_dat width

dat_and_ndx: 	${TBL} ${PDS}
	for i in *.pds;\
	do\
		${CVT20to12} $$i;\
	done
	>$@

$(TBL) $(FCP) $(ACP) $(SCP):
	cp ../$@ $@

install: all ${DEPDIRS}
	for i in *.dat *.${FCP} *.${ACP} SYMBOLS.9.symcp SYMBOLS.10.symcp; do \
		${INSTALL} ${IFLAGS} $$i ${FONTDIR}/$$i; done
	for i in ${FIXEDFONTS}; do \
		${INSTALL} ${IFLAGS} $$i ${DEVDIR}/$$i; done
	-./typcheck ${DESCFILE}
	sh -c 'test ! -f .install_substitutes || \
		make install_substitutes DESTDIR=${DESTDIR}'
	rm -f .install_substitutes

${DEPDIRS}:
	mkdir $@

clean:	clean_substitutes
	rm -f *.*cp fontnameTBL ${FCP} ${ACP}
	rm -f *.ndx *.dat *.ndx.real *.dat.real
	rm -f ${OTHERFONTS} ${FIXEDFONTS}
	rm -f .install_substitutes
	rm -f dat_and_ndx special_dat width

# 	Unfortunately, font names are not unique in the *.pds3820 files, so
# these dependancies have to be individually specified, so that they are
# converted to unique names.
#	The name collision primarily impacts Courier.10, and in order to
# prevent rebuilding Courier.10.ndx and Courier.10.dat needlessly, they are
# moved into Courier.10.ndx.real and Courier.10.dat.real, and then copied
# back before being used to build Courier.${CODEPAGE}.
#
# Courier index and data filenames
CI = Courier.10.ndx
CD = Courier.10.dat

special_dat: ${PDS3820}
	${CVT20to12} c0rc5590.pds3820
		mv ${CI} ${CI}.real
		mv ${CD} ${CD}.real
	${CVT20to12} c0rccm40.pds3820
	${CVT20to12} c0rc5591.pds3820
		mv ${CI} Courier.B.10.ndx
		mv ${CD} Courier.B.10.dat
	${CVT20to12} c0accm90.pds3820
		mv ${CI} Courier.C.10.ndx
		mv ${CD} Courier.C.10.dat
	${CVT20to12} c0accm91.pds3820
		mv ${CI} Courier.CB.10.ndx
		mv ${CD} Courier.CB.10.dat
	${CVT20to12} c0rcdw90.pds3820
		mv ${CI} Courier.E.10.ndx
		mv ${CD} Courier.E.10.dat
	${CVT20to12} c0rcdw91.pds3820
		mv ${CI} Courier.EB.10.ndx
		mv ${CD} Courier.EB.10.dat
	${CVT20to12} c0h0brk2.pds3820
	${CVT20to12} c0h0hb10.pds3820
	${CVT20to12} c0h0hb12.pds3820
		mv SHALOM12.9.ndx SHALOM.9.ndx
		mv SHALOM12.9.dat SHALOM.9.dat
	${CVT20to12} c0h0hb15.pds3820
		mv SHALOM15.10.ndx SHALOM.8.ndx
		mv SHALOM15.10.dat SHALOM.8.dat
	mv ${CI}.real ${CI}
	mv ${CD}.real ${CD}
	>$@

# This will build the width tables for all the free fonts.   
# The sizes are listed after the -s option.
# The fcp and acp code page tables are used.    

width:	    ${FCP} ${ACP} ${SCP} ${PDS} ${PDS3820} dat_and_ndx special_dat
	${WIDTH3812} -s 5 10 0     	-c fcp -n AP APL
	${WIDTH3812} -s 10 0       	-c fcp -n Bb BOOK.B
	${WIDTH3812} -s 10 0       	-c fcp -n Bi BOOK.BI
	${WIDTH3812} -s 9 10 0     	-c fcp -n CW COURIER
	${WIDTH3812} -s 10 0       	-c fcp -n Ci COURIER.I
	${WIDTH3812} -s 10 0       	-c fcp -n Du DOCUMENT
	${WIDTH3812} -s 10 0       	-c fcp -n E ESSAY
	${WIDTH3812} -s 10 0       	-c fcp -n EB ESSAY.B
	${WIDTH3812} -s 10 0       	-c fcp -n EI ESSAY.I
	${WIDTH3812} -s 10 0       	-c fcp -n EL ESSAY.L
	${WIDTH3812} -s 8 9 10 0   	-c fcp -n F FORMAT
	${WIDTH3812} -s 4 5 8 9 10 0 	-c fcp -n G GOTHIC
	${WIDTH3812} -s 9 10 0     	-c fcp -n GB GOTHIC.B
	${WIDTH3812} -s 9 0        	-c fcp -n GI GOTHIC.I
	${WIDTH3812} -s 9 0        	-c fcp -n GP GOTHICP
	${WIDTH3812} -s 10 0       	-c fcp -n KT KATAKANA
	${WIDTH3812} -s 9 0        	-c fcp -n Lr LETTER
	${WIDTH3812} -s 9 0        	-c fcp -n Lb LETTER.B
	${WIDTH3812} -s 10 0       	-c fcp -n RA OCRA
	${WIDTH3812} -s 10 0       	-c fcp -n RB OCRB
	${WIDTH3812} -s 10 0       	-c fcp -n O ORATOR
	${WIDTH3812} -s 10 0       	-c fcp -n OB ORATOR.B
	${WIDTH3812} -s 9 10 0     	-c fcp -n PP PRESTIGE
	${WIDTH3812} -s 9 0        	-c fcp -n PB PRESTIGE.B
	${WIDTH3812} -s 9 0        	-c fcp -n PI PRESTIGE.I
	${WIDTH3812} -s 10 0       	-c fcp -n RM ROMAN
	${WIDTH3812} -s 9 0        	-c fcp -n SC SCRIPT
	${WIDTH3812} -s 8 9 10 0   	-c fcp -n Sf SERIF
	${WIDTH3812} -s 9 0        	-c fcp -n Sb SERIF.B
	${WIDTH3812} -s 9 10 0     	-c fcp -n Si SERIF.I
	${WIDTH3812} -s 8 9 10 0   	-c fcp -n SH SHALOM
	${WIDTH3812} -s 10 0       	-c fcp -n TX TEXT
	${WIDTH3812} -s 10 0       	-c fcp -n BR BARAK.B
	${WIDTH3812} -s 4 10 0  	-c acp -n Cw Courier
	${WIDTH3812} -s 10 0    	-c acp -n Cb Courier.B
	${WIDTH3812} -s 10 0    	-c acp -n Cc Courier.C
	${WIDTH3812} -s 10 0    	-c acp -n Cd Courier.CB
	${WIDTH3812} -s 10 0    	-c acp -n Ce Courier.E
	${WIDTH3812} -s 10 0    	-c acp -n Cf Courier.EB
	${WIDTH3812} -s 9 10 0  	-c symcp -n SY SYMBOLS
	sh rmligatures ${FIXEDFONTS}
	-./typcheck ${DESCFILE}
	sh -c 'test ! -f .install_substitutes || make width_substitutes'
	rm -f .install_substitutes
	>$@

# The remainder of the targets in this Makefile are used to create
# substitute typographic fonts from the fixedfonts.
# It is intended that these targets will only be called from
# within this Makefile when it determines that the special IBM 
# typographical fonts (which can be purchased through your 
# IBM Representative) have not been installed.  

# THESE TARGETS WILL PROBABLY NOT DO THE CORRECT THING IF INVOKED DIRECTLY.

# Sustitute width tables
PISPECIAL_WT_SUBS   = S SB HS HZ D SP
SERIF_WT_SUBS	    = R I B BI L LI LB LY
SANS_WT_SUBS	    = H HB HI HY K KB KI KY


width_substitutes:	width_pispecial_substitutes \
			width_serif_substitutes width_sans_substitutes

install_substitutes:	install_pispecial_substitutes \
			install_serif_substitutes install_sans_substitutes
	rm -f .install_substitutes

clean_substitutes:	clean_pispecial_substitutes clean_serif_substitutes \
			clean_sans_substitutes

width_pispecial_substitutes:	fcp symcp 
	cp SYMBOLS.9.ndx SYMBOLS.6.ndx
	cp SYMBOLS.9.dat SYMBOLS.6.dat
	cp SYMBOLS.9.ndx SYMBOLS.7.ndx
	cp SYMBOLS.9.dat SYMBOLS.7.dat
	cp SYMBOLS.9.ndx SYMBOLS.8.ndx
	cp SYMBOLS.9.dat SYMBOLS.8.dat
	cp SYMBOLS.10.ndx SYMBOLS.11.ndx
	cp SYMBOLS.10.dat SYMBOLS.11.dat
	cp SYMBOLS.10.ndx SYMBOLS.12.ndx
	cp SYMBOLS.10.dat SYMBOLS.12.dat
	${WIDTH3812} -c symcp -S -s 6 7 8 9 10 11 12 0 -n S SYMBOLS
	${WIDTH3812} -c symcp -S -s 6 7 8 9 10 11 12 0 -n SB SYMBOLS
	${WIDTH3812} -c symcp -S -s 6 7 8 9 10 11 12 0 -n HS SYMBOLS
	${WIDTH3812} -c symcp -S -s 6 7 8 9 10 11 12 0 -n HZ SYMBOLS
	${WIDTH3812} -c fcp -s 9 0 -n D SCRIPT
	${WIDTH3812} -c fcp -s 4 0 -n SP GOTHIC
	sh rmligatures ${PISPECIAL_WT_SUBS}

install_pispecial_substitutes:	
	for i in ${PISPECIAL_WT_SUBS}; do \
		${INSTALL} ${IFLAGS} $$i ${DEVDIR}/$$i; done
	cp SYMBOLS.*.symcp  ${FONTDIR}/

clean_pispecial_substitutes:
	rm -f ${PISPECIAL_WT_SUBS} ${FCP} ${SCP}
	rm -f SYMBOLS.*.symcp

width_sans_substitutes:	fcp fcp
	${WIDTH3812} -c fcp -s 10 0 -n H ESSAY.L
	${WIDTH3812} -c fcp -s 10 0 -n HI ESSAY.I
	${WIDTH3812} -c fcp -s 10 0 -n HB ESSAY.B
	${WIDTH3812} -c fcp -s 10 0 -n HY ESSAY.I
	${WIDTH3812} -c fcp -s 10 0 -S -n K ESSAY.L
	${WIDTH3812} -c fcp -s 10 0 -S -n KI ESSAY.I
	${WIDTH3812} -c fcp -s 10 0 -S -n KB ESSAY.B
	${WIDTH3812} -c fcp -s 10 0 -S -n KY ESSAY.I
	sh rmligatures ${SANS_WT_SUBS}

install_sans_substitutes:
	for i in ${SANS_WT_SUBS}; do \
		${INSTALL} ${IFLAGS} $$i ${DEVDIR}/$$i; done
	cp ESSAY.*.fcp ${FONTDIR}/

clean_sans_substitutes:
	rm -f ${SANS_WT_SUBS} ${FCP} 
	rm -f ESSAY.*.fcp 

width_serif_substitutes:	symcp fcp fcp
	${WIDTH3812} -c fcp -s 10 0 -n R DOCUMENT
	${WIDTH3812} -c fcp -s 10 0 -n I BOOK.BI
	${WIDTH3812} -c fcp -s 10 0 -n B BOOK.B
	${WIDTH3812} -c fcp -s 10 0 -n BI BOOK.BI
	${WIDTH3812} -c fcp -s 10 0 -S -n L DOCUMENT
	${WIDTH3812} -c fcp -s 10 0 -S -n LI BOOK.BI
	${WIDTH3812} -c fcp -s 10 0 -S -n LB BOOK.B
	${WIDTH3812} -c fcp -s 10 0 -S -n LY BOOK.BI
	sh rmligatures ${SERIF_WT_SUBS}

install_serif_substitutes:
	for i in ${SERIF_WT_SUBS}; do \
		${INSTALL} ${IFLAGS} $$i ${DEVDIR}/$$i; done
	cp DOCUMENT.*.fcp BOOK.*.fcp ${FONTDIR}/

clean_serif_substitutes:
	rm -f ${FCP} fcp ${SERIF_WT_SUBS}
	rm -f BOOK.*.fcp DOCUMENT.*.fcp
