2 # This Plan 9 mkfile is for ``easy'' building.
3 # It worked for Ghostscript 8.53.
5 # This mkfile consists of two parts: the first part builds the gs executable,
6 # the second unpacks the gs distribution and sets configuration parameters.
8 # Place this mkfile in the root directory of the gs distribution (the gsX.XX dir)
9 # Edit the drivers list below, and mk fake-make to let gs configure
10 # itself. Fake-make doesn't actually build very much.
12 # Then you can run mk normally.
14 # Be sure to have the jpeg, libpng, and zlib subdirectories before starting.
15 # These have been included in recent gs tar files so we do not maintain
18 # Each time you change the drivers list you must rerun mk fake-make
21 # If you want to try out a new GS distribution, you should be able
22 # to mk try-X.XX, test it out, and then do mk install-X.XX, where X.XX
23 # is the version number (e.g. 5.70). If outside BL, you may have to edit the
24 # scripts to remove some local dependencies (e.g. calling outside and the
25 # cpu call to thresher, alpha to make mips.h, alpha.h).
27 # Recent versions of src/gxshade1.c cause the compiler to run out
28 # of registers. Brucee is looking into this. In the meantime, use this
32 # make_other_poles(patch_curve_t curve[4])
36 # for (i = 0; i < 4; i++) {
38 # curve[i].control[0].x = (curve[i].vertex.p.x * 2 + curve[j].vertex.p.x);
39 # curve[i].control[0].x /= 3;
40 # curve[i].control[0].y = (curve[i].vertex.p.y * 2 + curve[j].vertex.p.y);
41 # curve[i].control[0].y /= 3;
42 # curve[i].control[1].x = (curve[i].vertex.p.x + curve[j].vertex.p.x * 2);
43 # curve[i].control[1].y /= 3;
44 # curve[i].control[1].y = (curve[i].vertex.p.y + curve[j].vertex.p.y * 2);
45 # curve[i].control[1].y /= 3;
46 # curve[i].straight = true;
50 # (the original includes the /3 in the big expressions).
52 # src/gxshade6.c also needs editing to remove use of the
53 # vlong , operator on some architectures.
55 # you may need to change this line in gs/src/gshtscr.c:
56 # // sample = (int) (value * max_ht_sample) + max_ht_sample;
58 # sample = (vlong)(value * max_ht_sample) + max_ht_sample;
67 `{sed 's#^./obj/(.*)\.o .*#obj/\1.$O#' src/ld.tr >[2] /dev/null | sort}
69 # The first driver is the default.
109 # enforce some startup conditions
110 x=`{mkdir obj >[2]/dev/null; mv jpeg/jmorecfg.h jpeg/jmorecfg.h.save >[2] /dev/null}
123 update $UPDATEFLAGS $UPDATE `{cat lsr}
127 CFLAGS=-c -DPlan9 -D_POSIX_SOURCE -D_BSD_EXTENSION\
128 -I. -Isrc -Ijpeg -Izlib -Iicclib -DT$objtype '-DGS_INIT="gs_init.ps"'
131 obj/gconfig.$O obj/gconf.$O obj/gscdef.$O\
132 obj/gscdefs.$O obj/iconf.$O obj/iconfig.$O: src/gconfig.h
135 $CC $CFLAGS icclib/$stem.c; mv $stem.$O obj
138 $CC $CFLAGS jpeg/$stem.c; mv $stem.$O obj
141 $CC $CFLAGS zlib/$stem.c; mv $stem.$O obj
144 $CC $CFLAGS src/$stem.c; mv $stem.$O obj
146 #if possible, use genarch to build $objtype.h; it must run on same cpu type.
147 #if not, try to use a default header for the target architecture.
148 $objtype.h: $O.genarch
149 if(~ $objtype $cputype) {
154 if (test -r default.$objtype.h)
155 cp default.$objtype.h $target && chmod 664 $target
157 echo 'no default header file for target architecture'
158 echo 'run mk on the target architecture to build one'
163 $O.genarch:U: src/genarch.c
164 if(~ $objtype $cputype) {
167 pcc -DHAVE_LONG_LONG -B -o $O.genarch src/genarch.c
173 cp lib/* /sys/lib/ghostscript
176 rm -f *.[$OS] obj/* [$OS].out y.tab.? y.debug y.output $TARG src/plan9.mak
178 #################################################################################
180 fake-make:V: src/plan9.mak src/plan9-aux.mak fakecc
181 cp jpeg/jmorecfg.h.save jpeg/jmorecfg.h
182 ape/psh -c 'CC=fakecc make -f src/plan9.mak'
183 rm -f jpeg/jmorecfg.h
184 cp obj/*.c obj/*.h obj/ld.tr src
190 real-make:V: src/plan9.mak src/plan9-aux.mak
191 ape/psh -c 'CC=cc make -f src/plan9.mak'
195 if(~ ./obj/genconf $* || ~ ./obj/genarch $* || ~ ./obj/echogs $*) cc $*
196 status='''' ' >$target
199 src/plan9.mak: src/unixansi.mak /sys/src/cmd/gs/contrib9.mak src/contrib.mak
200 devlist='$(DD)'^$DRIVERS^'.dev'
202 sed 's#^GS_LIB_DEFAULT=.*#GS_LIB_DEFAULT=/sys/lib/ghostscript:/sys/lib/ghostscript/font:/sys/lib/postscript/font#
203 s#^XCFLAGS=.*#XCFLAGS=-D_BSD_EXTENSION -DPlan9#
204 s#^CFLAGS_STANDARD=.*#CFLAGS_STANDARD=#
205 s#^include \$\(.*\)/(.*)#include src/\1#
206 s#unix-aux.mak#plan9-aux.mak#
207 s#gsdatadir *=.*#gsdatadir=/sys/src/cmd/gs#
208 s#DEVICE_DEVS=.*#DEVICE_DEVS='$devlist'#
209 s#(DEVICE_DEVS[0-9]+)=.*#\1=#' $prereq >$target
211 src/plan9-aux.mak: src/unix-aux.mak
212 sed 's#^INCLUDE=.*#INCLUDE=/sys/include/ape#' $prereq >$target
215 bind gs$stem/$O.out /bin/gs
216 bind -b gs$stem/lib /sys/lib/ghostscript
217 echo 'give it a whirl'
219 gs([0-9]+\.[0-9]+)/$O.out:R: gs\1/src
221 # for(i in jpeg zlib libpng)
223 if(! test -f src/ld.tr)
228 # for(i in jpeg zlib libpng)
229 # unmount $i || status=''
232 gs%/src: ghostscript-%.tar.gz
234 gunzip < ghostscript-$stem.tar.gz | tar x
235 mv ghostscript-$stem gs$stem
236 chmod g+w gs$stem/* gs$stem/*/*
238 cp src/gdevifno.c src/gdevplan9.c src/gdevcd8.c gs$stem/src
240 ed gs$stem/lib/gs_init.ps <fixSAFER.ed
241 mkdir -p gs$stem/^(jpeg obj zlib libpng)
242 # rm -rf gs$stem/^(jpeg obj zlib libpng)^/*
243 echo '<../mkfile' >gs$stem/mkfile
244 cp default.*.h gs$stem
245 @{cd gs$stem; mk startover}
247 ghostscript-%.tar.gz:
249 #hget -o $target http://download.sourceforge.net/ghostscript/$target
250 hget -o $target ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/gs^`{echo $stem | sed 's/\.//'}^/$target
251 #ftpfs -a $user^'@' ftp.cs.wisc.edu
252 #cp /n/ftp/ghost/aladdin/*/ghostscript-$stem.tar.gz .
257 rm -f src/plan9.mak src/plan9-aux.mak
260 unmount /bin/gs || status=''
261 unmount /sys/lib/ghostscript || status=''
263 cpu -h thresher -c 'mk mips.h' || status=''
264 cpu -h alpha -c 'mk alpha.h' || status=''
268 if(! cmp $i /sys/lib/ghostscript/^`{basename $i} >/dev/null)
269 cp $i /sys/lib/ghostscript
270 cp /sys/lib/ghostscript/pdf_sec-ps.bak /sys/lib/ghostscript/pdf_sec.ps
272 installsrc-%:V: gs%/$O.out
274 # don't accidentally do this from gsX.XX
276 echo 'i don''t think you meant to do that' && exit oops
277 tocopy=(doc examples icclib lib man obj src zlib jpeg libpng)
278 if(! cmp src/version.mak gs$stem/src/version.mak) {
280 @{cd gs$stem; tar c $tocopy} | tar xT
287 unmount $i >[2]/dev/null || status=''
288 rm -rf gs$stem ghostscript-$stem.tar.gz