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/releases/release-110.63/install.sh
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2233 - (view) (download) (as text)
Original Path: config/trunk/install.sh

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 : blume 578 # The following is the _wrong_ value for many popular x86 chips
280 :     # (i.e., Celerons). However, the optimal value for those is 32k,
281 :     # and such a small value is not enough for the runtime system's boot
282 :     # code. Therefore, we use 256k here and re-set it to the proper
283 :     # value in .run-sml.
284 : blume 537 ALLOC=256k
285 :     ;;
286 :     alpha32)
287 :     ALLOC=512k
288 :     ;;
289 :     *)
290 :     ALLOC=512k
291 :     ;;
292 : monnier 249 esac
293 : blume 537
294 : monnier 249 case $OPSYS in
295 : blume 537 solaris)
296 :     MAKE=/usr/ccs/bin/make
297 :     ;;
298 :     linux)
299 :     EXTRA_DEFS=`$CONFIGDIR/chk-global-names.sh`
300 :     if [ "$?" != "0" ]; then
301 : blume 1058 complain "$this: !!! Problems checking for underscores in asm names."
302 : blume 537 fi
303 :     EXTRA_DEFS="XDEFS=$EXTRA_DEFS"
304 :     ;;
305 : monnier 249 esac
306 :    
307 :     #
308 :     # the name of the bin files directory
309 :     #
310 : blume 615 BOOT_ARCHIVE=boot.$ARCH-unix
311 :     BOOT_FILES=sml.$BOOT_ARCHIVE
312 : monnier 249
313 :     #
314 :     # build the run-time system
315 :     #
316 : mblume 1725 if [ -x "$RUNDIR"/run.$ARCH-$OPSYS ]; then
317 : blume 1058 vsay $this: Run-time system already exists.
318 : blume 537 else
319 : mblume 1725 "$CONFIGDIR"/unpack "$ROOT" runtime
320 : blume 2163 cd "$BASEDIR"/runtime/objs
321 : blume 577 echo $this: Compiling the run-time system.
322 : blume 537 $MAKE -f mk.$ARCH-$OPSYS $EXTRA_DEFS
323 :     if [ -x run.$ARCH-$OPSYS ]; then
324 : mblume 1725 mv run.$ARCH-$OPSYS "$RUNDIR"
325 : mblume 1747 if [ -f runx.$ARCH-$OPSYS ]; then
326 :     mv runx.$ARCH-$OPSYS "$RUNDIR"
327 :     fi
328 : mblume 1923 if [ -f run.$ARCH-$OPSYS.so ]; then
329 :     mv run.$ARCH-$OPSYS.so "$RUNDIR"
330 :     fi
331 :     if [ -f run.$ARCH-$OPSYS.a ]; then
332 :     mv run.$ARCH-$OPSYS.a "$RUNDIR"
333 :     fi
334 : jhr 724 $MAKE MAKE=$MAKE clean
335 : blume 537 else
336 : blume 1058 complain "$this: !!! Run-time system build failed for some reason."
337 : blume 537 fi
338 : monnier 249 fi
339 : blume 2163 cd "$BASEDIR"
340 : monnier 249
341 :     #
342 :     # boot the base SML system
343 :     #
344 : mblume 1725 if [ -r "$HEAPDIR"/sml.$HEAP_SUFFIX ]; then
345 : blume 1058 vsay $this: Heap image $HEAPDIR/sml.$HEAP_SUFFIX already exists.
346 : mblume 1873 fish "$LIBDIR"/smlnj/basis
347 : mblume 1385 # ignore requested arc name since we have to live with what is there:
348 : mblume 1572 export CM_DIR_ARC
349 :     CM_DIR_ARC=$ORIG_CM_DIR_ARC
350 : mblume 1794 # now re-dump the heap image:
351 :     vsay "$this: Re-creating a (customized) heap image..."
352 :     "$BINDIR"/sml @CMredump "$ROOT"/sml
353 :     cd "$ROOT"
354 :     if [ -r sml.$HEAP_SUFFIX ]; then
355 :     mv sml.$HEAP_SUFFIX "$HEAPDIR"
356 :     else
357 :     complain "$this !!! Unable to re-create heap image (sml.$HEAP_SUFFIX)."
358 :     fi
359 : monnier 249 else
360 : mblume 1725 "$CONFIGDIR"/unpack "$ROOT" "$BOOT_ARCHIVE"
361 : mblume 1385
362 : mblume 1873 fish "$ROOT"/"$BOOT_FILES"/smlnj/basis
363 : mblume 1385
364 : mblume 1725 cd "$ROOT"
365 : mblume 1385
366 :     # Target arc:
367 : mblume 1572 export CM_DIR_ARC
368 :     CM_DIR_ARC=${CM_DIR_ARC:-".cm"}
369 : mblume 1385
370 :     if [ $CM_DIR_ARC = $ORIG_CM_DIR_ARC ] ; then
371 :     : we are happy
372 :     else
373 :     # now we have to make a symbolic link for each occurrence of
374 :     # $ORIG_CM_DIR_ARC to $CM_DIR_ARC
375 : mblume 1725 dirarcs "$ORIG_CM_DIR_ARC" "$CM_DIR_ARC" "$BOOT_FILES"
376 : mblume 1385 fi
377 :    
378 : mblume 1725 cd "$ROOT"/"$BOOT_FILES"
379 : mblume 1385
380 :     # now link (boot) the system and let it initialize itself...
381 : mblume 1725 if "$BINDIR"/.link-sml @SMLheap="$ROOT"/sml @SMLboot=BOOTLIST @SMLalloc=$ALLOC
382 : blume 537 then
383 : mblume 1725 cd "$ROOT"
384 : blume 537 if [ -r sml.$HEAP_SUFFIX ]; then
385 : mblume 1725 mv sml.$HEAP_SUFFIX "$HEAPDIR"
386 :     cd "$BINDIR"
387 : blume 537 ln -s .run-sml sml
388 :     #
389 :     # Now move all stable libraries to #LIBDIR and generate
390 :     # the pathconfig file.
391 :     #
392 : mblume 1725 cd "$ROOT"/"$BOOT_FILES"
393 : blume 573 for anchor in * ; do
394 :     if [ -d $anchor ] ; then
395 : blume 1201 echo $anchor $anchor >>$CM_PATHCONFIG
396 : mblume 1725 move $anchor "$LIBDIR"/$anchor
397 : blume 573 fi
398 : blume 537 done
399 : mblume 1725 cd "$ROOT"
400 : blume 573 # $BOOT_FILES is now only an empty skeleton, let's get rid of it.
401 : mblume 1725 rm -rf "$BOOT_FILES"
402 : monnier 418
403 : blume 537 else
404 : blume 1058 complain "$this !!! No heap image generated (sml.$HEAP_SUFFIX)."
405 : blume 537 fi
406 : monnier 418 else
407 : blume 1058 complain "$this !!! Boot code failed, no heap image (sml.$HEAP_SUFFIX)."
408 : monnier 418 fi
409 : monnier 249 fi
410 :    
411 : mblume 1494 #
412 :     # now that we know CM_DIR_ARC we can install the ml-build driver...
413 :     #
414 :     installdriver _ml-build ml-build
415 :    
416 : mblume 1725 cd "$ROOT"
417 : monnier 249
418 :     #
419 : mblume 1391 # Now do all the rest using the precompiled installer:
420 : monnier 249 #
421 : mblume 1794 if [ $nolib = false ] ; then
422 :     echo $this: Installing other libraries and programs:
423 :     export ROOT INSTALLDIR CONFIGDIR BINDIR
424 :     if "$BINDIR"/sml -m \$smlnj/installer.cm
425 :     then
426 :     vsay $this: Installation complete.
427 :     else
428 :     complain "$this: !!! Installation of libraries and programs failed."
429 :     fi
430 : monnier 249 fi
431 :    
432 : blume 537 exit 0

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