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

Legend:
Removed from v.515  
changed lines
  Added in v.1252

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