README.BUILDING 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. Fetching and Building REDUCE
  2. ============================
  3. January 2015
  4. June 2020
  5. The notes here are about having a full set of Reduce sources fetched from
  6. Sourceforge and compiling them on your own computer. Following that path
  7. lets you track the most recent changes, updates and corrections. Because
  8. both Reduce and the platforms that people may wish to build on change over
  9. time what is explained here will almost always have a few details where it
  10. is out of date: so check the date to see how recently this has been refreshed.
  11. But almost always the changes needed to what is explained here will be small,
  12. and if you find some please report back to the Reduce mailing list for the
  13. benefit of others.
  14. The prerequisites for using this package will depend somewhat on whether
  15. you choose to use the CSL or PSL build.
  16. Users of PSL will use the ready-build binaries of the PSL Lisp system that
  17. are present in the material hosted at Sourceforge. Rebuilding PSL from source
  18. is possible but the procedures are not covered at all here and anybody needing
  19. to do that probably needs to consult the PSL experts. Because PSL uses
  20. pre-made binaries these have to be present for the architecture you are using.
  21. They are available for all the most important or common cases. Because the
  22. binaries are pre-made there are few demands for compilers or special
  23. libraries installed on the computer you will use PSL on.
  24. For CSL you need to be able to compile both CSL itself and the FOX toolkit
  25. on which it depends. Please note that even if you have FOX available already
  26. on your computer the code her uses a (slightly) customised version and your
  27. standard system-wide installation of FOX will not be used and should be
  28. irrelevant here. To join in development work on what is hoped to be a future
  29. version of CSL-Reduce you would also need to be able to work with wxWidgets.
  30. You will need:
  31. For Windows, the "cygwin" environment providing a "bash" shell.
  32. Note that building under "msys" or the plain Windows command
  33. prompt is not possible (without you doing significant work of your
  34. own to arrange for it). Obviously it will be sensible to keep your
  35. cygwin installation up to date, and some updates there have in the
  36. past not always been upards compatible. The aim is to keep the
  37. current CSL/Reduce at Sourceforge buildable using the most recent
  38. cygwin release. But any difficulty due to temporary bugs or glitches
  39. at the cygwin end can not be resolved here! These days you MUST use
  40. the 64-bit version of cygwin - note that the obsolete 32-bit one is
  41. deprecated by its suppliers.
  42. The command scripts/cygwin-sanity-check.sh attempts to check if
  43. sufficient cygwin components have been installed, and it may save
  44. you pain if you try it and respond to its suggestions before trying
  45. a full build of Reduce.
  46. For Macintosh you need the XCode command line tools, and you are liable
  47. to need to use Macports to fetch and install a significant number
  48. of commands and libraries that Apple do not provide as standard.
  49. There is a file in the scripts directory that I use to fetch the
  50. set of "ports" that I use. You will also need Xquartz to support the
  51. GUI.
  52. For Linux you can inspect scripts/ubuntu-sanity-check.sh or the fedora
  53. equivalent to find a script that installs what is probably a superset
  54. of the packages you will need.
  55. For other platforms there is a hope that everything will work if you
  56. can provide a bash shell and enough development libraries, but you
  57. mat need to sort out details for yourself. Here are a few more comments:
  58. GNU make (other versions of "make" are not liable to work), autoconf,
  59. automake and libtool. All should be at least tolerably up to date
  60. versions.
  61. You need a C++ development context. On Windows you need the
  62. and "mingw-x86_64" compiler variants (as well as plain g++) from
  63. cygwin while on other systems you need X11 and other
  64. development capability, including Xft, fontconfig, (n)curses, Posix
  65. threads. The building has been tested using versions of both gcc
  66. and clang. The compiler should be new enough that it supports C++11
  67. and for choice C++17.
  68. I have (recently) built using cygwin64, Ubuntu and Fedora Linuxes
  69. on pcs, Raspbian (raspberry Pi OS, both 32 and 64-bit variants) on a
  70. Raspberry Pi and OSX Catalina. In the past I have built using PCBSD/FreeBSD
  71. and Solaris on both pc and sparc (requiring significant
  72. extra software installation), SGI, HP-pa, the IBM z-architecture and at one
  73. stage (not now I think) I coudd run Reduce on an HP IPAQ 4700 PDA or an
  74. openWRT router. The hope is that almost any machine with a C++ compiler
  75. should suffice for the basic system. In case of a challenging environment
  76. it may be prudent to do initial testing by running
  77. "./configure --with-csl --without-gui" to avoid all attempts to build
  78. windowing libraries. Also in recent years I have started to suppose that all
  79. computers have substantial amounts of memory, so ones with only a few megabytes
  80. (or even only tend or hundreds) may cause problems.
  81. One of the most common problems people seem to have the first time that they
  82. try to build CSL arises when they do not have quite all the necessary tools,
  83. libraries and header files installed. While most relevant run-time libraries
  84. are liable to have been provided for them by default, the development versions
  85. might not have. The state of your cygwin installation can be checked using
  86. scripts/cygwin-sanity-check.sh but please be aware that the tests that does
  87. are indicative rather than definitive and when (occasionally) either Reduce
  88. is extended and additional dependencies arise or cygwin is reorganised and the
  89. names of some packages alter the tests may become outdated.
  90. If you try to build REDUCE but one of the programming tools or development
  91. libraries that is required is not available then there is no guarantee that
  92. the failure that results will describe itself to you clearly! If the failure
  93. is detected at configuer time the evidence will be in a file "config.log"
  94. (possibly somewhere within the cslbuild directory). In case of trouble I often
  95. go
  96. script buildlog.log
  97. rm -rf cslbuild
  98. ./configure --with-csl
  99. make
  100. exit
  101. and then buildlog.log contains a full transcript of all the output from the
  102. attempt. Its size can be daunting and distinguishing between messages,
  103. warnings, observations and errors can take experience!
  104. To try to make that easier to cope with I provide a script that attempts to
  105. check for prerequisites and that is lighter weight than the full configuration
  106. process and maybe reports trouble in a cleaner way. To use it select the
  107. Reduce "trunk" directory as current and at a bash prompt (you MUST have
  108. "bash" available as a shell, and you will run least risk if you run all
  109. scripts from it. I have tried to make most of them compatible with a legacy
  110. /bin/sh but testing and guaranteeing that is tedious) go
  111. scripts/csl-sanity-check.sh
  112. This should run auto-configure scripts and eventually compile and run a small
  113. program that pops up a dull window. If you get the window at the end it has
  114. succeeded and you can try building Reduce. If not then it probably reports
  115. a step where some header file or library is missing. You need to search the
  116. installation sources relevant your operating system and install more stuff,
  117. then try again. Eg for cygwin you re-run "setup", while on Linux you are
  118. looking at "apt-get" and "yum" and various other package managers. You need
  119. to check the documentation of your particular operating system - or perhaps
  120. better find local expert to get you started.
  121. Note that if you configure using "--with-csl --with-wx" you also need GTK2
  122. (GTK+) development files if you are on an X11-based platform, but at present
  123. csl-sanity-check.sh does not test for that.
  124. Some people may find that they need things that are not installed on
  125. their system but they have not been granted adminitrator authority and so
  126. can not merely install them in the obvious way. The easiest response is to
  127. talk to a local system manager! But for a range of the tools (eg autoconf,
  128. make, ncurses etc) if you can not identify a ready-built binary
  129. package that suits your environment it will be easy to build one from sources
  130. found "at the usual places", and may be easy to arrange that the resulting
  131. binaries are on your PATH and libraries somewhere where they will be found.
  132. But in such a case you may end up needing to hand-patch some of the Makefiles
  133. here.
  134. If you have run the main CSL/Reduce configure step, as in
  135. ./configure --with-csl
  136. and tried "make" at a stage when you do not have all relevant headers and
  137. libraries installed then the build can fail part way through in a messy way.
  138. In principle you can check ALL the logs and work out what happened, but in
  139. reality that can be daunting. Furthermore it can get in a state where a
  140. subsequent use of "make" fails in an unhelpful manner. Experts can patch
  141. things up and recover, but the simplest approach in case of confusion is
  142. rm -rf cslbuild
  143. ./configure --with-csl
  144. make
  145. where all the partially build stuff that had accumulated in cslbuild is
  146. discarded and the configuration and compilation is started afresh. Obviously
  147. you will not delete that directory if you have put important files of your
  148. own there!
  149. A feature of subversion is that if you change any file locally then your local
  150. edit is interpreted as a possibly valuable update that you may at some stage
  151. contribute back into the project. This is good, but it means that if you
  152. accidentally corrupt a local copy of some file then subversion will NOT
  153. automatically repair it. So if you have just recently started with Reduce and
  154. something odd is happening it may make sense to get yourself back in lock-step
  155. with the central repository. You are provided with two scripts
  156. scripts/make-pristine.sh
  157. scripts/stamp.sh
  158. The first of those merely issues the subversion commands that discard all local
  159. changes you have made to bring everything into step. The second updates the
  160. time-stamps on various configuration files so that when you run "configure"
  161. it should not attempt to use autoconf and automake locally, but instead should
  162. be content with the files as fetched. These two scripts can avoid confusion
  163. early on. Once you are fully working and especially if you are doing your own
  164. development within Reduce you will not wish to use them.
  165. You can fetch or update REDUCE in one of (at least) two ways
  166. (1) Fetch a file from the Sourceforge download area, eg from the
  167. reduce-algebra-source section. Unpack it. Note that the full archives
  168. at sourceforge are updated sporadically and not to any coherent schedule,
  169. so what you get could be a little out of date. Thus this scheme is not
  170. recommended!
  171. OR
  172. (2) Use subversion to fetch or refresh a copy from the master site.
  173. svn checkout \
  174. svn://svn.code.sf.net/p/reduce-algebra/code/trunk \
  175. reduce-algebra
  176. That should create a directory called "reduce-algebra" for you.
  177. To refresh your files, enter the reduce-algebra directory and go
  178. svn update
  179. You can check the documentation of subversion (svn) to discover
  180. what further options and possibilities tare provided. Two notable
  181. advanntages of this are (a) "svn update" lets you refresh your copy
  182. to match the very latest one available without needing to fetch
  183. everything again afresh and (n) "svn -r NNNN update" lets you update
  184. you local copy to match "revision NNNN", a possibly older copy of
  185. everything, so if the main development version is even temporarily
  186. broken (that should only happen accidentally!) you can fetch older
  187. versions for comparison.
  188. The version fetched and updated using subversion (hah - note that you
  189. need "subversion" installed on your computer to do this!) will be fully
  190. up to date. That naturally means that at some moments it will include
  191. changes that temporarily break it, but in general any such should be
  192. corrected fairly rapdily. Furthermore by browsing the documentation of
  193. subversion you can find out how to check out a version from say 2 weeks
  194. ago (or indeed any historical varient) if needbe.
  195. The simplest way version of the build process is to select the directory
  196. where REDUCE was unpacked as current and issue one of the command
  197. ./configure --with-csl
  198. OR ./configure --with-psl
  199. (or first one of those then the other)
  200. It ought not to be necessary to provide any other options to the configure
  201. script or to pre-set environment variables, but for experts there are (of
  202. course) many opportunities for customisation. If you find you are on a platform
  203. where simple use of the configure script is insufficient please report that
  204. so that things can be updated and users in the future will come closer to
  205. find that everything works first time without fuss.
  206. Follow that by the command "make" and if all goes well everything relevant
  207. will be compiled. But at least in the CSL case please try
  208. scripts/csl-sanity-check.sh first - it may save you a lot of agony.
  209. If you build both the CSL and PSL versions then it can be a comfort to
  210. run
  211. scripts/testall.sh
  212. which runs all the various test scripts and displays a report showing any
  213. places where the output on your machine does not match reference versions
  214. of the logs. Directories called csl-times and psl-times end up with the
  215. log output. In some cases log discrepancies are expected! For instance some
  216. of the test files generate timing reports so their output varies depending on
  217. the speed or size of your computer. In other cases improvements to the
  218. system may change test output but the reference logs may not have been
  219. updated to reflect it. Some logs are there to highlight difference between
  220. detailed behaviour of CSL and PSL that are not hugely important but that
  221. may be addressed at some stage in the future.
  222. For (some sort of) convenience a script "rebuild.sh" in the top level of
  223. the distribution tries to do this for both PSL and CSL and it then leaves
  224. overall log files also at the top level.
  225. You can then run REDUCE using the command
  226. bin/redcsl
  227. or
  228. bin/redpsl
  229. [At present I do not in any way guarantee (and I probably do not even expect)
  230. that the usual "configure" option "--prefix=..." or the idiom "make install"
  231. will behave as you might have hoped. Indeed there are reports that at
  232. present "make install" is deeply broken and SHOULD NOT BE ATTEMPTED.
  233. But there is scripts/mk-snapshots.sh which is used to build the distribution
  234. snapshots and those can then be installed.]
  235. Any machine you are on is attributed an identity such as x86_64-pc-windows
  236. or x86_64-unknown-ubuntu10.10. Note that this is slightly more specific than
  237. the normal GNU host triple in that it attempts to include the name of a Linux
  238. distribution. Binaries are actually built within cslbuild/<triple> or
  239. pslbuild/<triple>. This arrangement is intended to be helpful if you have one
  240. file-space shared between several machine that may have different
  241. architectures. So the scripts like bin/redcsl deduce where to look and
  242. chain to binaries there. In the CSL case you could make a symbolic link
  243. as in "ln -s .../trunk/cslbuild/<triple>/csl/reduce XXXX" where XXXX is some
  244. location on your PATH which then lets you launch Reduce more directly. Reduce
  245. needs some resources in the same directory as the main executable so merely
  246. copying <triple>/csl/reduce to somewhere else is not liable to be a good idea.
  247. Logs from building and testing Reduce end up in the directory where the
  248. main binary gets created, so if things go wrong that is where you may wish
  249. to look.
  250. There are a number of optional ways in which configuration may be customised:
  251. ./configure --with-csl --enable-debug
  252. Enable "gcc -g" compilation of the C parts of CSL so that gdb can be
  253. used to debug things.
  254. ./configure --with-csl --without-gui
  255. ./configure --with-csl --with-wx
  256. By default the CSL version build in support for a GUI using the FOX
  257. toolkit. If for some reason that is not required or can not be supported
  258. then "--without-gui" removes it. There are some plans to change to use
  259. wxWidgets rather than FOX, and "--with-wx" enables the experimental build
  260. for that. At the time of writing the code compiles but is significantly
  261. unfinished. Volunteers to help complete it would be useful! But neither of
  262. these options are a very good idea for ordinary users!
  263. There are other options, many of which are experimental or historical.
  264. See "./configure --help" for a definitive list.
  265. Developers and some more ambitious users may need to understand the
  266. directory layout in more detail. The document "Inside Reduce" the
  267. the "primers" part of the Reduce documentation directory may provide
  268. useful guidance.
  269. The main directories supplied are as follows, where MACHINE stands for
  270. a machine identification, eg x86_64-pc-windows-debug.
  271. trunk The main version of everything
  272. bin Scripts to launch REDUCE etc
  273. csl/cslbase Main CSL Lisp sources
  274. fox the FOX GUI toolkit, an LGPL package
  275. cslbuild/generated-c Part of REDUCE compiled into C
  276. MACHINE/csl where REDUCE binaries are built
  277. fox where the FOX GUI toolkit is built
  278. packages/alg REDUCE sources, on package per directory
  279. ...
  280. ztrans
  281. psl/psl-amd64 Ready-build binaries of the PSL Lisp system ...
  282. ... ...
  283. psl/win32 ... for a variety of architectures
  284. pslbuild/MACHINE/. where REDUCE gets built
  285. psl copy of relevant architecture-specific PSL
  286. red REDUCE built binary "fasl" and image files
  287. deps used to record dependencies in the build
  288. scripts scripts used to maintain the system.
  289. If you are working on just one platform and have completed the configuration
  290. and done an initial build you may like to select either cslbuild/MACHINE/csl
  291. or pslbuild/MACHINE as your current directory: the Makefile that ends up there
  292. is the main one used for rebuilding the system.
  293. For special purposes you may wish to investigate the csl/jlisp directory (all
  294. Reduce runnable via Java - distinctly slower and at present the user interface
  295. is not well sorted, but it might be fun) and csl/new-embedded (a kit for
  296. making a simple small C-coded version for potential use as a component in
  297. some other software rather than a free-standing complete program). Both of
  298. these are for experienced programmers who want to use them in some broader
  299. project rather than being fully supported variants on Reduce itself.
  300. There are also "spins" of Reduce by way of extra files and scripts that have
  301. made it possible to build the system on other Lisps, from Common Lisp as
  302. far as emacs lisp. There are a range of alternative interfaces for both
  303. console and GUI purposes in varying states of support and maturity.
  304. The more alive the Reduce project is the more you can expect there to be
  305. additions, changes and enhancements but please understand that these all
  306. carry risk of transient introduction of bugs. Report trouble to us via
  307. Sourceforge and when and if we can we will fix them. But all the source code
  308. is there so you can also join in the debugging and propose fixes (please!)
  309. A C Norman. July 2008. Updated Jan 2009, September 2010, March 2011,
  310. September 2014, January 2015, June 2020.