build: Support --srcdir build.
[mes.git] / configure.sh
1 #! /bin/sh
2
3 set -e
4
5 VERSION=0.17
6
7 # parse --prefix=prefix
8 cmdline=$(echo "$@")
9 p=${cmdline##*--prefix=}
10 p=${p% *}
11 p=${p% -*}
12 prefix=${p-${prefix}}
13 if [ -z "$prefix" ]; then
14    prefix=/usr/local
15 fi
16
17 . build-aux/trace.sh
18
19 BASH=${BASH-$(command -v bash)}
20 GUILE=${GUILE-$(command -v guile)} || true
21
22 srcdir=${srcdir-.}
23 top_builddest=${top_builddest-}
24 top_builddir=${top_builddest-.}
25 abs_top_srcdir=${abs_top_srcdir-$PWD}
26 abs_top_builddir=${abs_top_srcdir-$abs_top_builddir}
27
28 if [ -z "$GUILE" -o "$GUILE" = true ]; then
29     GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-2.2}
30 else
31     GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-$(guile -c '(display (effective-version))')}
32 fi
33 datadir=${datadir-$prefix/share}
34 docdir=${docdir-$datadir/doc/mes-$VERSION}
35 infodir=${infodir-$datadir/info}
36 mandir=${mandir-$datadir/man}
37 moduledir=${moduledir-$datadir/mes/module}
38 guile_site_dir=${guile_site_dir-$prefix/share/guile/site/$GUILE_EFFECTIVE_VERSION}
39 guile_site_ccache_dir=${guile_site_ccache_dir-$prefix/lib/guile/$GUILE_EFFECTIVE_VERSION/site-ccache}
40
41 sed \
42     -e s,"@srcdir@,$srcdir,"\
43     -e s,"@abs_top_srcdir@,$abs_top_srcdir,"\
44     -e s,"@abs_top_builddir@,$abs_top_builddir,"\
45     -e s,"@top_builddir@,$top_builddir,"\
46     -e s,"@top_builddest@,$top_builddest,"\
47     -e s,"@BASH@,$BASH,"\
48     -e s,"@GUILE@,$GUILE,"\
49     -e s,"@guile_site_dir@,$guile_site_dir,"\
50     -e s,"@guile_site_ccache_dir@,$guile_site_ccache_dir,"\
51     -e s,"@VERSION@,$VERSION,"\
52     -e s,"mes/module/,$moduledir,"\
53     build-aux/pre-inst-env.in\
54     > pre-inst-env
55
56 chmod +x pre-inst-env
57
58 sed \
59     -e s,"@srcdir@,$srcdir,"\
60     -e s,"@abs_top_srcdir@,$abs_top_srcdir,"\
61     -e s,"@abs_top_builddir@,$abs_top_builddir,"\
62     -e s,"@top_builddir@,$top_builddir,"\
63     -e s,"@top_builddest@,$top_builddest,"\
64     -e s,"@BASH@,$BASH,"\
65     -e s,"@GUILE@,$GUILE,"\
66     -e s,"@guile_site_dir@,$guile_site_dir,"\
67     -e s,"@guile_site_ccache_dir@,$guile_site_ccache_dir,"\
68     -e s,"@VERSION@,$VERSION,"\
69     -e s,"mes/module/,$moduledir,"\
70     mes/module/mes/boot-0.scm.in\
71     > mes/module/mes/boot-0.scm
72
73 sed \
74     -e s,"@srcdir@,$srcdir,"\
75     -e s,"@abs_top_srcdir@,$abs_top_srcdir,"\
76     -e s,"@abs_top_builddir@,$abs_top_builddir,"\
77     -e s,"@top_builddir@,$top_builddir,"\
78     -e s,"@top_builddest@,$top_builddest,"\
79     -e s,"@BASH@,$BASH,"\
80     -e s,"@GUILE@,$GUILE,"\
81     -e s,"@guile_site_dir@,$guile_site_dir,"\
82     -e s,"@guile_site_ccache_dir@,$guile_site_ccache_dir,"\
83     -e s,"@VERSION@,$VERSION,"\
84     -e s,"mes/module/,$moduledir,"\
85     scripts/mescc.in\
86     > scripts/mescc
87
88 chmod +x scripts/mescc
89
90 if [ "$srcdir" != . ]; then
91     mkdir -p mes/module/mes
92     { cd mes/module/mes; ln -sf $abs_top_srcdir/mes/module/mes/*.mes .; }
93 fi
94
95 cat <<EOF
96 Run:
97   prefix=$prefix ./build.sh      to build mes
98   prefix=$prefix ./check.sh      to check mes
99   prefix=$prefix ./install.sh    to install mes
100 EOF