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 5232 - (view) (download) (as text)

1 : monnier 249 #!/bin/sh
2 :     #
3 :     # Copyright (c) 1994 AT&T Bell Laboratories.
4 : jhr 4693 # Copyright (c) 2014-2018 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 : jhr 4905 echo "$this: installing $BINDIR/$2"
219 : blume 537 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 : jhr 4903 case `uname -s` in
254 :     CYGWIN*)
255 :     echo "$this: !!! SML/NJ does not support 64-bit cygwin"
256 : jhr 4905 echo "$this: !!! Please use the 32-bit version"
257 : jhr 4903 ;;
258 :     *)
259 :     echo "$this: !!! Script $BINDIR/.arch-n-opsys fails on this machine."
260 :     echo "$this: !!! You must patch this by hand and repeat the installation."
261 :     ;;
262 :     esac
263 : blume 1282 exit 2
264 :     else
265 :     vsay $this: Script $BINDIR/.arch-n-opsys reports $ARCH_N_OPSYS.
266 :     fi
267 :     eval $ARCH_N_OPSYS
268 :    
269 :     #
270 : mblume 1494 # now install most of the other driver scripts
271 :     # (except ml-build, since we don't know $CM_DIR_ARC yet)
272 : blume 1282 #
273 : blume 537 installdriver _run-sml .run-sml
274 :     installdriver _link-sml .link-sml
275 : blume 691 installdriver _ml-makedepend ml-makedepend
276 : blume 537
277 : mblume 1747 installdriver _heap2exec heap2exec
278 :    
279 : monnier 249 #
280 : jhr 5232 # set allocation size; for the x86, this gets reset in .run-sml
281 : monnier 249 #
282 : jhr 5232 ALLOC=512k
283 : blume 537
284 : jhr 4257 # OS-specific things for building the runtime system
285 :     #
286 : jhr 4895 RT_MAKEFILE=mk.$ARCH-$OPSYS
287 : monnier 249 case $OPSYS in
288 : jhr 4905 darwin)
289 :     SDK=none
290 :     if [ "$ARCH" = "x86" ] ; then
291 :     # the /usr/bin/as command does _not_ accept the -mmacosx-version-min
292 :     # command-line option prior to MacOS X 10.10 (Yosemite)
293 :     case `sw_vers -productVersion` in
294 :     10.6*) AS_ACCEPTS_SDK=no ;;
295 :     10.7*) AS_ACCEPTS_SDK=no ;;
296 :     10.8*) AS_ACCEPTS_SDK=no ;;
297 :     10.9*) AS_ACCEPTS_SDK=no ;;
298 : jhr 4935 10.14*)
299 : jhr 4905 AS_ACCEPTS_SDK=yes
300 : jhr 4935 # Mojave needs a special makefile, but we need to be careful
301 :     # about when we are running the postinstall script, so we check
302 :     # for the nolib argument
303 :     if [ x"$nolib" = xfalse ] ; then
304 :     RT_MAKEFILE=mk.x86-darwin18
305 :     # location of Xcode SDKs
306 :     if [ ! -x /usr/bin/xcode-select ] ; then
307 :     echo "$this: !!! /usr/bin/xcode-select is missing; please install Xcode"
308 :     exit 1
309 : jhr 4905 fi
310 : jhr 4935 SDK_DIR=`xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs
311 :     # look for an SDK that supports 32-bit builds (starting with 10.13 High Sierra
312 :     # and going back to 10.10 Yosemite)
313 :     #
314 :     for SDK_VERS in 13 12 11 10 ; do
315 :     if [ -d $SDK_DIR/MacOSX10.$SDK_VERS.sdk ] ; then
316 :     SDK="$SDK_DIR/MacOSX10.$SDK_VERS.sdk"
317 :     break
318 :     fi
319 :     done
320 :     if [ x"$SDK" = xnone ] ; then
321 :     echo "$this: !!! SML/NJ requires support for 32-bit executables."
322 :     echo " Please see http://www.smlnj.org/dist/working/$VERSION/MACOSXINSTALL for more details."
323 :     exit 1
324 :     fi
325 : jhr 4905 fi
326 :     ;;
327 :     *) AS_ACCEPTS_SDK=yes ;;
328 :     esac
329 :     if [ x"$SDK" = xnone ] ; then
330 : jhr 4257 EXTRA_DEFS="AS_ACCEPTS_SDK=$AS_ACCEPTS_SDK"
331 : jhr 3603 else
332 : jhr 4905 EXTRA_DEFS="AS_ACCEPTS_SDK=$AS_ACCEPTS_SDK SDK=$SDK"
333 : jhr 3603 fi
334 : jhr 4905 fi
335 : jhr 3603 ;;
336 : jhr 4905 linux)
337 :     EXTRA_DEFS=`"$CONFIGDIR/chk-global-names.sh"`
338 :     if [ "$?" != "0" ]; then
339 :     complain "$this: !!! Problems checking for underscores in asm names."
340 :     fi
341 :     EXTRA_DEFS="XDEFS=$EXTRA_DEFS"
342 :     if [ "$ARCH" = "x86" ] ; then
343 :     #
344 :     # on 64-bit linux systems, we need to check to see if the 32-bit emulation
345 :     # support is installed
346 :     #
347 :     case `uname -m` in
348 :     x86_64)
349 :     tmpFile=smlnj-test$$
350 :     echo "int main () { return 0; }" >> /tmp/$tmpFile.c
351 :     gcc -m32 -o /tmp/$tmpFile /tmp/$tmpFile.c 2> /dev/null 1>> /dev/null
352 :     if [ "$?" != "0" ] ; then
353 :     rm -f /tmp/$tmpFile /tmp/$tmpFile.c
354 :     echo "$this: !!! SML/NJ requires support for 32-bit executables."
355 :     echo "$this: !!! Please see http://www.smlnj.org/dist/working/$VERSION/INSTALL for more details."
356 :     exit 1
357 :     else
358 :     rm -f /tmp/$tmpFile /tmp/$tmpFile.c
359 :     fi
360 :     ;;
361 :     *) ;;
362 :     esac
363 :     fi
364 :     ;;
365 :     solaris)
366 :     MAKE=/usr/ccs/bin/make
367 :     ;;
368 :     esac
369 : jhr 3603
370 :     #
371 : monnier 249 # the name of the bin files directory
372 :     #
373 : blume 615 BOOT_ARCHIVE=boot.$ARCH-unix
374 :     BOOT_FILES=sml.$BOOT_ARCHIVE
375 : monnier 249
376 :     #
377 :     # build the run-time system
378 :     #
379 : mblume 1725 if [ -x "$RUNDIR"/run.$ARCH-$OPSYS ]; then
380 : blume 1058 vsay $this: Run-time system already exists.
381 : blume 537 else
382 : mblume 1725 "$CONFIGDIR"/unpack "$ROOT" runtime
383 : blume 2163 cd "$BASEDIR"/runtime/objs
384 : blume 577 echo $this: Compiling the run-time system.
385 : jhr 4895 $MAKE -f $RT_MAKEFILE $EXTRA_DEFS
386 : blume 537 if [ -x run.$ARCH-$OPSYS ]; then
387 : mblume 1725 mv run.$ARCH-$OPSYS "$RUNDIR"
388 : mblume 1747 if [ -f runx.$ARCH-$OPSYS ]; then
389 :     mv runx.$ARCH-$OPSYS "$RUNDIR"
390 :     fi
391 : mblume 1923 if [ -f run.$ARCH-$OPSYS.so ]; then
392 :     mv run.$ARCH-$OPSYS.so "$RUNDIR"
393 :     fi
394 :     if [ -f run.$ARCH-$OPSYS.a ]; then
395 :     mv run.$ARCH-$OPSYS.a "$RUNDIR"
396 :     fi
397 : jhr 724 $MAKE MAKE=$MAKE clean
398 : blume 537 else
399 : blume 1058 complain "$this: !!! Run-time system build failed for some reason."
400 : blume 537 fi
401 : monnier 249 fi
402 : blume 2163 cd "$BASEDIR"
403 : monnier 249
404 :     #
405 :     # boot the base SML system
406 :     #
407 : mblume 1725 if [ -r "$HEAPDIR"/sml.$HEAP_SUFFIX ]; then
408 : blume 1058 vsay $this: Heap image $HEAPDIR/sml.$HEAP_SUFFIX already exists.
409 : mblume 1873 fish "$LIBDIR"/smlnj/basis
410 : mblume 1385 # ignore requested arc name since we have to live with what is there:
411 : mblume 1572 export CM_DIR_ARC
412 :     CM_DIR_ARC=$ORIG_CM_DIR_ARC
413 : mblume 1794 # now re-dump the heap image:
414 :     vsay "$this: Re-creating a (customized) heap image..."
415 :     "$BINDIR"/sml @CMredump "$ROOT"/sml
416 :     cd "$ROOT"
417 :     if [ -r sml.$HEAP_SUFFIX ]; then
418 :     mv sml.$HEAP_SUFFIX "$HEAPDIR"
419 :     else
420 :     complain "$this !!! Unable to re-create heap image (sml.$HEAP_SUFFIX)."
421 :     fi
422 : monnier 249 else
423 : mblume 1725 "$CONFIGDIR"/unpack "$ROOT" "$BOOT_ARCHIVE"
424 : mblume 1385
425 : mblume 1873 fish "$ROOT"/"$BOOT_FILES"/smlnj/basis
426 : mblume 1385
427 : mblume 1725 cd "$ROOT"
428 : mblume 1385
429 :     # Target arc:
430 : mblume 1572 export CM_DIR_ARC
431 :     CM_DIR_ARC=${CM_DIR_ARC:-".cm"}
432 : mblume 1385
433 :     if [ $CM_DIR_ARC = $ORIG_CM_DIR_ARC ] ; then
434 :     : we are happy
435 :     else
436 :     # now we have to make a symbolic link for each occurrence of
437 :     # $ORIG_CM_DIR_ARC to $CM_DIR_ARC
438 : mblume 1725 dirarcs "$ORIG_CM_DIR_ARC" "$CM_DIR_ARC" "$BOOT_FILES"
439 : mblume 1385 fi
440 :    
441 : mblume 1725 cd "$ROOT"/"$BOOT_FILES"
442 : mblume 1385
443 :     # now link (boot) the system and let it initialize itself...
444 : mblume 1725 if "$BINDIR"/.link-sml @SMLheap="$ROOT"/sml @SMLboot=BOOTLIST @SMLalloc=$ALLOC
445 : blume 537 then
446 : mblume 1725 cd "$ROOT"
447 : blume 537 if [ -r sml.$HEAP_SUFFIX ]; then
448 : mblume 1725 mv sml.$HEAP_SUFFIX "$HEAPDIR"
449 :     cd "$BINDIR"
450 : blume 537 ln -s .run-sml sml
451 :     #
452 :     # Now move all stable libraries to #LIBDIR and generate
453 :     # the pathconfig file.
454 :     #
455 : mblume 1725 cd "$ROOT"/"$BOOT_FILES"
456 : blume 573 for anchor in * ; do
457 :     if [ -d $anchor ] ; then
458 : blume 1201 echo $anchor $anchor >>$CM_PATHCONFIG
459 : mblume 1725 move $anchor "$LIBDIR"/$anchor
460 : blume 573 fi
461 : blume 537 done
462 : mblume 1725 cd "$ROOT"
463 : blume 573 # $BOOT_FILES is now only an empty skeleton, let's get rid of it.
464 : mblume 1725 rm -rf "$BOOT_FILES"
465 : monnier 418
466 : blume 537 else
467 : blume 1058 complain "$this !!! No heap image generated (sml.$HEAP_SUFFIX)."
468 : blume 537 fi
469 : monnier 418 else
470 : blume 1058 complain "$this !!! Boot code failed, no heap image (sml.$HEAP_SUFFIX)."
471 : monnier 418 fi
472 : monnier 249 fi
473 :    
474 : mblume 1494 #
475 :     # now that we know CM_DIR_ARC we can install the ml-build driver...
476 :     #
477 :     installdriver _ml-build ml-build
478 :    
479 : mblume 1725 cd "$ROOT"
480 : monnier 249
481 :     #
482 : jhr 3925 # Now do all the rest using the precompiled installer
483 :     # (see base/system/smlnj/installer for details)
484 : monnier 249 #
485 : mblume 1794 if [ $nolib = false ] ; then
486 :     echo $this: Installing other libraries and programs:
487 :     export ROOT INSTALLDIR CONFIGDIR BINDIR
488 : blume 2577 CM_TOLERATE_TOOL_FAILURES=true
489 :     export CM_TOLERATE_TOOL_FAILURES
490 : mblume 1794 if "$BINDIR"/sml -m \$smlnj/installer.cm
491 :     then
492 :     vsay $this: Installation complete.
493 :     else
494 :     complain "$this: !!! Installation of libraries and programs failed."
495 :     fi
496 : monnier 249 fi
497 :    
498 : blume 537 exit 0

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