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