Trust non-returning functions during sb-xc.
[sbcl.git] / install.sh
blob52bd2048c5ac4e2235e56e5edb237d8cbf8c6695
1 #!/bin/sh
2 set -e
4 # Install SBCL files into the usual places.
6 umask 022
8 bad_option() {
9 echo $1
10 echo "Enter \"$0 --help\" for list of valid options."
11 exit 1
14 for option
16 optarg_ok=true
17 # Split --foo=bar into --foo and bar.
18 case $option in
19 *=*)
20 # For ease of scripting skip valued options with empty
21 # values.
22 optarg=`expr "X$option" : '[^=]*=\(.*\)'` || optarg_ok=false
23 option=`expr "X$option" : 'X\([^=]*=\).*'`
26 optarg=""
28 esac
30 case $option in
31 --prefix=)
32 $optarg_ok || bad_option "Bad argument for --prefix="
33 INSTALL_ROOT=$optarg
35 --help | -help | -h)
36 cat <<EOF
37 --prefix=<path> Specify the install location.
39 See ./INSTALL for more information
40 EOF
41 exit 0
44 bad_option "Unknown command-line option to $0: \"$option\""
46 esac
48 done
50 ensure_dirs ()
52 for j in "$@"; do
53 test -d "$j" || mkdir -p "$j"
54 done;
57 if [ "$OSTYPE" = "cygwin" -o "$OSTYPE" = "msys" ] ; then
58 RUNTIME=sbcl.exe
59 OLD_RUNTIME=sbcl.exe.old
60 else
61 RUNTIME=sbcl
62 OLD_RUNTIME=sbcl.old
65 # Before doing anything else, make sure we have an SBCL to install
66 if [ -f src/runtime/$RUNTIME ]; then
67 if [ -f output/sbcl.core ]; then
68 true
69 else
70 echo "output/sbcl.core not found, aborting installation."
71 echo 'See ./INSTALL, the "SOURCE DISTRIBUTION" section'
72 exit 1
74 else
75 echo "src/runtime/$RUNTIME not found, aborting installation."
76 echo 'See ./INSTALL, the "SOURCE DISTRIBUTION" section'
77 exit 1
80 . output/prefix.def
81 DEFAULT_INSTALL_ROOT=$SBCL_PREFIX
83 INSTALL_ROOT=${INSTALL_ROOT:-$DEFAULT_INSTALL_ROOT}
84 MAN_DIR=${MAN_DIR:-"$INSTALL_ROOT"/share/man}
85 INFO_DIR=${INFO_DIR:-"$INSTALL_ROOT"/share/info}
86 DOC_DIR=${DOC_DIR:-"$INSTALL_ROOT"/share/doc/sbcl}
87 echo $INSTALL_ROOT
88 # Does the environment look sane?
89 if [ -n "$SBCL_HOME" -a "$INSTALL_ROOT/lib/sbcl" != "$SBCL_HOME" ];then
90 echo SBCL_HOME environment variable is set, and conflicts with INSTALL_ROOT.
91 echo Aborting installation. Unset one or reset the other, then try again
92 echo INSTALL_ROOT="$INSTALL_ROOT"
93 echo SBCL_HOME="$SBCL_HOME"
94 exit 1
97 SBCL_HOME="$INSTALL_ROOT"/lib/sbcl
98 export SBCL_HOME INSTALL_ROOT
99 ensure_dirs "$BUILD_ROOT$INSTALL_ROOT" "$BUILD_ROOT$INSTALL_ROOT"/bin \
100 "$BUILD_ROOT$INSTALL_ROOT"/lib \
101 "$BUILD_ROOT$MAN_DIR" "$BUILD_ROOT$MAN_DIR"/man1 \
102 "$BUILD_ROOT$INFO_DIR" "$BUILD_ROOT$DOC_DIR" \
103 "$BUILD_ROOT$DOC_DIR"/html \
104 "$BUILD_ROOT$SBCL_HOME"
106 # move old versions out of the way. Safer than copying: don't want to
107 # break any running instances that have these files mapped
108 test -f "$BUILD_ROOT$INSTALL_ROOT"/bin/$RUNTIME && \
109 mv "$BUILD_ROOT$INSTALL_ROOT"/bin/$RUNTIME \
110 "$BUILD_ROOT$INSTALL_ROOT"/bin/$OLD_RUNTIME
111 test -f "$BUILD_ROOT$SBCL_HOME"/sbcl.core && \
112 mv "$BUILD_ROOT$SBCL_HOME"/sbcl.core "$BUILD_ROOT$SBCL_HOME"/sbcl.core.old
114 cp src/runtime/$RUNTIME "$BUILD_ROOT$INSTALL_ROOT"/bin/
115 cp output/sbcl.core "$BUILD_ROOT$SBCL_HOME"/sbcl.core
116 test -f src/runtime/libsbcl.so && \
117 cp src/runtime/libsbcl.so "$BUILD_ROOT$INSTALL_ROOT"/lib/
119 cp src/runtime/sbcl.mk "$BUILD_ROOT$SBCL_HOME"/sbcl.mk
120 for i in $(grep '^LIBSBCL=' src/runtime/sbcl.mk | cut -d= -f2-) ; do
121 cp "src/runtime/$i" "$BUILD_ROOT$SBCL_HOME/$i"
122 done
124 # installing contrib
126 ensure_dirs "$BUILD_ROOT$SBCL_HOME/contrib/"
127 cp obj/sbcl-home/contrib/* "$BUILD_ROOT$SBCL_HOME/contrib/"
129 echo
130 echo "SBCL has been installed:"
131 echo " binary $BUILD_ROOT$INSTALL_ROOT/bin/$RUNTIME"
132 echo " core and contribs in $BUILD_ROOT$INSTALL_ROOT/lib/sbcl/"
134 # Installing manual & misc bits of documentation
136 # Locations based on FHS 2.3.
137 # See: <http://www.pathname.com/fhs/pub/fhs-2.3.html>
139 # share/ architecture independent read-only things
140 # share/man/ manpages, should be the same as man/
141 # share/info/ info files
142 # share/doc/ misc documentation
144 echo
145 echo "Documentation:"
146 CP="cp -f"
148 # man
149 $CP doc/sbcl.1 "$BUILD_ROOT$MAN_DIR"/man1/ && echo " man $BUILD_ROOT$MAN_DIR/man1/sbcl.1"
151 # info
152 for info in doc/manual/*.info
154 test -e $info && $CP $info "$BUILD_ROOT$INFO_DIR"/ \
155 && BN=`basename $info` \
156 && DIRFAIL=`install-info --info-dir="$BUILD_ROOT$INFO_DIR" \
157 "$BUILD_ROOT$INFO_DIR"/$BN > /dev/null 2>&1 \
158 || echo "(could not add to system catalog)"` \
159 && echo " info $BUILD_ROOT$INFO_DIR/`basename $info` [$BUILD_ROOT$INFO_DIR/dir] $DIRFAIL"
160 done
162 for info in doc/manual/*.info-*
164 test -e $info && $CP $info "$BUILD_ROOT$INFO_DIR"/ \
165 && echo " info $BUILD_ROOT$INFO_DIR/`basename $info`"
166 done
168 # pdf
169 for pdf in doc/manual/*.pdf
171 test -e $pdf && $CP $pdf "$BUILD_ROOT$DOC_DIR"/ \
172 && echo " pdf $BUILD_ROOT$DOC_DIR/`basename $pdf`"
173 done
175 # html
176 for html in doc/manual/sbcl doc/manual/asdf
178 test -d $html && $CP -R -L $html "$BUILD_ROOT$DOC_DIR"/html \
179 && echo " html $BUILD_ROOT$DOC_DIR/html/`basename $html`/index.html"
180 done
182 for html in doc/manual/sbcl.html doc/manual/asdf.html
184 test -e $html && $CP $html "$BUILD_ROOT$DOC_DIR"/ \
185 && echo " html $BUILD_ROOT$DOC_DIR/`basename $html`"
186 done
188 for f in BUGS CREDITS COPYING NEWS
190 test -e $f && $CP $f "$BUILD_ROOT$DOC_DIR"/
191 done