doc: Initial version.
[mes.git] / install.sh
1 #! /bin/sh
2
3 set -e
4 set -o pipefail
5
6 export PREFIX
7 SHELL=${SHELL-$(command -v sh)}
8 PREFIX=${PREFIX-/usr/local}
9 MES_PREFIX=${MES_PREFIX-$PREFIX/share/mes}
10 MES_SEED=${MES_SEED-../mes-seed}
11 TINYCC_SEED=${TINYCC_SEED-../tinycc-seed}
12
13 mkdir -p $PREFIX/bin
14 cp src/mes $PREFIX/bin/mes
15
16 mkdir -p $PREFIX/lib
17 mkdir -p $MES_PREFIX/lib
18 cp scripts/mescc $PREFIX/bin/mescc
19
20 mkdir -p $MES_PREFIX
21 tar -cf- doc guile include lib module scaffold | tar -xf- -C $MES_PREFIX
22
23 GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-2.2}
24 DATADIR=${MODULEDIR-$PREFIX/share/mes}
25 DOCDIR=${MODULEDIR-$PREFIX/share/doc/mes}
26 MODULEDIR=${MODULEDIR-$DATADIR/module}
27 GUILEDIR=${MODULEDIR-$PREFIX/share/guile/site/$GUILE_EFFECTIVE_VERSION}
28 GODIR=${GODIR-$PREFIX/lib/guile/$GUILE_EFFECTIVE_VERSION/site-ccache}
29 DOCDIR=${MODULEDIR-$PREFIX/share/doc/mes}
30
31 chmod +w $PREFIX/bin/mescc
32 sed \
33     -e "s,^#! /bin/sh,#! $SHELL," \
34     -e "s,module/,$MODULEDIR/," \
35     -e "s,@DATADIR@,$DATADIR,g" \
36     -e "s,@DOCDIR@,$DOCDIR,g" \
37     -e "s,@GODIR@,$GODIR,g" \
38     -e "s,@GUILEDIR@,$GUILEDIR,g" \
39     -e "s,@MODULEDIR@,$MODULEDIR,g" \
40     -e "s,@PREFIX@,$PREFIX,g" \
41     -e "s,@VERSION@,$VERSION,g" \
42     scripts/mescc > $PREFIX/bin/mescc
43 chmod +w $MODULEDIR/mes/boot-0.scm
44 sed \
45     -e "s,^#! /bin/sh,#! $SHELL," \
46     -e "s,module/,$MODULEDIR/," \
47     -e "s,@DATADIR@,$DATADIR,g" \
48     -e "s,@DOCDIR@,$DOCDIR,g" \
49     -e "s,@GODIR@,$GODIR,g" \
50     -e "s,@GUILEDIR@,$GUILEDIR,g" \
51     -e "s,@MODULEDIR@,$MODULEDIR,g" \
52     -e "s,@PREFIX@,$PREFIX,g" \
53     -e "s,@VERSION@,$VERSION,g" \
54     module/mes/boot-0.scm > $MODULEDIR/mes/boot-0.scm
55
56 sed \
57     -e "s,^#! /bin/sh,#! $SHELL," \
58     scripts/diff.scm > $PREFIX/bin/diff.scm
59 chmod -w+x $PREFIX/bin/diff.scm
60
61 if [ -f doc/mes.info ]; then
62     mkdir -p $PREFIX/share/info
63     install-info --info-dir=$PREFIX/share/info doc/mes.info
64     tar -cf- doc/mes.info* | tar -xf- --strip-components=1 -C $PREFIX/share/info
65 fi