0.9.12.23
[sbcl.git] / install.sh
1 #!/bin/sh
2 set -e
3
4 # Install SBCL files into the usual places.
5
6 ensure_dirs ()
7 {
8     for j in $*; do
9         test -d $j || mkdir -p $j
10     done;
11 }
12
13 if [ "$OSTYPE" = "cygwin" -o "$OSTYPE" = "msys" ] ; then
14     DEFAULT_INSTALL_ROOT="$PROGRAMFILES/sbcl"
15     RUNTIME=sbcl.exe
16     OLD_RUNTIME=sbcl_old.exe
17 else
18     DEFAULT_INSTALL_ROOT=/usr/local
19     RUNTIME=sbcl
20     OLD_RUNTIME=sbcl.old
21 fi
22 INSTALL_ROOT=${INSTALL_ROOT-$DEFAULT_INSTALL_ROOT}
23 MAN_DIR=${MAN_DIR-$INSTALL_ROOT/share/man}
24 INFO_DIR=${INFO_DIR-$INSTALL_ROOT/share/info}
25 DOC_DIR=${DOC_DIR-$INSTALL_ROOT/share/doc/sbcl}
26
27 # Does the environment look sane?
28 SBCL_SOURCE=`pwd`
29 if [ -n "$SBCL_HOME" -a "$INSTALL_ROOT/lib/sbcl" != "$SBCL_HOME" ];then
30    echo SBCL_HOME environment variable is set, and conflicts with INSTALL_ROOT.
31    echo Aborting installation.  Unset one or reset the other, then try again
32    echo INSTALL_ROOT="$INSTALL_ROOT"
33    echo SBCL_HOME="$SBCL_HOME"
34    exit 1
35 fi
36
37 # Before doing anything else, make sure we have an SBCL to install
38 if [ -f src/runtime/$RUNTIME ]; then
39     if [ -f output/sbcl.core ]; then
40         true
41     else
42         echo "output/sbcl.core not found, aborting installation."
43         exit 1
44     fi
45 else
46     echo "src/runtime/$RUNTIME not found, aborting installation."
47     exit 1
48 fi
49
50 SBCL_HOME=$INSTALL_ROOT/lib/sbcl
51 export SBCL_HOME INSTALL_ROOT
52 ensure_dirs $BUILD_ROOT$INSTALL_ROOT $BUILD_ROOT$INSTALL_ROOT/bin \
53     $BUILD_ROOT$INSTALL_ROOT/lib  \
54     $BUILD_ROOT$MAN_DIR $BUILD_ROOT$MAN_DIR/man1 \
55     $BUILD_ROOT$INFO_DIR $BUILD_ROOT$DOC_DIR \
56     $BUILD_ROOT$DOC_DIR/html \
57     $BUILD_ROOT$SBCL_HOME \
58     $BUILD_ROOT$SBCL_HOME/site-systems
59
60 # move old versions out of the way.  Safer than copying: don't want to
61 # break any running instances that have these files mapped
62 test -f $BUILD_ROOT$INSTALL_ROOT/bin/$RUNTIME && \
63  mv $BUILD_ROOT$INSTALL_ROOT/bin/$RUNTIME \
64     $BUILD_ROOT$INSTALL_ROOT/bin/$OLD_RUNTIME
65 test -f $BUILD_ROOT$SBCL_HOME/sbcl.core && \
66     mv $BUILD_ROOT$SBCL_HOME/sbcl.core $BUILD_ROOT$SBCL_HOME/sbcl.core.old
67
68 cp src/runtime/sbcl $BUILD_ROOT$INSTALL_ROOT/bin/
69 cp output/sbcl.core $BUILD_ROOT$SBCL_HOME/sbcl.core
70
71 # installing contrib
72
73 SBCL="`pwd`/src/runtime/sbcl --noinform --core `pwd`/output/sbcl.core --no-userinit --no-sysinit --disable-debugger"
74 SBCL_BUILDING_CONTRIB=1
75 export SBCL SBCL_BUILDING_CONTRIB
76
77 . ./find-gnumake.sh
78 find_gnumake
79
80 for i in contrib/*; do
81     test -d $i && test -f $i/test-passed || continue;
82     INSTALL_DIR=$SBCL_HOME/`basename $i `
83     export INSTALL_DIR
84     ensure_dirs $BUILD_ROOT$INSTALL_DIR && $GNUMAKE -C $i install
85 done
86
87 echo
88 echo "SBCL has been installed:"
89 echo " binary $BUILD_ROOT$INSTALL_ROOT/bin/$RUNTIME"
90 echo " core and contribs in $BUILD_ROOT$INSTALL_ROOT/lib/sbcl/"
91
92 # Installing manual & misc bits of documentation
93 #
94 # Locations based on FHS 2.3.
95 # See: <http://www.pathname.com/fhs/pub/fhs-2.3.html>
96 #
97 # share/       architecture independent read-only things
98 # share/man/   manpages, should be the same as man/
99 # share/info/  info files
100 # share/doc/   misc documentation
101
102 echo
103 echo "Documentation:"
104
105 # man
106 cp doc/sbcl.1 $BUILD_ROOT$MAN_DIR/man1/ && echo " man $BUILD_ROOT$MAN_DIR/man1/sbcl.1"
107
108 # info
109 for info in doc/manual/*.info
110 do
111   cp $info $BUILD_ROOT$INFO_DIR/ \
112       && echo -n " info $BUILD_ROOT$INFO_DIR/`basename $info` $BUILD_ROOT$INFO_DIR/dir" \
113       && ( install-info $BUILD_ROOT$INFO_DIR/`basename $info` $BUILD_ROOT$INFO_DIR/dir > /dev/null 2>&1 \
114            || echo -n " (could not add to system catalog)" ) \
115       && echo
116 done
117
118 # pdf
119 for pdf in doc/manual/*.pdf
120 do
121   cp $pdf $BUILD_ROOT$DOC_DIR/ \
122       && echo " pdf $BUILD_ROOT$DOC_DIR/`basename $pdf`"
123 done
124
125 # html
126 for html in doc/manual/sbcl doc/manual/asdf
127 do
128   test -d $html && cp -R -L $html $BUILD_ROOT$DOC_DIR/html \
129       && echo " html $BUILD_ROOT$DOC_DIR/html/`basename $html`/index.html"
130 done
131
132 for f in BUGS SUPPORT CREDITS COPYING NEWS
133 do
134   cp $f $BUILD_ROOT$DOC_DIR/
135 done