old-build-all.sh 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. #! /bin/sh -v
  2. #
  3. # This is a script for rebuilding a CSL-based Reduce system in either
  4. # a release or development world.
  5. #.
  6. # The INTENT is that this should run under a fairly vanilla version of
  7. # the "sh" Bourne shell, but it will be developed and mostly tested
  8. # on systems where the real shell in place is "bash"...
  9. #*****************************************************************************
  10. # A first major part of this file will be used to define shell functions
  11. # that do the work. Skip to a line make almost all of stars to find the
  12. # logic of this script...
  13. #=============================================================================
  14. find_directory() {
  15. # Find the directory that this script was called from.
  16. # I expect that $0 to this script will give me the name of the current script.
  17. # This will be interpreted in the way bash (and perhaps other shells) find
  18. # commands:
  19. # If the name does not contain a "/" it is expected that $PATH contains
  20. # a directory with an executable file of that name in it;
  21. # If the name starts with a "/" it is an absolute path;
  22. # In remaining cases it is relative to the current working directory.
  23. #
  24. # Given the above rules I can convert the name to give me an absolute
  25. # path... I do a minor tidy-up involving commands called "./something"
  26. # in that I remove the "./" when it is unnecessary.
  27. # I will use single-letter shall variable names for temporary work-space and
  28. # longer clearer names when I end up with something worth keeping.
  29. a=$1
  30. c=unknown
  31. case $a in
  32. /* )
  33. c=$a
  34. ;;
  35. */* )
  36. case $a in
  37. ./* )
  38. a=`echo $a | sed -e 's/\.\///'`
  39. ;;
  40. esac
  41. c=`pwd`/$a
  42. ;;
  43. * )
  44. for d in $PATH
  45. do
  46. if test -x $d/$a
  47. then
  48. c=$d/$a
  49. fi
  50. done
  51. ;;
  52. esac
  53. # The error case here ought never to arise...
  54. case $c in
  55. unknown )
  56. echo "Unable to find full path for script. Please re-try"
  57. echo "launching it using a fully rooted path."
  58. exit 1
  59. ;;
  60. esac
  61. echo Full path of script is $c
  62. # Now I want the directory that this script is in. So I remove the
  63. # tail of its full name, from the final "/" to the end of the string.
  64. csl_directory=`echo $c | sed -e 's/\/[^/]*$//'`
  65. lisp_directory=`echo $csl_directory | sed -e 's/\/[^/]*$//'`
  66. reduce_directory=`echo $lisp_directory | sed -e 's/\/[^/]*$//'`
  67. echo reduce_directory = $reduce_directory
  68. return
  69. }
  70. #=============================================================================
  71. get_fox_checksum() {
  72. # This finds a checksum for the FOX sources.
  73. r=$reduce_directory
  74. # The files passed through md5sum here are an attempt to identify all the
  75. # ones in the support-packages directory that could have a big effect on
  76. # FOX. So there is the source archive for the whole of FOX, the set of local
  77. # patches that I apply to it and the shell scripts used to compile it.
  78. # By checking all of these it will be the case that if (say) the script to
  79. # compile FOX on windows-64 is altered then FOX will get flagged as in need
  80. # or re-compilation on all platforms.
  81. # This function will only ever be called if the build-all.sh file exists and
  82. # so it is guaranteed that md5sum gets at least one argument here.
  83. new_fox_signature=`md5sum $r/support-packages/fox*.gz \
  84. $r/support-packages/*.patches \
  85. $r/support-packages/build-all.sh \
  86. $r/support-packages/build-fox*.sh | md5sum | sed -e 's/ .*$//'`
  87. # A previous version of the signature for FOX may be present in a shell
  88. # scrip in this directory. Pick it up...
  89. old_fox_signature="no_old_signature_of_FOX_source_found"
  90. if test -x $csl_directory/fox_signature.sh
  91. then
  92. . $csl_directory/fox_signature.sh
  93. fi
  94. echo "FOX signatures: " $old_fox_signature " and " $new_fox_signature
  95. return
  96. }
  97. #=============================================================================
  98. save_fox_checksum() {
  99. # Create a shell script that locally saves the signature for FOX sources.
  100. echo "#!/bin/sh" > $csl_directory/fox_signature.sh
  101. echo "old_fox_signature=\"$new_fox_signature\"" >> $csl_directory/fox_signature.sh
  102. echo "export old_fox_signature" >> $csl_directory/fox_signature.sh
  103. chmod +x $csl_directory/fox_signature.sh
  104. return
  105. }
  106. #=============================================================================
  107. get_fox_binary_checksum() {
  108. # This finds a checksum for the FOX binaries.
  109. r=$reduce_directory
  110. if test X"`cat fox/include/*/fxver.h 2>/dev/null`" = "X"
  111. then
  112. new_fox_binary_signature="no_installed_fox_found"
  113. else
  114. new_fox_binary_signature=`md5sum $r/fox/lib/* \
  115. $r/fox/include/*/*.h | md5sum | sed -e 's/ .*$//'`
  116. fi
  117. old_fox_binary_signature="no_old_signature_of_an_installed_FOX_found"
  118. if test -x $csl_directory/fox_binary_signature.sh
  119. then
  120. . $csl_directory/fox_binary_signature.sh
  121. fi
  122. echo "FOX binary signatures: " $old_fox_binary_signature " and " $new_fox_binary_signature
  123. return
  124. }
  125. #=============================================================================
  126. save_fox_binary_checksum() {
  127. # Create a shell script that locally saves the signature for FOX sources.
  128. echo "#!/bin/sh" > $csl_directory/fox_binary_signature.sh
  129. echo "old_fox_binary_signature=\"$new_fox_binary_signature\"" >> $csl_directory/fox_binary_signature.sh
  130. echo "export old_fox_binary_signature" >> $csl_directory/fox_binary_signature.sh
  131. chmod +x $csl_directory/fox_binary_signature.sh
  132. return
  133. }
  134. #=============================================================================
  135. get_autoconf_checksum() {
  136. # This finds a checksum for autoconf-related files
  137. c=$csl_directory/cslbase
  138. m=$csl_directory/$machine
  139. # I do not include the ".deps" directory in the checksum here, nor
  140. # all other files like config.log etc. But the files that
  141. # I do check here should be a pretty convincing way of telling that
  142. # the system is "configured".
  143. if test -f $m/config.h && \
  144. test -f $m/Makefile
  145. then
  146. new_autoconf_signature=`md5sum $c/configure.ac \
  147. $c/Makefile.am \
  148. $c/Makefile.in \
  149. $c/aclocal.m4 \
  150. $c/config.h.in \
  151. $c/configure \
  152. $m/config.h \
  153. $m/Makefile | md5sum | sed -e 's/ .*$//'`
  154. else
  155. new_autoconf_signature="some_autoconf_files_are_missing"
  156. fi
  157. old_autoconf_signature="no_old_autoconf_signature_found"
  158. if test -x $csl_directory/autoconf_signature.sh
  159. then
  160. . $csl_directory/autoconf_signature.sh
  161. fi
  162. echo "Autoconf signatures: " $old_autoconf_signature " and " $new_autoconf_signature
  163. return
  164. }
  165. #=============================================================================
  166. save_autoconf_checksum() {
  167. # Create a shell script that locally saves the signature for FOX sources.
  168. echo "#!/bin/sh" > $csl_directory/autoconf_signature.sh
  169. echo "old_autoconf_signature=\"$new_autoconf_signature\"" >> $csl_directory/autoconf_signature.sh
  170. echo "export old_autoconf_signature" >> $csl_directory/autoconf_signature.sh
  171. chmod +x $csl_directory/autoconf_signature.sh
  172. return
  173. }
  174. #*****************************************************************************
  175. # STEP 0: record my current working directory wherever that is.
  176. initial_directory=`pwd`
  177. # STEP 1: identify file directory and system architecture.
  178. find_directory $0
  179. # The "config.guess" script finds a GNU-style triple to identify the
  180. # machine being used. Eg "i686-pc-cygwin". The script us inder the GNU
  181. # license but with a special excepotion that if it is distributed along
  182. # with a program that contains a configuration script generated by
  183. # Autoconf it can be distributed under the terms that apply to that
  184. # program. In this instance the program concerned is CSL.
  185. # It may be that I could just use a built-in shell variable $MACHTYPE
  186. # here. But if that was generally possible why whould autoconf supply
  187. # config.guess?
  188. machine=`/bin/sh $csl_directory/cslbase/config.guess`
  189. echo machine=$machine
  190. # STEP 2: see if FOX has changed
  191. # If the file build-all.sh does not exist then it is clear
  192. # that the FOX sources and build scripts have not been
  193. # downloaded, so there is not point in trying to fuss about
  194. # wjhether it needs building or rebuilding
  195. if test -f $reduce_directory/support-packages/build-all.sh
  196. then
  197. get_fox_checksum
  198. get_fox_binary_checksum
  199. # I need to build FOX if EITHER the sources for FOX have been updated or
  200. # if this is the first time and it is not in place.
  201. if test $old_fox_signature != $new_fox_signature || \
  202. test $old_fox_binary_signature != $new_fox_binary_signature
  203. then
  204. # A situation that is probably BAD is that at present to rebuild FOX I
  205. # need to set my support-packages directory as current. So here I go.
  206. # That is something that I should perhaps review in my FOX build
  207. # scripts. A further issue (to be addressed in the same place) is that
  208. # at present FOX is built in the same place whatever architecture you build
  209. # on, so a cluster of different architectures with a shared file-system
  210. # would not be supported well.
  211. cd $reduce_directory/support-packages
  212. # In case any of the script files are not marked as executable I will
  213. # force things. File transfer might have lost permissions.
  214. chmod +x *.sh
  215. echo "+++ about to recompile FOX"
  216. echo " Please be aware that this can take a while"
  217. echo " A log will be in $reduce_directory/log/fox.log"
  218. if test ! -d $reduce_directory/log
  219. then
  220. mkdir $reduce_directory/log
  221. fi
  222. # Here I attempt to re-compile all of FOX. If that process returns with
  223. # a clean return-code I will record checksums that identify the
  224. # state of both the FOX source directory and the one into which a
  225. # built version has been installed. But if the build fails I will not
  226. # update those recorded checksums, and so I expect that future uses of
  227. # this script will re-do the compilation. Eventually with luck it will
  228. # succeed!
  229. . ./build-all.sh $machine > $reduce_directory/log/fox.log 2>&1 && \
  230. save_fox_checksum && \
  231. save_fox_binary_checksum
  232. fi
  233. # The above is only done if there is some reason to believe that FOX
  234. # sources are present...
  235. fi
  236. cd $csl_directory
  237. # STEP 3: ensure that a directory exists to build the system in. Make it
  238. # the current directory and get a Makefile in there.
  239. if test -f $machine
  240. then
  241. if test ! -d $machine
  242. then
  243. rm $machine
  244. fi
  245. fi
  246. if test ! -d $machine
  247. then
  248. mkdir $machine
  249. fi
  250. cd $machine
  251. c=$csl_directory/cslbase
  252. if test ! -f $c/configure.ac || \
  253. test ! -f $c/Makefile.am || \
  254. test ! -f $c/Makefile.in || \
  255. test ! -f $c/aclocal.m4 || \
  256. test ! -f $c/config.h.in || \
  257. test ! -f $c/configure
  258. then
  259. echo "Some autoconfig-related files are not present in the CSL"
  260. echo "source directory. Please update it and try again."
  261. exit 1
  262. fi
  263. get_autoconf_checksum
  264. if test $old_autoconf_signature != $new_autoconf_signature
  265. then
  266. # I had tried $csl_directory/cslbase/configure here, but that binds in
  267. # an absolute path for the CSL source directory. That will be just fine
  268. # on Linux/Unix/MacOS, but on Windows I build under Cygwin and then I can
  269. # find that Cygwin and Native (absolute) paths are not compatible with one
  270. # another. And the result can be horrid. Specifically during the build
  271. # process I run a program called "objtype" that I build, and it needs
  272. # to interpret the paths. A relative one is easier for it...
  273. #
  274. # I also want to detect $1=--with-xp64 and then configure for xp64!
  275. ../cslbase/configure $1 --with-fox=$reduce_directory/fox/$machine &&
  276. save_autoconf_checksum
  277. fi
  278. # STEP 3:
  279. #
  280. # Well what I will do now is to do a full cold expensive rebuild of
  281. # utterly everything from scratch, just to be on the safe side.
  282. if test -f $csl_directory/util/config.lsp
  283. then
  284. rm $csl_directory/util/config.lsp
  285. fi
  286. if test -f $csl_directory/util/devconfig.lsp
  287. then
  288. rm $csl_directory/util/devconfig.lsp
  289. fi
  290. case $1 in
  291. --with-xp64 )
  292. echo "No attempt to re-create C code here..."
  293. make r38
  294. ;;
  295. * )
  296. # Well pragmatically right now I will NOT run the profile job
  297. # every time. It takes too long. But re-creating the C code from Lisp
  298. # is fairly cheap and should be safe.
  299. make slowr38.img
  300. #make profile
  301. #make prof-inst
  302. make c-code
  303. make r38.img
  304. ;;
  305. esac
  306. # FINALLY: restore the initial working directory and display a message
  307. # of triumph.
  308. echo r38 built in $csl_directory/$machine
  309. cd $initial_directory
  310. exit 0
  311. # end of arthurs-script.sh