build: Prepare for autoconfiscation.
[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 GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-$(guile -c '(display (effective-version))')}
19 bindir=${bindir-$prefix/bin}
20 datadir=${datadir-$prefix/share/mes}
21 docdir=${docdir-$prefix/share/doc/mes}
22 infodir=${infodir-$prefix/share/info}
23 mandir=${mandir-$prefix/share/man}
24 moduledir=${moduledir-$datadir/module}
25 guile_site_dir=${guile_site_dir-$prefix/share/guile/site/$GUILE_EFFECTIVE_VERSION}
26 guile_site_ccache_dir=${guile_site_ccache_dir-$prefix/lib/guile/$GUILE_EFFECTIVE_VERSION/site-ccache}
27
28 mkdir -p $DESTDIR$bindir
29 cp src/mes $DESTDIR$bindir/mes
30 cp scripts/mescc $DESTDIR$bindir/mescc
31
32 sed \
33     -e "s,^#! /bin/sh,#! $SHELL," \
34     scripts/diff.scm > $DESTDIR$bindir/diff.scm
35 chmod -w+x $DESTDIR$bindir/diff.scm
36
37
38 mkdir -p $docdir
39 cp\
40     AUTHORS\
41     BOOTSTRAP\
42     COPYING\
43     HACKING\
44     INSTALL\
45     NEWS\
46     README\
47     $DESTDIR$docdir
48
49 if [ -f ${top_builddest}ChangeLog ]; then
50     cp ${top_builddest}ChangeLog $DESTDIR$docdir
51 else
52     cp ChangeLog $DESTDIR$docdir
53 fi
54
55 tar -cf- include lib | tar -xf- -C $DESTDIR$MES_PREFIX
56 tar -cf- scaffold --exclude='*.gcc*' --exclude='*.mes*' | tar -xf- -C $DESTDIR$MES_PREFIX
57 tar -cf- --exclude='*.go' module | tar -xf- -C $DESTDIR$MES_PREFIX
58 tar -cf- -C mes module | tar -xf- -C $DESTDIR$MES_PREFIX
59
60 mkdir -p $DESTDIR$guile_site_dir
61 mkdir -p $DESTDIR$guile_site_ccache_dir
62 tar -cf- -C module --exclude='*.go' . | tar -xf- -C $DESTDIR$guile_site_dir
63 tar -cf- -C module --exclude='*.scm' . | tar -xf- -C $DESTDIR$guile_site_ccache_dir
64
65 if [ -f doc/mes.info ]; then
66     mkdir -p $DESTDIR$prefix/share/info
67     tar -cf- doc/mes.info* doc/images | tar -xf- --strip-components=1 -C $DESTDIR$infodir
68     install-info --info-dir=$DESTDIR$prefix/share/info doc/mes.info
69 fi
70
71 if [ -f doc/mes.1 ]; then
72     mkdir -p $DESTDIR$mandir/man1
73     cp doc/mes.1 $DESTDIR$mandir/man1/
74 fi
75
76 if [ -f doc/mescc.1 ]; then
77     mkdir -p $DESTDIR$mandir/man1
78     cp doc/mescc.1 $DESTDIR$mandir/man1/
79 fi