saveimage.sh 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. #! /bin/sh
  2. # Extract from build.sh to only save a new image.
  3. # First parameter is architecture.
  4. #
  5. # Without additional parameters it builds in the current directory.
  6. #
  7. # Takes build dir and toplevel pslbuild dir pathname as optional second and third
  8. # arguments.
  9. # Optional fourth argument is topdir to be used for load-path in saved image
  10. #
  11. # Usage:
  12. # .../psl/saveimage.sh .../builddir /usr/lib/reduce/pslbuild [topdir]
  13. # This script must live in the PSL directory.
  14. a=$0
  15. c=unknown
  16. case $a in
  17. /* )
  18. c=$a
  19. ;;
  20. */* )
  21. case $a in
  22. ./* )
  23. a=`echo $a | sed -e s+./++`
  24. ;;
  25. esac
  26. c=`pwd`/$a
  27. ;;
  28. * )
  29. for d in $PATH
  30. do
  31. if test -x $d/$a
  32. then
  33. c=$d/$a
  34. fi
  35. done
  36. if test $c = "unknown" ;then
  37. echo "Unable to find full path for script. Please re-try"
  38. echo "launching it using a fully rooted path."
  39. exit 1
  40. fi
  41. ;;
  42. esac
  43. #
  44. # Check whether this script with called with one parameter (as classic reduce.img.sh)
  45. # or with two or three (as saveimage.sh)
  46. #
  47. if test -n "$2"
  48. then
  49. builddir="$1"
  50. imagedir="$2"
  51. if test -d "$imagedir"
  52. then
  53. :
  54. else
  55. mkdir -p "$imagedir"
  56. fi
  57. if test -z "$3"
  58. then
  59. topdir="$builddir"
  60. else
  61. topdir="$3"
  62. fi
  63. bhere="$builddir"
  64. logdir=$bhere/log
  65. logfile=reduce.blg
  66. #logfile=saveimage.blg
  67. else
  68. builddir=.
  69. imagedir=../red
  70. bhere=`pwd`
  71. logdir=../buildlogs
  72. logfile=reduce.img.blg
  73. echo Create red/reduce.img for architecture $1
  74. fi
  75. cpsldir=`echo $c | sed -e 's+/[^/]*$++'`
  76. creduce=$cpsldir/..
  77. chere=`pwd`
  78. cfasl="$builddir/red"
  79. if test -x /usr/bin/cygpath
  80. then
  81. psldir=`cygpath -m "$cpsldir"`
  82. reduce=`cygpath -m "$creduce"`
  83. here=`cygpath -m "$chere"`
  84. fasl=`cygpath -m "$cfasl"`
  85. imagedir=`cygpath -m "$imagedir"`
  86. else
  87. psldir="$cpsldir"
  88. reduce="$creduce"
  89. here="$chere"
  90. fasl="$cfasl"
  91. fi
  92. if test -f psl/64
  93. then
  94. STORE=600
  95. else
  96. STORE=64000000
  97. fi
  98. export here fasl psldir reduce
  99. if test -d "$logdir"
  100. then
  101. :
  102. else
  103. mkdir -p "$logdir"
  104. fi
  105. cd "$builddir"
  106. bhere=`pwd`
  107. test -x /usr/bin/cygpath && bhere=`cygpath -m $bhere`
  108. cd psl
  109. ./bpsl -td $STORE <<XXX > "$logdir/$logfile"
  110. % This re-starts a bare reduce and loads in the modules compiled
  111. % by the very first step. It then checkpoints a system that can be
  112. % used to rebuild all other modules.
  113. (setq symbolfilename!* "$bhere/psl/bpsl")
  114. (setq loaddirectories!* (quote ("" "$bhere/red/" "$bhere/psl/")))
  115. (reclaim)
  116. (setq !*init!-stats!* (list (time) (gtheap nil) (free-bps) nextsymbol))
  117. (setq !*usermode nil)
  118. (setq !*verboseload t)
  119. (setq !*argnochk t) % Check argument count.
  120. (setq prolog_file 'pslprolo)
  121. (setq rend_file 'pslrend)
  122. (cond ((filep "symget.b")
  123. (dskin "$reduce/psl/symget.dat")))
  124. (cond ((filep "addr2id.b")
  125. (load addr2id))) % For debugging purposes.
  126. (cond ((filep "pipes.b")
  127. (load pipes))) % Unix pipes.
  128. (errorset '(load hashtable) nil nil) % Hashtables for simp module
  129. (load zbig) % PSL bignums.
  130. (errorset '(load pslcompat) nil nil) % Load PSL-based functions if there.
  131. (load module) % Contains definition of load-package.
  132. (load pslprolo) % PSL specific code.
  133. (load!-package 'revision)
  134. (load!-package 'rlisp)
  135. (load!-package rend_file)
  136. (load!-package 'poly)
  137. (load!-package 'arith)
  138. (load!-package 'alg)
  139. (load!-package 'rtools)
  140. (load!-package 'mathpr)
  141. (load!-package 'entry)
  142. (setq version!* (compress (append
  143. (explode2 """Reduce (Free PSL version, revision ")
  144. (append (explode2 revision!*) '(!) !")))))
  145. (setq date!* (date))
  146. (initreduce)
  147. (setq !*loadversion t) % Load entry module during BEGIN.
  148. (setq !*verboseload nil) % Inhibit loading messages.
  149. (cond ((and (memq (quote sparc) lispsystem!*)
  150. (getd (quote supersparc)))
  151. (supersparc)))
  152. (flag '(fancy) 'switch)
  153. (put 'fancy 'simpfg
  154. '((t (load fmprint) (fmp!-switch t))
  155. (nil (load fmprint) (fmp!-switch nil)) ))
  156. % implant graphics mode switch
  157. (setq *fancy nil)
  158. (cond ((not (unboundp 'win-messages))
  159. (putv win-messages 3 '(~on '(fancy)))
  160. (putv win-messages 4 '(and *fancy (~off '(fancy))))))
  161. (prog nil
  162. (reclaim)
  163. (terpri)
  164. (prin2 "Time for build: ")
  165. (prin2 (quotient (difference (time) (car !*init!-stats!*)) 1000.0))
  166. (prin2t " secs")
  167. (prin2 "Symbols used: ")
  168. (prin2t (difference nextsymbol (cadddr !*init!-stats!*)))
  169. (prin2 "Heap used: ")
  170. (prin2t (difference (cadr !*init!-stats!*) (gtheap nil)))
  171. (prin2 "BPS used: ")
  172. (prin2t (difference (caddr !*init!-stats!*) (free-bps)))
  173. (prin2 "Heap left: ")
  174. (prin2t (gtheap nil))
  175. (prin2 "BPS left: ")
  176. (prin2t (free-bps))
  177. (setq !*init!-stats!* nil))
  178. (de alterheapsize (d) (rederr "Sorry, but at present the Heap cannot be extended. Please start Reduce again with a larger heap (-td parameter) and rerun."))
  179. (setq symbolfilename!* "$topdir/psl/bpsl")
  180. (setq loaddirectories!* (quote ("" "$topdir/red/" "$topdir/psl/")))
  181. (savesystem "REDUCE" "$imagedir/reduce" (quote ((reduce-init-forms))))
  182. (bye)
  183. XXX
  184. cd $chere