Ticket #11070: prereq-0.8-install

File prereq-0.8-install, 16.2 KB (added by drkirkby, 10 years ago)

To be installed as $SAGE_ROOT/spkg/base/prereq-0.8-install

Line 
1#!/bin/sh
2###########################################
3## Check for prerequisite programs
4###########################################
5
6
7BUILD=build
8ROOT=`pwd`
9LOCAL="$ROOT/../local"
10TARGET=prereq-0.8
11
12cd $BUILD
13
14echo "Starting prerequisite check."
15echo "Machine: `uname -a`"
16
17if [ "$SAGE_PORT" = "" ]; then
18    if [ `uname | sed -e 's/WIN.\+/WIN/'` = "CYGWIN" ]; then
19        echo "Unfortunately, building SAGE on Cygwin is not currently supported,"
20        echo "though we are actively working on supporting it.  If you would like"
21        echo "to help with the porting effort, please post to"
22        echo ""
23        echo "   http://groups.google.com/group/sage-windows"
24        echo ""
25        echo "Also, see http://trac.sagemath.org/sage_trac/ticket/6743"
26        echo "In the meantime, to run Sage on Windows, please use"
27        echo "a virtualization solution instead, such as VirtualBox"
28        echo ""
29        echo "To get past this message, export the variable 'SAGE_PORT' to"
30        echo "something non-empty."
31        exit 1
32    elif [ `uname` = "SunOS" ]; then
33       if [ "x`uname -r`" = "x5.9" ] ||  [ "x`uname -r`" = "x5.8" ] || [ "x`uname -r`" = "x5.7" ] ||  [ "x`uname -r`" = "x5.6" ] ; then
34          echo "Sage is not supported on any version of Solaris earlier than 10"
35          echo "Sage has been tested on the first release of Solaris 10"
36          echo "(03/2005) and works on that. Sage may or may not work with"
37          echo "your version of Solaris."
38          echo ""
39          echo "More information can be found about Sage on Solaris"
40          echo "on the Wiki at http://wiki.sagemath.org/solaris"
41          echo ""
42          echo "To get past this message, export the variable SAGE_PORT to"
43          echo "something non-empty."
44          exit 1
45       fi
46    elif [ "x`uname`" = "xHP-UX" ]; then
47        echo "You are attempting to build Sage on HP's HP-UX operating system,"
48        echo "which is not a supported platform for Sage yet though"
49        echo "some work has been done on HP-UX. A port does not look to"
50        echo "be particularly difficult. Some information can be"
51        echo "found on the Sage Wiki at http://wiki.sagemath.org/HP-UX"
52        echo ""
53        echo "If you would like to help port Sage to HP-UX,"
54        echo "please join the sage-devel discussion list - see"
55        echo "http://groups.google.com/group/sage-devel"
56        echo "The Sage community would also appreciate any patches you submit."
57        echo ""
58        echo "To get past this message, export the variable SAGE_PORT to"
59        echo "something non-empty."
60        exit 1
61    elif [ "x`uname`" = "xAIX" ]; then
62        echo "You are attempting to build Sage on IBM's AIX operating system,"
63        echo "which is not a supported platform for Sage yet. Things may or"
64        echo "may not work. If you would like to help port Sage to AIX,"
65        echo "please join the sage-devel discussion list - see"
66        echo "http://groups.google.com/group/sage-devel"
67        echo "The Sage community would also appreciate any patches you submit."
68        echo ""
69        echo "To get past this message, export the variable SAGE_PORT to"
70        echo "something non-empty."
71        exit 1
72    elif [ "x`uname`" = "xIRIX" ] ||  [ "x`uname`" = "xIRIX64"  ]; then
73        echo "You are attempting to build Sage on SGI's IRIX operating system,"
74        echo "which is not a supported platform for Sage yet. Things may or"
75        echo "may not work. If you would like to help port Sage to IRIX,"
76        echo "please join the sage-devel discussion list - see"
77        echo "http://groups.google.com/group/sage-devel"
78        echo "The Sage community would also appreciate any patches you submit."
79        echo ""
80        echo "To get past this message, export the variable SAGE_PORT to"
81        echo "something non-empty."
82        exit 1
83    elif [ "x`uname`" = "xTru64" ]; then
84        echo "You are attempting to build Sage on HP's Tru64 operating system,"
85        echo "which is not a supported platform for Sage yet. Things may or"
86        echo "may not work. If you would like to help port Sage to Tru64,"
87        echo "please join the sage-devel discussion list - see"
88        echo "http://groups.google.com/group/sage-devel"
89        echo "The Sage community would also appreciate any patches you submit."
90        echo ""
91        echo "To get past this message, export the variable SAGE_PORT to"
92        echo "something non-empty."
93        exit 1
94    elif [ "x`uname`" = "xFreeBSD" ]; then
95        echo "You are attempting to build Sage on the FreeBSD operating system,"
96        echo "which is not a supported platform for Sage yet, though"
97        echo "developers are working on adding FreeBSD support. Things may or"
98        echo "may not work. If you would like to help port Sage to FreeBSD,"
99        echo "please join the sage-devel discussion list - see"
100        echo "http://groups.google.com/group/sage-devel"
101        echo "The Sage community would also appreciate any patches you submit."
102        echo ""
103        echo "To get past this message, export the variable SAGE_PORT to"
104        echo "something non-empty."
105        exit 1
106    elif [ "x`uname`" != "xSunOS" ] && [ "x`uname`" != "xDarwin" ] && [ "x`uname`" != "xLinux" ]; then
107        echo "You are attempting to build Sage on `uname`,"
108        echo "which is not a supported platform for Sage yet. Things may or"
109        echo "may not work. If you would like to help port Sage to `uname`,"
110        echo "please join the sage-devel discussion list - see"
111        echo "http://groups.google.com/group/sage-devel"
112        echo "The Sage community would also appreciate any patches you submit."
113        echo ""
114        echo "To get past this message, export the variable SAGE_PORT to"
115        echo "something non-empty."
116        exit 1
117    fi
118fi
119
120
121if [ "x`uname`" = "xSunOS" ] && [ "x`uname -r`" = "x5.9" ]; then
122    echo "WARNING: Building Sage is not supported on Solaris 9"
123    echo "but it might work, so the build will continue"
124    echo "Solaris 9: copying work around stdint.h"
125    cp $SAGE_ROOT/spkg/base/stdint.h_Solaris9 $SAGE_LOCAL/include/stdint.h
126fi
127
128if [ "x`uname`" = "xSunOS" ] && [ "x`uname -r`" = "x5.8" ]; then
129    echo "WARNING: Building Sage is not supported on Solaris 8"
130    echo "but it might work, so the build will continue"
131    echo "Solaris 8: copying work around stdint.h"
132    cp $SAGE_ROOT/spkg/base/stdint.h_Solaris9 $SAGE_LOCAL/include/stdint.h
133fi
134
135if [ "x`uname`" = "xDarwin" ] && [ "x$SAGE64" = "xyes" ]; then
136    echo "64-bit OS X build"
137    SAGE_OPT="-O2 -g -m64 " && export SAGE_OPT
138fi
139
140# From Kate Minola kate01123@gmail.com
141# On my powerpc-Darwin machine with csh as my shell, when I attempt
142# to build SAGE in the background (i.e., "make &") the build
143# stops when executing 'prereq-0.2-install'.  The reason is
144# that the line
145#     which $1 > /dev/null
146# issues a SIGTTOU signal (background process attempting to write
147# to tty).  Solution:
148trap '' TTOU
149
150# A reasonably sophisticated test is performed in a configure
151# script, which checks compilers exist, their version numbers,
152# the fact GNU and non-GNU compilers are not mixed etc.
153
154tar mxvf "../base/$TARGET.tar"
155cd "$TARGET"
156
157./configure
158
159if [ $? -ne 0 ]; then
160    echo " ERROR: You do not have all of the prerequisites needed"
161    echo " to build Sage from source.  See the errors above."
162    exit 1
163fi
164
165echo `pwd` | grep " "
166
167if [ $? -eq 0 ]; then
168    echo ""
169    echo "*********************************************************"
170    echo ""
171    echo " ERROR: Sage will (probably) not build correctly if there is a space"
172    echo " in the path to the current directory."
173    echo ""
174    echo " Path = `pwd`"
175    echo ""
176    echo "*********************************************************"
177    exit 1
178fi
179
180
181###########################################################################
182# (OS X only)
183# Sage will probably not build at all if either Fink or MacPorts can be
184# found, and the error messages can be extremely confusing.  Even if it does
185# build, the product will probably be wrong.  This runs a basic check to
186# find them. Once the Sage build process is perfected, this won't be necessary.
187# dphilp 15/9/2008
188###########################################################################
189
190if [ `uname` = "Darwin" ]; then
191    echo "***************************************************"
192    echo "***************************************************"
193    echo "***************************************************"
194    echo "WARNING: You are strongly advised to install Apple's latest XCode unless"
195    echo "you already have it. You can download this from "
196    echo "http://developer.apple.com/TOOLS/Xcode/"
197    echo "***************************************************"
198    echo "***************************************************"
199    echo "***************************************************"
200    SAGE_ABORT=no
201    # Try to find ports automatically.
202    PORTS_PATH=`which port`
203    if [ -f "`which port`" ]; then
204        echo "Found MacPorts in " $PORTS_PATH
205        SAGE_ABORT="yes"; export SAGE_ABORT
206    fi
207
208    # Try to find fink automatically.
209    FINK_PATH=`which fink`
210    if [ -f "`which fink`" ]; then
211        echo "Found Fink in " $FINK_PATH
212        SAGE_ABORT="yes"; export SAGE_ABORT
213    fi
214
215    if [ "$SAGE_ABORT" = "yes" ]; then
216        echo ""
217        echo "*********************************************************"
218        echo ""
219        echo "Found either MacPorts or Fink in your PATH, which potentially wrecks the Sage build process."
220        if [ "$SAGE_COMPILE_DESPITE_PORTS_AND_FINK" ]; then
221            echo "Continuing because SAGE_COMPILE_DESPITE_PORTS_AND_FINK is set."
222            echo ""
223            echo "*********************************************************"
224            echo ""
225        else
226            echo "You should make sure MacPorts and Fink cannot be found.  Either:"
227            echo "(1) rename /opt/local and /sw, or"
228            echo "(2) change PATH and DYLD_LIBRARY_PATH"
229            echo "(Once Sage is built, you can restore them.)"
230            echo ""
231            echo "*********************************************************"
232            echo ""
233            exit 1
234        fi
235    fi
236fi
237
238# Solaris only
239# Sun's 'tar' and 'make' are unsuitable for building Sage.
240# So check on Solaris systems that the GNU versions are used.
241# One issue, which still remains and will make a build non-trivial
242# on Solaris is the fact that the first linker and assembler
243# in the path must be the ones used by gcc if the user is using gcc
244# to compile Sage. This is not addressed in this version of 'prereq'
245# but will in a later one.
246
247if [ `uname` = "SunOS" ] ; then
248   if [ -z "`tar --version 2>&1 | grep GNU`" ] ; then
249      echo ""
250      echo "ERROR **********************************************"
251      echo "ERROR **********************************************"
252      echo "You MUST also use the GNU version of tar, as some parts"
253      echo "of the Sage source code are compressed tar files, which"
254      echo "were compressed with GNU tar. GNU tar does not produce"
255      echo "POSIX compliant tar files unless called with the --posix"
256      echo "option, so can not always be extracted with Sun's tar."
257      echo ""
258      echo ""
259      echo "Therefore, to build Sage on Solaris you MUST have"
260      echo "the GNU version of tar in your path before the Sun version"
261      echo ""
262      if [ -f "/usr/sfw/bin/gtar" ]  && [ -f "/usr/sfw/bin/gmake" ] ; then
263          echo "There is a copy of GNU tar, but renamed to 'gtar' in"
264          echo "the directory /usr/sfw/bin. It is suggested that you copy"
265          echo "/usr/sfw/bin/gtar to a different directory, renaming it" 
266          echo "'tar' instead of gtar. Then ensure that directory is in"
267          echo "you path before /usr/bin, so whenever you type 'tar' you"
268          echo "run the GNU version, and not the Sun version of tar." 
269          echo ""
270          echo "Due to some GNUisms, the same applies with 'make'" 
271          echo ""
272          echo "Executing something like"
273          echo ""
274          echo "$ mkdir \$HOME/bins-for-sage"
275          echo "$ cp /usr/sfw/bin/gmake \$HOME/bins-for-sage/make"
276          echo "$ cp /usr/sfw/bin/gtar \$HOME/bins-for-sage/tar"
277          echo "$ export PATH=\$HOME/bins-for-sage:\$PATH"
278          echo ""
279          echo "will put the GNU versions of 'tar' and 'make' in your path"   
280          echo "before the Sun versions"
281          echo ""
282          echo "If you type 'tar --version' it should be obvious whether"
283          echo "the GNU version of 'tar' is first in your path or not" 
284          echo ""
285          echo "If you type  'make --version' is should be obvious whether"
286          echo "the GNU version of 'make' is first in your path or not" 
287          echo ""
288      fi
289      exit 1
290   fi
291   if [ -z "`make --version 2>&1 | grep GNU`" ] ; then
292      echo "Due to numerous GNUisms, you MUST use the GNU version of 'make'"
293      echo "to build Sage on Solaris - Sun's version will not work."
294      echo ""
295      if [ -f "/usr/sfw/bin/gtar" ]  && [ -f "/usr/sfw/bin/gmake" ] ; then
296         echo "There is a copy of GNU 'make', but renamed to 'gmake' in"
297         echo "the directory /usr/sfw/bin. It is suggested that you copy"
298         echo "/usr/sfw/bin/gmake to a different directory, renaming it" 
299         echo "'make' instead of gmake. Then ensure that directory is in"
300         echo "you path before /usr/ccs/bin, so whenever you type 'make' you"
301         echo "run the GNU version, and not the Sun version of make." 
302         echo ""
303         echo "You MUST also use the GNU version of tar, as some parts"
304         echo "of the Sage source code are compressed tar files, which"
305         echo "were compressed with GNU tar. GNU tar does not produce"
306         echo "POSIX compliant tar files unless called with the --posix"
307         echo "option, so can not always be extracted with Sun's tar."
308         echo ""
309         echo "Executing something like"
310         echo "$ mkdir \$HOME/bins-for-sage"
311         echo "$ cp /usr/sfw/bin/gmake \$HOME/bins-for-sage/make"
312         echo "$ cp /usr/sfw/bin/gtar \$HOME/bins-for-sage/tar"
313         echo "$ export PATH=\$HOME/bins-for-sage:\$PATH"
314         echo "will put the GNU versions of 'tar' and 'make' in your path"   
315         echo "before the Sun versions"
316         echo ""
317         echo "If you type 'make --version' it should be obvious whether"
318         echo "the GNU version of 'make' is first in your path or not" 
319         echo ""
320         echo "If you type  'tar --version' is should be obvious whether"
321         echo "the GNU version of 'tar' is first in your path or not" 
322         echo ""
323      else
324         echo "You can either compile GNU make from source, or it may be"
325         echo "obtained from Blastwave or Sunfreeware.com"
326         echo ""
327         echo "On Open Solaris, some GNU tools can be found at /usr/gnu"
328         echo "although at the time of writing, this directory did not contain"
329         echo "make or tar, but you might try looking there."
330      fi
331      exit 1
332   fi
333fi
334
335# Test for GNU versions of tar and make on AIX, HP-UX, IRIX and Tru64
336# Unlike on Solaris, no help is given about where to find the GNU
337# versions, as I've not used a sufficient number of these machines
338# to know where to find the GNU tools. The tests for operating system
339# are split across two lines, as it's unwise to make more than 4 test.
340# The split shown seemed the most natural, with making the
341# IRIX and IRIX64 tests on a line of their own. David Kirkby January 2010
342
343if [ -z "`tar --version 2>&1 | grep GNU`" ] ; then
344   if [ "x`uname`" = "xHP-UX" ] ||  [ "x`uname`" = "xAIX" ] ||   [ "x`uname`" = "Tru64" ] ; then
345       echo ""
346       echo "You must use the GNU version of tar on `uname` Please"
347       echo "ensure that a GNU version of tar is first in your path"
348       exit 1
349   elif [ "x`uname`" = "xIRIX" ] ||  [ "x`uname`" = "xIRIX64" ] ; then
350       echo ""
351       echo "You must use the GNU version of tar on IRIX. Please"
352       echo "ensure that a GNU version of tar is first in your path"
353       exit 1
354   fi
355fi
356
357
358if [ -z "`make --version 2>&1 | grep GNU`" ] ; then
359   if [ "x`uname`" = "xHP-UX" ] ||  [ "x`uname`" = "xAIX" ] ||   [ "x`uname`" = "xTru64" ] ; then
360       echo ""
361       echo "You must use the GNU version of make on `uname` Please"
362       echo "ensure that a GNU version of make is first in your path"
363       exit 1
364   elif [ "x`uname`" = "xIRIX" ] ||  [ "x`uname`" = "xIRIX64" ] ; then
365       echo ""
366       echo "You must use the GNU version of make on IRIX. Please"
367       echo "ensure that a GNU version of make is first in your path"
368       exit 1
369   fi
370fi
371
372
373touch $ROOT/installed/$TARGET
374