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

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

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

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