mkfile 7.4 KB

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