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