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

SCM Repository

[smlnj] Annotation of /config/trunk/install.sh
ViewVC logotype

Annotation of /config/trunk/install.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3603 - (view) (download) (as text)

1 : monnier 249 #!/bin/sh
2 :     #
3 :     # Copyright (c) 1994 AT&T Bell Laboratories.
4 : mblume 1385 # Copyright (c) 2003 The Fellowship of SML/NJ
5 : monnier 249 #
6 : blume 537 # Installation script for SML/NJ and related tools; this is a temporary
7 : monnier 249 # placeholder until the configuration tool is finished.
8 :     #
9 : mblume 1385 # Significant changes to take advantage of a new portable installer
10 :     # script for everything after booting the interactive system.
11 : blume 537 #
12 : mblume 1385 # Author: Matthias Blume (blume@tti-c.org)
13 :     #
14 : monnier 249
15 : mblume 1794 if [ x$1 = xnolib ] ; then
16 :     nolib=true
17 :     else
18 :     nolib=false
19 :     fi
20 :    
21 : blume 1058 if [ x${INSTALL_QUIETLY} = xtrue ] ; then
22 : mblume 1572 export CM_VERBOSE
23 :     CM_VERBOSE=false
24 : blume 1058 fi
25 :    
26 :     vsay() {
27 :     if [ x${INSTALL_DEBUG} = xtrue ] ; then
28 :     echo "$@"
29 :     elif [ x${INSTALL_QUIETLY} = xtrue ] ; then
30 :     :
31 :     else
32 :     echo "$@"
33 :     fi
34 :     }
35 :    
36 :     complain() {
37 :     echo "$@"
38 :     exit 1
39 :     }
40 :    
41 : blume 577 this=$0
42 :    
43 : blume 1058
44 : monnier 249 #
45 : monnier 504 # create the preloads.standard file
46 :     #
47 :     if [ ! -r config/preloads ]; then
48 : blume 1058 complain "$this: !!! File config/preloads is missing."
49 : monnier 504 fi
50 :     cp config/preloads preloads.standard
51 :    
52 :     #
53 : blume 537 # Some OSs have make in strange places, but most of the time it is
54 :     # simply on the PATH:
55 : monnier 249 #
56 :     MAKE=make
57 :    
58 : blume 537 SHELL=/bin/sh
59 : blume 1058 vsay $this: Using shell $SHELL.
60 : monnier 249
61 :     #
62 :     # set the SML root directory
63 :     #
64 :     REAL_PWD=`pwd`
65 :     ROOT=${PWD:-$REAL_PWD}
66 : blume 1058 vsay $this: SML root is $ROOT.
67 : monnier 249
68 : mblume 1725 cd "${INSTALLDIR:=$ROOT}"
69 : mblume 1409 INSTALLDIR=`pwd`
70 : mblume 1725 cd "$ROOT"
71 : mblume 1409 vsay $this: Installation directory is ${INSTALLDIR}.
72 :    
73 : monnier 249 #
74 : monnier 418 # set the various directory and file pathname variables
75 : monnier 249 #
76 : monnier 439 BINDIR=$INSTALLDIR/bin # main dir for binary stuff
77 : monnier 249 CONFIGDIR=$ROOT/config
78 : monnier 418 HEAPDIR=$BINDIR/.heap # where heap images live
79 :     RUNDIR=$BINDIR/.run # where executables (i.e., the RTS) live
80 : blume 2163 BASEDIR=$ROOT/base # where the base source tree is rooted
81 : monnier 439 LIBDIR=$INSTALLDIR/lib # where libraries live
82 : monnier 249
83 :     #
84 : blume 569 # files to be deleted after we are done...
85 :     #
86 :     tmpfiles=""
87 : mblume 1725 tmpfiles="$tmpfiles preloads.standard"
88 : blume 569 #
89 :     # make sure we always clean up after ourselves...
90 :     #
91 : mblume 1725 trap 'cd "$ROOT"; rm -f $tmpfiles' 0 1 2 3 15
92 : blume 569
93 :    
94 :     #
95 : monnier 249 # set the CM configuration variables (these are environment variables
96 :     # that will be queried by the bootstrap code)
97 : blume 1201 # Especially important is CM_PATHCONFIG.
98 : monnier 249 #
99 : mblume 1572 export CM_PATHCONFIG
100 : blume 1201 CM_PATHCONFIG=$LIBDIR/pathconfig
101 : monnier 249 #
102 :     # the release version that we are installing
103 :     #
104 : mblume 1725 VERSION=`cat "$CONFIGDIR/version"`
105 : blume 1058 vsay $this: Installing version $VERSION.
106 : monnier 249
107 :     #
108 : blume 573 # the URL for the (usually remote) source archive
109 :     #
110 : mblume 1725 . "$CONFIGDIR"/srcarchiveurl
111 : blume 1058 vsay $this: URL of source archive is $SRCARCHIVEURL.
112 : blume 573
113 :     #
114 : blume 844 # Function to make a directory including its ancestors.
115 : monnier 418 #
116 :     makedir() {
117 : mblume 1725 if [ x"$1" = x ] ; then
118 : blume 844 :
119 : mblume 1725 elif [ -d "$1" ] ; then
120 : blume 844 :
121 :     else
122 : mblume 1725 makedirtmp=`dirname "$1"`
123 :     makedir "$makedirtmp"
124 : blume 1058 if [ x${INSTALL_VERBOSE} = xtrue ] ; then
125 :     vsay "$this: Making directory $1"
126 :     fi
127 : mblume 1725 if mkdir "$1" ; then
128 : blume 844 :
129 : monnier 418 else
130 : blume 1058 complain "$this: !!! Unable to make directory $1!"
131 : monnier 418 fi
132 :     fi
133 :     }
134 :    
135 :     #
136 : mblume 1385 # Fish out the CM metadata directory name from library files
137 :     # and store it in ORIG_CM_DIR_ARC.
138 :     # The single argument is the name of the directory containing
139 :     # a single subdirectory which is a CM metadata directory:
140 : blume 573 #
141 : mblume 1385 fish() {
142 : mblume 1725 cd "$1"
143 : mblume 1385 ORIG_CM_DIR_ARC=unknown
144 :     for i in * .[a-zA-Z0-9]* ; do
145 :     if [ -d $i ] ; then
146 :     ORIG_CM_DIR_ARC=$i
147 :     break
148 :     fi
149 : blume 573 done
150 : mblume 1385 if [ $ORIG_CM_DIR_ARC = unknown ] ; then
151 :     complain "$this: could not determine CM metadata directory name"
152 : blume 615 else
153 : mblume 1385 echo "$this: CM metadata directory name is \"${ORIG_CM_DIR_ARC}\""
154 : blume 615 fi
155 :     }
156 :    
157 : blume 573
158 :     # A function to move all stable library files to a parallel directory
159 :     # hierarchy.
160 :     # The first argument must be a simple path (no / inside), and
161 :     # the second argument must be an absolute path.
162 :     move() {
163 : mblume 1725 if [ -L "$1" ] ; then
164 :     rm -f "$1" # remove symbolic link made by diracs (see below)
165 :     elif [ -d "$1" ] ; then
166 :     if [ ! -d "$2" ] ; then
167 :     if [ -f "$2" ] ; then
168 : blume 1058 complain $this: $2 exists as a non-directory.
169 : blume 573 fi
170 : mblume 1725 mkdir "$2"
171 : monnier 418 fi
172 : mblume 1725 cd "$1"
173 : mblume 1385 for i in * .[a-zA-Z0-9]* ; do
174 : mblume 1725 move "$i" "$2"/"$i"
175 : blume 573 done
176 :     cd ..
177 : mblume 1725 elif [ -f "$1" ] ; then
178 :     rm -f "$2"
179 :     mv "$1" "$2"
180 : monnier 418 fi
181 :     }
182 :    
183 :     #
184 : mblume 1385 # Traverse the directory tree rooted at $3 (must be single arc!).
185 :     # Find all directories named $1, rename them into $2 and make
186 :     # and establish $1 as a symbolic link to $2:
187 : monnier 418 #
188 : mblume 1385 dirarcs() {
189 : mblume 1725 if [ -d "$3" ] ; then
190 :     if [ "$3" = "$1" ] ; then
191 :     mv "$1" "$2"
192 :     ln -s "$2" "$1"
193 : monnier 418 else
194 : mblume 1725 cd "$3"
195 : mblume 1385 for d in * .[a-zA-Z0-9]* ; do
196 : mblume 1725 dirarcs "$1" "$2" "$d"
197 : mblume 1385 done
198 :     cd ..
199 : monnier 418 fi
200 :     fi
201 :     }
202 :    
203 : mblume 1385
204 : blume 1058 ######################################################################
205 :    
206 : monnier 418 #
207 : monnier 249 # create the various sub directories
208 :     #
209 : blume 2163 for dir in "$BINDIR" "$HEAPDIR" "$RUNDIR" "$LIBDIR" "$BASEDIR" ; do
210 : mblume 1725 makedir "$dir"
211 : monnier 249 done
212 :    
213 :     #
214 : blume 537 # Function to install a "driver" script...
215 :     # This takes care of patching the source of the script with the SHELL,
216 :     # BINDIR, and VERSION variables to use.
217 :     #
218 :     installdriver() {
219 :     dsrc=$1
220 :     ddst=$2
221 : blume 569 # We install the driver unconditionally. (It would be better to test
222 :     # for an outdated driver script, but not all "test" commands understand
223 :     # the -nt comparison operator....)
224 :     # if [ -x $BINDIR/$ddst ]; then
225 : blume 577 # echo $this: Script $BINDIR/$ddst already exists.
226 : blume 569 # else
227 : mblume 1725 rm -f "$BINDIR"/"$ddst"
228 :     cat "$CONFIGDIR"/"$dsrc" | \
229 : blume 537 sed -e "s,@SHELL@,$SHELL,g" \
230 :     -e "s,@BINDIR@,$BINDIR," \
231 : blume 2233 -e "s,@LIBDIR@,$LIBDIR," \
232 : blume 537 -e "s,@VERSION@,$VERSION," \
233 : mblume 1494 -e "s,@CMDIRARC@,${CM_DIR_ARC:-dummy}," \
234 : mblume 1725 > "$BINDIR"/"$ddst"
235 :     chmod 555 "$BINDIR"/"$ddst"
236 :     if [ ! -x "$BINDIR"/"$ddst" ]; then
237 : blume 1058 complain "$this: !!! Installation of $BINDIR/${ddst} failed."
238 : blume 537 fi
239 : blume 569 # fi
240 : blume 537 }
241 : monnier 249
242 : blume 1282 #
243 :     # install the script that tests architecture and os...
244 :     #
245 :     installdriver _arch-n-opsys .arch-n-opsys
246 :    
247 :     #
248 :     # run it to figure out what architecture and os we are using, define
249 :     # corresponding variables...
250 :     #
251 : mblume 1725 ARCH_N_OPSYS=`"$BINDIR"/.arch-n-opsys`
252 : blume 1282 if [ "$?" != "0" ]; then
253 :     echo "$this: !!! Script $BINDIR/.arch-n-opsys fails on this machine."
254 :     echo "$this: !!! You must patch this by hand and repeat the installation."
255 :     exit 2
256 :     else
257 :     vsay $this: Script $BINDIR/.arch-n-opsys reports $ARCH_N_OPSYS.
258 :     fi
259 :     eval $ARCH_N_OPSYS
260 :    
261 :     #
262 : mblume 1494 # now install most of the other driver scripts
263 :     # (except ml-build, since we don't know $CM_DIR_ARC yet)
264 : blume 1282 #
265 : blume 537 installdriver _run-sml .run-sml
266 :     installdriver _link-sml .link-sml
267 : blume 691 installdriver _ml-makedepend ml-makedepend
268 : blume 537
269 : mblume 1747 installdriver _heap2exec heap2exec
270 :    
271 : monnier 249 #
272 :     # set some architecture dependent run-time system flags
273 :     #
274 :     case $ARCH in
275 : blume 537 mips*)
276 :     ALLOC=1M
277 :     ;;
278 :     x86)
279 : jhr 3603 # The following is the _wrong_ value for some x86 chips
280 :     # (i.e., Celerons). We use 512k here and re-set it to the proper
281 : blume 578 # value in .run-sml.
282 : jhr 3603 ALLOC=512k
283 : blume 537 ;;
284 :     alpha32)
285 :     ALLOC=512k
286 :     ;;
287 :     *)
288 :     ALLOC=512k
289 :     ;;
290 : monnier 249 esac
291 : blume 537
292 : monnier 249 case $OPSYS in
293 : blume 537 solaris)
294 :     MAKE=/usr/ccs/bin/make
295 :     ;;
296 :     linux)
297 : blume 2721 EXTRA_DEFS=`"$CONFIGDIR/chk-global-names.sh"`
298 : blume 537 if [ "$?" != "0" ]; then
299 : blume 1058 complain "$this: !!! Problems checking for underscores in asm names."
300 : blume 537 fi
301 :     EXTRA_DEFS="XDEFS=$EXTRA_DEFS"
302 :     ;;
303 : monnier 249 esac
304 :    
305 :     #
306 : jhr 3603 # on 64-bit linux systems, we need to check to see if the 32-bit emulation
307 :     # support is installed
308 :     #
309 :     if [ x"$ARCH" = "xx86" -a x"$OPSYS" = "xlinux" ] ; then
310 :     case `uname -m` in
311 :     x86_64)
312 :     tmpFile=smlnj-test$$
313 :     echo "int main () { return 0; }" >> /tmp/$tmpFile.c
314 :     gcc -m32 -o /tmp/$tmpFile /tmp/$tmpFile.c 2> /dev/null 1>> /dev/null
315 :     if [ "$?" != "0" ] ; then
316 :     complain "$this: !!! SML/NJ requires support for 32-bit executables"
317 :     else
318 :     rm -f /tmp/$tmpFile /tmp/$tmpFile.c
319 :     fi
320 :     ;;
321 :     *) ;;
322 :     esac
323 :     fi
324 :    
325 :     #
326 : monnier 249 # the name of the bin files directory
327 :     #
328 : blume 615 BOOT_ARCHIVE=boot.$ARCH-unix
329 :     BOOT_FILES=sml.$BOOT_ARCHIVE
330 : monnier 249
331 :     #
332 :     # build the run-time system
333 :     #
334 : mblume 1725 if [ -x "$RUNDIR"/run.$ARCH-$OPSYS ]; then
335 : blume 1058 vsay $this: Run-time system already exists.
336 : blume 537 else
337 : mblume 1725 "$CONFIGDIR"/unpack "$ROOT" runtime
338 : blume 2163 cd "$BASEDIR"/runtime/objs
339 : blume 577 echo $this: Compiling the run-time system.
340 : blume 537 $MAKE -f mk.$ARCH-$OPSYS $EXTRA_DEFS
341 :     if [ -x run.$ARCH-$OPSYS ]; then
342 : mblume 1725 mv run.$ARCH-$OPSYS "$RUNDIR"
343 : mblume 1747 if [ -f runx.$ARCH-$OPSYS ]; then
344 :     mv runx.$ARCH-$OPSYS "$RUNDIR"
345 :     fi
346 : mblume 1923 if [ -f run.$ARCH-$OPSYS.so ]; then
347 :     mv run.$ARCH-$OPSYS.so "$RUNDIR"
348 :     fi
349 :     if [ -f run.$ARCH-$OPSYS.a ]; then
350 :     mv run.$ARCH-$OPSYS.a "$RUNDIR"
351 :     fi
352 : jhr 724 $MAKE MAKE=$MAKE clean
353 : blume 537 else
354 : blume 1058 complain "$this: !!! Run-time system build failed for some reason."
355 : blume 537 fi
356 : monnier 249 fi
357 : blume 2163 cd "$BASEDIR"
358 : monnier 249
359 :     #
360 :     # boot the base SML system
361 :     #
362 : mblume 1725 if [ -r "$HEAPDIR"/sml.$HEAP_SUFFIX ]; then
363 : blume 1058 vsay $this: Heap image $HEAPDIR/sml.$HEAP_SUFFIX already exists.
364 : mblume 1873 fish "$LIBDIR"/smlnj/basis
365 : mblume 1385 # ignore requested arc name since we have to live with what is there:
366 : mblume 1572 export CM_DIR_ARC
367 :     CM_DIR_ARC=$ORIG_CM_DIR_ARC
368 : mblume 1794 # now re-dump the heap image:
369 :     vsay "$this: Re-creating a (customized) heap image..."
370 :     "$BINDIR"/sml @CMredump "$ROOT"/sml
371 :     cd "$ROOT"
372 :     if [ -r sml.$HEAP_SUFFIX ]; then
373 :     mv sml.$HEAP_SUFFIX "$HEAPDIR"
374 :     else
375 :     complain "$this !!! Unable to re-create heap image (sml.$HEAP_SUFFIX)."
376 :     fi
377 : monnier 249 else
378 : mblume 1725 "$CONFIGDIR"/unpack "$ROOT" "$BOOT_ARCHIVE"
379 : mblume 1385
380 : mblume 1873 fish "$ROOT"/"$BOOT_FILES"/smlnj/basis
381 : mblume 1385
382 : mblume 1725 cd "$ROOT"
383 : mblume 1385
384 :     # Target arc:
385 : mblume 1572 export CM_DIR_ARC
386 :     CM_DIR_ARC=${CM_DIR_ARC:-".cm"}
387 : mblume 1385
388 :     if [ $CM_DIR_ARC = $ORIG_CM_DIR_ARC ] ; then
389 :     : we are happy
390 :     else
391 :     # now we have to make a symbolic link for each occurrence of
392 :     # $ORIG_CM_DIR_ARC to $CM_DIR_ARC
393 : mblume 1725 dirarcs "$ORIG_CM_DIR_ARC" "$CM_DIR_ARC" "$BOOT_FILES"
394 : mblume 1385 fi
395 :    
396 : mblume 1725 cd "$ROOT"/"$BOOT_FILES"
397 : mblume 1385
398 :     # now link (boot) the system and let it initialize itself...
399 : mblume 1725 if "$BINDIR"/.link-sml @SMLheap="$ROOT"/sml @SMLboot=BOOTLIST @SMLalloc=$ALLOC
400 : blume 537 then
401 : mblume 1725 cd "$ROOT"
402 : blume 537 if [ -r sml.$HEAP_SUFFIX ]; then
403 : mblume 1725 mv sml.$HEAP_SUFFIX "$HEAPDIR"
404 :     cd "$BINDIR"
405 : blume 537 ln -s .run-sml sml
406 :     #
407 :     # Now move all stable libraries to #LIBDIR and generate
408 :     # the pathconfig file.
409 :     #
410 : mblume 1725 cd "$ROOT"/"$BOOT_FILES"
411 : blume 573 for anchor in * ; do
412 :     if [ -d $anchor ] ; then
413 : blume 1201 echo $anchor $anchor >>$CM_PATHCONFIG
414 : mblume 1725 move $anchor "$LIBDIR"/$anchor
415 : blume 573 fi
416 : blume 537 done
417 : mblume 1725 cd "$ROOT"
418 : blume 573 # $BOOT_FILES is now only an empty skeleton, let's get rid of it.
419 : mblume 1725 rm -rf "$BOOT_FILES"
420 : monnier 418
421 : blume 537 else
422 : blume 1058 complain "$this !!! No heap image generated (sml.$HEAP_SUFFIX)."
423 : blume 537 fi
424 : monnier 418 else
425 : blume 1058 complain "$this !!! Boot code failed, no heap image (sml.$HEAP_SUFFIX)."
426 : monnier 418 fi
427 : monnier 249 fi
428 :    
429 : mblume 1494 #
430 :     # now that we know CM_DIR_ARC we can install the ml-build driver...
431 :     #
432 :     installdriver _ml-build ml-build
433 :    
434 : mblume 1725 cd "$ROOT"
435 : monnier 249
436 :     #
437 : mblume 1391 # Now do all the rest using the precompiled installer:
438 : monnier 249 #
439 : mblume 1794 if [ $nolib = false ] ; then
440 :     echo $this: Installing other libraries and programs:
441 :     export ROOT INSTALLDIR CONFIGDIR BINDIR
442 : blume 2577 CM_TOLERATE_TOOL_FAILURES=true
443 :     export CM_TOLERATE_TOOL_FAILURES
444 : mblume 1794 if "$BINDIR"/sml -m \$smlnj/installer.cm
445 :     then
446 :     vsay $this: Installation complete.
447 :     else
448 :     complain "$this: !!! Installation of libraries and programs failed."
449 :     fi
450 : monnier 249 fi
451 :    
452 : blume 537 exit 0

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