mkfile 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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. </$objtype/mkfile
  65. CPUS=386 mips alpha arm power
  66. BIN=/$objtype/bin
  67. TARG=gs
  68. OFILES=\
  69. obj/gs.$O\
  70. `{sed 's#^./obj/(.*)\.o .*#obj/\1.$O#' src/ld.tr >[2] /dev/null | sort}
  71. # The first driver is the default.
  72. DRIVERS=\
  73. plan9\
  74. bj10e\
  75. bjc600\
  76. bjc800\
  77. cdj1600\
  78. cdj670\
  79. cdj850\
  80. cdj890\
  81. dfaxlow\
  82. epswrite\
  83. inferno\
  84. jpeg\
  85. jpeggray\
  86. laserjet\
  87. ljet2p\
  88. ljet3\
  89. ljet3d\
  90. ljet4\
  91. pbm\
  92. pbmraw\
  93. pdfwrite\
  94. pgm\
  95. pgmraw\
  96. plan9bm\
  97. pnm\
  98. pnmraw\
  99. ppm\
  100. ppmraw\
  101. pswrite\
  102. stcolor\
  103. tiffg32d\
  104. tiffg3\
  105. tiffg4\
  106. HFILES=$objtype.h\
  107. arch.h\
  108. # enforce some startup conditions
  109. x=`{mkdir obj >[2]/dev/null; mv jpeg/jmorecfg.h jpeg/jmorecfg.h.save >[2] /dev/null}
  110. </sys/src/cmd/mkone
  111. UPDATE=\
  112. /386/bin/gs\
  113. /sys/man/1/gs\
  114. /rc/bin/ps2pdf\
  115. /rc/bin/pdf2ps\
  116. /sys/man/1/ps2pdf\
  117. update:V:
  118. update $UPDATEFLAGS $UPDATE `{cat lsr}
  119. CC=pcc
  120. CFLAGS=-c -DPlan9 -D_POSIX_SOURCE -D_BSD_EXTENSION\
  121. -I. -Isrc -Ijpeg -Izlib -Iicclib -DT$objtype '-DGS_INIT="gs_init.ps"'
  122. obj/gconfig.$O obj/gconf.$O obj/gscdef.$O\
  123. obj/gscdefs.$O obj/iconf.$O obj/iconfig.$O: src/gconfig.h
  124. obj/%.$O: icclib/%.c
  125. $CC $CFLAGS icclib/$stem.c; mv $stem.$O obj
  126. obj/%.$O: jpeg/%.c
  127. $CC $CFLAGS jpeg/$stem.c; mv $stem.$O obj
  128. obj/%.$O: zlib/%.c
  129. $CC $CFLAGS zlib/$stem.c; mv $stem.$O obj
  130. obj/%.$O: src/%.c
  131. $CC $CFLAGS src/$stem.c; mv $stem.$O obj
  132. #if possible, use genarch to build $objtype.h; it must run on same cpu type.
  133. #if not, try to use a default header for the target architecture.
  134. $objtype.h: $O.genarch
  135. if(~ $objtype $cputype) {
  136. ./$O.genarch $target
  137. rm -f $O.genarch
  138. }
  139. if not {
  140. if (test -r default.$objtype.h)
  141. cp default.$objtype.h $target && chmod 664 $target
  142. if not {
  143. echo 'no default header file for target architecture'
  144. echo 'run mk on the target architecture to build one'
  145. exit false
  146. }
  147. }
  148. $O.genarch:U: src/genarch.c
  149. if(~ $objtype $cputype) {
  150. rfork e
  151. objtype=$cputype
  152. pcc -DHAVE_LONG_LONG -B -o $O.genarch src/genarch.c
  153. }
  154. if not
  155. status=''
  156. libinstall:V:
  157. cp lib/* /sys/lib/ghostscript
  158. nuke clean:V:
  159. rm -f *.[$OS] obj/* [$OS].out y.tab.? y.debug y.output $TARG
  160. #################################################################################
  161. fake-make:V: src/plan9.mak src/plan9-aux.mak fakecc
  162. cp jpeg/jmorecfg.h.save jpeg/jmorecfg.h
  163. ape/psh -c 'CC=fakecc make -f src/plan9.mak'
  164. rm -f jpeg/jmorecfg.h
  165. cp obj/*.c obj/*.h obj/ld.tr src
  166. rm -f src/arch.h
  167. rm -f obj/*.o
  168. rm -f obj/*.c
  169. rm -f fakecc
  170. real-make:V: src/plan9.mak src/plan9-aux.mak
  171. ape/psh -c 'CC=cc make -f src/plan9.mak'
  172. fakecc:V:
  173. echo '#!/bin/rc
  174. if(~ ./obj/genconf $* || ~ ./obj/genarch $* || ~ ./obj/echogs $*) cc $*
  175. status='''' ' >$target
  176. chmod +x $target
  177. src/plan9.mak: src/unixansi.mak /sys/src/cmd/gs/contrib9.mak
  178. devlist='$(DD)'^$DRIVERS^'.dev'
  179. devlist=$"devlist
  180. sed 's#^GS_LIB_DEFAULT=.*#GS_LIB_DEFAULT=/sys/lib/ghostscript:/sys/lib/ghostscript/font:/sys/lib/postscript/font#
  181. s#^XCFLAGS=.*#XCFLAGS=-D_BSD_EXTENSION -DPlan9#
  182. s#^CFLAGS_STANDARD=.*#CFLAGS_STANDARD=#
  183. s#^include \$\(.*\)/(.*)#include src/\1#
  184. s#unix-aux.mak#plan9-aux.mak#
  185. s#gsdatadir *=.*#gsdatadir=/sys/src/cmd/gs#
  186. s#DEVICE_DEVS=.*#DEVICE_DEVS='$devlist'#
  187. s#(DEVICE_DEVS[0-9]+)=.*#\1=#' $prereq >$target
  188. src/plan9-aux.mak: src/unix-aux.mak
  189. sed 's#^INCLUDE=.*#INCLUDE=/sys/include/ape#' $prereq >$target
  190. try-%:V: gs%/$O.out
  191. bind gs$stem/$O.out /bin/gs
  192. bind -b gs$stem/lib /sys/lib/ghostscript
  193. echo 'give it a whirl'
  194. gs([0-9]+\.[0-9]+)/$O.out:R: gs\1/src
  195. @{ cd gs$stem1
  196. # for(i in jpeg zlib libpng)
  197. # bind -c ../$i $i
  198. if(! test -f src/ld.tr)
  199. mk fake-make
  200. cp ../arch.h .
  201. rm -f obj/*.c
  202. mk $O.out
  203. # for(i in jpeg zlib libpng)
  204. # unmount $i || status=''
  205. }
  206. gs%/src: ghostscript-%.tar.gz
  207. rm -rf gs$stem
  208. gunzip < ghostscript-$stem.tar.gz | tar x
  209. mv ghostscript-$stem gs$stem
  210. chmod g+w gs$stem/* gs$stem/*/*
  211. # local drivers
  212. cp src/gdevifno.c src/gdevplan9.c src/gdevcd8.c gs$stem/src
  213. # local conventions
  214. ed gs$stem/lib/gs_init.ps <fixSAFER.ed
  215. mkdir -p gs$stem/^(jpeg obj zlib libpng)
  216. # rm -rf gs$stem/^(jpeg obj zlib libpng)^/*
  217. echo '<../mkfile' >gs$stem/mkfile
  218. cp default.*.h gs$stem
  219. @{cd gs$stem; mk startover}
  220. ghostscript-%.tar.gz:
  221. #outside
  222. #hget -o $target http://download.sourceforge.net/ghostscript/$target
  223. hget -o $target ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/gs^`{echo $stem | sed 's/\.//'}^/$target
  224. #ftpfs -a $user^'@' ftp.cs.wisc.edu
  225. #cp /n/ftp/ghost/aladdin/*/ghostscript-$stem.tar.gz .
  226. startover:V:
  227. rm -rf obj/*
  228. rm -f src/ld.tr
  229. rm -f src/plan9.mak src/plan9-aux.mak
  230. install-%:V:
  231. unmount /bin/gs || status=''
  232. unmount /sys/lib/ghostscript || status=''
  233. mk installsrc-$stem
  234. cpu -h thresher -c 'mk mips.h' || status=''
  235. cpu -h alpha -c 'mk alpha.h' || status=''
  236. mk all
  237. mk installall
  238. for(i in lib/*.ps)
  239. if(! cmp $i /sys/lib/ghostscript/^`{basename $i} >/dev/null)
  240. cp $i /sys/lib/ghostscript
  241. cp /sys/lib/ghostscript/pdf_sec-ps.bak /sys/lib/ghostscript/pdf_sec.ps
  242. installsrc-%:V: gs%/$O.out
  243. pwd=`{pwd}
  244. # don't accidentally do this from gsX.XX
  245. if(! ~ $pwd */gs)
  246. echo 'i don''t think you meant to do that' && exit oops
  247. tocopy=(doc examples icclib lib man obj src zlib jpeg libpng)
  248. if(! cmp src/version.mak gs$stem/src/version.mak) {
  249. rm -rf $tocopy
  250. @{cd gs$stem; tar c $tocopy} | tar xT
  251. mk clean
  252. }
  253. status=''
  254. clean-%:V:
  255. for (i in gs$stem/*)
  256. unmount $i >[2]/dev/null || status=''
  257. rm -rf gs$stem ghostscript-$stem.tar.gz