3 # GNU Mes --- Maxwell Equations of Software
4 # Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
6 # This file is part of GNU Mes.
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.
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.
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/>.
24 srcdir=${srcdir-$(dirname $0)}
25 . ${srcdest}build-aux/trace.sh
27 # parse --with-system-libc
29 p=${cmdline/ --with-system-libc/}
30 if test "$p" != "$cmdline"; then
31 mes_libc=${mes_libc-system}
36 # parse --with-courage
38 p=${cmdline/ --with-courage/}
39 if test "$p" != "$cmdline"; then
45 # parse --prefix=PREFIX
46 p=${cmdline/ --prefix=/ -prefix=}
47 if test "$p" != "$cmdline"; then
51 prefix=${p-/usr/local}
53 prefix=${prefix-/usr/local}
57 p=${cmdline/ --build=/ -build=}
58 if [ "$p" != "$cmdline" ]; then
68 p=${cmdline/ --host=/ -host=}
69 if [ "$p" != "$cmdline" ]; then
74 elif test -n "$build"; then
78 # parse --program-prefix=
79 p=${cmdline/ --program-prefix=/ -program-prefix=}
80 if test "$p" != "$cmdline"; then
81 p=${p##* -program-prefix=}
87 AR=${AR-$(command -v ar)} || true
88 BASH=${BASH-$(command -v bash)}
89 BLOOD_ELF=${BLOOD_ELF-$(command -v blood-elf)}
90 CC=${CC-$(command -v gcc)} || true
91 DIFF=${DIFF-$(command -v diff || echo $PWD/pre-inst-env diff.scm)}
92 GUILD=${GUILD-$(command -v guild)} || true
93 GUILE_TOOLS=${GUILE_TOOLS-$(command -v guile-tools)} || true
94 if test ! "$GUILD"; then
95 if test "$GUILE_TOOLS"; then
101 GUILE=${GUILE-$(command -v guile)} || true
102 HEX2=${HEX2-$(command -v hex2)}
103 M1=${M1-$(command -v M1)}
104 MES_FOR_BUILD=${MES_FOR_BUILD-$(command -v mes || command -v guile || echo mes)}
105 GIT=${GIT-$(command -v git)} || true
106 PERL=${PERL-$(command -v perl)} || true
109 MES_SEED=${MES_SEED-../mes-seed}
111 if test "$srcdir" = .; then
117 abs_top_srcdir=${abs_top_srcdir-$(cd ${srcdir} && pwd)}
118 abs_top_builddir=$PWD
120 if test -z "$GUILE" -o "$GUILE" = true; then
121 GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-2.2}
123 GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-$(guile -c '(display (effective-version))')}
125 bindir=$(eval echo ${bindir-$prefix/bin})
126 datadir=$(eval echo ${datadir-$prefix/share})
127 docdir=$(eval echo ${docdir-$datadir/doc/mes-$VERSION})
128 infodir=$(eval echo ${infodir-$datadir/info})
129 includedir=$(eval echo ${libdir-$prefix/include})
130 libdir=$(eval echo ${libdir-$prefix/lib})
131 pkgdatadir=$(eval echo ${pkgdatadir-$datadir/mes})
132 mandir=$(eval echo ${mandir-$datadir/man})
133 guile_site_dir=$(eval echo ${guile_site_dir-$prefix/share/guile/site/$GUILE_EFFECTIVE_VERSION})
134 guile_site_ccache_dir=$(eval echo ${guile_site_ccache_dir-$prefix/lib/guile/$GUILE_EFFECTIVE_VERSION/site-ccache})
139 -e s,"@PACKAGE@,$PACKAGE,"\
140 -e s,"@PACKAGE_NAME@,$PACKAGE_NAME,"\
141 -e s,"@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,"\
142 -e s,"@VERSION@,$VERSION,"\
143 -e s,"@build@,$build,"\
144 -e s,"@host@,$host,"\
145 -e s,"@compiler@,$compiler,"\
146 -e s,"@courageous@,$courageous,"\
147 -e s,"@mes_bits@,$mes_bits,"\
148 -e s,"@mes_kernel@,$mes_kernel,"\
149 -e s,"@mes_cpu@,$mes_cpu,"\
150 -e s,"@mes_libc@,$mes_libc,"\
151 -e s,"@mes_system@,$mes_system,"\
152 -e s,"@abs_top_srcdir@,$abs_top_srcdir,"\
153 -e s,"@abs_top_builddir@,$abs_top_builddir,"\
154 -e s,"@top_builddir@,$top_builddir,"\
155 -e s,"@srcdest@,$srcdest,"\
156 -e s,"@srcdir@,$srcdir,"\
157 -e s,"@prefix@,$prefix,"\
158 -e s,"@program_prefix@,$program_prefix,"\
159 -e s,"@bindir@,$bindir,"\
160 -e s,"@datadir@,$datadir,"\
161 -e s,"@docdir@,$docdir,"\
162 -e s,"@guile_site_dir@,$guile_site_dir,"\
163 -e s,"@guile_site_ccache_dir@,$guile_site_ccache_dir,"\
164 -e s,"@infodir@,$infodir,"\
165 -e s,"@includedir@,$includedir,"\
166 -e s,"@libdir@,$libdir,"\
167 -e s,"@mandir@,$mandir,"\
168 -e s,"@pkgdatadir@,$pkgdatadir,"\
169 -e s,"@sysconfdir@,$sysconfdir,"\
170 -e s,"@GUILE_EFFECTIVE_VERSION@,$GUILE_EFFECTIVE_VERSION,"\
173 -e s,"@BASH@,$BASH,"\
174 -e s,"@BLOOD_ELF@,$BLOOD_ELF,"\
176 -e s,"@DIFF@,$DIFF,"\
178 -e s,"@GUILD@,$GUILD,"\
179 -e s,"@GUILE@,$GUILE,"\
180 -e s,"@PERL@,$PERL,"\
181 -e s,"@CFLAGS@,$CFLAGS,"\
182 -e s,"@HEX2@,$HEX2,"\
183 -e s,"@HEX2FLAGS@,$HEX2FLAGS,"\
185 -e s,"@M1FLAGS@,$M1FLAGS,"\
186 -e s,"@MES_FOR_BUILD@,$MES_FOR_BUILD,"\
187 -e s,"@MES_SEED@,$MES_SEED,"\
188 -e s,"@MES_SEED@,$MES_SEED,"\
189 -e s,"@SHELL@,$SHELL,"\
193 host=${host-$($CC -dumpmachine 2>/dev/null)}
194 if test -z "$host$host_type"; then
195 mes_cpu=${arch-$(get_machine || uname -m)}
199 if test "$mes_cpu" = i386\
200 || test "$mes_cpu" = i486\
201 || test "$mes_cpu" = i586\
202 || test "$mes_cpu" = i686; then
205 if test "$mes_cpu" = armv4\
206 || test "$arch" = armv7l; then
209 if test "$mes_cpu" = amd64; then
229 if $CC --version | grep gcc; then #2>/dev/null; then
231 elif $CC --version | grep tcc; then #2>/dev/null; then
237 mes_system=$mes_cpu-$mes_kernel-mes
239 subst ${srcdest}build-aux/GNUmakefile.in GNUmakefile
240 subst ${srcdest}build-aux/config.sh.in config.sh
241 subst ${srcdest}build-aux/bootstrap.sh.in bootstrap.sh
242 chmod +x bootstrap.sh
243 subst ${srcdest}build-aux/build.sh.in build.sh
245 subst ${srcdest}build-aux/check.sh.in check.sh
247 subst ${srcdest}build-aux/install.sh.in install.sh
249 subst ${srcdest}build-aux/pre-inst-env.in pre-inst-env
250 chmod +x pre-inst-env
251 subst ${srcdest}scripts/ar.in scripts/ar
253 subst ${srcdest}scripts/mescc.scm.in scripts/mescc.scm
254 chmod +x scripts/mescc.scm
255 subst ${srcdest}scripts/mescc.in scripts/mescc
256 chmod +x scripts/mescc
257 subst ${srcdest}build-aux/uninstall.sh.in uninstall.sh
258 chmod +x uninstall.sh
261 rm -f include/mes/config.h
262 if test $mes_libc = system; then
263 cat >> include/mes/config.h <<EOF
264 #define SYSTEM_LIBC 1
267 cat >> include/mes/config.h <<EOF
271 cat >> include/mes/config.h <<EOF
272 #define MES_VERSION "$VERSION"
273 #define MES_PKGDATADIR "$pkgdatadir"
277 GNU Mes is configured for
286 ./build.sh to build mes
287 ./check.sh to check mes
288 ./install.sh to install mes