# (find-node "(make)Automatic")

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

all: math

mktclapp.h:
	mktclapp -header > mktclapp.h

%.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
%.veryclean:
	rm -fv $*.mta.c $*.mta.E $*.E $*.mta.o $*.o $*



# 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) -ltcl8.0 -lm -ldl -o $@ $^

math1.8: ega1.8 vtutil vtutilsh
	./vtutil modifyfont 256 8 $<  $@
math850.map: defkeymap850b.map vtutil vtutilsh
	(cat $<; echo '#'; ./vtutil composetable) > $@

math: math1.8 math850.map vtutil vtutilsh
	./vtutil setfont  256 8 math1.8  file0
	loadkeys math850.map

# Why "file0"? See:
# (find-fline "~/MTA/vtutil" "file0")
# Other options: /dev/tty, /dev/tty0, /dev/tty3, `tty`...

math1.16: ega1.16 vtutil vtutilsh
	./vtutil modifyfont 256 16 $<  $@
math16: math1.16 math850.map vtutil vtutilsh
	./vtutil setfont  256 16 math1.16  file0
	loadkeys math850.map

# math850sparc.map: defkeymap850sparc.map vtutil vtutilsh
#	(cat $<; echo '#'; ./vtutil composetable) > $@
# math-sparc:
#	./vtutil setfont  256 16 math1.16  /dev/tty1
#	./vtutil setfont  256 16 math1.16  /dev/tty2
#	./vtutil setfont  256 16 math1.16  /dev/tty3
#	./vtutil setfont  256 16 math1.16  /dev/tty4
#	./vtutil setfont  256 16 math1.16  /dev/tty5
#	./vtutil setfont  256 16 math1.16  /dev/tty6
#	loadkeys math850sparc.map


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