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
|
#
# This Plan 9 mkfile is for ``easy'' building.
# It worked for Ghostscript 8.53.
#
# This mkfile consists of two parts: the first part builds the gs executable,
# the second unpacks the gs distribution and sets configuration parameters.
#
# Place this mkfile in the root directory of the gs distribution (the gsX.XX dir)
# Edit the drivers list below, and mk fake-make to let gs configure
# itself. Fake-make doesn't actually build very much.
#
# Then you can run mk normally.
#
# Be sure to have the jpeg, libpng, and zlib subdirectories before starting.
# These have been included in recent gs tar files so we do not maintain
# our own anymore.
#
# Each time you change the drivers list you must rerun mk fake-make
# before building.
#
# If you want to try out a new GS distribution, you should be able
# to mk try-X.XX, test it out, and then do mk install-X.XX, where X.XX
# is the version number (e.g. 5.70). If outside BL, you may have to edit the
# scripts to remove some local dependencies (e.g. calling outside and the
# cpu call to thresher, alpha to make mips.h, alpha.h).
#
# Recent versions of src/gxshade1.c cause the compiler to run out
# of registers. Brucee is looking into this. In the meantime, use this
# replacement:
#
# private inline void
# make_other_poles(patch_curve_t curve[4])
# {
# int i, j;
#
# for (i = 0; i < 4; i++) {
# j = (i + 1) % 4;
# curve[i].control[0].x = (curve[i].vertex.p.x * 2 + curve[j].vertex.p.x);
# curve[i].control[0].x /= 3;
# curve[i].control[0].y = (curve[i].vertex.p.y * 2 + curve[j].vertex.p.y);
# curve[i].control[0].y /= 3;
# curve[i].control[1].x = (curve[i].vertex.p.x + curve[j].vertex.p.x * 2);
# curve[i].control[1].y /= 3;
# curve[i].control[1].y = (curve[i].vertex.p.y + curve[j].vertex.p.y * 2);
# curve[i].control[1].y /= 3;
# curve[i].straight = true;
# }
# }
#
# (the original includes the /3 in the big expressions).
#
# src/gxshade6.c also needs editing to remove use of the
# vlong , operator on some architectures.
#
# you may need to change this line in gs/src/gshtscr.c:
# // sample = (int) (value * max_ht_sample) + max_ht_sample;
# to
# sample = (vlong)(value * max_ht_sample) + max_ht_sample;
</$objtype/mkfile
BIN=/$objtype/bin
TARG=gs
OFILES=\
obj/gs.$O\
`{sed 's#^./obj/(.*)\.o .*#obj/\1.$O#' src/ld.tr >[2] /dev/null | sort}
# The first driver is the default.
DRIVERS=\
plan9\
bj10e\
bjc600\
bjc800\
cdj1600\
cdj670\
cdj850\
cdj890\
dfaxlow\
epsonc\
epswrite\
inferno\
jpeg\
jpeggray\
laserjet\
ljet2p\
ljet3\
ljet3d\
ljet4\
pbm\
pbmraw\
pdfwrite\
pgm\
pgmraw\
plan9bm\
pnm\
pnmraw\
ppm\
ppmraw\
pswrite\
stcolor\
tiffg32d\
tiffg3\
tiffg4\
HFILES=$objtype.h\
arch.h\
# enforce some startup conditions
x=`{mkdir obj >[2]/dev/null; mv jpeg/jmorecfg.h jpeg/jmorecfg.h.save >[2] /dev/null}
</sys/src/cmd/mkone
UPDATE=\
/386/bin/gs\
/sys/man/1/gs\
/rc/bin/ps2pdf\
/rc/bin/pdf2ps\
/sys/man/1/ps2pdf\
update:V:
update $UPDATEFLAGS $UPDATE `{cat lsr}
CC=pcc
CFLAGS=-c -DPlan9 -D_POSIX_SOURCE -D_BSD_EXTENSION\
-I. -Isrc -Ijpeg -Izlib -Iicclib -DT$objtype '-DGS_INIT="gs_init.ps"'
LD=pcc
obj/gconfig.$O obj/gconf.$O obj/gscdef.$O\
obj/gscdefs.$O obj/iconf.$O obj/iconfig.$O: src/gconfig.h
obj/%.$O: icclib/%.c
$CC $CFLAGS icclib/$stem.c; mv $stem.$O obj
obj/%.$O: jpeg/%.c
$CC $CFLAGS jpeg/$stem.c; mv $stem.$O obj
obj/%.$O: zlib/%.c
$CC $CFLAGS zlib/$stem.c; mv $stem.$O obj
obj/%.$O: src/%.c
$CC $CFLAGS src/$stem.c; mv $stem.$O obj
#if possible, use genarch to build $objtype.h; it must run on same cpu type.
#if not, try to use a default header for the target architecture.
$objtype.h: $O.genarch
if(~ $objtype $cputype) {
./$O.genarch $target
rm -f $O.genarch
}
if not {
if (test -r default.$objtype.h)
cp default.$objtype.h $target && chmod 664 $target
if not {
echo 'no default header file for target architecture'
echo 'run mk on the target architecture to build one'
exit false
}
}
$O.genarch:U: src/genarch.c
if(~ $objtype $cputype) {
rfork e
objtype=$cputype
pcc -DHAVE_LONG_LONG -B -o $O.genarch src/genarch.c
}
if not
status=''
libinstall:V:
cp lib/* /sys/lib/ghostscript
nuke clean:V:
rm -f *.[$OS] obj/* [$OS].out y.tab.? y.debug y.output $TARG src/plan9.mak
#################################################################################
fake-make:V: src/plan9.mak src/plan9-aux.mak fakecc
cp jpeg/jmorecfg.h.save jpeg/jmorecfg.h
ape/psh -c 'CC=fakecc make -f src/plan9.mak'
rm -f jpeg/jmorecfg.h
cp obj/*.c obj/*.h obj/ld.tr src
rm -f src/arch.h
rm -f obj/*.o
rm -f obj/*.c
rm -f fakecc
real-make:V: src/plan9.mak src/plan9-aux.mak
ape/psh -c 'CC=cc make -f src/plan9.mak'
fakecc:V:
echo '#!/bin/rc
if(~ ./obj/genconf $* || ~ ./obj/genarch $* || ~ ./obj/echogs $*) cc $*
status='''' ' >$target
chmod +x $target
src/plan9.mak: src/unixansi.mak /sys/src/cmd/gs/contrib9.mak src/contrib.mak
devlist='$(DD)'^$DRIVERS^'.dev'
devlist=$"devlist
sed 's#^GS_LIB_DEFAULT=.*#GS_LIB_DEFAULT=/sys/lib/ghostscript:/sys/lib/ghostscript/font:/sys/lib/postscript/font#
s#^XCFLAGS=.*#XCFLAGS=-D_BSD_EXTENSION -DPlan9#
s#^CFLAGS_STANDARD=.*#CFLAGS_STANDARD=#
s#^include \$\(.*\)/(.*)#include src/\1#
s#unix-aux.mak#plan9-aux.mak#
s#gsdatadir *=.*#gsdatadir=/sys/src/cmd/gs#
s#DEVICE_DEVS=.*#DEVICE_DEVS='$devlist'#
s#(DEVICE_DEVS[0-9]+)=.*#\1=#' $prereq >$target
src/plan9-aux.mak: src/unix-aux.mak
sed 's#^INCLUDE=.*#INCLUDE=/sys/include/ape#' $prereq >$target
try-%:V: gs%/$O.out
bind gs$stem/$O.out /bin/gs
bind -b gs$stem/lib /sys/lib/ghostscript
echo 'give it a whirl'
gs([0-9]+\.[0-9]+)/$O.out:R: gs\1/src
@{ cd gs$stem1
# for(i in jpeg zlib libpng)
# bind -c ../$i $i
if(! test -f src/ld.tr)
mk fake-make
cp ../arch.h .
rm -f obj/*.c
mk $O.out
# for(i in jpeg zlib libpng)
# unmount $i || status=''
}
gs%/src: ghostscript-%.tar.gz
rm -rf gs$stem
gunzip < ghostscript-$stem.tar.gz | tar x
mv ghostscript-$stem gs$stem
chmod g+w gs$stem/* gs$stem/*/*
# local drivers
cp src/gdevifno.c src/gdevplan9.c src/gdevcd8.c gs$stem/src
# local conventions
ed gs$stem/lib/gs_init.ps <fixSAFER.ed
mkdir -p gs$stem/^(jpeg obj zlib libpng)
# rm -rf gs$stem/^(jpeg obj zlib libpng)^/*
echo '<../mkfile' >gs$stem/mkfile
cp default.*.h gs$stem
@{cd gs$stem; mk startover}
ghostscript-%.tar.gz:
#outside
#hget -o $target http://download.sourceforge.net/ghostscript/$target
hget -o $target ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/gs^`{echo $stem | sed 's/\.//'}^/$target
#ftpfs -a $user^'@' ftp.cs.wisc.edu
#cp /n/ftp/ghost/aladdin/*/ghostscript-$stem.tar.gz .
startover:V:
rm -rf obj/*
rm -f src/ld.tr
rm -f src/plan9.mak src/plan9-aux.mak
install-%:V:
unmount /bin/gs || status=''
unmount /sys/lib/ghostscript || status=''
mk installsrc-$stem
cpu -h thresher -c 'mk mips.h' || status=''
cpu -h alpha -c 'mk alpha.h' || status=''
mk all
mk installall
for(i in lib/*.ps)
if(! cmp $i /sys/lib/ghostscript/^`{basename $i} >/dev/null)
cp $i /sys/lib/ghostscript
cp /sys/lib/ghostscript/pdf_sec-ps.bak /sys/lib/ghostscript/pdf_sec.ps
installsrc-%:V: gs%/$O.out
pwd=`{pwd}
# don't accidentally do this from gsX.XX
if(! ~ $pwd */gs)
echo 'i don''t think you meant to do that' && exit oops
tocopy=(doc examples icclib lib man obj src zlib jpeg libpng)
if(! cmp src/version.mak gs$stem/src/version.mak) {
rm -rf $tocopy
@{cd gs$stem; tar c $tocopy} | tar xT
mk clean
}
status=''
clean-%:V:
for (i in gs$stem/*)
unmount $i >[2]/dev/null || status=''
rm -rf gs$stem ghostscript-$stem.tar.gz
|