Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /config/releases/release-110.63/install.sh
ViewVC logotype

Diff of /config/releases/release-110.63/install.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 489, Tue Nov 23 12:55:00 1999 UTC revision 1145, Fri Mar 15 02:30:53 2002 UTC
# Line 2  Line 2 
2  #  #
3  # Copyright (c) 1994 AT&T Bell Laboratories.  # Copyright (c) 1994 AT&T Bell Laboratories.
4  #  #
5  # installation script for SML/NJ and related tools; this is a temporary  # Installation script for SML/NJ and related tools; this is a temporary
6  # placeholder until the configuration tool is finished.  # placeholder until the configuration tool is finished.
7  #  #
8    # Significant changes to accommodate (and take advantage of) the new CM
9    # by M.Blume (2/2000).
10    #
11    
12    if [ x${INSTALL_QUIETLY} = xtrue ] ; then
13        export CM_VERBOSE=false
14    fi
15    
16  #set -x  vsay() {
17        if [ x${INSTALL_DEBUG} = xtrue ] ; then
18            echo "$@"
19        elif [ x${INSTALL_QUIETLY} = xtrue ] ; then
20            :
21        else
22            echo "$@"
23        fi
24    }
25    
26    dsay() {
27        if [ x${INSTALL_DEBUG} = xtrue ] ; then
28            echo "$@"
29        fi
30    }
31    
32    complain() {
33        echo "$@"
34        exit 1
35    }
36    
37    # The following variable holds the name of all possible targets.
38    # The names must occur in the order in which targets are to be built.
39    ALLTARGETS=\
40    "src-smlnj \
41     ml-yacc \
42     ml-lex \
43     ml-burg \
44     ml-nlffigen \
45     smlnj-lib \
46     cml \
47     cml-lib \
48     eXene \
49     ckit \
50     ml-nlffi-lib \
51     pgraph-util \
52     mlrisc-tools \
53     nowhere \
54     doc"
55    
56    this=$0
57    
58    # By default, move libraries to lib directory:
59    MOVE_LIBRARIES=true
60    
61    # function to be used in config/targets:
62    dont_move_libraries() { MOVE_LIBRARIES=false ; }
63    
64    # Initialize target list.
65    TARGETS=""
66    
67    # function to be used in config/targets:
68    request() { TARGETS="$TARGETS $1" ; }
69    
70  #  #
71  # get the target list  # get the target list
72  #  #
73  if [ ! -r config/targets ]; then  if [ -r config/targets.customized ] ; then
74    echo "!!! File config/targets is missing."      . config/targets.customized
75    exit 1;  elif [ ! -r config/targets ]; then
76  fi      complain "$this: !!! File config/targets is missing."
77    else
78  . config/targets  . config/targets
79    fi
80    
81  #  #
82  # some OSs have make in strange places  # resolve dependencies
83  #  #
84  MAKE=make  isnotin() {
85        tested_x=$1
86        shift
87        for set_y in "$@" ; do
88            if [ ${tested_x} = ${set_y} ] ; then
89                return 1
90            fi
91        done
92        return 0
93    }
94    
95    require() {
96        require_who=$1
97        shift
98        if isnotin ${require_who} ${TARGETS} ; then
99            :
100        else
101            for required_x in "$@" ; do
102                if isnotin ${required_x} ${TARGETS} ; then
103                    echo "Including ${required_x} (needed by ${require_who})."
104                    request ${required_x}
105                    CHANGED=true
106                fi
107            done
108        fi
109    }
110    
111    onepass() {
112        while read depline ; do
113            require $depline
114        done
115    }
116    
117    if [ -r config/dependencies ] ; then
118        CHANGED=true
119        while [ $CHANGED = true ]; do
120            CHANGED=false
121            onepass <config/dependencies
122        done
123    fi
124    
125    #
126    # Rebuild target list using the order defined by ALLTARGETS.
127  #  #
128  # check for ksh  NEWTARGETS=""
129    for t in ${ALLTARGETS} ; do
130        if isnotin $t ${TARGETS} ; then
131            :
132        else
133            NEWTARGETS="$NEWTARGETS $t"
134        fi
135    done
136    TARGETS=$NEWTARGETS
137    
138  #  #
139  # ksh causes some people problems so we will always use /bin/sh  # create the preloads.standard file
140  #  #
141  #echo "checking for ksh"  if [ ! -r config/preloads ]; then
142  #if [ -x /bin/ksh ]; then      complain "$this: !!! File config/preloads is missing."
143  #  SHELL=/bin/ksh  fi
144  #elif [ -x /usr/local/bin/ksh ]; then  cp config/preloads preloads.standard
145  #  SHELL=/usr/local/bin/ksh  
146  #else  #
147    # Some OSs have make in strange places, but most of the time it is
148    # simply on the PATH:
149    #
150    MAKE=make
151    
152    #
153    # Make sure we don't have any unpleasant surprises due to the installing
154    # user's process environment:
155    #
156    unset CM_PATHCONFIG
157    
158    SHELL=/bin/sh    SHELL=/bin/sh
159  #fi  vsay $this: Using shell $SHELL.
 echo Using shell $SHELL.  
160    
161  #  #
162  # set the SML root directory  # set the SML root directory
163  #  #
164  REAL_PWD=`pwd`  REAL_PWD=`pwd`
165  ROOT=${PWD:-$REAL_PWD}  ROOT=${PWD:-$REAL_PWD}
166  echo SML root is $ROOT.  vsay $this: SML root is $ROOT.
167  echo Installation directory is ${INSTALLDIR:=$ROOT}.  vsay $this: Installation directory is ${INSTALLDIR:=$ROOT}.
168    
169  #  #
170  # set the various directory and file pathname variables  # set the various directory and file pathname variables
# Line 55  Line 176 
176  SRCDIR=$ROOT/src                # where the source tree is rooted  SRCDIR=$ROOT/src                # where the source tree is rooted
177  LIBDIR=$INSTALLDIR/lib          # where libraries live  LIBDIR=$INSTALLDIR/lib          # where libraries live
178  LIBLIST=$ROOT/liblist           # list of commands to stabilize libraries  LIBLIST=$ROOT/liblist           # list of commands to stabilize libraries
179    LATESTANDALONES=$ROOT/latestandalones # standalone programs to be built late
180  LIBMOVESCRIPT=$ROOT/libmove     # a temporary script  LIBMOVESCRIPT=$ROOT/libmove     # a temporary script
181  LOCALPATHCONFIG=$INSTALLDIR/pathconfig # a temporary pathconfig file  LOCALPATHCONFIG=$INSTALLDIR/pathconfig # a temporary pathconfig file
182    
183  #  #
184  # the paths to ml-yacc, ml-burg, and ml-lex; needed to configure CM  # The path to the dir where ml-yacc, ml-burg, ml-lex, ml-build, and
185    # ml-makedepend live.  This path will be interpreted relative to $LIBDIR.
186    #
187    TOOLDIR=../bin
188    
189    #
190    # A temporary file for post-editing the pathconfig file...
191  #  #
192  YACCPATH=$BINDIR/ml-yacc  PCEDITTMP=$INSTALLDIR/pcedittmp.$$
193  LEXPATH=$BINDIR/ml-lex  
194  BURGPATH=$BINDIR/ml-burg  #
195    # files to be deleted after we are done...
196    #
197    tmpfiles=""
198    tmpfiles="$tmpfiles $ROOT/preloads.standard"
199    tmpfiles="$tmpfiles $LIBLIST"
200    tmpfiles="$tmpfiles $LATESTANDALONES"
201    tmpfiles="$tmpfiles $LOCALPATHCONFIG"
202    tmpfiles="$tmpfiles $LIBMOVESCRIPT"
203    tmpfiles="$tmpfiles $PCEDITTMP"
204    #
205    # make sure we always clean up after ourselves...
206    #
207    trap 'rm -f $tmpfiles' 0 1 2 3 15
208    
209    
210  #  #
211  # set the CM configuration variables (these are environment variables  # set the CM configuration variables (these are environment variables
212  # that will be queried by the bootstrap code)  # that will be queried by the bootstrap code)
213  # Especially important is CM_PATHCONFIG_DEFAULT.  # Especially important is CM_PATHCONFIG_DEFAULT.
214  #  #
 CM_YACC_DEFAULT=$YACCPATH  
 CM_LEX_DEFAULT=$LEXPATH  
 CM_BURG_DEFAULT=$BURGPATH  
215  CM_PATHCONFIG_DEFAULT=$LIBDIR/pathconfig  CM_PATHCONFIG_DEFAULT=$LIBDIR/pathconfig
216  export CM_YACC_DEFAULT CM_LEX_DEFAULT CM_BURG_DEFAULT CM_PATHCONFIG_DEFAULT  export CM_PATHCONFIG_DEFAULT
217    
218  #  #
219  # the release version that we are installing  # the release version that we are installing
220  #  #
221  VERSION=`cat $CONFIGDIR/version`  VERSION=`cat $CONFIGDIR/version`
222  echo Installing version $VERSION.  vsay $this: Installing version $VERSION.
223    
224  #  #
225  # Function to make a directory (and advertise such action).  # the URL for the (usually remote) source archive
226    #
227    SRCARCHIVEURL=`cat $CONFIGDIR/srcarchiveurl`
228    vsay $this: URL of source archive is $SRCARCHIVEURL.
229    
230    #
231    # Function to make a directory including its ancestors.
232  #  #
233  makedir() {  makedir() {
234      if [ ! -d $1 ] ; then      if [ x$1 = x ] ; then
235          echo Making directory $1          :
236        elif [ -d $1 ] ; then
237            :
238        else
239            makedir `dirname $1`
240            if [ x${INSTALL_VERBOSE} = xtrue ] ; then
241                vsay "$this: Making directory $1"
242            fi
243          if mkdir $1 ; then          if mkdir $1 ; then
244              : everything is fine              :
245          else          else
246              echo "!!! Unable to make directory $1!"              complain "$this: !!! Unable to make directory $1!"
247            fi
248        fi
249    }
250    
251    #
252    # Function for asking user to fetch source archive.
253    #   $1 - descriptive name
254    #   $2 - base name without extension, without version, and without dir
255    #   $3 - remote directory
256    #
257    askurl() {
258        echo "$this: Please, fetch $1 archive"
259        echo ' ('$2.'*' or $VERSION-$2.'*)'
260        echo " from $3"
261        echo " and then re-run this script!"
262              exit 1              exit 1
263    }
264    
265    #
266    # Function for fetching source archives automatically using wget or lynx.
267    #   $1 - command to actually get the stuff
268    #   $2 - descriptive name
269    #   $3 - base name without extension and without dir
270    #   $4 - remote directory
271    #
272    fetchurl() {
273        getter=$1 ; shift
274        vsay $this: Fetching $1 from $3. Please stand by...
275        fetched=no
276        for base in $2 $VERSION-$2 ; do
277            for ext in tar.gz tgz tar.Z tz tar tar.bz2 ; do
278                try=$base.$ext
279                vsay $this: Trying $try ...
280                if $getter $3/$try $ROOT/$try ; then
281                    fetched=yes
282                    vsay $this: Fetching $try was a success.
283                    break 2         # get out of both for-loops
284                else
285                    rm -f $ROOT/$try
286          fi          fi
287            done
288        done
289        if [ $fetched = no ] ; then
290            echo $this: Fetching $try was no success.
291            echo '  ' You should try to do it manually now.
292            askurl "$1" "$2" "$3"
293        fi
294    }
295    
296    # wrapper for wget
297    usewget() {
298        wget -nv -O $2 $1
299    }
300    
301    # wrapper for lynx
302    uselynx() {
303        lynx -source $1 >$2
304    }
305    
306    # wrapper for curl
307    usecurl() {
308        curl -s $1 >$2
309    }
310    
311    testurlgetter() {
312        (exec >/dev/null 2>&1 ; exec $*)
313    }
314    
315    #
316    # Function to check whether wget or lynx is available.
317    # Set URLGETTER accordingly.  URLGETTER can be set externally
318    # to either 'wget' or 'curl' or 'lynx' -- in which case the
319    # corresponding command will be used (properly wrapped).  Any
320    # other external setting will be passed directly to fetchurl (without
321    # wrapping -- meaning it must take precisely two argumets: source and
322    # destination, in that order).
323    #
324    urlgetter() {
325        case ${URLGETTER:-unknown} in
326            fetchurl*)
327                ;;
328            unknown)
329                # automatically figure out which wrapper to use
330                if testurlgetter wget --help ; then
331                    URLGETTER="fetchurl usewget"
332                elif testurlgetter curl -s -O file:///dev/null -o /dev/null ; then
333                    URLGETTER="fetchurl usecurl"
334                elif testurlgetter lynx -help ; then
335                    URLGETTER="fetchurl uselynx"
336                else
337                    URLGETTER="askurl"
338                fi
339                ;;
340            wget|curl|lynx)
341                # special getters we know how to wrap
342                URLGETTER="fetchurl use${URLGETTER}"
343                ;;
344            *)
345                # other -- must be able to work without wrapper
346                URLGETTER="fetchurl ${URLGETTER}"
347                ;;
348        esac
349    }
350    
351    # wrapper for tar
352    un_tar() {
353        vsay "$this: Un-TAR-ing $1 archive."
354        tar -xf $2
355    }
356    
357    # wrapper for zcat followed by tar
358    un_tar_Z() {
359        vsay "$this: Un-COMPRESS-ing and un-TAR-ing $1 archive."
360        zcat $2 | tar -xf -
361    }
362    
363    # wrapper for gunzip followed by tar
364    un_tar_gz() {
365        vsay "$this: Un-GZIP-ing and un-TAR-ing $1 archive."
366        gunzip -c $2 | tar -xf -
367    }
368    
369    # wrapper for bunzip2 followed by tar
370    un_tar_bz2() {
371        vsay "$this: Un-BZIP2-ing and un-TAR-ing $1 archive."
372        bunzip2 -c $2 | tar -xf -
373    }
374    
375    # unarchive archive without and with version number attached
376    unarchive() {
377        # $1: descriptive string, $2: archive, $3: unpacker
378        if [ -r $ROOT/$2 ] ; then
379            $3 "$1" $ROOT/$2
380        elif [ -r $ROOT/$VERSION-$2 ]; then
381            $3 "$1" $ROOT/$VERSION-$2
382        else
383            return 1
384      fi      fi
385  }  }
386    
# Line 106  Line 393 
393  # $4: the basename of the source archive (the script will check several  # $4: the basename of the source archive (the script will check several
394  #     different suffixes to determine what kind of de-compression is to  #     different suffixes to determine what kind of de-compression is to
395  #     be used)  #     be used)
396  unpack() {  #
397      if [ ! -d $2/$3 ]; then  # fetch_n_unpack is the helper function that does the real work.  If
398          echo Unpacking $1 source files.  # no archive is found locally, it invokes $URLGETTER and tries again.
399    # The variable $tryfetch is used to make sure this happens only once.
400    fetch_n_unpack() {
401          cd $2          cd $2
402          if [ -r $4.tar.Z ] ; then      if unarchive "$1" $4.tar.gz un_tar_gz ||
403              zcat $4.tar.Z | tar -xf -         unarchive "$1" $4.tgz un_tar_gz ||
404          elif [ -r $4.tar ] ; then         unarchive "$1" $4.tar.Z un_tar_Z ||
405              tar -xf $4.tar         unarchive "$1" $4.tar un_tar ||
406          elif [ -r $4.tar.gz ] ; then         unarchive "$1" $4.tar.bz2 un_tar_bz2 ||
407              gunzip -c $4.tar.gz | tar -xf -         unarchive "$1" $4.tz un_tar_Z
408          elif [ -r $4.tar.bz2 ] ; then      then
409              bunzip2 -c $4.tar.bz2 | tar -xf -          : we are done
410          elif [ -r $4.tgz ] ; then      elif [ $tryfetch = yes ] ; then
411              gunzip -c $4.tgz | tar -xf -          urlgetter
412          elif [ -r $4.tz ] ; then          $URLGETTER "$1" $4 $SRCARCHIVEURL
413              zcat $4.tz | tar -xf -          tryfetch=no
414            fetch_n_unpack "$1" "$2" "$3" "$4"
415        fi
416    }
417    
418    #
419    # The main "unpack" driver function that invokes the above helper.
420    #
421    unpack() {
422        tryfetch=yes
423        if [ -d $2/$3 ]; then
424            vsay "$this: The $1 tree already exists."
425          else          else
426              echo "!!! The $1 source files are missing."          fetch_n_unpack "$1" "$2" "$3" "$4"
             exit 1  
427          fi          fi
428          if [ ! -d $2/$3 ]; then          if [ ! -d $2/$3 ]; then
429              echo "!!! Unable to unpack $1 source files."          complain "$this: !!! Unable to unpack $1 archive."
             exit 1  
         fi  
430      fi      fi
431  }  }
432    
433  #  # A function to move all stable library files to a parallel directory
434  # Move the stable archive of a library whose description file was $1/$2 to  # hierarchy.
435  # $LIBDIR/$2/CM/$ARCH-unix/$2 so that it appears as if the description file  # The first argument must be a simple path (no / inside), and
436  # had been at $LIBDIR/$2/$2  # the second argument must be an absolute path.
437  #  move() {
438  # (This script will also move all other libraries that show up in      if [ -d $1 ] ; then
439  #  $1/CM/$ARCH-unix because in the case of the boot directory this indicates          if [ ! -d $2 ] ; then
440  #  that some library did not have its own path anchor but was specified              if [ -f $2 ] ; then
441  #  relative to $1/$2. Still, don't rely on this to be robust -- rather make                  complain $this: $2 exists as a non-directory.
442  #  separate anchors for every library!)              fi
443  #              mkdir $2
444  movelibs() {          fi
445      for lib in `/bin/ls $1/CM/$ARCH-unix` ; do          cd $1
446          case $lib in          for i in * ; do
447          *.cm)              move $i $2/$i
             if [ $lib != $2 ] ; then  
                 echo "! Warning:" $lib specified relative to $2  
             fi  
             echo Moving library $lib to $LIBDIR  
             makedir $LIBDIR/$2  
             makedir $LIBDIR/$2/CM  
             makedir $LIBDIR/$2/CM/$ARCH-unix  
             mv $1/CM/$ARCH-unix/$lib $LIBDIR/$2/CM/$ARCH-unix/$lib  
             ;;  
         *)  
             ;;  
         esac  
448       done       done
449            cd ..
450        elif [ -f $1 ] ; then
451            rm -f $2
452            mv $1 $2
453        fi
454    }
455    
456    # move stable library file from $1 to $2
457    movelib()
458    {
459        SOURCE=$1
460        TARGET=$2
461        TARGETDIR=`dirname ${TARGET}`
462        if [ ! -d ${TARGETDIR} ] ; then
463            makedir ${TARGETDIR}
464        fi
465        mv ${SOURCE} ${TARGET}
466  }  }
467    
468  # A shell function that registers a library for being built.  # A shell function that registers a library for being built.
469  # This function takes two arguments: 1. a name under which the library  # This function takes 3 arguments:
470  # is to be known later (something.cm) and 2. the path relative to $SRCDIR  #   $1 = controlling anchor
471  # that leads to the library's .cm file.  The library's .cm file must be the  #   $2 = name relative to controlling anchor
472  # same as $1.  #   $3 = dir (relative to ${SRCDIR}) corresponding to $1
473  #  #
474  # This works by adding ML code to file $LIBLIST.  The code in this file  # This works by adding ML code to file $LIBLIST.  The code in this file
475  # will be executed near the end of this script.  If $MOVE_LIBRARIES is  # will be executed near the end of this script.  If $MOVE_LIBRARIES is
476  # set to true, then reglib will also register a "movelibs" to be executed at  # set to true, then reglib will also register a "movelib" to be executed at
477  # the end by putting a "movelibs" line into $LIBMOVESCRIPT.  # the end by putting a "movelib" line into $LIBMOVESCRIPT.
   
478  reglib() {  reglib() {
479        ANCHOR=$1
480        RELNAME=$2
481        LIBNAME='$'${ANCHOR}/${RELNAME}
482        ADIR=${SRCDIR}/$3
483        RELDIR=`dirname $RELNAME`
484        RELBASE=`basename $RELNAME`
485        if [ x$RELDIR = x. ] ; then
486            RELDIR=
487        else
488            RELDIR=/$RELDIR
489        fi
490        RELLOC=${RELDIR}/CM/${ARCH}-unix/${RELBASE}
491        SRCFINALLOC=${ADIR}${RELLOC}
492      if [ x$MOVE_LIBRARIES = xtrue ] ; then      if [ x$MOVE_LIBRARIES = xtrue ] ; then
493          FINALLOCATION=$LIBDIR/$1          FINALLOC=${LIBDIR}/${ANCHOR}${RELLOC}
494            FINALCONFIGPATH=${ANCHOR}
495      else      else
496          FINALLOCATION=$SRCDIR/$2          FINALLOC=${SRCFINALLOC}
497            FINALCONFIGPATH=${ADIR}
498      fi      fi
499      if [ -d $FINALLOCATION/CM/$ARCH-unix ] ; then  
500          echo "Library $1 already exists in $FINALLOCATION."      if [ -f ${FINALLOC} ] ; then
501            vsay "$this: Library ${LIBNAME} already exists in ${FINALLOC}"
502      else      else
503          echo "Scheduling library $1 to be built in $FINALLOCATION."          vsay "$this: Scheduling library ${LIBNAME} to be built as ${FINALLOC}."
504          echo "andalso CM.stabilize false \"$1\"" >>$LIBLIST          echo "  andalso CM.stabilize false \"${LIBNAME}\"" >>${LIBLIST}
505          echo $1 $SRCDIR/$2 >>$LOCALPATHCONFIG          echo ${ANCHOR} ${ADIR} >>${LOCALPATHCONFIG}
506          if [ x$MOVE_LIBRARIES = xtrue ] ; then          if [ x$MOVE_LIBRARIES = xtrue ] ; then
507              echo movelibs $SRCDIR/$2 $1 >>$LIBMOVESCRIPT              echo movelib ${SRCFINALLOC} ${FINALLOC} >>${LIBMOVESCRIPT}
508          fi          fi
         echo $1 $FINALLOCATION >>$CM_PATHCONFIG_DEFAULT  
509      fi      fi
510        echo ${ANCHOR} ${FINALCONFIGPATH} >>${CM_PATHCONFIG_DEFAULT}
511  }  }
512    
513  #  #
514  # Function to build a standalone program such as ml-yacc.  The function takes  # Function to build a standalone program such as ml-yacc.  The function takes
515  # 2 or 3 arguments.  First the name of the program which at the same time  # 2 or 3 or 4 arguments.  First the name of the program which at the same time
516  # is the directory name under $SRCDIR where the sources reside.  The second  # is the directory name under $SRCDIR/$4 where the sources reside.  The second
517  # argument is a descriptive name for the program (passed on to "unpack").  # argument is a descriptive name for the program (passed on to "unpack").
518  # The optional third argument specifies the path relative to $SRCDIR/$1  # The optional third argument specifies the path relative to $SRCDIR/$4/$1
519  # of the directory where the program's heap image is to be found.  # of the directory where the program's heap image is to be found.
520    # The fourth argument, if missing, defaults to "."
521  #  #
522    
523  standalone() {  standalone() {
# Line 209  Line 527 
527      else      else
528          TARGETLOC=$TARGET          TARGETLOC=$TARGET
529      fi      fi
530        if [ $# = 4 ] ; then
531             MYSRCDIR=$SRCDIR/$4
532        else
533             MYSRCDIR=$SRCDIR
534        fi
535      if [ -r $HEAPDIR/$TARGET ] ; then      if [ -r $HEAPDIR/$TARGET ] ; then
536          echo Target $TARGET already exists.          vsay $this: Target $TARGET already exists.
537      else      else
538          echo Building $TARGET.          echo $this: Building $TARGET.
539          unpack $2 $SRCDIR $1 $ROOT/$VERSION-$1          unpack $2 $MYSRCDIR $1 $1
540          cd $SRCDIR/$1          cd $MYSRCDIR/$1
541          ./build          # build it, but make sure we don't pick up some (unrelated)
542            # local path configuration...
543            CM_LOCAL_PATHCONFIG=/dev/null ./build
544          if [ -r $TARGETLOC ] ; then          if [ -r $TARGETLOC ] ; then
545              mv $TARGETLOC $HEAPDIR/$TARGET              mv $TARGETLOC $HEAPDIR/$TARGET
546              if [ ! -f $BINDIR/$1 ] ; then              if [ ! -f $BINDIR/$1 ] ; then
# Line 223  Line 548 
548                  ln -s .run-sml $1                  ln -s .run-sml $1
549              fi              fi
550          else          else
551              echo "!!! Build of $TARGET failed."              echo "$this: !!! Build of $TARGET failed."
552          fi          fi
553      fi      fi
554  }  }
555    
556    ######################################################################
557    
558  #  #
559  # create the various sub directories  # create the various sub directories
560  #  #
561  for dir in $BINDIR $HEAPDIR $RUNDIR $LIBDIR $SRCDIR  for dir in $BINDIR $HEAPDIR $RUNDIR $LIBDIR $SRCDIR ; do
 do  
562      makedir $dir      makedir $dir
563  done  done
564    
   
565  #  #
566  # install the script that tests the architecture, and make sure that it works  # install the script that tests the architecture, and make sure that it works
567  #  #
568  if [ -x $BINDIR/.arch-n-opsys ]; then  if [ -x $BINDIR/.arch-n-opsys ]; then
569    echo Script $BINDIR/.arch-n-opsys already exists.      vsay $this: Script $BINDIR/.arch-n-opsys already exists.
570  else  else
571    cat $CONFIGDIR/_arch-n-opsys | sed -e "s,@SHELL@,$SHELL,g" > $BINDIR/.arch-n-opsys      cat $CONFIGDIR/_arch-n-opsys \
572        | sed -e "s,@SHELL@,$SHELL,g" > $BINDIR/.arch-n-opsys
573    chmod 555 $BINDIR/.arch-n-opsys    chmod 555 $BINDIR/.arch-n-opsys
574    if [ ! -x $BINDIR/.arch-n-opsys ]; then    if [ ! -x $BINDIR/.arch-n-opsys ]; then
575      echo "!!! Installation of $BINDIR/.arch-n-opsys failed for some reason."          complain "$this: !!! Installation of $BINDIR/.arch-n-opsys failed."
     exit 1  
576    fi    fi
577  fi  fi
578    
579  ARCH_N_OPSYS=`$BINDIR/.arch-n-opsys`  ARCH_N_OPSYS=`$BINDIR/.arch-n-opsys`
580  if [ "$?" != "0" ]; then  if [ "$?" != "0" ]; then
581    echo "!!! Script $BINDIR/.arch-n-opsys fails on this machine."      echo "$this: !!! Script $BINDIR/.arch-n-opsys fails on this machine."
582    echo "!!! You must patch this by hand and repeat the installation."      echo "$this: !!! You must patch this by hand and repeat the installation."
583    exit 2    exit 2
584  else  else
585    echo Script $BINDIR/.arch-n-opsys reports $ARCH_N_OPSYS.      vsay $this: Script $BINDIR/.arch-n-opsys reports $ARCH_N_OPSYS.
586  fi  fi
587  eval $ARCH_N_OPSYS  eval $ARCH_N_OPSYS
588    
589  if [ -x $BINDIR/.run-sml ]; then  #
590    echo Script $BINDIR/.run-sml already exists.  # Function to install a "driver" script...
591  else  #   This takes care of patching the source of the script with the SHELL,
592    cat $CONFIGDIR/_run-sml | \  #   BINDIR, and VERSION variables to use.
593      sed -e "s,@SHELL@,$SHELL,g" -e "s,@BINDIR@,$BINDIR," -e "s,@VERSION@,$VERSION," \  #
594      > $BINDIR/.run-sml  installdriver() {
595    chmod 555 $BINDIR/.run-sml      dsrc=$1
596    if [ ! -x $BINDIR/.run-sml ]; then      ddst=$2
597      echo "!!! Installation of $BINDIR/.run-sml failed for some reason."  # We install the driver unconditionally. (It would be better to test
598      exit 1  # for an outdated driver script, but not all "test" commands understand
599    fi  # the -nt comparison operator....)
600    #   if [ -x $BINDIR/$ddst ]; then
601    #       echo $this: Script $BINDIR/$ddst already exists.
602    #   else
603            rm -f $BINDIR/$ddst
604            cat $CONFIGDIR/$dsrc | \
605            sed -e "s,@SHELL@,$SHELL,g" \
606                -e "s,@BINDIR@,$BINDIR," \
607                -e "s,@VERSION@,$VERSION," \
608                > $BINDIR/$ddst
609            chmod 555 $BINDIR/$ddst
610            if [ ! -x $BINDIR/$ddst ]; then
611                complain "$this: !!! Installation of $BINDIR/${ddst} failed."
612  fi  fi
613    #   fi
614    }
615    
616    installdriver _run-sml .run-sml
617    installdriver _link-sml .link-sml
618    installdriver _ml-build ml-build
619    installdriver _ml-makedepend ml-makedepend
620    
621  #  #
622  # set some architecture dependent run-time system flags  # set some architecture dependent run-time system flags
623  #  #
624  case $ARCH in  case $ARCH in
625    mips*) ALLOC=1M ;;      mips*)
626            ALLOC=1M
627            ;;
628    x86)    x86)
629            # The following is the _wrong_ value for many popular x86 chips
630            # (i.e., Celerons).  However, the optimal value for those is 32k,
631            # and such a small value is not enough for the runtime system's boot
632            # code.  Therefore, we use 256k here and re-set it to the proper
633            # value in .run-sml.
634      ALLOC=256k      ALLOC=256k
635    ;;    ;;
636    alpha32)    alpha32)
# Line 288  Line 640 
640      ALLOC=512k      ALLOC=512k
641    ;;    ;;
642  esac  esac
643    
644  case $OPSYS in  case $OPSYS in
645    solaris)    solaris)
646      MAKE=/usr/ccs/bin/make      MAKE=/usr/ccs/bin/make
# Line 295  Line 648 
648    linux)    linux)
649      EXTRA_DEFS=`$CONFIGDIR/chk-global-names.sh`      EXTRA_DEFS=`$CONFIGDIR/chk-global-names.sh`
650      if [ "$?" != "0" ]; then      if [ "$?" != "0" ]; then
651        echo "!!! Problems checking for underscores in global names."              complain "$this: !!! Problems checking for underscores in asm names."
       exit 1  
652      fi      fi
653      EXTRA_DEFS="XDEFS=$EXTRA_DEFS"      EXTRA_DEFS="XDEFS=$EXTRA_DEFS"
654    ;;    ;;
# Line 305  Line 657 
657  #  #
658  # the name of the bin files directory  # the name of the bin files directory
659  #  #
660  BOOT_FILES=comp.boot.$ARCH-unix  BOOT_ARCHIVE=boot.$ARCH-unix
661    BOOT_FILES=sml.$BOOT_ARCHIVE
662    
663  #  #
664  # build the run-time system  # build the run-time system
665  #  #
666  unpack "run-time" $SRCDIR runtime $ROOT/$VERSION-runtime  unpack "run-time" $SRCDIR runtime runtime
667  if [ ! -x $RUNDIR/run.$ARCH-$OPSYS ]; then  if [ -x $RUNDIR/run.$ARCH-$OPSYS ]; then
668        vsay $this: Run-time system already exists.
669    else
670    cd $SRCDIR/runtime/objs    cd $SRCDIR/runtime/objs
671    echo Compiling the run-time system.      echo $this: Compiling the run-time system.
672    $MAKE -f mk.$ARCH-$OPSYS $EXTRA_DEFS    $MAKE -f mk.$ARCH-$OPSYS $EXTRA_DEFS
673    if [ -x run.$ARCH-$OPSYS ]; then    if [ -x run.$ARCH-$OPSYS ]; then
674      mv run.$ARCH-$OPSYS $RUNDIR      mv run.$ARCH-$OPSYS $RUNDIR
675      # $MAKE MAKE=$MAKE clean          $MAKE MAKE=$MAKE clean
676    else    else
677      echo "!!! Run-time system build failed for some reason."          complain "$this: !!! Run-time system build failed for some reason."
     exit 1  
678    fi    fi
679  fi  fi
680  cd $SRCDIR  cd $SRCDIR
# Line 329  Line 683 
683  # boot the base SML system  # boot the base SML system
684  #  #
685  if [ -r $HEAPDIR/sml.$HEAP_SUFFIX ]; then  if [ -r $HEAPDIR/sml.$HEAP_SUFFIX ]; then
686    echo Heap image $HEAPDIR/sml.$HEAP_SUFFIX already exists.      vsay $this: Heap image $HEAPDIR/sml.$HEAP_SUFFIX already exists.
687  else  else
688    unpack bin $ROOT $BOOT_FILES $ROOT/$VERSION-$BOOT_FILES      unpack bin $ROOT $BOOT_FILES $BOOT_ARCHIVE
689    cd $ROOT      cd $ROOT/$BOOT_FILES
690    if $RUNDIR/run.$ARCH-$OPSYS @SMLheap=sml \      if $BINDIR/.link-sml @SMLheap=$ROOT/sml @SMLboot=BOOTLIST @SMLalloc=$ALLOC
         @SMLboot=$ROOT/$BOOT_FILES @SMLrtpid=`cat $BOOT_FILES/RTPID` \  
         @SMLalloc=$ALLOC  
691    then    then
692            cd $ROOT
693      if [ -r sml.$HEAP_SUFFIX ]; then      if [ -r sml.$HEAP_SUFFIX ]; then
694          mv sml.$HEAP_SUFFIX $HEAPDIR          mv sml.$HEAP_SUFFIX $HEAPDIR
695          cd $BINDIR          cd $BINDIR
696          ln -s .run-sml sml          ln -s .run-sml sml
   
697          #          #
698          # Now move all stable libraries to #LIBDIR and generate          # Now move all stable libraries to #LIBDIR and generate
699          # the pathconfig file.          # the pathconfig file.
700          #          #
   
701          cd $ROOT/$BOOT_FILES          cd $ROOT/$BOOT_FILES
702          for lib in *.cm ; do              for anchor in * ; do
703              echo $lib $LIBDIR/$lib >>$CM_PATHCONFIG_DEFAULT                  if [ -d $anchor ] ; then
704              movelibs $ROOT/$BOOT_FILES/$lib $lib                      echo $anchor $anchor >>$CM_PATHCONFIG_DEFAULT
705                        move $anchor $LIBDIR/$anchor
706                    fi
707          done          done
708          cd $ROOT          cd $ROOT
709          # rm -rf $BOOT_FILES              # $BOOT_FILES is now only an empty skeleton, let's get rid of it.
710                rm -rf $BOOT_FILES
711    
712      else      else
713          echo "!!! Boot code did not produce heap image (sml.$HEAP_SUFFIX)."              complain "$this !!! No heap image generated (sml.$HEAP_SUFFIX)."
         exit 1  
714      fi      fi
715    else    else
716      echo "!!! Boot code failed, no heap image built (sml.$HEAP_SUFFIX)."          complain "$this !!! Boot code failed, no heap image (sml.$HEAP_SUFFIX)."
     exit 1  
717    fi    fi
718  fi  fi
719    
# Line 370  Line 722 
722  #  #
723  cd $ROOT  cd $ROOT
724  rm -f $LOCALPATHCONFIG $LIBLIST  rm -f $LOCALPATHCONFIG $LIBLIST
725  echo 'OS.Process.exit (if true' >$LIBLIST  echo 'ignore (OS.Process.exit (if true' >$LIBLIST
726    
727  #  #
728  # now build (or prepare to build) the individual targets  # now build (or prepare to build) the individual targets
729  #  #
730  cd $SRCDIR  cd $SRCDIR
731  echo Installing other targets.  vsay $this: Installing other targets.
732  for i in $TARGETS ; do  for i in $TARGETS ; do
733      case $i in      case $i in
734        src-smlnj)        src-smlnj)
735          for src in compiler comp-lib cm MLRISC smlnj-lib ml-yacc system          for src in compiler cm MLRISC smlnj-lib ml-yacc system
736          do          do
737              unpack $src $ROOT/src $src $ROOT/$VERSION-$src              unpack $src $ROOT/src $src $src
738          done          done
739          ;;          ;;
740        ml-yacc)        ml-yacc)
741          standalone ml-yacc ML-Yacc src          standalone ml-yacc ML-Yacc src
742            echo ml-yacc $TOOLDIR >>$CM_PATHCONFIG_DEFAULT
743          ;;          ;;
744        ml-lex)        ml-lex)
745          standalone ml-lex ML-Lex          standalone ml-lex ML-Lex
746            echo ml-lex $TOOLDIR >>$CM_PATHCONFIG_DEFAULT
747          ;;          ;;
748        ml-burg)        ml-burg)
749          standalone ml-burg ML-Burg          standalone ml-burg ML-Burg
750            echo ml-burg $TOOLDIR >>$CM_PATHCONFIG_DEFAULT
751            ;;
752          ml-nlffigen)
753            echo standalone ml-nlffigen ML-NLFFI-Gen >>$LATESTANDALONES
754            echo ml-nlffigen $TOOLDIR >>$CM_PATHCONFIG_DEFAULT
755          ;;          ;;
756        smlnj-lib)        smlnj-lib)
757          unpack "SML/NJ Library" $SRCDIR smlnj-lib $ROOT/$VERSION-smlnj-lib          unpack "SML/NJ Library" $SRCDIR smlnj-lib smlnj-lib
758    
759          # Don't make the Util library -- it came pre-made and has been          # Don't make the Util library -- it came pre-made and has been
760          # installed when making the base system.  In other words, don't do...          # installed when making the base system.  In other words, don't do...
761              #reglib smlnj-lib.cm smlnj-lib/Util              #reglib smlnj-lib.cm smlnj-lib.cm smlnj-lib/Util
762            # ... and don't make the HTML library ...
763                #reglib html-lib.cm html-lib.cm smlnj-lib/HTML
764            # ... and don't make the PP library ...
765                #reglib pp-lib.cm pp-lib.cm smlnj-lib/PP
766            # ... and don't make the controls library ...
767                #reglib controls-lib.cm controls-lib.cm smlnj-lib/Controls
768          # make the Unix library          # make the Unix library
769              reglib unix-lib.cm smlnj-lib/Unix              reglib unix-lib.cm unix-lib.cm smlnj-lib/Unix
770          # make the INet library          # make the INet library
771              reglib inet-lib.cm smlnj-lib/INet              reglib inet-lib.cm inet-lib.cm smlnj-lib/INet
         # make the HTML library  
             reglib html-lib.cm smlnj-lib/HTML  
         # make the PP library  
             reglib pp-lib.cm smlnj-lib/PP  
772          # make the RegExp library          # make the RegExp library
773              reglib regexp-lib.cm smlnj-lib/RegExp              reglib regexp-lib.cm regexp-lib.cm smlnj-lib/RegExp
774          # make the Reactive library          # make the Reactive library
775              reglib reactive-lib.cm smlnj-lib/Reactive              reglib reactive-lib.cm reactive-lib.cm smlnj-lib/Reactive
776            # make the HashCons library
777                reglib hash-cons-lib.cm hash-cons-lib.cm smlnj-lib/HashCons
778          ;;          ;;
779        cml)        cml)
780          unpack CML $SRCDIR cml $ROOT/$VERSION-cml          unpack CML $SRCDIR cml cml
781          reglib core-cml.cm cml/src/core-cml          reglib cml core-cml.cm cml/src
782          reglib cml.cm cml/src          reglib cml cml-internal.cm cml/src
783          reglib cml-basis.cm cml          reglib cml cml.cm cml/src
784            reglib cml basis.cm cml/src
785          ;;          ;;
786        cml-lib)        cml-lib)
787          unpack CML $SRCDIR cml $ROOT/$VERSION-cml          unpack CML $SRCDIR cml cml
788          reglib cml-lib.cm cml/cml-lib          reglib cml-lib trace-cml.cm cml/cml-lib/cm
789            reglib cml-lib smlnj-lib.cm cml/cml-lib/cm
790          ;;          ;;
791        eXene)        eXene)
792          unpack EXene $SRCDIR eXene $ROOT/$VERSION-eXene          unpack EXene $SRCDIR eXene eXene
793          reglib eXene.cm eXene          reglib eXene.cm eXene.cm eXene
794            ;;
795          ckit)
796            unpack "C-Kit" $ROOT ckit ckit
797            reglib ckit-lib.cm ckit-lib.cm ../ckit/src
798            ;;
799          ml-nlffi-lib)
800            unpack "NLFFI Library" $SRCDIR ml-nlffi-lib ml-nlffi-lib
801            reglib c memory/memory.cm ml-nlffi-lib
802            reglib c internals/c-int.cm ml-nlffi-lib
803            reglib c c.cm ml-nlffi-lib
804            ;;
805          pgraph-util)
806            unpack "CM source code" $SRCDIR cm cm
807            reglib pgraph-util.cm pgraph-util.cm cm/pgraph
808            ;;
809          mlrisc-tools)
810            unpack "MLRISC Tools Library" $SRCDIR MLRISC MLRISC
811            reglib mlrisc-tools pp.cm MLRISC/Tools
812            reglib mlrisc-tools source-map.cm MLRISC/Tools
813            reglib mlrisc-tools sml-ast.cm MLRISC/Tools
814            reglib mlrisc-tools prec-parser.cm MLRISC/Tools
815            reglib mlrisc-tools parser.cm MLRISC/Tools
816            reglib mlrisc-tools match-compiler.cm MLRISC/Tools
817            ;;
818          nowhere)
819            unpack "MLRISC Tools Library" $SRCDIR MLRISC MLRISC
820            echo standalone nowhere NoWhere . MLRISC/Tools >>$LATESTANDALONES
821            echo nowhere $TOOLDIR >>$CM_PATHCONFIG_DEFAULT
822          ;;          ;;
823        doc)        doc)
824          unpack Doc $ROOT doc $ROOT/$VERSION-doc          echo Package doc is currently unavailable.
825          cd $ROOT/doc          # unpack Doc $ROOT doc doc
826          build $ROOT          # cd $ROOT/doc
827            # build $ROOT
828          ;;          ;;
829        *)        *)
830          echo "!!! Unknown target $i."          echo "$this: !!! Unknown target $i."
831          ;;          ;;
832      esac      esac
833  done  done
# Line 444  Line 838 
838  # $SRCDIR, so we must consult $LOCALPATHCONFIG.  # $SRCDIR, so we must consult $LOCALPATHCONFIG.
839  #  #
840    
841  echo Compiling library code.  echo $this: Compiling library code.
842  echo 'then OS.Process.success else OS.Process.failure);' >>$LIBLIST  echo 'then OS.Process.success else OS.Process.failure));' >>$LIBLIST
843  if CM_LOCAL_PATHCONFIG=$LOCALPATHCONFIG $BINDIR/sml <$LIBLIST ; then  if CM_LOCAL_PATHCONFIG=$LOCALPATHCONFIG $BINDIR/sml <$LIBLIST ; then
844      echo Libraries compiled successfully.      vsay $this: Libraries compiled successfully.
845  else  else
846      echo "!!! Something went wrong when compiling the libraries."      complain "$this: !!! Something went wrong when compiling the libraries."
     exit 1  
847  fi  fi
 rm -f $LIBLIST $LOCALPATHCONFIG  
848    
849  #  #
850  # Finally, move the libraries to their final locations...  # Move the libraries to their final locations...
851  #  #
852    
853  if [ -r $LIBMOVESCRIPT ] ; then  if [ -r $LIBMOVESCRIPT ] ; then
854      echo Moving libraries to $LIBDIR.      vsay $this: Moving libraries to $LIBDIR.
855      . $LIBMOVESCRIPT      . $LIBMOVESCRIPT
     rm -f $LIBMOVESCRIPT  
856  fi  fi
857    
858    #
859    # Build "late" standalone programs (i.e., those that must be built
860    # after libraries are already in place):
861    #
862    
863    if [ -r $LATESTANDALONES ] ; then
864        vsay $this: Building late standalone programs.
865        . $LATESTANDALONES
866    fi
867    
868    #
869    # Finally, remove duplicate entries from pathconfig file...
870    #
871    if [ -f $CM_PATHCONFIG_DEFAULT ] ; then
872        cp $CM_PATHCONFIG_DEFAULT $PCEDITTMP
873        rm -f $CM_PATHCONFIG_DEFAULT
874        awk <$PCEDITTMP 'NF == 2 { mapping[$1] = $2 }
875    NF != 2 { print $0 }
876    END { for (i in mapping) print i, mapping[i] }' \
877          | sort >$CM_PATHCONFIG_DEFAULT
878    fi
879    
880    exit 0

Legend:
Removed from v.489  
changed lines
  Added in v.1145

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0