1# 2# This Plan 9 mkfile is for ``easy'' building. 3# It worked for Ghostscript 8.53. 4# 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. 7# 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. 11# 12# Then you can run mk normally. 13# 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 16# our own anymore. 17# 18# Each time you change the drivers list you must rerun mk fake-make 19# before building. 20# 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). 26# 27# If you get weird floating point errors, the culprit is usually the 28# halftone code, which converts double to uint, something 8c handles 29# incorrectly (treats as double to int). Look in src/gshtscr.c for a line like 30# 31# sample = (ht_sample_t)((value+1) * max_ht_sample); 32# 33# and change it to one of: 34# 35# sample = (int)(vlong)((value+1) * max_ht_sample); 36# sample = (ht_sample_t)(value * max_ht_sample) + max_ht_sample; 37# 38# depending on your preference. 39# 40# Also, recent versions of src/gxshade1.c cause the compiler to run out 41# of registers. Brucee is looking into this. In the meantime, use this 42# replacement: 43# 44# private inline void 45# make_other_poles(patch_curve_t curve[4]) 46# { 47# int i, j; 48# 49# for (i = 0; i < 4; i++) { 50# j = (i + 1) % 4; 51# curve[i].control[0].x = (curve[i].vertex.p.x * 2 + curve[j].vertex.p.x); 52# curve[i].control[0].x /= 3; 53# curve[i].control[0].y = (curve[i].vertex.p.y * 2 + curve[j].vertex.p.y); 54# curve[i].control[0].y /= 3; 55# curve[i].control[1].x = (curve[i].vertex.p.x + curve[j].vertex.p.x * 2); 56# curve[i].control[1].y /= 3; 57# curve[i].control[1].y = (curve[i].vertex.p.y + curve[j].vertex.p.y * 2); 58# curve[i].control[1].y /= 3; 59# curve[i].straight = true; 60# } 61# } 62# 63# (the original includes the /3 in the big expressions). 64 65</$objtype/mkfile 66CPUS=386 mips alpha arm power 67 68BIN=/$objtype/bin 69 70TARG=gs 71OFILES=\ 72 obj/gs.$O\ 73 `{sed 's#^./obj/(.*)\.o .*#obj/\1.$O#' src/ld.tr >[2] /dev/null | sort} 74 75# The first driver is the default. 76DRIVERS=\ 77 plan9\ 78 bj10e\ 79 bjc600\ 80 bjc800\ 81 cdj1600\ 82 cdj670\ 83 cdj850\ 84 cdj890\ 85 dfaxlow\ 86 epswrite\ 87 inferno\ 88 jpeg\ 89 jpeggray\ 90 laserjet\ 91 ljet2p\ 92 ljet3\ 93 ljet3d\ 94 ljet4\ 95 pbm\ 96 pbmraw\ 97 pdfwrite\ 98 pgm\ 99 pgmraw\ 100 plan9bm\ 101 pnm\ 102 pnmraw\ 103 ppm\ 104 ppmraw\ 105 pswrite\ 106 stcolor\ 107 tiffg32d\ 108 tiffg3\ 109 tiffg4\ 110 111HFILES=$objtype.h\ 112 arch.h\ 113 114# enforce some startup conditions 115x=`{mkdir obj >[2]/dev/null; mv jpeg/jmorecfg.h jpeg/jmorecfg.h.save >[2] /dev/null} 116 117 118</sys/src/cmd/mkone 119 120UPDATE=\ 121 /386/bin/gs\ 122 /sys/man/1/gs\ 123 /rc/bin/ps2pdf\ 124 /rc/bin/pdf2ps\ 125 /sys/man/1/ps2pdf\ 126 127update:V: 128 update $UPDATEFLAGS $UPDATE `{cat lsr} 129 130 131CC=pcc 132CFLAGS=-c -DPlan9 -D_POSIX_SOURCE -D_BSD_EXTENSION\ 133 -I. -Isrc -Ijpeg -Izlib -Iicclib -DT$objtype '-DGS_INIT="gs_init.ps"' 134 135 136obj/gconfig.$O obj/gconf.$O obj/gscdef.$O\ 137 obj/gscdefs.$O obj/iconf.$O obj/iconfig.$O: src/gconfig.h 138 139obj/%.$O: icclib/%.c 140 $CC $CFLAGS icclib/$stem.c; mv $stem.$O obj 141 142obj/%.$O: jpeg/%.c 143 $CC $CFLAGS jpeg/$stem.c; mv $stem.$O obj 144 145obj/%.$O: zlib/%.c 146 $CC $CFLAGS zlib/$stem.c; mv $stem.$O obj 147 148obj/%.$O: src/%.c 149 $CC $CFLAGS src/$stem.c; mv $stem.$O obj 150 151#if possible, use genarch to build $objtype.h; it must run on same cpu type. 152#if not, try to use a default header for the target architecture. 153$objtype.h: $O.genarch 154 if(~ $objtype $cputype) { 155 ./$O.genarch $target 156 rm -f $O.genarch 157 } 158 if not { 159 if (test -r default.$objtype.h) 160 cp default.$objtype.h $target && chmod 664 $target 161 if not { 162 echo 'no default header file for target architecture' 163 echo 'run mk on the target architecture to build one' 164 exit false 165 } 166 } 167 168$O.genarch:U: src/genarch.c 169 if(~ $objtype $cputype) { 170 rfork e 171 objtype=$cputype 172 pcc -DHAVE_LONG_LONG -B -o $O.genarch src/genarch.c 173 } 174 if not 175 status='' 176 177libinstall:V: 178 cp lib/* /sys/lib/ghostscript 179 180nuke clean:V: 181 rm -f *.[$OS] obj/* [$OS].out y.tab.? y.debug y.output $TARG 182 183################################################################################# 184 185fake-make:V: src/plan9.mak src/plan9-aux.mak fakecc 186 cp jpeg/jmorecfg.h.save jpeg/jmorecfg.h 187 ape/psh -c 'CC=fakecc make -f src/plan9.mak' 188 rm -f jpeg/jmorecfg.h 189 cp obj/*.c obj/*.h obj/ld.tr src 190 rm -f src/arch.h 191 rm -f obj/*.o 192 rm -f obj/*.c 193 rm -f fakecc 194 195real-make:V: src/plan9.mak src/plan9-aux.mak 196 ape/psh -c 'CC=cc make -f src/plan9.mak' 197 198fakecc:V: 199 echo '#!/bin/rc 200 if(~ ./obj/genconf $* || ~ ./obj/genarch $* || ~ ./obj/echogs $*) cc $* 201 status='''' ' >$target 202 chmod +x $target 203 204src/plan9.mak: src/unixansi.mak /sys/src/cmd/gs/contrib9.mak 205 devlist='$(DD)'^$DRIVERS^'.dev' 206 devlist=$"devlist 207 sed 's#^GS_LIB_DEFAULT=.*#GS_LIB_DEFAULT=/sys/lib/ghostscript:/sys/lib/ghostscript/font:/sys/lib/postscript/font# 208 s#^XCFLAGS=.*#XCFLAGS=-D_BSD_EXTENSION -DPlan9# 209 s#^CFLAGS_STANDARD=.*#CFLAGS_STANDARD=# 210 s#^include \$\(.*\)/(.*)#include src/\1# 211 s#unix-aux.mak#plan9-aux.mak# 212 s#gsdatadir *=.*#gsdatadir=/sys/src/cmd/gs# 213 s#DEVICE_DEVS=.*#DEVICE_DEVS='$devlist'# 214 s#(DEVICE_DEVS[0-9]+)=.*#\1=#' $prereq >$target 215 216src/plan9-aux.mak: src/unix-aux.mak 217 sed 's#^INCLUDE=.*#INCLUDE=/sys/include/ape#' $prereq >$target 218 219try-%:V: gs%/$O.out 220 bind gs$stem/$O.out /bin/gs 221 bind -b gs$stem/lib /sys/lib/ghostscript 222 echo 'give it a whirl' 223 224gs([0-9]+\.[0-9]+)/$O.out:R: gs\1/src 225 @{ cd gs$stem1 226 # for(i in jpeg zlib libpng) 227 # bind -c ../$i $i 228 if(! test -f src/ld.tr) 229 mk fake-make 230 cp ../arch.h . 231 rm -f obj/*.c 232 mk $O.out 233 # for(i in jpeg zlib libpng) 234 # unmount $i || status='' 235 } 236 237gs%/src: ghostscript-%.tar.gz 238 rm -rf gs$stem 239 gunzip < ghostscript-$stem.tar.gz | tar x 240 mv ghostscript-$stem gs$stem 241 chmod g+w gs$stem/* gs$stem/*/* 242 # local drivers 243 cp src/gdevifno.c src/gdevplan9.c src/gdevcd8.c gs$stem/src 244 # local conventions 245 ed gs$stem/lib/gs_init.ps <fixSAFER.ed 246 mkdir -p gs$stem/^(jpeg obj zlib libpng) 247 # rm -rf gs$stem/^(jpeg obj zlib libpng)^/* 248 echo '<../mkfile' >gs$stem/mkfile 249 cp default.*.h gs$stem 250 @{cd gs$stem; mk startover} 251 252ghostscript-%.tar.gz: 253 #outside 254 #hget -o $target http://download.sourceforge.net/ghostscript/$target 255 hget -o $target ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/gs^`{echo $stem | sed 's/\.//'}^/$target 256 #ftpfs -a $user^'@' ftp.cs.wisc.edu 257 #cp /n/ftp/ghost/aladdin/*/ghostscript-$stem.tar.gz . 258 259startover:V: 260 rm -rf obj/* 261 rm -f src/ld.tr 262 rm -f src/plan9.mak src/plan9-aux.mak 263 264install-%:V: 265 unmount /bin/gs || status='' 266 unmount /sys/lib/ghostscript || status='' 267 mk installsrc-$stem 268 cpu -h thresher -c 'mk mips.h' || status='' 269 cpu -h alpha -c 'mk alpha.h' || status='' 270 mk all 271 mk installall 272 for(i in lib/*.ps) 273 if(! cmp $i /sys/lib/ghostscript/^`{basename $i} >/dev/null) 274 cp $i /sys/lib/ghostscript 275 cp /sys/lib/ghostscript/pdf_sec-ps.bak /sys/lib/ghostscript/pdf_sec.ps 276 277installsrc-%:V: gs%/$O.out 278 pwd=`{pwd} 279 # don't accidentally do this from gsX.XX 280 if(! ~ $pwd */gs) 281 echo 'i don''t think you meant to do that' && exit oops 282 tocopy=(doc examples icclib lib man obj src zlib jpeg libpng) 283 if(! cmp src/version.mak gs$stem/src/version.mak) { 284 rm -rf $tocopy 285 @{cd gs$stem; tar c $tocopy} | tar xT 286 mk clean 287 } 288 status='' 289 290clean-%:V: 291 for (i in gs$stem/*) 292 unmount $i >[2]/dev/null || status='' 293 rm -rf gs$stem ghostscript-$stem.tar.gz 294