Warning: this is an htmlized version!
The original is across this link,
and the conversion rules are here.
# (find-node "(make)Automatic")

# (find-angg "MTA/vtutil")
# (find-angg "MTA/vtutilsh.c")
# «.mktclapp»	(to "mktclapp")
# «.fonts»	(to "fonts")
# «.psfs»	(to "psfs")

# To prepare this directory for use if you don't have mktclapp, just
# make "psfs". The other interesting targets are math and 850.


# all: math
all: setlatinmath
TCLVERSION ?= 8.2
INCLUDES = -I/usr/include/tcl$(TCLVERSION)
# VTUTIL = tclsh$(TCLVERSION) vtutil
# VTUTIL = ./vtutilsh vtutil

# (find-fline "/usr/doc/console-tools/file-formats/psf" "psf_header =")
RAWTOPSF8  = (perl -e 'printf "%c%c%c%c", 0x36, 0x04, 0,  8'; cat)
RAWTOPSF16 = (perl -e 'printf "%c%c%c%c", 0x36, 0x04, 0, 16'; cat)

CHARS0TO255   = perl -e 'for ($$i=0;   $$i<256; ++$$i) { printf "%c", $$i }'
CHARS128TO255 = perl -e 'for ($$i=128; $$i<256; ++$$i) { printf "%c", $$i }'





# (find-es "charsets" "tcs_patch")
#TR850TOISO = tcs -f latin1-850 -t ps2
#TRISOTO850 = tcs -f ps2 -t latin1-850
#128:
#	$(CHARS128TO255) > $@
#128b: 128
#	$(CHARS128TO255) | $(TR850TOISO) > $@

TR850TOISO = tr `cat 128b` `cat 128`
TRISOTO850 = tr `cat 128` `cat 128b`
# SETPSFFONT = pio_fontx
SETPSFFONT ?= consolechars -f

isoto850.cmap:
	$(CHARS0TO255) | $(TRISOTO850) > $@

latinmath.map: math850.map
	$(TR850TOISO) < $< > $@


850 math set850math: psfs
	$(SETPSFFONT) math1.8.psf
	loadkeys math850.map
iso setlatinmath: psfs
	$(SETPSFFONT) latinmath.8.psf
	loadkeys latinmath.map

16: psfs
	$(SETPSFFONT) math1.16.psf



#####
#
# «mktclapp»  (to ".mktclapp")
#
#####

# (find-node "(make)Catalogue of Rules")

# Cc = gcc -g -Wall
CC = gcc -g -Wall

VTUTILDEPS = vtutilsh.so vtutilsh

mktclapp.h:
	mktclapp -header > mktclapp.h

%.o : %.c
	$(CC) -c $(INCLUDES) $(CFLAGS) -o $@ $<
%.mta.c : %.c
	mktclapp -dont-strip-tcl -notk -read-stdin $*.c > $*.mta.c
%.E : %.c
	gcc -E $*.c > $*.E
%.clean:
	rm -fv $*.mta.c $*.mta.E $*.E $*.mta.o $*.o
%.cleanshared:
	rm -fv $*.o $*_e.c $*_e.o $*.so
%.veryclean:
	rm -fv $*.mta.c $*.mta.E $*.E $*.mta.o $*.o   $*_e.c $*_e.o $*.so   $*

# The first of these rules prevents make from deleting %.mta.c,
# the second forces mktclapp.h to be created. See:
# (find-node "(make)Chained Rules" "not mentioned")
# (find-node "(make)Chained Rules" "it deletes B later on")
#
vtutilsh.mta.o: vtutilsh.mta.c
vtutilsh.o:     mktclapp.h
vtutilsh:       vtutilsh.mta.o vtutilsh.o
	$(CC) -ltcl$(TCLVERSION) -lm -ldl -o $@ $^

clean: vtutilsh.clean
veryclean: vtutilsh.veryclean
	rm -fv mktclapp.h

# (find-es "mktclapp" "vtutil.so")

vtutilsh_e.c: vtutilsh.c
	mktclapp -notk -extension Vtutil vtutilsh.c > vtutilsh_e.c
vtutilsh_e.o: vtutilsh_e.c mktclapp.h
vtutilsh.so: vtutilsh_e.o vtutilsh.o
	gcc -shared -o vtutilsh.so  vtutilsh_e.o vtutilsh.o




#####
#
# «fonts»  (to ".fonts")
#
#####

# math: math1.8

MTAFONTS = 850math.8 latin850.8 latin850math.8 math1.8 math1.16 math850.map
sostuff:
	make VTUTIL="tclsh$(TCLVERSION) vtutil" \
	     VTUTILDEPS="vtutil vtutilsh.so" $(MTAFONTS)
shstuff:
	make VTUTIL="./vtutilsh vtutil" \
	     VTUTILDEPS="vtutil vtutilsh" $(MTAFONTS)


ifneq ($(VTUTIL),)

FOO := $(shell echo $(VTUTIL) argh > /dev/stderr)

850math.8: ega1.8 $(VTUTILDEPS)
	$(VTUTIL) modifyfont 256 8 ega1.8 850math.8
latin850.8: ega1.8 isoto850.cmap vtutil vtutilsh
	$(VTUTIL) reorderfont 256 8 ega1.8 isoto850.cmap latin850.8
latin850math.8: 850math.8 isoto850.cmap vtutil vtutilsh
	$(VTUTIL) reorderfont 256 8 850math.8 isoto850.cmap latin850math.8

math1.8: ega1.8 $(VTUTILDEPS)
	$(VTUTIL) modifyfont 256 8 $<  $@
math1.16: ega1.16 $(VTUTILDEPS)
	$(VTUTIL) modifyfont 256 16 $<  $@

math850.map: defkeymap850b.map $(VTUTILDEPS)
	(cat $<; echo '#'; $(VTUTIL) composetable) > $@

math850: math1.8 math850.map $(VTUTILDEPS)
	$(VTUTIL) setfont  256 8 math1.8  file0
	loadkeys math850.map

fonts: 850math.8 latin850.8 latin850math.8

math16: math1.16 math850.map $(VTUTILDEPS)
	$(VTUTIL) setfont  256 16 math1.16  file0
	loadkeys math850.map

# An explanation for using "file0" is in:
# (find-fline "~/MTA/vtutil" "file0")
# Other options: /dev/tty, /dev/tty0, /dev/tty3, `tty`...

endif



# Names of fonts:
#   latin1       - very standard stuff; chars 128..159 are empty
#   ega1, cp850  - standard but obsolete; its chars are in a weird order
#   latin850     - all chars of cp850 reordered in a latin1ish way
#   850math      - ega1 (i.e., cp850) with some chars mathified
#   latin850math - latin850 with some chars mathified (850math reordered)
#     latinmath   - ambiguous; not used


# «psfs»  (to ".psfs")
# (find-angg "TH/Files.tcl" "do_not_translate")
psfs: ega1.8.psf latin1-850.8.psf latinmath.8.psf math1.8.psf \
  latinmath.map

%.8.psf: %.8
	cat $< | $(RAWTOPSF8) > $@
%.16.psf: %.16
	cat $< | $(RAWTOPSF16) > $@


# 850math.8.psf: 850math.8
# 	cat $< | $(RAWTOPSF8) > $@
# ega0.8.psf: ega0.8
# 	cat $< | $(RAWTOPSF8) > $@
# ega1.8.psf: ega1.8
# 	cat $< | $(RAWTOPSF8) > $@
# latin1-850.8.psf: latin1-850.8
# 	cat $< | $(RAWTOPSF8) > $@
# latinmath.8.psf: latinmath.8
# 	cat $< | $(RAWTOPSF8) > $@
# math1.8.psf: math1.8
# 	cat $< | $(RAWTOPSF8) > $@
# math2.8.psf: math2.8
# 	cat $< | $(RAWTOPSF8) > $@










#  Local Variables:
#  coding:               no-conversion
#  ee-anchor-format:     "«%s»"
#  ee-charset-indicator: "Ñ"
#  End: