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/trunk/install.sh
ViewVC logotype

Diff of /config/trunk/install.sh

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

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

Legend:
Removed from v.249  
changed lines
  Added in v.1047

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