mkfile 7.4 KB

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