mkfile 6.1 KB

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