summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/Makefile.in
blob: c19bb3f6051e2299f6206e185b31673e68d8d49f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
# Makefile for web2c --kb@mail.tug.org. Public domain.
# $Id: //depot/Build/source.development/TeX/texk/web2c/Makefile.in#66 $
version = @WEB2CVERSION@

# This makefile uses static rules with many targets (to be compatible to
# non-gnu make) and will not work correctly when parallelized.
# So we switch off parallel makes with gnu make.
.NOTPARALLEL:

# These lines define the memory dumps that fmts/bases/mems will make and
# install-fmts/install-bases/install-mems will install. plain.* is
# created automatically (as a link).  See the Formats node in
# doc/web2c.texi for details on the fmts.
fmts = olatex.fmt # amstex.fmt eplain.fmt texinfo.fmt
efmts = latex.fmt
pdffmts = pdfolatex.fmt
pdfefmts = pdflatex.fmt
afmts = lamed.fmt
ofmts = lambda.fmt
eofmts = elambda.fmt
bases = # I do not recommend building cmmf.base.
mems =  # mfplain.mem is probably not generally useful.

# The name of the file that defines your local devices for Metafont.
# (Only relevant during `make bases'.)  I recommend `modes.mf', which
# defines all known modes, plus useful definitions for all fonts.  It's
# available from ftp://ftp.tug.org/tex/modes.mf, among other places.
localmodes = modes

kpse_include ../make/paths.mk

# Used for triptrap.
DIFF = diff
DIFFFLAGS =

.SUFFIXES: # get rid of .p.o
kpse_include ../make/common.mk
kpse_include ../make/programs.mk

CXX = @CXX@
CXXLD = $(CXX)
cxx_link_command = $(CXXLD) -o $@ $(LDFLAGS)
kpathsea_cxx_link = $(LIBTOOL) --mode=link $(cxx_link_command)

@MAINT@ifeq ($(CC), gcc)
@MAINT@XDEFS = -Wimplicit -Wreturn-type -Wcomment -Wformat
@MAINT@endif

# Make `#include <X11/...>' and `-lX...' work.
# This matches xdvik.
# wlibs is substituted by web2c's configure, LIBS by general configure
# routines, and the others by AC_PATH_XTRA.
# All the x_... variables will be empty if we aren't supporting X.
x_cppflags = @X_CFLAGS@
x_ldflags = @X_LIBS@
x_pre_libs = @X_PRE_LIBS@
x_extra_libs = @X_EXTRA_LIBS@
x_tool_libs = @x_tool_libs@
x_ext_lib = @x_ext_lib@
wlibs = @wlibs@
# Follow the library order used in X11R6 itself:
#   -lXaw -lXmu -lXt -lSM -lICE -lXext -lX11 (some may not be present).
windowlink = $(windowlib) $(x_ldflags) $(x_tool_libs) $(x_pre_libs) $(x_ext_lib) $(wlibs) $(x_extra_libs)

# With --enable-ipc, TeX may need to link with -lsocket.
socketlibs = @socketlibs@

common_makeargs = $(MFLAGS) CC='$(CC)' CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' $(XMAKEARGS)
window_makeargs = x_cppflags='$(x_cppflags)' $(common_makeargs)
install_makeargs = INSTALL='$(INSTALL)' INSTALL_DATA='$(INSTALL_DATA)' \
  INSTALL_PROGRAM='$(INSTALL_PROGRAM)' \
  $(makevars) $(common_makeargs)  

proglib = lib/lib.a
windowlib = window/window.a

# The sh script that does the conversion:
web2c = srcdir=$(srcdir) $(SHELL) $(srcdir)/web2c/convert
# Additional dependencies:
web2c_common = web2c/convert web2c/common.defines
web2c_programs = web2c/fixwrites web2c/splitup web2c/web2c
web2c_texmf = $(web2c_common) $(web2c_programs) web2c/texmf.defines web2c/coerce.h

# The helper programs:
TANGLEBOOT = @TANGLEBOOT@
CTANGLEBOOT = @CTANGLEBOOT@
TANGLE = @TANGLE@
CTANGLE = @CTANGLE@
TIE = @TIE@

# Calling tangle
tangle = WEBINPUTS=$(srcdir) $(TANGLE)
ctangle = $(CTANGLE)
tie = $(TIE)

# The environment for making dumps.
# No need to specify TEXMF, as ../kpathsea/texmf.cnf should contain
# suitable absolute paths at this point.  Those are converted to
# SELFAUTO* paths on installation.
dumpenv = TEXMFCNF=../kpathsea

# Unfortunately, suffix rules can't have dependencies, or multiple
# targets, and we can't assume all makes supports pattern rules.
#.SUFFIXES: .p .c .ch .p
#.p.c: # really depends on $(web2c_programs), and generates .h.
#	$(web2c) $*
#.ch.p: # really depends on tangle; for mf/mp/tex, also generates .pool
#	./tangle $(srcdir)/$*.web $<

# These definitions have to come before the rules that expand them.
# The *{ini,[0-2]}.c files are created by splitup, run as part of convert.
# {mf,mp,tex}extra.c are created from lib/texmfmp.c, below.

# Prevent Make from deleting the intermediate forms.
.PRECIOUS: %.ch %.p %.c

tex = tex
mf = mf
@MFN@mfn = mf-nowin
#  
default all: programs manpages doc/web2c.info @FMU@ dumps
check: dumps

bibtex: bibtex.o
	$(kpathsea_link) bibtex.o $(LOADLIBES)
bibtex.c bibtex.h: $(web2c_common) $(web2c_programs) web2c/cvtbib.sed bibtex.p
	$(web2c) bibtex
bibtex.p: tangle bibtex.web bibtex.ch
	$(tangle) bibtex bibtex
check: bibtex-check
bibtex-check: bibtex
	test -f tests/exampl.aux || \
	  cp $(srcdir)/tests/exampl.aux tests/exampl.aux
	TEXMFCNF=../kpathsea \
	  BSTINPUTS=$(srcdir)/tests \
	  BIBINPUTS=$(srcdir)/tests \
	  ./bibtex tests/exampl
clean:: bibtex-clean
bibtex-clean:
	$(LIBTOOL) --mode=clean rm -f bibtex
	rm -f bibtex.o bibtex.c bibtex.h bibtex.p
	rm -f tests/exampl.blg tests/exampl.bbl

ctie: ctie.o
	$(kpathsea_link) ctie.o $(LOADLIBES)
ctie.c: ctangle ctiedir/ctie.w ctiedir/ctie-k.ch
	CWEBINPUTS=$(srcdir)/ctiedir $(ctangle) ctie.w ctie-k.ch
clean:: ctie-clean
ctie-clean:
	$(LIBTOOL) --mode=clean rm -f ctie
	rm -f ctie.o ctie.c

cweave: cweave.o cweb.o
	$(kpathsea_link) cweave.o cweb.o $(LOADLIBES)
cweave.c: ctangle cwebdir/cweave.w cwebdir/cweav-w2c.ch
	CWEBINPUTS=$(srcdir)/cwebdir $(ctangle) cweave cweav-w2c
check: cweave-check
cweave-check: cweave
	CWEBINPUTS=$(srcdir)/cwebdir ./cweave common.w
clean:: cweave-clean
cweave-clean:
	$(LIBTOOL) --mode=clean rm -f cweave
	rm -f cweave.o cweave.c
	rm -f common.tex common.scn common.idx

dvicopy: dvicopy.o
	$(kpathsea_link) dvicopy.o $(LOADLIBES)
dvicopy.c dvicopy.h: $(web2c_common) $(web2c_programs) dvicopy.p
	$(web2c) dvicopy
dvicopy.p: tangle dvicopy.web dvicopy.ch
	$(tangle) dvicopy dvicopy
check: dvicopy-check
dvicopy-check: dvicopy
	TEXMFCNF=../kpathsea \
	  ./dvicopy $(srcdir)/tests/story tests/xstory.dvi
# Redirect stderr so the terminal output will end up in the log file.
	(TFMFONTS=$(srcdir)/tests VFFONTS=$(srcdir)/tests ./dvicopy \
	  <$(srcdir)/tests/pplr.dvi \
	  >tests/xpplr.dvi) 2>&1
clean:: dvicopy-clean
dvicopy-clean:
	$(LIBTOOL) --mode=clean rm -f dvicopy
	rm -f dvicopy.o dvicopy.c dvicopy.h dvicopy.p
	rm -f tests/xstory.dvi tests/xpplr.dvi

## dvitomp is a special case
kpse_include dvitomp.mk
##

dvitype: dvitype.o
	$(kpathsea_link) dvitype.o $(LOADLIBES)
dvitype.c dvitype.h: $(web2c_common) $(web2c_programs) dvitype.p
	$(web2c) dvitype
dvitype.p: tangle dvitype.web dvitype.ch
	$(tangle) dvitype dvitype
check: dvitype-check
dvitype-check: dvitype
	./dvitype -show-opcodes $(srcdir)/tests/story >tests/xstory.dvityp
	./dvitype --p=\*.\*.2 $(srcdir)/tests/pagenum.dvi >tests/xpagenum.typ
clean:: dvitype-clean
dvitype-clean:
	$(LIBTOOL) --mode=clean rm -f dvitype
	rm -f dvitype.o dvitype.c dvitype.h dvitype.p
	rm -f tests/xstory.dvityp tests/xpagenum.typ

gftodvi: gftodvi.o
	$(kpathsea_link) gftodvi.o $(LOADLIBES)
gftodvi.c gftodvi.h: $(web2c_common) $(web2c_programs) gftodvi.p
	$(web2c) gftodvi
gftodvi.p: tangle gftodvi.web gftodvi.ch
	$(tangle) gftodvi gftodvi
check: gftodvi-check
gftodvi-check: gftodvi
	TFMFONTS=$(srcdir)/tests ./gftodvi -verbose \
	  $(srcdir)/tests/cmr10.600gf
	mv cmr10.dvi tests/xcmr10.dvi
clean:: gftodvi-clean
gftodvi-clean:
	$(LIBTOOL) --mode=clean rm -f gftodvi
	rm -f gftodvi.o gftodvi.c gftodvi.h gftodvi.p
	rm -f tests/xcmr10.dvi

gftopk: gftopk.o
	$(kpathsea_link) gftopk.o $(LOADLIBES)
gftopk.c gftopk.h: $(web2c_common) $(web2c_programs) gftopk.p
	$(web2c) gftopk
gftopk.p: tangle gftopk.web gftopk.ch
	$(tangle) gftopk gftopk
check: gftopk-check
gftopk-check: gftopk
	./gftopk -verbose $(srcdir)/tests/cmr10.600gf tests/xcmr10.pk
	./gftopk $(srcdir)/tests/cmr10.600gf cmr10.pk && rm cmr10.pk
clean:: gftopk-clean
gftopk-clean:
	$(LIBTOOL) --mode=clean rm -f gftopk
	rm -f gftopk.o gftopk.c gftopk.h gftopk.p
	rm -f tests/xcmr10.pk

gftype: gftype.o
	$(kpathsea_link) gftype.o $(LOADLIBES)
gftype.c gftype.h: $(web2c_common) $(web2c_programs) gftype.p
	$(web2c) gftype
gftype.p: tangle gftype.web gftype.ch
	$(tangle) gftype gftype
check: gftype-check
gftype-check: gftype
	./gftype $(srcdir)/tests/cmr10.600gf >tests/xcmr10.gft1
	./gftype -m -i $(srcdir)/tests/cmr10.600gf >tests/xcmr10.gft2
clean:: gftype-clean
gftype-clean:
	$(LIBTOOL) --mode=clean rm -f gftype
	rm -f gftype.o gftype.c gftype.h gftype.p
	rm -f tests/xcmr10.gft1 tests/xcmr10.gft2

mft: mft.o
	$(kpathsea_link) mft.o $(LOADLIBES)
mft.c mft.h: $(web2c_common) $(web2c_programs) mft.p
	$(web2c) mft
mft.p: tangle mft.web mft.ch
	$(tangle) mft mft
check: mft-check
mft-check: mft
	./mft $(srcdir)/tests/io; mv io.tex tests/io.tex
clean:: mft-clean
mft-clean:
	$(LIBTOOL) --mode=clean rm -f mft
	rm -f mft.o mft.c mft.h mft.p
	rm -f tests/io.tex

patgen: patgen.o
	$(kpathsea_link) patgen.o $(LOADLIBES)
patgen.c patgen.h: $(web2c_common) $(web2c_programs) patgen.p
	$(web2c) patgen
patgen.p: tangle patgen.web patgen.ch
	$(tangle) patgen patgen
check: patgen-check
patgen-check: patgen
	./patgen $(srcdir)/tests/dict $(srcdir)/tests/patterns tests/xpatout \
	   $(srcdir)/tests/translate <$(srcdir)/tests/patgen.in
clean:: patgen-clean
patgen-clean:
	$(LIBTOOL) --mode=clean rm -f patgen
	rm -f patgen.o patgen.c patgen.h patgen.p
	rm -f tests/xpatout pattmp.4

pktogf: pktogf.o
	$(kpathsea_link) pktogf.o $(LOADLIBES)
pktogf.c pktogf.h: $(web2c_common) $(web2c_programs) pktogf.p
	$(web2c) pktogf
pktogf.p: tangle pktogf.web pktogf.ch
	$(tangle) pktogf pktogf
check: pktogf-check
pktogf-check: pktogf
	./pktogf -verbose $(srcdir)/tests/cmr10.pk tests/xcmr10.600gf
	./pktogf $(srcdir)/tests/cmr10.pk && rm cmr10.gf
clean:: pktogf-clean
pktogf-clean:
	$(LIBTOOL) --mode=clean rm -f pktogf
	rm -f pktogf.o pktogf.c pktogf.h pktogf.p
	rm -f tests/xcmr10.600gf

pktype: pktype.o
	$(kpathsea_link) pktype.o $(LOADLIBES)
pktype.c pktype.h: $(web2c_common) $(web2c_programs) pktype.p
	$(web2c) pktype
pktype.p: tangle pktype.web pktype.ch
	$(tangle) pktype pktype
check: pktype-check
pktype-check: pktype
	./pktype $(srcdir)/tests/cmr10.pk >tests/xcmr10.pktyp
clean:: pktype-clean
pktype-clean:
	$(LIBTOOL) --mode=clean rm -f pktype
	rm -f pktype.o pktype.c pktype.h pktype.p
	rm -f tests/xcmr10.pktyp

pltotf: pltotf.o
	$(kpathsea_link) pltotf.o $(LOADLIBES)
pltotf.c pltotf.h: $(web2c_common) $(web2c_programs) pltotf.p
	$(web2c) pltotf
pltotf.p: tangle pltotf.web pltotf.ch
	$(tangle) pltotf pltotf
check: pltotf-check
pltotf-check: pltotf
	./pltotf -verbose $(srcdir)/tests/cmr10 tests/xcmr10
clean:: pltotf-clean
pltotf-clean:
	$(LIBTOOL) --mode=clean rm -f pltotf
	rm -f pltotf.o pltotf.c pltotf.h pltotf.p
	rm -f tests/xcmr10.tfm

pooltype: pooltype.o
	$(kpathsea_link) pooltype.o $(LOADLIBES)
pooltype.c pooltype.h: $(web2c_common) $(web2c_programs) pooltype.p
	$(web2c) pooltype
pooltype.p: tangle pooltype.web pooltype.ch
	$(tangle) pooltype pooltype
check: pooltype-check
pooltype-check: tex.pool
pooltype-check: pooltype
	./pooltype tex.pool >tests/xtexpool.typ
clean:: pooltype-clean
pooltype-clean:
	$(LIBTOOL) --mode=clean rm -f pooltype
	rm -f pooltype.o pooltype.c pooltype.h pooltype.p
	rm -f tests/xtexpool.typ

tie: tie.o
	$(kpathsea_link) tie.o $(LOADLIBES)
tie.c: ctangle tiedir/tie.w tiedir/tie-w2c.ch
	CWEBINPUTS=$(srcdir)/tiedir $(ctangle) tie.w tie-w2c.ch
clean:: tie-clean
tie-clean:
	$(LIBTOOL) --mode=clean rm -f tie
	rm -f tie.o tie.c

tftopl: tftopl.o
	$(kpathsea_link) tftopl.o $(LOADLIBES)
tftopl.c tftopl.h: $(web2c_common) $(web2c_programs) tftopl.p
	$(web2c) tftopl
tftopl.p: tangle tftopl.web tftopl.ch
	$(tangle) tftopl tftopl
check: tftopl-check
tftopl-check: tftopl
	./tftopl -verbose $(srcdir)/tests/cmr10 tests/xcmr10
clean:: tftopl-clean
tftopl-clean:
	$(LIBTOOL) --mode=clean rm -f tftopl
	rm -f tftopl.o tftopl.c tftopl.h tftopl.p
	rm -f tests/xcmr10.pl

vftovp: vftovp.o
	$(kpathsea_link) vftovp.o $(LOADLIBES)
vftovp.c vftovp.h: $(web2c_common) $(web2c_programs) vftovp.p
	$(web2c) vftovp
vftovp.p: tangle vftovp.web vftovp.ch
	$(tangle) vftovp vftovp
check: vftovp-check
vftovp-check: vftovp
	TFMFONTS=$(srcdir)/tests ./vftovp -verbose $(srcdir)/tests/ptmr ptmr tests/xptmr
clean:: vftovp-clean
vftovp-clean:
	$(LIBTOOL) --mode=clean rm -f vftovp
	rm -f vftop.o vftovp.c vftovp.h vftovp.p
	rm -f tests/xptmr.vpl

vptovf: vptovf.o
	$(kpathsea_link) vptovf.o $(LOADLIBES)
vptovf.c vptovf.h: $(web2c_common) $(web2c_programs) vptovf.p
	$(web2c) vptovf
vptovf.p: tangle vptovf.web vptovf.ch
	$(tangle) vptovf vptovf
check: vptovf-check
vptovf-check: vptovf
	./vptovf $(srcdir)/tests/ptmr tests/xptmr tests/xptmr
clean:: vptovf-clean
vptovf-clean:
	$(LIBTOOL) --mode=clean rm -f vptovf
	rm -f vptovf.o vptovf.c vptovf.h vptovf.p
	rm -f tests/xptmr.vf tests/xptmr.tfm

weave: weave.o
	$(kpathsea_link) weave.o $(LOADLIBES)
weave.c weave.h: $(web2c_common) $(web2c_programs) weave.p
	$(web2c) weave
weave.p: tangle weave.web weave.ch
	$(tangle) weave weave
check: weave-check
weave-check: weave
	./weave $(srcdir)/pooltype
clean:: weave-clean
weave-clean:
	$(LIBTOOL) --mode=clean rm -f weave
	rm -f weave.o weave.c weave.h weave.p
	rm -f pooltype.tex

# 
# Defines that are common to the texmf programs.

triptrap: trip trap mptrap
testdir = $(srcdir)/triptrap
testenv = TEXMFCNF=$(testdir)
dvitype_args = -output-level=2 -dpi=72.27 -page-start='*.*.*.*.*.*.*.*.*.*'

# 
# Metafont
mf_c = mfini.c mf0.c mf1.c mf2.c
mf_o = mfini.o mf0.o mf1.o mf2.o mfextra.o
mfn_o = mfini.o mf0.o mf1.o mf2.o mfnowin.o
mf: $(mf_o) $(windowlib)
	$(kpathsea_link) $(mf_o) $(windowlink) $(LOADLIBES)
mf-nowin: $(mfn_o) window/trap.o
	$(kpathsea_link) $(mfn_o) window/trap.o $(LOADLIBES)
mfnowin.o: mfnowin.c
	$(compile) -DMFNOWIN -c $< -o $@
$(mf_c) mfcoerce.h mfd.h: mf.p $(web2c_texmf) web2c/cvtmf1.sed web2c/cvtmf2.sed
	$(web2c) mf
mfextra.c: lib/texmfmp.c
	sed s/TEX-OR-MF-OR-MP/mf/ $(srcdir)/lib/texmfmp.c >$@
mfnowin.c: lib/texmfmp.c
	sed s/TEX-OR-MF-OR-MP/mf/ $(srcdir)/lib/texmfmp.c >$@
mf.p mf.pool: tangle mf.web mf.ch
	$(tangle) mf.web mf.ch
check: mf-check
mf-check: trap mf.base
	./mf --progname=mf '&./mf \tracingstats:=1; end.'
	./mf --progname=mf $(srcdir)/tests/online
	./mf --progname=mf $(srcdir)/tests/one.two
	./mf --progname=mf $(srcdir)/tests/uno.dos
clean:: mf-clean
mf-clean: trap-clean
	$(LIBTOOL) --mode=clean rm -f mf
	$(LIBTOOL) --mode=clean rm -f mf-nowin
	rm -f $(mf_c) mfcoerce.h mfd.h mf.p mf.pool
	rm -f $(mf_o) mfextra.c
	rm -f $(mfn_o) mfnowin.c
	rm -f mf.base mf.log
	rm -f mfput.log online.2602gf online.log one.two.log uno.log

# Can't run trap and mptrap in parallel, because both write trap.{log,tfm}.
trap: mf tftopl gftype trap-clean
	@echo ">>> See $(testdir)/mftrap.diffs for example of acceptable diffs." >&2
	$(LN) $(testdir)/trap.mf . # get same filename in log
	-$(SHELL) -c '$(testenv) ./mf --progname=inimf <$(testdir)/mftrap1.in >mftrapin.fot'
	mv trap.log mftrapin.log
	-diff $(testdir)/mftrapin.log mftrapin.log
	-$(SHELL) -c '$(testenv) ./mf --progname=inimf <$(testdir)/mftrap2.in >mftrap.fot'
	mv trap.log mftrap.log
	mv trap.tfm mftrap.tfm
	-diff $(testdir)/mftrap.fot mftrap.fot
	-diff $(testdir)/mftrap.log mftrap.log
	./tftopl ./mftrap.tfm mftrap.pl
	-diff $(testdir)/mftrap.pl mftrap.pl
	$(SHELL) -c '$(testenv) ./gftype -m -i ./trap.72270gf >trap.typ'
	-diff $(testdir)/trap.typ trap.typ

trap-clean:
	rm -f trap.mf trap.base
	rm -f mftrapin.fot mftrapin.log
	rm -f mftrap.fot mftrap.log mftrap.tfm
	rm -f mftrap.pl trap.72270gf trap.typ
# 
# MetaPost
kpse_include metapost.mk
kpse_include mpdir/mpostlib.mk
# 
# TeX
tex_c = texini.c tex0.c tex1.c tex2.c
tex_o = texini.o tex0.o tex1.o tex2.o texextra.o
tex: $(tex_o)
	$(kpathsea_link) $(tex_o) $(socketlibs) $(LOADLIBES)
$(tex_c) texcoerce.h texd.h: tex.p $(web2c_texmf)
	$(web2c) tex
texextra.c: lib/texmfmp.c
	sed s/TEX-OR-MF-OR-MP/tex/ $(srcdir)/lib/texmfmp.c >$@
tex.p tex.pool: tangle tex.web tex.ch
	$(tangle) tex.web tex.ch
check: tex-check
tex-check: trip tex.fmt
# Test truncation (but don't bother showing the warning msg).
	./tex --progname=tex --output-comment="`cat $(srcdir)/PROJECTS`" \
	    $(srcdir)/tests/hello 2>/dev/null \
	  && ./dvitype hello.dvi | grep olaf@infovore.xs4all.nl >/dev/null
# \openout should show up in \write's.
	./tex --progname=tex $(srcdir)/tests/openout && grep xfoo openout.log
# one.two.tex -> one.two.log
	./tex --progname=tex $(srcdir)/tests/one.two && ls -l one.two.log
# uno.dos -> uno.log
	./tex --progname=tex $(srcdir)/tests/uno.dos && ls -l uno.log
	./tex --progname=tex $(srcdir)/tests/just.texi && ls -l just.log
	-./tex --progname=tex $(srcdir)/tests/batch.tex
	./tex --progname=tex --shell $(srcdir)/tests/write18 | grep echo
	TEXMFCNF=../kpathsea \
	  ./tex --mltex --progname=initex --ini $(srcdir)/tests/mltextst
	-./tex </dev/null
	-PATH=`pwd`:$(kpathsea_dir):$(kpathsea_srcdir):$$PATH \
	  WEB2C=$(kpathsea_srcdir) TMPDIR=.. \
	  ./tex --progname=tex '\nonstopmode\font\foo=nonesuch\end'
clean:: tex-clean
tex-clean: trip-clean
	$(LIBTOOL) --mode=clean rm -f tex
	rm -f $(tex_o) $(tex_c) texextra.c texcoerce.h texd.h
	rm -f tex.p tex.pool
	rm -f tex.fmt tex.log
	rm -f hello.dvi hello.log xfoo.out openout.log on.two.log uno.log
	rm -f just.log batch.log write18.log mltextst.log texput.log
	rm -f missfont.log
	rm -rf tfm

trip: dvitype pltotf tftopl tex trip-clean
	@echo ">>> See $(testdir)/trip.diffs for example of acceptable diffs." >&2
	./pltotf $(testdir)/trip.pl trip.tfm
	./tftopl ./trip.tfm trip.pl
	-diff $(testdir)/trip.pl trip.pl
	$(LN) $(testdir)/trip.tex . # get same filename in log
	-$(SHELL) -c '$(testenv) ./tex --progname=initex --ini <$(testdir)/trip1.in >tripin.fot'
	mv trip.log tripin.log
	-diff $(testdir)/tripin.log tripin.log
# May as well test non-ini second time through.
	-$(SHELL) -c '$(testenv) ./tex --progname=tex <$(testdir)/trip2.in >trip.fot'
	-diff $(testdir)/trip.fot trip.fot
# We use $(DIFF) instead of `diff' only for those files where there
# might actually be legitimate numerical differences.
	-$(DIFF) $(DIFFFLAGS) $(testdir)/trip.log trip.log
	$(SHELL) -c '$(testenv) ./dvitype $(dvitype_args) trip.dvi >trip.typ'
	-$(DIFF) $(DIFFFLAGS) $(testdir)/trip.typ trip.typ

trip-clean:
	rm -f trip.tfm trip.pl trip.tex trip.fmt tripin.fot tripin.log
	rm -f trip.fot trip.log trip.dvi trip.typ tripos.tex 8terminal.tex
	rm -rf tfm
# 
# Helper makefile fragment for pdf*tex.
kpse_include pdftexdir/pdftexlib.mk
# 
# Makefile fragments:
kpse_include etexdir/etex.mk
kpse_include omegadir/omega.mk
kpse_include alephdir/aleph.mk
kpse_include pdftexdir/pdftex.mk
kpse_include pdfetexdir/pdfetex.mk
kpse_include xetexdir/xetex.mk
# 
# Common
programs = bibtex ctangle ctie cweave dvicopy dvitomp dvitype gftodvi gftopk \
 gftype mft $(odvicopy) $(odvitype) $(otangle) patgen pktogf pktype pltotf \
 pooltype tangle tftopl tie $(ttf2afm) vftovp vptovf weave
engines = $(tex) $(etex) $(mf) $(mfn) $(mpost) \
          $(omega) $(aleph) \
          $(pdftex) $(pdfetex) \
          $(xetex)

programs: $(programs) $(engines) $(mpware_programs) \
          $(omegafonts_programs) $(otps_programs) $(pdftosrc)

# Additional dependencies for relinking.
# Note that each program and engine already depends on $(web2c_programs).
$(web2c_programs) tangleboot ctangleboot: $(kpathsea) $(proglib)

# 
# Bootstrapping tangle requires making it with itself.  We use the opportunity
# to create an up-to-date tangleboot as well.
tangle: tangle.o
	$(kpathsea_link) tangle.o $(LOADLIBES)
	$(MAKE) $(common_makeargs) tangleboot.p
tangle.c tangle.h: tangle.p
	$(web2c) tangle
# tangle.p is a special case, since it is needed to compile itself.  We
# convert and compile the (distributed) tangleboot.p to make a tangle
# which we use to make the other programs.  We depend on tangleboot, even
# though we might not use it.
tangle.p: tangleboot tangle.web tangle.ch
	WEBINPUTS=$(srcdir) $(TANGLEBOOT) tangle tangle
tangle.web:
	@echo "You seem to be missing tangle.web, perhaps because you" >&2
	@echo "didn't retrieve web.tar.gz, only web2c.tar.gz." >&2
	@echo "You need both." >&2
	@echo >&2
	@echo "web.tar.gz should be available from the" >&2
	@echo "same place that you got web2c.tar.gz." >&2
	@echo "In any case, you can get it from" >&2
	@echo "ftp://ftp.tug.org/tex/web.tar.gz." >&2
	false
clean:: tangle-clean
tangle-clean:
	$(LIBTOOL) --mode=clean rm -f tangle
	rm -f tangle.o tangle.c tangle.h tangle.p

tangleboot: tangleboot.o
	$(kpathsea_link) tangleboot.o $(LOADLIBES)
tangleboot.c tangleboot.h: stamp-tangle $(web2c_programs) $(web2c_common)
	$(web2c) tangleboot
# tangleboot.p is in the distribution
stamp-tangle: tangleboot.p
	date >stamp-tangle
# This is not run unless tangle.web or tangle.ch is changed.
# Only try to run ./tangle if it actually exists, otherwise
# just touch tangleboot.p and build tangle.
tangleboot.p: tangle.web tangle.ch
	if [ -r $(TANGLE) ] || [ -r $(TANGLE).exe ]; then \
	  WEBINPUTS=$(srcdir) $(TANGLE) tangle tangle; \
	  mv tangle.p tangleboot.p; \
	elif [ -r tangleboot.p ]; then \
	  touch tangleboot.p; \
	else \
	  cp $(srcdir)/tangleboot.p .; \
	fi
	date >stamp-tangle
	$(MAKE) $(common_makeargs) tangle
clean:: tangleboot-clean
tangleboot-clean:
	$(LIBTOOL) --mode=clean rm -f tangleboot
	rm -f tangleboot.o tangleboot.c tangleboot.h

# Bootstrapping ctangle requires making it with itself.  We use the opportunity
# to create an up-to-date ctangleboot as well.
ctangle: ctangle.o cweb.o
	$(kpathsea_link) ctangle.o cweb.o $(LOADLIBES)
	$(MAKE) $(common_makeargs) ctangleboot.c cwebboot.c
# ctangle.c is a special case, since it is needed to compile itself.
ctangle.c: ctangleboot cwebdir/ctangle.w cwebdir/ctang-w2c.ch
	CWEBINPUTS=$(srcdir)/cwebdir $(CTANGLEBOOT) ctangle ctang-w2c
cweb.c: ctangleboot cwebdir/common.w cwebdir/comm-w2c.ch
	CWEBINPUTS=$(srcdir)/cwebdir $(CTANGLEBOOT) common comm-w2c cweb.c
clean:: ctangle-clean
clean:: cweb-clean
ctangle-clean:
	$(LIBTOOL) --mode=clean rm -f ctangle
	rm -f ctangle.o ctangle.c
cweb-clean:
	rm -f cweb.o cweb.c

ctangleboot: ctangleboot.o cwebboot.o
	$(kpathsea_link) ctangleboot.o cwebboot.o $(LOADLIBES)
# ctangleboot.c is in the distribution
stamp-ctangle: ctangleboot.c cwebboot.c
ctangleboot.c: cwebdir/ctangle.w cwebdir/ctang-w2c.ch
	if [ -r $(CTANGLE) ] || [ -r $(CTANGLE).exe ]; then \
	  CWEBINPUTS=$(srcdir)/cwebdir $(CTANGLE) ctangle ctang-w2c; \
	  mv ctangle.c ctangleboot.c; \
	elif [ -r ctangleboot.c ]; then \
	  touch ctangleboot.c; \
	else \
	  cp $(srcdir)/ctangleboot.c .; \
	fi
	date >stamp-ctangle
	$(MAKE) $(common_makeargs) ctangle
cwebboot.c: cwebdir/common.w cwebdir/comm-w2c.ch
	if [ -r $(CTANGLE) ] || [ -r $(CTANGLE).exe ]; then \
	  CWEBINPUTS=$(srcdir)/cwebdir $(CTANGLE) common comm-w2c cweb.c; \
	  mv cweb.c cwebboot.c; \
	elif [ -r cwebboot.c ]; then \
	  touch cwebboot.c; \
	else \
	  cp $(srcdir)/cwebboot.c .; \
	fi
	date >stamp-ctangle
	$(MAKE) $(common_makeargs) ctangle
clean:: ctangleboot-clean
clean:: cwebboot-clean
ctangleboot-clean:
	$(LIBTOOL) --mode=clean rm -f ctangleboot
	rm -f ctangleboot.o
cwebboot-clean:
	rm -f cwebboot.o

# Even web2c itself uses the library.
# It's annoying to have to give all the filenames here, 
# but texmfmp.c is an exception.
lib_sources = lib/alloca.c lib/basechsuffix.c lib/chartostring.c \
  lib/eofeoln.c lib/fprintreal.c lib/input2int.c lib/inputint.c lib/main.c \
  lib/openclose.c lib/printversion.c lib/uexit.c lib/usage.c lib/version.c \
  lib/zround.c 
$(proglib): $(lib_sources) stamp-auto
	cd lib && $(MAKE) $(common_makeargs)

# No exceptions in this library.
window_sources = $(srcdir)/window/*.c
$(windowlib): mfd.h $(window_sources)
	cd window && $(MAKE) $(window_makeargs)
window/trap.o: $(srcdir)/window/trap.c
	cd window && $(MAKE) $(common_makeargs) trap.o

# The web2c program consists of several executables.
web2c/fixwrites: web2c/fixwrites.c web2c/kps.c
	cd web2c && $(MAKE) $(common_makeargs) fixwrites
web2c/splitup: web2c/splitup.c web2c/kps.c
	cd web2c && $(MAKE) $(common_makeargs) splitup
web2c/web2c: web2c/main.c web2c/web2c.h web2c/web2c.l web2c/web2c.y web2c/kps.c
	cd web2c && $(MAKE) $(common_makeargs) web2c

kpse_include ../make/tkpathsea.mk

# 
# Making dumps.
all_fmts = tex.fmt $(fmts)
all_bases = mf.base $(bases)
all_mems = mpost.mem $(mems)

dumps: fmts bases mems
fmts: $(all_fmts)
bases: $(all_bases)
mems: $(all_mems)

tex.fmt: tex
	$(dumpenv) $(MAKE) progname=tex files="plain.tex cmr10.tfm" prereq-check
	$(dumpenv) ./tex --progname=tex --jobname=tex --ini \\input plain \\dump </dev/null

#latex.fmt: tex
#	$(dumpenv) $(MAKE) progname=latex files="latex.ltx" prereq-check
#	$(dumpenv) ./tex --progname=latex --jobname=latex --ini \\input latex.ltx </dev/null

olatex.fmt: tex
	$(dumpenv) $(MAKE) progname=olatex files="latex.ltx" prereq-check
	$(dumpenv) ./tex --progname=olatex --jobname=olatex --ini \\input latex.ltx </dev/null

mltex.fmt: tex
	$(dumpenv) $(MAKE) progname=mltex files="plain.tex cmr10.tfm" prereq-check
	$(dumpenv) ./tex --mltex --progname=mltex --jobname=mltex --ini \\input plain \\dump </dev/null

#mllatex.fmt: tex
#	$(dumpenv) $(MAKE) progname=mllatex files="latex.ltx" prereq-check
#	$(dumpenv) ./tex --mltex --progname=mllatex --jobname=mllatex --ini \\input latex.ltx </dev/null

mf.base: mf
	$(dumpenv) $(MAKE) progname=mf files="plain.mf cmr10.mf $(localmodes).mf" prereq-check
	$(dumpenv) ./mf --progname=mf --jobname=mf --ini \\input plain input $(localmodes) dump </dev/null

mpost.mem: mpost
	$(dumpenv) $(MAKE) progname=mpost files=plain.mp prereq-check
	$(dumpenv) ./mpost --progname=mpost --jobname=mpost --ini \\input plain dump </dev/null

# This is meant to be called recursively, with $(files) set.
prereq-check: $(kpathsea_dir)/kpsewhich
	$(kpathsea_dir)/kpsewhich --progname=$(progname) $(files) >/dev/null || $(MAKE) prereq-lose >/dev/null

prereq-lose:
	@echo "You seem to be missing input files necessary to make the" >&2
	@echo "basic formats (some or all of: $(files))." >&2
	@echo "Perhaps you've defined the default paths incorrectly, or" >&2
	@echo "perhaps you have environment variables set pointing" >&2
	@echo "to an incorrect location.  See ../kpathsea/BUGS." >&2
	@echo >&2
	@echo "If you simply do not have the files, you can" >&2
	@echo "retrieve a minimal set of input files from CTAN hosts." >&2
	false

$(kpathsea_dir)/kpsewhich: $(kpathsea)

amstex.fmt: tex
	$(dumpenv) ./tex --progname=amstex --jobname=amstex --ini amstex.ini </dev/null

# Texinfo changes the escape character from `\' to `@'.
texinfo.fmt: tex.fmt
	$(dumpenv) ./tex --progname=texinfo --jobname=texinfo --ini texinfo @dump </dev/null

eplain.fmt: tex.fmt
	touch eplain.aux # Makes cross-reference warnings work right.
	$(dumpenv) ./tex --progname=eplain --jobname=eplain --ini \&./tex eplain \\dump </dev/null

# 
install: install-exec install-data
install-exec:: install-programs @FMU@ install-links
install-data:: install-tex-data install-mf-data install-mpost-data
install-dumps: install-tex-dumps install-mf-dumps install-mpost-dumps

# Installation directories.
$(bindir)::
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(bindir)
$(texpooldir)::
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(texpooldir)
$(mfpooldir)::
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(mfpooldir)
$(mppooldir)::
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(mppooldir)
$(fmtdir)::
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(fmtdir)
$(basedir)::
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(basedir)
$(memdir)::
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(memdir)
$(web2cdir)::
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(web2cdir)

# Installing the programs.
install-programs: $(programs) $(bindir)
	for p in $(programs); do $(INSTALL_LIBTOOL_PROG) $$p $(bindir); done

# Installation of each of the three main engines.
install-tex: install-tex-exec install-tex-data
install-mf: install-mf-exec install-mf-data
install-mpost: install-mpost-exec install-mpost-data

install-tex-exec: @FMU@ install-tex-links
install-mf-exec: @FMU@ install-mf-links
install-mpost-exec: @FMU@ install-mpost-links

install-tex-data: install-tex-pool @FMU@ install-tex-dumps
install-mf-data: install-mf-pool @FMU@ install-mf-dumps
install-mpost-data: install-mpost-pool @FMU@ install-mpost-dumps

install-tex-dumps: install-tex-fmts
install-mf-dumps: install-mf-bases
install-mpost-dumps: install-mpost-mems

# Actual binaries.
install-programs: install-tex-programs
install-tex-programs: tex $(bindir)
	tex="tex"; \
	  for p in $$tex; do $(INSTALL_LIBTOOL_PROG) $$p $(bindir); done
install-programs: install-mf-programs
install-mf-programs: mf $(mfn) $(bindir)
	mf="mf $(mfn)"; \
	  for p in $$mf; do $(INSTALL_LIBTOOL_PROG) $$p $(bindir); done
install-programs: install-mpost-programs
install-mpost-programs: mpost $(bindir)
	mpost="mpost"; \
	  for p in $$mpost; do $(INSTALL_LIBTOOL_PROG) $$p $(bindir); done

# The links to {mf,mp,tex} for each format and for {ini,vir}{mf,mp,tex},
# plus the equivalents for e-TeX, Omega, and pdf[ex]TeX.
install-links: install-tex-links
install-tex-links: install-tex-programs
	#cd $(bindir) && (rm -f initex virtex; \
	#  $(LN) tex initex; $(LN) tex virtex)

install-links: install-mf-links
install-mf-links: install-mf-programs
	#cd $(bindir) && (rm -f inimf virmf; \
	#  $(LN) mf inimf; $(LN) mf virmf)

install-links: install-mpost-links
install-mpost-links: install-mpost-programs
	#cd $(bindir) && (rm -f inimpost virmpost; \
	#  $(LN) mpost inimpost; $(LN) mpost virmpost)

# Always do plain.*, so examples from the TeXbook (etc.) will work.
install-fmts: install-tex-fmts
install-tex-fmts: fmts $(fmtdir)
	fmts="$(all_fmts)"; \
	  for f in $$fmts; do $(INSTALL_DATA) $$f $(fmtdir)/$$f; done
	cd $(fmtdir) && (rm -f plain.fmt; $(LN) tex.fmt plain.fmt)
	fmts="$(fmts)"; \
	  for f in $$fmts; do base=`basename $$f .fmt`; \
	    (cd $(bindir) && (rm -f $$base; $(LN) tex $$base)); done

install-bases: install-mf-bases
install-mf-bases: bases $(basedir)
	bases="$(all_bases)"; \
	  for f in $$bases; do $(INSTALL_DATA) $$f $(basedir)/$$f; done
	cd $(basedir) && (rm -f plain.base; $(LN) mf.base plain.base)
	bases="$(bases)"; \
	  for f in $$bases; do base=`basename $$f .base`;\
	    (cd $(bindir) && (rm -f $$base; $(LN) mf $$base)); done

install-mems: install-mpost-mems
install-mpost-mems: mems $(memdir)
	mems="$(all_mems)"; \
	  for f in $$mems; do $(INSTALL_DATA) $$f $(memdir)/$$f; done
	cd $(memdir) && (rm -f plain.mem; $(LN) mpost.mem plain.mem)
	mems="$(mems)"; \
	  for f in $$mems; do base=`basename $$f .mem`; \
            (cd $(bindir) && (rm -f $$base; $(LN) mpost $$base)); done

install-tex-pool: tex.pool $(texpooldir)
	$(INSTALL_DATA) tex.pool $(texpooldir)/tex.pool
install-mf-pool: mf.pool $(mfpooldir)
	$(INSTALL_DATA) mf.pool $(mfpooldir)/mf.pool
install-mpost-pool: mp.pool $(mppooldir)
	$(INSTALL_DATA) mp.pool $(mppooldir)/mp.pool

# Auxiliary files.
install-data:: $(web2cdir)
	cd doc && $(MAKE) $(install_makeargs) install-data
	cd man && $(MAKE) $(install_makeargs) install-data
	$(INSTALL_DATA) $(srcdir)/tiedir/tie.1 $(man1dir)/tie.$(manext)
	$(INSTALL_DATA) $(srcdir)/ctiedir/ctie.1 $(man1dir)/ctie.$(manext)
	$(INSTALL_DATA) fmtutil.cnf $(web2cdir)/fmtutil.cnf

# Dummy target.
uninstall uninstall-exec uninstall-data:
	@echo "*** Warning: uninstall is a dummy target in web2c/Makefile"

# The distribution comes with up-to-date .info* files,
# so this should never be used unless something goes wrong
# with the unpacking, or you modify the manual.
doc/web2c.info:
	cd doc && $(MAKE) info
info dvi:
	cd doc && $(MAKE) $@

# Manual pages
manpages:
	cd man && $(MAKE) all

# 
# make dist won't work for anyone but me. Sorry.

@MAINT@all-dist: dist web-dist etex-dist omega-dist aleph-dist pdftex-dist libs-dist
@MAINT@
@MAINT@distname = web2c
@MAINT@program_files = PROJECTS *.ac *.ch tangleboot.p
@MAINT@# The files that omega places in the main directory.
@MAINT@omega_files = omegamem.h {odvicopy,odvitype,otangle}.{web,ch}
@MAINT@
@MAINT@triptrapdiffs: triptrap/trip.diffs triptrap/mftrap.diffs triptrap/mptrap.diffs
@MAINT@triptrap/trip.diffs: tex
@MAINT@	$(MAKE) trip | tail +1 >triptrap/trip.diffs
@MAINT@triptrap/mftrap.diffs: mf
@MAINT@	$(MAKE) trap | tail +1 >triptrap/mftrap.diffs
@MAINT@triptrap/mptrap.diffs: mpost
@MAINT@	$(MAKE) mptrap | tail +1 >triptrap/mptrap.diffs
@MAINT@
@MAINT@tests/check.log: $(programs) $(engines)
@MAINT@	$(MAKE) check | tail +1 >tests/check.log
@MAINT@
@MAINT@dist_subdirs = doc lib $(mpware) tests web2c window
@MAINT@pre-dist-$(distname): depend triptrapdiffs tests/check.log tangleboot.p
@MAINT@	cd web2c && $(MAKE) lex.yy.c y_tab.c
@MAINT@	cd doc && $(MAKE) doc dvi
@MAINT@
@MAINT@post-dist-$(distname): 
@MAINT@# Make the subdirectories.
@MAINT@	for d in $(dist_subdirs); do \
@MAINT@	  mkdir -p $(texk_distdir)/$(distname)/$$d; done
@MAINT@# Link files in subdirectories.
@MAINT@	for f in `find $(dist_subdirs)		\
@MAINT@		       \(    -name README	\
@MAINT@			  -o -name convert	\
@MAINT@			  -o -name ChangeLog	\
@MAINT@			  -o -name 'coerce.*'	\
@MAINT@			  -o -name ref.aux	\
@MAINT@			  -o -name ref.bbl	\
@MAINT@			  -o -name ref.tex	\
@MAINT@			  -o -name ref.txi	\
@MAINT@			  -o -name texinfo.bst	\
@MAINT@			  -o -name web2c.cps	\
@MAINT@			  -o -name web2c.aux	\
@MAINT@			  -o -name '*.asm'	\
@MAINT@			  -o -name '*.[chly]'	\
@MAINT@			  -o -name '*.defines'	\
@MAINT@			  -o -name '*.in'	\
@MAINT@			  -o -name '*.info*'	\
@MAINT@	                  -o -name '*.map'	\
@MAINT@			  -o -name '*.sed'	\
@MAINT@			  -o -name '*.tcx'	\
@MAINT@			  -o -name '*.texi'	\
@MAINT@		       \) -print`; do		\
@MAINT@	  ln $$f $(distdir)/`dirname $$f`; done
@MAINT@# Handle the dependeny files in the subdirectories.
@MAINT@	for d in lib $(mpware) web2c window; do \
@MAINT@	  cp -p $$d/depend.mk $(texk_distdir)/$(distname)/$$d; done
@MAINT@# Other subdirectories.
@MAINT@	mkdir $(distdir)/triptrap && cd $(distdir)/triptrap && \
@MAINT@	  for i in ../../../../triptrap/*; do \
@MAINT@	    if test -f $$i; then ln -s $$i .; fi; done
@MAINT@	mkdir $(distdir)/tiedir && cd $(distdir)/tiedir && \
@MAINT@	  for i in ../../../../tiedir/*; do \
@MAINT@	    if test -f $$i; then ln -s $$i .; fi; done
@MAINT@	mkdir $(distdir)/ctiedir && cd $(distdir)/ctiedir && \
@MAINT@	  for i in ../../../../ctiedir/*; do \
@MAINT@	    if test -f $$i; then ln -s $$i .; fi; done
@MAINT@	mkdir $(distdir)/cwebdir && cd $(distdir)/cwebdir && \
@MAINT@	  for i in ../../../../cwebdir/*; do \
@MAINT@	    if test -f $$i; then ln -s $$i .; fi; done
@MAINT@	mkdir $(distdir)/cwebdir/examples && cd $(distdir)/cwebdir/examples && \
@MAINT@	  for i in ../../../../cwebdir/examples/*; do \
@MAINT@	    if test -f $$i; then ln -s $$i .; fi; done
@MAINT@	mkdir $(distdir)/man && cd $(distdir)/man && \
@MAINT@	  for i in ../../../../man/*; do \
@MAINT@	    if test -f $$i; then ln -s $$i .; fi; done;
@MAINT@	cd $(distdir)/man && rm -f *.1 Makefile sedscript
@MAINT@	rm -f $(distdir)/window/x11.c
@MAINT@	rm -f $(distdir)/tests/patgen.in
@MAINT@	cd $(distdir)/tests && (rm just.texi; ln -s ../../../../tests/* .; rm -f x* CVS)
@MAINT@	cd $(distdir)/tests && rm -f missfont.log ptmr.mpx io.tex exampl.b??
@MAINT@# We supply the flex/bison output in case the user can't generate them.
@MAINT@	cd $(distdir)/web2c; ../../../../../rename 's/$$/-dist/' lex.yy.c y_tab.[ch]
@MAINT@# Remove cruft.
@MAINT@	cd $(distdir); rm -f $(addsuffix .c, $(programs) tangleboot)
@MAINT@	cd $(distdir); rm -f $(addsuffix .h, $(programs) tangleboot)
@MAINT@	cd $(distdir); rm -f etex.ch omega.ch aleph.ch
@MAINT@	cd $(distdir); rm -f pdftex.ch pdfetex.ch
@MAINT@	cd $(distdir); bash -c "rm -f tests/x* tests/allbib.{bbl,blg,dvi,log}"
@MAINT@	cd $(distdir)/tests && ln -s ../../../../tests/xampl.bib .
@MAINT@	cd $(distdir); bash -c "rm -f $(omega_files) alephmem.h"
@MAINT@	cd $(distdir); bash -c "rm -f cweb.c *{coerce,d}.h"
@MAINT@	cd $(distdir); bash -c "rm -f omega*.c aleph*.c"
@MAINT@	cd $(distdir); bash -c "rm -f tex*.c etex*.c"
@MAINT@	cd $(distdir); bash -c "rm -f pdftex*.c pdfetex*.c"
@MAINT@	cd $(distdir); bash -c "rm -f mf*.c mp*.c"
@MAINT@	cd $(distdir); bash -c "rm -f macnames.c *extra.c"
@MAINT@	touch $(distdir)/doc/*.info*
@MAINT@
@MAINT@web-dist:
@MAINT@	rm -rf $(top_distdir)
@MAINT@	mkdir -p $(distdir)
@MAINT@	for f in *.web; do ln $$f $(distdir); done
@MAINT@	rm -f $(distdir)/etex.web $(distdir)/omega.web $(distdir)/aleph.web
@MAINT@	rm -f $(distdir)/pdftex.web $(distdir)/pdfetex.web
@MAINT@	cd $(distdir); bash -c "rm -f $(omega_files)"
@MAINT@	chmod -w $(distdir)/*
@MAINT@	GZIP=-9 tar czf web-$(version).tar.gz $(top_distdir)
@MAINT@	rm -rf $(top_distdir)
@MAINT@
@MAINT@etex-dist: etexdir/etex.version
@MAINT@	rm -rf $(top_distdir)
@MAINT@	mkdir -p $(distdir)/etexdir
@MAINT@	cp -rp etexdir/* $(distdir)/etexdir
@MAINT@	rm -rf $(distdir)/etexdir/CVS $(distdir)/etexdir/*/CVS
@MAINT@	rm -f $(distdir)/etexdir/etexextra.h $(distdir)/etexdir/etex.version
@MAINT@	GZIP=-9 tar czf web2c-$(version)-etex-`cat etexdir/etex.version`.tar.gz $(top_distdir)
@MAINT@	rm -rf $(top_distdir)
@MAINT@
@MAINT@omega-dist:
@MAINT@	rm -rf $(top_distdir)
@MAINT@	mkdir -p $(distdir)/omegadir
@MAINT@	mkdir -p $(distdir)/omegaware $(distdir)/omegafonts $(distdir)/otps
@MAINT@	cp -p omegadir/* $(distdir)/omegadir
@MAINT@	cd omegafonts && $(MAKE) lex.yy.c y_tab.c
@MAINT@	for f in omegafonts/*.[chly] omegafonts/*.in; do cp -p $$f $(distdir)/omegafonts; done
@MAINT@	cp -p omegaware/* $(distdir)/omegaware
@MAINT@	cd otps && $(MAKE) lex.yy.c y_tab.c
@MAINT@	for f in otps/*.[chly] otps/*.in; do cp -p $$f $(distdir)/otps; done
@MAINT@	cp -p otps/mkocp otps/mkofm $(distdir)/otps
@MAINT@# We supply the flex/bison output in case the user can't generate them.
@MAINT@	cd $(distdir)/omegafonts; ../../../../../rename 's/$$/-dist/' lex.yy.c y_tab.[ch]
@MAINT@	cd $(distdir)/otps; ../../../../../rename 's/$$/-dist/' lex.yy.c y_tab.[ch]
@MAINT@	GZIP=-9 tar czf web2c-$(version)-omega-`cat omegadir/omega.version`.tar.gz $(top_distdir)
@MAINT@	rm -rf $(top_distdir)
@MAINT@
@MAINT@aleph-dist: alephdir/aleph.version
@MAINT@	rm -rf $(top_distdir)
@MAINT@	mkdir -p $(distdir)/alephdir
@MAINT@	cp -p alephdir/* $(distdir)/alephdir
@MAINT@	@echo "*** Removing generated files ***"
@MAINT@	rm -f $(distdir)/alephdir/alephextra.h
@MAINT@	GZIP=-9 tar czf web2c-$(version)-aleph-`cat alephdir/aleph.version`.tar.gz $(top_distdir)
@MAINT@	rm -rf $(top_distdir)
@MAINT@
@MAINT@pdftex-dist: pdftexdir/pdftex.version
@MAINT@	rm -rf $(top_distdir)
@MAINT@	mkdir -p $(distdir)/pdftexdir $(distdir)/pdfetexdir
@MAINT@	cp -rp pdftexdir/* $(distdir)/pdftexdir
@MAINT@	cp -rp pdfetexdir/* $(distdir)/pdfetexdir
@MAINT@	rm -rf $(distdir)/pdf*texdir/CVS $(distdir)/pdf*texdir/*/CVS
@MAINT@	rm -f $(distdir)/pdf*texdir/Makefile
@MAINT@	rm -f $(distdir)/pdf*texdir/*.[oa]
@MAINT@	rm -f $(distdir)/pdf*texdir/*/config.*
@MAINT@	rm -f $(distdir)/pdf*texdir/*/Makefile
@MAINT@	rm -f $(distdir)/pdf*texdir/*/*.[oa]
@MAINT@	rm -f $(distdir)/pdf*texdir/*/*/Makefile
@MAINT@	rm -f $(distdir)/pdf*texdir/*/*/*.[ao]
@MAINT@	rm -f $(distdir)/pdf*texdir/*/*/pdftoepdf.cc
@MAINT@	rm -f $(distdir)/pdf*texdir/*/*/epdf.h
@MAINT@	rm -f $(distdir)/pdf*texdir/pdf*texextra.h
@MAINT@	rm -f $(distdir)/pdf*texdir/pdf*tex.version
@MAINT@	mkdir -p $(top_distdir)/libs/xpdf
@MAINT@	cp -rp $(top_srcdir)/../../libs/xpdf/* $(top_distdir)/libs/xpdf
@MAINT@	rm -rf $(top_distdir)/libs/xpdf/CVS $(top_distdir)/libs/xpdf/*/CVS
@MAINT@	rm -f $(top_distdir)/libs/xpdf/Makefile
@MAINT@	rm -f $(top_distdir)/libs/xpdf/config.*
@MAINT@	rm -f $(top_distdir)/libs/xpdf/aconf.h
@MAINT@	rm -f $(top_distdir)/libs/xpdf/*/Makefile
@MAINT@	rm -f $(top_distdir)/libs/xpdf/*/*.[oa]
@MAINT@	rm -f $(top_distdir)/libs/xpdf/*/c-auto.h
@MAINT@	GZIP=-9 tar czf web2c-$(version)-pdftex-`cat pdftexdir/pdftex.version`.tar.gz $(top_distdir)
@MAINT@	rm -rf $(top_distdir)
@MAINT@
@MAINT@libs-dist:
@MAINT@	rm -rf $(top_distdir)
@MAINT@	mkdir -p $(libs_distdir)/zlib
@MAINT@	cp -rp $(top_srcdir)/../../libs/zlib/* $(libs_distdir)/zlib
@MAINT@	mkdir -p $(libs_distdir)/libpng
@MAINT@	cp -rp $(top_srcdir)/../../libs/libpng/* $(libs_distdir)/libpng
@MAINT@	mkdir -p $(libs_distdir)/md5
@MAINT@	cp -rp $(top_srcdir)/../../libs/md5/* $(libs_distdir)/md5
@MAINT@	rm -f $(libs_distdir)/*/Makefile
@MAINT@	rm -f $(libs_distdir)/*/config.*
@MAINT@	rm -f $(libs_distdir)/*/c-auto.h
@MAINT@	rm -f $(libs_distdir)/*/*.[oa]
@MAINT@	GZIP=-9 tar czf web2c-$(version)-pdftexlibs.tar.gz $(top_distdir)
@MAINT@	rm -rf $(top_distdir)

kpse_include ../make/dist.mk

kpse_include ../make/config.mk

@MAINT@$(srcdir)/configure: $(srcdir)/withenable.ac

# 

installcheck:
	cd $(srcdir)/tests && bibtex allbib
	mf '\mode:=ljfour; input logo10' && tftopl logo10.tfm >/dev/null
	tex '\nonstopmode \tracingstats=1 \input story \bye'

# 
# Cleaning.
all_subdirs = doc lib man $(mpware) web2c window $(omegafonts) $(otps) $(pdftexdir) $(pdfetexdir) $(mpostdir)

# Having a multiple-target rule with the subdir loop fails because of
# the dependencies introduced by clean.mk.  Yet, we want the
# dependencies here at the top level so that distclean will run the
# clean rules, etc.  So, sigh, put the subdir loop in each target and
# only run it if we have a Makefile.  Alternatively, we could do as
# Automake does.

mostlyclean:: tangleboot-clean ctangleboot-clean
	test ! -r lib/Makefile \
	  || for d in $(all_subdirs); do (cd $$d && $(MAKE) $@); done
clean::
	test ! -r lib/Makefile \
	  || for d in $(all_subdirs); do (cd $$d && $(MAKE) $@); done
	rm -f *.log *.fmt *.base *.mem *.fls *.ofl *.aux
distclean::
	test ! -r lib/Makefile \
	  || for d in $(all_subdirs); do (cd $$d && $(MAKE) $@); done
	rm -f fmtutil.cnf
extraclean::
	test ! -r lib/Makefile \
	  || for d in $(all_subdirs); do (cd $$d && $(MAKE) $@); done
maintainer-clean::
	test ! -r lib/Makefile \
	  || for d in $(all_subdirs); do (cd $$d && $(MAKE) $@); done

kpse_include ../make/clean.mk

@MAINT@depend::
@MAINT@	for d in lib $(mpware) web2c window $(otps); do \
@MAINT@	  (cd $$d && $(MAKE) depend); done

kpse_include ../make/rdepend.mk
kpse_include depend.mk

# 
# Local variables:
# page-delimiter: "^# \f"
# End: