9ff242e1ef7ed3b5e0413d51b6beda38deccafe8
[mes.git] / install.sh
1 #! /bin/sh
2
3 set -e
4 if [ -n "$BUILD_DEBUG" ]; then
5     set -x
6 fi
7
8 # use bash or lose if pipes fail
9 [ -n "$BASH" ] && set -o pipefail
10
11 SHELL=${SHELL-$(command -v sh)}
12 prefix=${prefix-/usr/local}
13
14 MES_PREFIX=${MES_PREFIX-$prefix/share/mes}
15 MES_SEED=${MES_SEED-../MES-SEED}
16 TINYCC_SEED=${TINYCC_SEED-../TINYCC-SEED}
17
18 mkdir -p $DESTDIR$prefix/bin
19 cp src/mes $DESTDIR$prefix/bin/mes
20
21 mkdir -p $DESTDIR$prefix/lib
22 mkdir -p $DESTDIR$MES_PREFIX/lib
23 cp scripts/mescc $DESTDIR$prefix/bin/mescc
24
25 mkdir -p $DESTDIR$MES_PREFIX
26 tar -cf- doc guile include lib module scaffold | tar -xf- -C $DESTDIR$MES_PREFIX
27
28 GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-2.2}
29 datadir=${moduledir-$prefix/share/mes}
30 docdir=${moduledir-$prefix/share/doc/mes}
31 mandir=${mandir-$prefix/share/man}
32 moduledir=${moduledir-$datadir/module}
33 guile_site_dir=${moduledir-$prefix/share/guile/site/$GUILE_EFFECTIVE_VERSION}
34 guile_site_ccache_dir=${guile_site_ccache_dir-$prefix/lib/guile/$GUILE_EFFECTIVE_VERSION/site-ccache}
35 docdir=${moduledir-$prefix/share/doc/mes}
36
37 chmod +w $DESTDIR$prefix/bin/mescc
38 sed \
39     -e "s,^#! /bin/sh,#! $SHELL," \
40     -e "s,module/,$moduledir/," \
41     -e "s,@datadir@,$datadir,g" \
42     -e "s,@docdir@,$docdir,g" \
43     -e "s,@guile_site_ccache_dir@,$guile_site_ccache_dir,g" \
44     -e "s,@guile_site_dir@,$guile_site_dir,g" \
45     -e "s,@moduledir@,$moduledir,g" \
46     -e "s,@prefix@,$prefix,g" \
47     -e "s,@VERSION@,$VERSION,g" \
48     scripts/mescc > $DESTDIR$prefix/bin/mescc
49 chmod +w $DESTDIR$moduledir/mes/boot-0.scm
50 sed \
51     -e "s,^#! /bin/sh,#! $SHELL," \
52     -e "s,module/,$moduledir/," \
53     -e "s,@datadir@,$datadir,g" \
54     -e "s,@docdir@,$docdir,g" \
55     -e "s,@guile_site_ccache_dir@,$guile_site_ccache_dir,g" \
56     -e "s,@guile_site_dir@,$guile_site_dir,g" \
57     -e "s,@moduledir@,$moduledir,g" \
58     -e "s,@prefix@,$prefix,g" \
59     -e "s,@VERSION@,$VERSION,g" \
60     module/mes/boot-0.scm > $DESTDIR$moduledir/mes/boot-0.scm
61
62 sed \
63     -e "s,^#! /bin/sh,#! $SHELL," \
64     scripts/diff.scm > $DESTDIR$prefix/bin/diff.scm
65 chmod -w+x $DESTDIR$prefix/bin/diff.scm
66
67 if [ -f doc/mes.info ]; then
68     mkdir -p $DESTDIR$prefix/share/info
69     tar -cf- doc/mes.info* doc/images | tar -xf- --strip-components=1 -C $DESTDIR$prefix/share/info
70     install-info --info-dir=$DESTDIR$prefix/share/info doc/mes.info
71 fi
72
73 if [ -f doc/mes.1 ]; then
74     mkdir -p $DESTDIR$mandir/man1
75     cp doc/mes.1 $DESTDIR$mandir/man1/
76 fi
77
78 if [ -f doc/mescc.1 ]; then
79     mkdir -p $DESTDIR$mandir/man1
80     cp doc/mescc.1 $DESTDIR$mandir/man1/
81 fi