summaryrefslogtreecommitdiff
path: root/Build/source/texk/windvi/mksedscript.perl
blob: 2934e612445d4a462820c0e6b0506c5c7358cacc (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
# Values from c-auto.h

$mk_NOTOOL='';
$mk_GREY='';
$mk_BUTTONS='';
$mk_PS_GS='';
$mk_GS_PATH='gswin32c';
$mk_PS_DPS='';
$mk_PS_NEWS='';
$mk_A4='';

# HyperTeX: There appears to be no (easy) way to disable this
$mk_HTEX=1;

# Kpathsea defaults, they are #if'ed in the source but there is no
# config option to disable them.
$mk_SELFILE=1;
$mk_KPATHSEA=1;

# Optional values from CFLAGS

$mk_MFMODE='unspecified';
$mk_BDPI=600;
$mk_DEFAULT_FONT_SIZES='m0:m0.5:m1:m2:m3:m4:m5';
$mk_SHRINK=8;

&main;

exit 0;

sub arg_cflags 
{
    while(<@ARGV>) {
	if ($_ =~ m/-D(.*)=(.*)/) {
	    eval ("\$mk_$1=$2\n");
	}
	elsif ($_ =~ m/-D(.*)/ ) {
	    eval ("\$mk_$1=1\n");
	}
    }
}

sub cauto_cflags
{
    open IN, "<c-auto.h";
    while (<IN>) {
	if ($_ =~ m/#define\s+(\S+)\s*=\s*(\S+)/ ) {
	    eval("\$mk_$1=$2");
	}
    }
    close IN;
}

sub main
{
    &arg_cflags();
    &cauto_cflags();

    if ($mk_NOTOOL ne '') {
	$mk_BUTTONS='';
    }
    if ($mk_GREY eq '') {
	print  "/^#ifgrey/,/^#/d\n";		
    }
    if ($mk_BUTTONS eq '') {
	print  "/^#ifbuttons/,/^#/d\n";	
    }
    if ($mk_PS_DPS eq '') {
	print  "/^#ifdps/,/^#/d\n";		
    }
    if ($mk_PS_NEWS eq '') {
	print  "/^#ifnews/,/^#/d\n";		
    }
    if ($mk_HTEX eq '') {
	print  "/^#ifhyper/,/^#/d\n";		
    }
    if ($mk_NOGRID ne '') {
	print "/^#ifgrid/,/^#/d\n";
    }

    if ($mk_KPATHSEA eq '') {
	print "/^#ifkpathsea/,/^#/d\n";
    }
    else {
	print "/^#ifnokpathsea/,/^#/d\n";
    }

# -DNOSELFILE is supposed to override everything
    if ($mk_NOSELFILE == 1) {
	print "/^#ifselfile/,/^#/d\n";
    }
    elsif ($$mk_SELFILE == 1) {
	print "/^#ifnoselfile/,/^#/d\n";
    }

# See HTEX comment above    
# if test -z "$mk_HAVE_LIBWWW" || test -z "$mk_HAVE_WWWLIB_H";
# 				then echo '/^#ifhyper/,/^#/d';		fi

# Process remaining PostScript emulation arguments

    if ($mk_PS_GS eq '') {
	print "/^#ifghost/,/^#/d\n";
    }
    else {
	print "s^\@GS_PATH\@^$mk_GS_PATH^\n";
    }

    if ($mk_PS_GS ne '' || $mk_PS_DPS ne '' || $mk_PS_NEWS ne '') {
	$mk_PS='y';
	print "/^#ifnops/,/^#/d\n";
    }
    else {
	$mk_PS='';
	print "/^#ifps/,/^#/d\n";
    }

# Miscellaneous args

    if ($mk_A4 ne '') {
	print "s/\@DEFAULT_PAGE_SIZE\@/21 x 29.7 cm (A4 size)/\n";
	print "s/\@DEFAULT_UNIT\@/cm \" (centimeters)\"/\n";
    }
    else {
	print "s/\@DEFAULT_PAGE_SIZE\@/8.5 x 11 inches/\n";
	print "s/\@DEFAULT_UNIT\@/in \" (inches)\"/\n";
    }

    print "s^\@MFMODE\@^$mk_MFMODE^\n";
    print "s/\@BDPI\@/$mk_BDPI/\n";
    print "s/\@SHRINK\@/$mk_SHRINK/\n";

    $tmp = "s/\@DEFAULT_FONT_SIZES\@/$mk_DEFAULT_FONT_SIZES/";
    $tmp =~ s/:/ :\\\\\\/g;
    print "$tmp\n";
# Remove all remaining '#' lines

    print	"/^#/d\n";

# Done

    exit 0;
}