build: Install ChangeLog.
[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
40 if [ -n "$PERL" -a -n "$GIT" ]\
41        && $PERL -v > /dev/null\
42        && $GIT --status > /dev/null; then
43     $PERL build-aux/gitlog-to-changelog --srcdir=. > ChangeLog
44 fi
45
46 cp\
47     AUTHORS\
48     BOOTSTRAP\
49     COPYING\
50     ChangeLog\
51     HACKING\
52     INSTALL\
53     NEWS\
54     README\
55     $DESTDIR$docdir
56
57 if [ -f ${top_builddest}ChangeLog ]; then
58     cp ${top_builddest}ChangeLog $DESTDIR$docdir
59 else
60     cp ChangeLog $DESTDIR$docdir
61 fi
62
63 tar -cf- include lib | tar -xf- -C $DESTDIR$MES_PREFIX
64 tar -cf- scaffold --exclude='*.gcc*' --exclude='*.mes*' | tar -xf- -C $DESTDIR$MES_PREFIX
65 tar -cf- --exclude='*.go' module | tar -xf- -C $DESTDIR$MES_PREFIX
66 tar -cf- -C mes module | tar -xf- -C $DESTDIR$MES_PREFIX
67
68 mkdir -p $DESTDIR$guile_site_dir
69 mkdir -p $DESTDIR$guile_site_ccache_dir
70 tar -cf- -C module --exclude='*.go' . | tar -xf- -C $DESTDIR$guile_site_dir
71 tar -cf- -C module --exclude='*.scm' . | tar -xf- -C $DESTDIR$guile_site_ccache_dir
72
73 if [ -f doc/mes.info ]; then
74     mkdir -p $DESTDIR$prefix/share/info
75     tar -cf- doc/mes.info* doc/images | tar -xf- --strip-components=1 -C $DESTDIR$infodir
76     install-info --info-dir=$DESTDIR$prefix/share/info doc/mes.info
77 fi
78
79 if [ -f doc/mes.1 ]; then
80     mkdir -p $DESTDIR$mandir/man1
81     cp doc/mes.1 $DESTDIR$mandir/man1/
82 fi
83
84 if [ -f doc/mescc.1 ]; then
85     mkdir -p $DESTDIR$mandir/man1
86     cp doc/mescc.1 $DESTDIR$mandir/man1/
87 fi