build: Mark lib/tests/dirent/90-readdir.c as XFAIL on x86_64-gcc.
[mes.git] / configure.sh
1 #! /bin/sh
2
3 # GNU Mes --- Maxwell Equations of Software
4 # Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
5 #
6 # This file is part of GNU Mes.
7 #
8 # GNU Mes is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or (at
11 # your option) any later version.
12 #
13 # GNU Mes is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with GNU Mes.  If not, see <http://www.gnu.org/licenses/>.
20
21 set -e
22
23 VERSION=0.20
24 srcdir=${srcdir-$(dirname $0)}
25 . ${srcdest}build-aux/trace.sh
26
27 # parse arguments
28 while [ $# -gt 0 ]; do
29     case $1 in
30         (--with-courage)
31             courageous=true
32             ;;
33         (--with-system-libc)
34             mes_libc=system
35             ;;
36         (--build=*)
37             build=${1#--build=}
38             ;;
39         (--host=*)
40             host=${1#--host=}
41             ;;
42         (--prefix=*)
43             prefix=${1#--prefix=}
44             ;;
45         (--program-prefix=*)
46             program_prefix=${1#--program-prefix=}
47             ;;
48     esac
49     shift
50 done
51
52 prefix=${prefix-/usr/local}
53 mes_libc=${mes_libc-mes}
54 courageous=${courageous-false}
55 host=${host-$build}
56
57 AR=${AR-$(command -v ar)} || true
58 BASH=${BASH-$(command -v bash)}
59 BLOOD_ELF=${BLOOD_ELF-$(command -v blood-elf)}
60 CC=${CC-$(command -v gcc)} || true
61 DIFF=${DIFF-$(command -v diff || echo $PWD/pre-inst-env diff.scm)}
62 GUILD=${GUILD-$(command -v guild)} || true
63 GUILE_TOOLS=${GUILE_TOOLS-$(command -v guile-tools)} || true
64 if test ! "$GUILD"; then
65     if test "$GUILE_TOOLS"; then
66         GUILD=$GUILE_TOOLS
67     else
68         GUILD=true
69     fi
70 fi
71 GUILE=${GUILE-$(command -v guile)} || true
72 HEX2=${HEX2-$(command -v hex2)}
73 M1=${M1-$(command -v M1)}
74 MES_FOR_BUILD=${MES_FOR_BUILD-$(command -v mes || command -v guile || echo mes)}
75 GIT=${GIT-$(command -v git)} || true
76 PERL=${PERL-$(command -v perl)} || true
77 SHELL=${BASH-$SHELL}
78
79 MES_SEED=${MES_SEED-../mes-seed}
80
81 if test "$srcdir" = .; then
82     top_builddir=.
83 else
84     srcdest=${srcdest}
85     top_builddir=$PWD
86 fi
87 abs_top_srcdir=${abs_top_srcdir-$(cd ${srcdir} && pwd)}
88 abs_top_builddir=$PWD
89
90 if test -z "$GUILE" -o "$GUILE" = true; then
91     GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-2.2}
92 else
93     GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-$(guile -c '(display (effective-version))')}
94 fi
95 bindir=$(eval echo ${bindir-$prefix/bin})
96 datadir=$(eval echo ${datadir-$prefix/share})
97 docdir=$(eval echo ${docdir-$datadir/doc/mes-$VERSION})
98 infodir=$(eval echo ${infodir-$datadir/info})
99 includedir=$(eval echo ${includedir-$prefix/include})
100 libdir=$(eval echo ${libdir-$prefix/lib})
101 pkgdatadir=$(eval echo ${pkgdatadir-$datadir/mes})
102 mandir=$(eval echo ${mandir-$datadir/man})
103 guile_site_dir=$(eval echo ${guile_site_dir-$prefix/share/guile/site/$GUILE_EFFECTIVE_VERSION})
104 guile_site_ccache_dir=$(eval echo ${guile_site_ccache_dir-$prefix/lib/guile/$GUILE_EFFECTIVE_VERSION/site-ccache})
105
106 subst () {
107     echo "creating $2"
108     sed \
109     -e s,"@PACKAGE@,$PACKAGE,"\
110     -e s,"@PACKAGE_NAME@,$PACKAGE_NAME,"\
111     -e s,"@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,"\
112     -e s,"@VERSION@,$VERSION,"\
113     -e s,"@bootstrap@,yes,"\
114     -e s,"@build@,$build,"\
115     -e s,"@host@,$host,"\
116     -e s,"@compiler@,$compiler,"\
117     -e s,"@courageous@,$courageous,"\
118     -e s,"@mes_bits@,$mes_bits,"\
119     -e s,"@mes_kernel@,$mes_kernel,"\
120     -e s,"@mes_cpu@,$mes_cpu,"\
121     -e s,"@mes_libc@,$mes_libc,"\
122     -e s,"@mes_system@,$mes_system,"\
123     -e s,"@abs_top_srcdir@,$abs_top_srcdir,"\
124     -e s,"@abs_top_builddir@,$abs_top_builddir,"\
125     -e s,"@top_builddir@,$top_builddir,"\
126     -e s,"@srcdest@,$srcdest,"\
127     -e s,"@srcdir@,$srcdir,"\
128     -e s,"@prefix@,$prefix,"\
129     -e s,"@program_prefix@,$program_prefix,"\
130     -e s,"@bindir@,$bindir,"\
131     -e s,"@datadir@,$datadir,"\
132     -e s,"@docdir@,$docdir,"\
133     -e s,"@guile_site_dir@,$guile_site_dir,"\
134     -e s,"@guile_site_ccache_dir@,$guile_site_ccache_dir,"\
135     -e s,"@infodir@,$infodir,"\
136     -e s,"@includedir@,$includedir,"\
137     -e s,"@libdir@,$libdir,"\
138     -e s,"@mandir@,$mandir,"\
139     -e s,"@pkgdatadir@,$pkgdatadir,"\
140     -e s,"@sysconfdir@,$sysconfdir,"\
141     -e s,"@GUILE_EFFECTIVE_VERSION@,$GUILE_EFFECTIVE_VERSION,"\
142     -e s,"@V@,$V,"\
143     -e s,"@AR@,$AR,"\
144     -e s,"@BASH@,$BASH,"\
145     -e s,"@BLOOD_ELF@,$BLOOD_ELF,"\
146     -e s,"@CC@,$CC,"\
147     -e s,"@DIFF@,$DIFF,"\
148     -e s,"@GIT@,$GIT,"\
149     -e s,"@GUILD@,$GUILD,"\
150     -e s,"@GUILE@,$GUILE,"\
151     -e s,"@PERL@,$PERL,"\
152     -e s,"@CFLAGS@,$CFLAGS,"\
153     -e s,"@HEX2@,$HEX2,"\
154     -e s,"@HEX2FLAGS@,$HEX2FLAGS,"\
155     -e s,"@M1@,$M1,"\
156     -e s,"@M1FLAGS@,$M1FLAGS,"\
157     -e s,"@MES_FOR_BUILD@,$MES_FOR_BUILD,"\
158     -e s,"@MES_SEED@,$MES_SEED,"\
159     -e s,"@MES_SEED@,$MES_SEED,"\
160     -e s,"@SHELL@,$SHELL,"\
161     $1 > $2
162 }
163
164 host=${host-$($CC -dumpmachine 2>/dev/null)}
165 if test -z "$host$host_type"; then
166     mes_cpu=${arch-$(get_machine || uname -m)}
167 else
168     mes_cpu=${host%%-*}
169 fi
170 if test "$mes_cpu" = i386\
171         || test "$mes_cpu" = i486\
172         || test "$mes_cpu" = i586\
173         || test "$mes_cpu" = i686; then
174     mes_cpu=x86
175 fi
176 if test "$mes_cpu" = armv4\
177         || test "$arch" = armv7l; then
178     mes_cpu=arm
179 fi
180 if test "$mes_cpu" = amd64; then
181     mes_cpu=x86_64
182 fi
183
184 case "$host" in
185     *linux-gnu|*linux)
186         mes_kernel=linux;;
187     *gnu)
188         mes_kernel=gnu;;
189     *)
190         mes_kernel=linux;;
191 esac
192
193 case "$mes_cpu" in
194     x86_64)
195         mes_bits=64;;
196     *)
197         mes_bits=32;;
198 esac
199 #
200 if $CC --version | grep gcc; then #2>/dev/null; then
201     compiler=gcc
202 elif $CC --version | grep tcc; then #2>/dev/null; then
203     compiler=gcc
204 else
205     compiler=mescc
206 fi
207
208 mes_system=$mes_cpu-$mes_kernel-mes
209
210 subst ${srcdest}build-aux/GNUmakefile.in GNUmakefile
211 subst ${srcdest}build-aux/config.sh.in config.sh
212 subst ${srcdest}build-aux/bootstrap.sh.in bootstrap.sh
213 chmod +x bootstrap.sh
214 subst ${srcdest}build-aux/build.sh.in build.sh
215 chmod +x build.sh
216 subst ${srcdest}build-aux/check.sh.in check.sh
217 chmod +x check.sh
218 subst ${srcdest}build-aux/install.sh.in install.sh
219 chmod +x install.sh
220 subst ${srcdest}build-aux/pre-inst-env.in pre-inst-env
221 chmod +x pre-inst-env
222 subst ${srcdest}scripts/mesar.in scripts/mesar
223 chmod +x scripts/mesar
224 subst ${srcdest}scripts/mescc.scm.in scripts/mescc.scm
225 chmod +x scripts/mescc.scm
226 subst ${srcdest}scripts/mescc.in scripts/mescc
227 chmod +x scripts/mescc
228 subst ${srcdest}build-aux/uninstall.sh.in uninstall.sh
229 chmod +x uninstall.sh
230
231 mkdir -p include/mes
232 rm -f include/mes/config.h
233 if test $mes_libc = system; then
234     cat >> include/mes/config.h <<EOF
235 #define SYSTEM_LIBC 1
236 EOF
237 else
238     cat >> include/mes/config.h <<EOF
239 #undef SYSTEM_LIBC
240 EOF
241 fi
242 cat >> include/mes/config.h <<EOF
243 #define MES_VERSION "$VERSION"
244 #define MES_PKGDATADIR "$pkgdatadir"
245 EOF
246
247 cat <<EOF
248 GNU Mes is configured for
249    compiler: $compiler
250    cpu:      $mes_cpu
251    bits:     $mes_bits
252    libc:     $mes_libc
253    kernel:   $mes_kernel
254    system:   $mes_system
255
256 Run:
257   ./build.sh      to build mes
258   ./check.sh      to check mes
259   ./install.sh    to install mes
260 EOF