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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : monnier 249 #!/bin/sh
2 :     #
3 :     # Copyright (c) 1994 AT&T Bell Laboratories.
4 : jhr 3921 # Copyright (c) 2014 The Fellowship of SML/NJ
5 : monnier 249 #
6 : jhr 3921 # Installation script for SML/NJ and related tools.
7 : monnier 249 #
8 : mblume 1385 # Significant changes to take advantage of a new portable installer
9 :     # script for everything after booting the interactive system.
10 : blume 537 #
11 : mblume 1385 # Author: Matthias Blume (blume@tti-c.org)
12 :     #
13 : monnier 249
14 : mblume 1794 if [ x$1 = xnolib ] ; then
15 :     nolib=true
16 :     else
17 :     nolib=false
18 :     fi
19 :    
20 : blume 1058 if [ x${INSTALL_QUIETLY} = xtrue ] ; then
21 : mblume 1572 export CM_VERBOSE
22 :     CM_VERBOSE=false
23 : blume 1058 fi
24 :    
25 :     vsay() {
26 :     if [ x${INSTALL_DEBUG} = xtrue ] ; then
27 :     echo "$@"
28 :     elif [ x${INSTALL_QUIETLY} = xtrue ] ; then
29 :     :
30 :     else
31 :     echo "$@"
32 :     fi
33 :     }
34 :    
35 :     complain() {
36 :     echo "$@"
37 :     exit 1
38 :     }
39 :    
40 : blume 577 this=$0
41 :    
42 : blume 1058
43 : monnier 249 #
44 : monnier 504 # create the preloads.standard file
45 :     #
46 :     if [ ! -r config/preloads ]; then
47 : blume 1058 complain "$this: !!! File config/preloads is missing."
48 : monnier 504 fi
49 :     cp config/preloads preloads.standard
50 :    
51 :     #
52 : blume 537 # Some OSs have make in strange places, but most of the time it is
53 :     # simply on the PATH:
54 : monnier 249 #
55 :     MAKE=make
56 :    
57 : blume 537 SHELL=/bin/sh
58 : blume 1058 vsay $this: Using shell $SHELL.
59 : monnier 249
60 :     #
61 :     # set the SML root directory
62 :     #
63 :     REAL_PWD=`pwd`
64 :     ROOT=${PWD:-$REAL_PWD}
65 : blume 1058 vsay $this: SML root is $ROOT.
66 : monnier 249
67 : mblume 1725 cd "${INSTALLDIR:=$ROOT}"
68 : mblume 1409 INSTALLDIR=`pwd`
69 : mblume 1725 cd "$ROOT"
70 : mblume 1409 vsay $this: Installation directory is ${INSTALLDIR}.
71 :    
72 : monnier 249 #
73 : monnier 418 # set the various directory and file pathname variables
74 : monnier 249 #
75 : monnier 439 BINDIR=$INSTALLDIR/bin # main dir for binary stuff
76 : monnier 249 CONFIGDIR=$ROOT/config
77 : monnier 418 HEAPDIR=$BINDIR/.heap # where heap images live
78 :     RUNDIR=$BINDIR/.run # where executables (i.e., the RTS) live
79 : blume 2163 BASEDIR=$ROOT/base # where the base source tree is rooted
80 : monnier 439 LIBDIR=$INSTALLDIR/lib # where libraries live
81 : monnier 249
82 :     #
83 : blume 569 # files to be deleted after we are done...
84 :     #
85 :     tmpfiles=""
86 : mblume 1725 tmpfiles="$tmpfiles preloads.standard"
87 : blume 569 #
88 :     # make sure we always clean up after ourselves...
89 :     #
90 : mblume 1725 trap 'cd "$ROOT"; rm -f $tmpfiles' 0 1 2 3 15
91 : blume 569
92 :    
93 :     #
94 : monnier 249 # set the CM configuration variables (these are environment variables
95 :     # that will be queried by the bootstrap code)
96 : blume 1201 # Especially important is CM_PATHCONFIG.
97 : monnier 249 #
98 : mblume 1572 export CM_PATHCONFIG
99 : blume 1201 CM_PATHCONFIG=$LIBDIR/pathconfig
100 : monnier 249 #
101 :     # the release version that we are installing
102 :     #
103 : mblume 1725 VERSION=`cat "$CONFIGDIR/version"`
104 : blume 1058 vsay $this: Installing version $VERSION.
105 : monnier 249
106 :     #
107 : blume 573 # the URL for the (usually remote) source archive
108 :     #
109 : mblume 1725 . "$CONFIGDIR"/srcarchiveurl
110 : blume 1058 vsay $this: URL of source archive is $SRCARCHIVEURL.
111 : blume 573
112 :     #
113 : blume 844 # Function to make a directory including its ancestors.
114 : monnier 418 #
115 :     makedir() {
116 : mblume 1725 if [ x"$1" = x ] ; then
117 : blume 844 :
118 : mblume 1725 elif [ -d "$1" ] ; then
119 : blume 844 :
120 :     else
121 : mblume 1725 makedirtmp=`dirname "$1"`
122 :     makedir "$makedirtmp"
123 : blume 1058 if [ x${INSTALL_VERBOSE} = xtrue ] ; then
124 :     vsay "$this: Making directory $1"
125 :     fi
126 : mblume 1725 if mkdir "$1" ; then
127 : blume 844 :
128 : monnier 418 else
129 : blume 1058 complain "$this: !!! Unable to make directory $1!"
130 : monnier 418 fi
131 :     fi
132 :     }
133 :    
134 :     #
135 : mblume 1385 # Fish out the CM metadata directory name from library files
136 :     # and store it in ORIG_CM_DIR_ARC.
137 :     # The single argument is the name of the directory containing
138 :     # a single subdirectory which is a CM metadata directory:
139 : blume 573 #
140 : mblume 1385 fish() {
141 : mblume 1725 cd "$1"
142 : mblume 1385 ORIG_CM_DIR_ARC=unknown
143 :     for i in * .[a-zA-Z0-9]* ; do
144 :     if [ -d $i ] ; then
145 :     ORIG_CM_DIR_ARC=$i
146 :     break
147 :     fi
148 : blume 573 done
149 : mblume 1385 if [ $ORIG_CM_DIR_ARC = unknown ] ; then
150 :     complain "$this: could not determine CM metadata directory name"
151 : blume 615 else
152 : mblume 1385 echo "$this: CM metadata directory name is \"${ORIG_CM_DIR_ARC}\""
153 : blume 615 fi
154 :     }
155 :    
156 : blume 573
157 :     # A function to move all stable library files to a parallel directory
158 :     # hierarchy.
159 :     # The first argument must be a simple path (no / inside), and
160 :     # the second argument must be an absolute path.
161 :     move() {
162 : mblume 1725 if [ -L "$1" ] ; then
163 :     rm -f "$1" # remove symbolic link made by diracs (see below)
164 :     elif [ -d "$1" ] ; then
165 :     if [ ! -d "$2" ] ; then
166 :     if [ -f "$2" ] ; then
167 : blume 1058 complain $this: $2 exists as a non-directory.
168 : blume 573 fi
169 : mblume 1725 mkdir "$2"
170 : monnier 418 fi
171 : mblume 1725 cd "$1"
172 : mblume 1385 for i in * .[a-zA-Z0-9]* ; do
173 : mblume 1725 move "$i" "$2"/"$i"
174 : blume 573 done
175 :     cd ..
176 : mblume 1725 elif [ -f "$1" ] ; then
177 :     rm -f "$2"
178 :     mv "$1" "$2"
179 : monnier 418 fi
180 :     }
181 :    
182 :     #
183 : mblume 1385 # Traverse the directory tree rooted at $3 (must be single arc!).
184 :     # Find all directories named $1, rename them into $2 and make
185 :     # and establish $1 as a symbolic link to $2:
186 : monnier 418 #
187 : mblume 1385 dirarcs() {
188 : mblume 1725 if [ -d "$3" ] ; then
189 :     if [ "$3" = "$1" ] ; then
190 :     mv "$1" "$2"
191 :     ln -s "$2" "$1"
192 : monnier 418 else
193 : mblume 1725 cd "$3"
194 : mblume 1385 for d in * .[a-zA-Z0-9]* ; do
195 : mblume 1725 dirarcs "$1" "$2" "$d"
196 : mblume 1385 done
197 :     cd ..
198 : monnier 418 fi
199 :     fi
200 :     }
201 :    
202 : mblume 1385
203 : blume 1058 ######################################################################
204 :    
205 : monnier 418 #
206 : monnier 249 # create the various sub directories
207 :     #
208 : blume 2163 for dir in "$BINDIR" "$HEAPDIR" "$RUNDIR" "$LIBDIR" "$BASEDIR" ; do
209 : mblume 1725 makedir "$dir"
210 : monnier 249 done
211 :    
212 :     #
213 : blume 537 # Function to install a "driver" script...
214 :     # This takes care of patching the source of the script with the SHELL,
215 :     # BINDIR, and VERSION variables to use.
216 :     #
217 :     installdriver() {
218 :     dsrc=$1
219 :     ddst=$2
220 : blume 569 # We install the driver unconditionally. (It would be better to test
221 :     # for an outdated driver script, but not all "test" commands understand
222 :     # the -nt comparison operator....)
223 :     # if [ -x $BINDIR/$ddst ]; then
224 : blume 577 # echo $this: Script $BINDIR/$ddst already exists.
225 : blume 569 # else
226 : mblume 1725 rm -f "$BINDIR"/"$ddst"
227 :     cat "$CONFIGDIR"/"$dsrc" | \
228 : blume 537 sed -e "s,@SHELL@,$SHELL,g" \
229 :     -e "s,@BINDIR@,$BINDIR," \
230 : blume 2233 -e "s,@LIBDIR@,$LIBDIR," \
231 : blume 537 -e "s,@VERSION@,$VERSION," \
232 : mblume 1494 -e "s,@CMDIRARC@,${CM_DIR_ARC:-dummy}," \
233 : mblume 1725 > "$BINDIR"/"$ddst"
234 :     chmod 555 "$BINDIR"/"$ddst"
235 :     if [ ! -x "$BINDIR"/"$ddst" ]; then
236 : blume 1058 complain "$this: !!! Installation of $BINDIR/${ddst} failed."
237 : blume 537 fi
238 : blume 569 # fi
239 : blume 537 }
240 : monnier 249
241 : blume 1282 #
242 :     # install the script that tests architecture and os...
243 :     #
244 :     installdriver _arch-n-opsys .arch-n-opsys
245 :    
246 :     #
247 :     # run it to figure out what architecture and os we are using, define
248 :     # corresponding variables...
249 :     #
250 : mblume 1725 ARCH_N_OPSYS=`"$BINDIR"/.arch-n-opsys`
251 : blume 1282 if [ "$?" != "0" ]; then
252 :     echo "$this: !!! Script $BINDIR/.arch-n-opsys fails on this machine."
253 :     echo "$this: !!! You must patch this by hand and repeat the installation."
254 :     exit 2
255 :     else
256 :     vsay $this: Script $BINDIR/.arch-n-opsys reports $ARCH_N_OPSYS.
257 :     fi
258 :     eval $ARCH_N_OPSYS
259 :    
260 :     #
261 : mblume 1494 # now install most of the other driver scripts
262 :     # (except ml-build, since we don't know $CM_DIR_ARC yet)
263 : blume 1282 #
264 : blume 537 installdriver _run-sml .run-sml
265 :     installdriver _link-sml .link-sml
266 : blume 691 installdriver _ml-makedepend ml-makedepend
267 : blume 537
268 : mblume 1747 installdriver _heap2exec heap2exec
269 :    
270 : monnier 249 #
271 :     # set some architecture dependent run-time system flags
272 :     #
273 :     case $ARCH in
274 : blume 537 mips*)
275 :     ALLOC=1M
276 :     ;;
277 :     x86)
278 : jhr 3603 # The following is the _wrong_ value for some x86 chips
279 :     # (i.e., Celerons). We use 512k here and re-set it to the proper
280 : blume 578 # value in .run-sml.
281 : jhr 3603 ALLOC=512k
282 : blume 537 ;;
283 :     alpha32)
284 :     ALLOC=512k
285 :     ;;
286 :     *)
287 :     ALLOC=512k
288 :     ;;
289 : monnier 249 esac
290 : blume 537
291 : monnier 249 case $OPSYS in
292 : blume 537 solaris)
293 :     MAKE=/usr/ccs/bin/make
294 :     ;;
295 :     linux)
296 : blume 2721 EXTRA_DEFS=`"$CONFIGDIR/chk-global-names.sh"`
297 : blume 537 if [ "$?" != "0" ]; then
298 : blume 1058 complain "$this: !!! Problems checking for underscores in asm names."
299 : blume 537 fi
300 :     EXTRA_DEFS="XDEFS=$EXTRA_DEFS"
301 :     ;;
302 : monnier 249 esac
303 :    
304 :     #
305 : jhr 3603 # on 64-bit linux systems, we need to check to see if the 32-bit emulation
306 :     # support is installed
307 :     #
308 :     if [ x"$ARCH" = "xx86" -a x"$OPSYS" = "xlinux" ] ; then
309 :     case `uname -m` in
310 :     x86_64)
311 :     tmpFile=smlnj-test$$
312 :     echo "int main () { return 0; }" >> /tmp/$tmpFile.c
313 :     gcc -m32 -o /tmp/$tmpFile /tmp/$tmpFile.c 2> /dev/null 1>> /dev/null
314 :     if [ "$?" != "0" ] ; then
315 : jhr 3615 rm -f /tmp/$tmpFile /tmp/$tmpFile.c
316 : jhr 3869 complain "$this: !!! SML/NJ requires support for 32-bit executables. On Debian Linux, you may need to apt-get install gcc-multilib g++-multilib ia32-libs. On RH Fedora, try: yum install glibc-devel.i686 libgcc.i686"
317 : jhr 3603 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 : jhr 3925 # Now do all the rest using the precompiled installer
438 :     # (see base/system/smlnj/installer for details)
439 : monnier 249 #
440 : mblume 1794 if [ $nolib = false ] ; then
441 :     echo $this: Installing other libraries and programs:
442 :     export ROOT INSTALLDIR CONFIGDIR BINDIR
443 : blume 2577 CM_TOLERATE_TOOL_FAILURES=true
444 :     export CM_TOLERATE_TOOL_FAILURES
445 : mblume 1794 if "$BINDIR"/sml -m \$smlnj/installer.cm
446 :     then
447 :     vsay $this: Installation complete.
448 :     else
449 :     complain "$this: !!! Installation of libraries and programs failed."
450 :     fi
451 : monnier 249 fi
452 :    
453 : blume 537 exit 0

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