2018-07-21 22:43:39 +00:00
|
|
|
#! /bin/sh
|
|
|
|
|
2018-07-23 17:10:34 +00:00
|
|
|
# GNU Mes --- Maxwell Equations of Software
|
2019-06-08 13:36:22 +00:00
|
|
|
# Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
2018-07-23 17:10:34 +00:00
|
|
|
#
|
|
|
|
# This file is part of GNU Mes.
|
|
|
|
#
|
|
|
|
# GNU Mes is free software; you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
# your option) any later version.
|
|
|
|
#
|
|
|
|
# GNU Mes is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2018-07-21 22:43:39 +00:00
|
|
|
set -e
|
|
|
|
|
2019-09-08 07:31:38 +00:00
|
|
|
VERSION=0.20
|
2018-11-06 19:29:35 +00:00
|
|
|
srcdir=${srcdir-$(dirname $0)}
|
|
|
|
. ${srcdest}build-aux/trace.sh
|
2018-07-21 22:43:39 +00:00
|
|
|
|
2019-10-01 17:12:56 +00:00
|
|
|
# parse arguments
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case $1 in
|
|
|
|
(--with-courage)
|
|
|
|
courageous=true
|
|
|
|
;;
|
|
|
|
(--with-system-libc)
|
|
|
|
mes_libc=system
|
|
|
|
;;
|
|
|
|
(--build=*)
|
|
|
|
build=${1#--build=}
|
|
|
|
;;
|
|
|
|
(--host=*)
|
|
|
|
host=${1#--host=}
|
|
|
|
;;
|
|
|
|
(--prefix=*)
|
|
|
|
prefix=${1#--prefix=}
|
|
|
|
;;
|
|
|
|
(--program-prefix=*)
|
|
|
|
program_prefix=${1#--program-prefix=}
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2018-11-06 19:29:35 +00:00
|
|
|
|
2019-10-01 17:12:56 +00:00
|
|
|
prefix=${prefix-/usr/local}
|
|
|
|
mes_libc=${mes_libc-mes}
|
|
|
|
courageous=${courageous-false}
|
|
|
|
host=${host-$build}
|
2018-11-06 19:29:35 +00:00
|
|
|
|
|
|
|
AR=${AR-$(command -v ar)} || true
|
2018-07-21 22:43:39 +00:00
|
|
|
BASH=${BASH-$(command -v bash)}
|
2018-11-06 19:29:35 +00:00
|
|
|
BLOOD_ELF=${BLOOD_ELF-$(command -v blood-elf)}
|
|
|
|
CC=${CC-$(command -v gcc)} || true
|
2019-06-08 13:36:22 +00:00
|
|
|
DIFF=${DIFF-$(command -v diff || echo $PWD/pre-inst-env diff.scm)}
|
2018-11-06 19:29:35 +00:00
|
|
|
GUILD=${GUILD-$(command -v guild)} || true
|
|
|
|
GUILE_TOOLS=${GUILE_TOOLS-$(command -v guile-tools)} || true
|
2019-06-08 13:36:22 +00:00
|
|
|
if test ! "$GUILD"; then
|
|
|
|
if test "$GUILE_TOOLS"; then
|
2018-11-06 19:29:35 +00:00
|
|
|
GUILD=$GUILE_TOOLS
|
|
|
|
else
|
|
|
|
GUILD=true
|
|
|
|
fi
|
|
|
|
fi
|
2018-07-21 22:43:39 +00:00
|
|
|
GUILE=${GUILE-$(command -v guile)} || true
|
2018-11-06 19:29:35 +00:00
|
|
|
HEX2=${HEX2-$(command -v hex2)}
|
|
|
|
M1=${M1-$(command -v M1)}
|
|
|
|
MES_FOR_BUILD=${MES_FOR_BUILD-$(command -v mes || command -v guile || echo mes)}
|
2018-11-24 20:07:31 +00:00
|
|
|
GIT=${GIT-$(command -v git)} || true
|
2018-11-06 19:29:35 +00:00
|
|
|
PERL=${PERL-$(command -v perl)} || true
|
2019-06-25 19:40:43 +00:00
|
|
|
SHELL=${BASH-$SHELL}
|
|
|
|
|
2018-11-06 19:29:35 +00:00
|
|
|
MES_SEED=${MES_SEED-../mes-seed}
|
2018-07-21 22:43:39 +00:00
|
|
|
|
2019-06-08 13:36:22 +00:00
|
|
|
if test "$srcdir" = .; then
|
2018-07-25 06:14:13 +00:00
|
|
|
top_builddir=.
|
|
|
|
else
|
|
|
|
srcdest=${srcdest}
|
|
|
|
top_builddir=$PWD
|
|
|
|
fi
|
|
|
|
abs_top_srcdir=${abs_top_srcdir-$(cd ${srcdir} && pwd)}
|
|
|
|
abs_top_builddir=$PWD
|
2018-07-21 22:43:39 +00:00
|
|
|
|
2019-06-08 13:36:22 +00:00
|
|
|
if test -z "$GUILE" -o "$GUILE" = true; then
|
2018-07-21 22:43:39 +00:00
|
|
|
GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-2.2}
|
|
|
|
else
|
|
|
|
GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-$(guile -c '(display (effective-version))')}
|
|
|
|
fi
|
2018-11-06 19:29:35 +00:00
|
|
|
bindir=$(eval echo ${bindir-$prefix/bin})
|
2018-08-09 09:00:10 +00:00
|
|
|
datadir=$(eval echo ${datadir-$prefix/share})
|
|
|
|
docdir=$(eval echo ${docdir-$datadir/doc/mes-$VERSION})
|
|
|
|
infodir=$(eval echo ${infodir-$datadir/info})
|
2019-11-13 08:23:27 +00:00
|
|
|
includedir=$(eval echo ${includedir-$prefix/include})
|
2018-11-06 19:29:35 +00:00
|
|
|
libdir=$(eval echo ${libdir-$prefix/lib})
|
2019-07-07 10:17:03 +00:00
|
|
|
pkgdatadir=$(eval echo ${pkgdatadir-$datadir/mes})
|
2018-08-09 09:00:10 +00:00
|
|
|
mandir=$(eval echo ${mandir-$datadir/man})
|
|
|
|
guile_site_dir=$(eval echo ${guile_site_dir-$prefix/share/guile/site/$GUILE_EFFECTIVE_VERSION})
|
|
|
|
guile_site_ccache_dir=$(eval echo ${guile_site_ccache_dir-$prefix/lib/guile/$GUILE_EFFECTIVE_VERSION/site-ccache})
|
2018-07-21 22:43:39 +00:00
|
|
|
|
2018-07-25 06:14:13 +00:00
|
|
|
subst () {
|
2019-07-07 10:17:03 +00:00
|
|
|
echo "creating $2"
|
2018-07-25 06:14:13 +00:00
|
|
|
sed \
|
2018-11-06 19:29:35 +00:00
|
|
|
-e s,"@PACKAGE@,$PACKAGE,"\
|
2019-06-08 13:36:22 +00:00
|
|
|
-e s,"@PACKAGE_NAME@,$PACKAGE_NAME,"\
|
|
|
|
-e s,"@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,"\
|
2018-11-06 19:29:35 +00:00
|
|
|
-e s,"@VERSION@,$VERSION,"\
|
2019-10-15 18:18:31 +00:00
|
|
|
-e s,"@bootstrap@,yes,"\
|
2018-11-06 19:29:35 +00:00
|
|
|
-e s,"@build@,$build,"\
|
|
|
|
-e s,"@host@,$host,"\
|
|
|
|
-e s,"@compiler@,$compiler,"\
|
2019-06-08 13:36:22 +00:00
|
|
|
-e s,"@courageous@,$courageous,"\
|
|
|
|
-e s,"@mes_bits@,$mes_bits,"\
|
|
|
|
-e s,"@mes_kernel@,$mes_kernel,"\
|
|
|
|
-e s,"@mes_cpu@,$mes_cpu,"\
|
|
|
|
-e s,"@mes_libc@,$mes_libc,"\
|
|
|
|
-e s,"@mes_system@,$mes_system,"\
|
2018-07-21 22:43:39 +00:00
|
|
|
-e s,"@abs_top_srcdir@,$abs_top_srcdir,"\
|
|
|
|
-e s,"@abs_top_builddir@,$abs_top_builddir,"\
|
|
|
|
-e s,"@top_builddir@,$top_builddir,"\
|
2018-11-06 19:29:35 +00:00
|
|
|
-e s,"@srcdest@,$srcdest,"\
|
|
|
|
-e s,"@srcdir@,$srcdir,"\
|
2018-08-09 06:58:20 +00:00
|
|
|
-e s,"@prefix@,$prefix,"\
|
2018-11-06 19:29:35 +00:00
|
|
|
-e s,"@program_prefix@,$program_prefix,"\
|
|
|
|
-e s,"@bindir@,$bindir,"\
|
|
|
|
-e s,"@datadir@,$datadir,"\
|
|
|
|
-e s,"@docdir@,$docdir,"\
|
2018-07-21 22:43:39 +00:00
|
|
|
-e s,"@guile_site_dir@,$guile_site_dir,"\
|
|
|
|
-e s,"@guile_site_ccache_dir@,$guile_site_ccache_dir,"\
|
2018-11-06 19:29:35 +00:00
|
|
|
-e s,"@infodir@,$infodir,"\
|
2019-06-08 13:36:22 +00:00
|
|
|
-e s,"@includedir@,$includedir,"\
|
2018-11-06 19:29:35 +00:00
|
|
|
-e s,"@libdir@,$libdir,"\
|
|
|
|
-e s,"@mandir@,$mandir,"\
|
2019-07-07 10:17:03 +00:00
|
|
|
-e s,"@pkgdatadir@,$pkgdatadir,"\
|
2018-11-06 19:29:35 +00:00
|
|
|
-e s,"@sysconfdir@,$sysconfdir,"\
|
|
|
|
-e s,"@GUILE_EFFECTIVE_VERSION@,$GUILE_EFFECTIVE_VERSION,"\
|
|
|
|
-e s,"@V@,$V,"\
|
|
|
|
-e s,"@AR@,$AR,"\
|
|
|
|
-e s,"@BASH@,$BASH,"\
|
|
|
|
-e s,"@BLOOD_ELF@,$BLOOD_ELF,"\
|
|
|
|
-e s,"@CC@,$CC,"\
|
2019-06-08 13:36:22 +00:00
|
|
|
-e s,"@DIFF@,$DIFF,"\
|
2018-11-24 20:07:31 +00:00
|
|
|
-e s,"@GIT@,$GIT,"\
|
2018-11-06 19:29:35 +00:00
|
|
|
-e s,"@GUILD@,$GUILD,"\
|
|
|
|
-e s,"@GUILE@,$GUILE,"\
|
|
|
|
-e s,"@PERL@,$PERL,"\
|
|
|
|
-e s,"@CFLAGS@,$CFLAGS,"\
|
|
|
|
-e s,"@HEX2@,$HEX2,"\
|
|
|
|
-e s,"@HEX2FLAGS@,$HEX2FLAGS,"\
|
|
|
|
-e s,"@M1@,$M1,"\
|
|
|
|
-e s,"@M1FLAGS@,$M1FLAGS,"\
|
|
|
|
-e s,"@MES_FOR_BUILD@,$MES_FOR_BUILD,"\
|
|
|
|
-e s,"@MES_SEED@,$MES_SEED,"\
|
2018-11-24 20:07:31 +00:00
|
|
|
-e s,"@MES_SEED@,$MES_SEED,"\
|
|
|
|
-e s,"@SHELL@,$SHELL,"\
|
2018-07-25 06:14:13 +00:00
|
|
|
$1 > $2
|
|
|
|
}
|
2018-07-21 22:43:39 +00:00
|
|
|
|
2019-06-08 13:36:22 +00:00
|
|
|
host=${host-$($CC -dumpmachine 2>/dev/null)}
|
|
|
|
if test -z "$host$host_type"; then
|
|
|
|
mes_cpu=${arch-$(get_machine || uname -m)}
|
2018-11-06 19:29:35 +00:00
|
|
|
else
|
2019-06-08 13:36:22 +00:00
|
|
|
mes_cpu=${host%%-*}
|
2018-11-06 19:29:35 +00:00
|
|
|
fi
|
2019-06-08 13:36:22 +00:00
|
|
|
if test "$mes_cpu" = i386\
|
|
|
|
|| test "$mes_cpu" = i486\
|
|
|
|
|| test "$mes_cpu" = i586\
|
|
|
|
|| test "$mes_cpu" = i686; then
|
|
|
|
mes_cpu=x86
|
2018-11-06 19:29:35 +00:00
|
|
|
fi
|
2019-05-22 15:55:20 +00:00
|
|
|
if test "$mes_cpu" = armv4\
|
|
|
|
|| test "$arch" = armv7l; then
|
|
|
|
mes_cpu=arm
|
|
|
|
fi
|
2019-07-07 10:17:03 +00:00
|
|
|
if test "$mes_cpu" = amd64; then
|
|
|
|
mes_cpu=x86_64
|
|
|
|
fi
|
2018-11-06 19:29:35 +00:00
|
|
|
|
2019-06-08 13:36:22 +00:00
|
|
|
case "$host" in
|
|
|
|
*linux-gnu|*linux)
|
|
|
|
mes_kernel=linux;;
|
|
|
|
*gnu)
|
|
|
|
mes_kernel=gnu;;
|
|
|
|
*)
|
|
|
|
mes_kernel=linux;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case "$mes_cpu" in
|
|
|
|
x86_64)
|
|
|
|
mes_bits=64;;
|
|
|
|
*)
|
|
|
|
mes_bits=32;;
|
|
|
|
esac
|
2018-11-06 19:29:35 +00:00
|
|
|
#
|
2018-11-24 20:07:31 +00:00
|
|
|
if $CC --version | grep gcc; then #2>/dev/null; then
|
2018-11-06 19:29:35 +00:00
|
|
|
compiler=gcc
|
2018-11-24 20:07:31 +00:00
|
|
|
elif $CC --version | grep tcc; then #2>/dev/null; then
|
2019-06-08 13:36:22 +00:00
|
|
|
compiler=gcc
|
2018-11-06 19:29:35 +00:00
|
|
|
else
|
|
|
|
compiler=mescc
|
|
|
|
fi
|
|
|
|
|
2019-06-08 13:36:22 +00:00
|
|
|
mes_system=$mes_cpu-$mes_kernel-mes
|
2018-11-06 19:29:35 +00:00
|
|
|
|
2018-07-25 06:14:13 +00:00
|
|
|
subst ${srcdest}build-aux/GNUmakefile.in GNUmakefile
|
2019-06-08 13:36:22 +00:00
|
|
|
subst ${srcdest}build-aux/config.sh.in config.sh
|
2019-07-07 10:17:03 +00:00
|
|
|
subst ${srcdest}build-aux/bootstrap.sh.in bootstrap.sh
|
|
|
|
chmod +x bootstrap.sh
|
2018-07-25 06:14:13 +00:00
|
|
|
subst ${srcdest}build-aux/build.sh.in build.sh
|
2018-11-06 19:29:35 +00:00
|
|
|
chmod +x build.sh
|
2018-07-25 06:14:13 +00:00
|
|
|
subst ${srcdest}build-aux/check.sh.in check.sh
|
2018-11-06 19:29:35 +00:00
|
|
|
chmod +x check.sh
|
2018-07-25 06:14:13 +00:00
|
|
|
subst ${srcdest}build-aux/install.sh.in install.sh
|
2018-11-06 19:29:35 +00:00
|
|
|
chmod +x install.sh
|
2019-06-08 13:36:22 +00:00
|
|
|
subst ${srcdest}build-aux/pre-inst-env.in pre-inst-env
|
|
|
|
chmod +x pre-inst-env
|
2019-07-21 14:44:54 +00:00
|
|
|
subst ${srcdest}scripts/mesar.in scripts/mesar
|
|
|
|
chmod +x scripts/mesar
|
2019-06-08 13:36:22 +00:00
|
|
|
subst ${srcdest}scripts/mescc.scm.in scripts/mescc.scm
|
|
|
|
chmod +x scripts/mescc.scm
|
|
|
|
subst ${srcdest}scripts/mescc.in scripts/mescc
|
|
|
|
chmod +x scripts/mescc
|
2018-07-25 06:14:13 +00:00
|
|
|
subst ${srcdest}build-aux/uninstall.sh.in uninstall.sh
|
2018-11-06 19:29:35 +00:00
|
|
|
chmod +x uninstall.sh
|
2018-07-21 22:43:39 +00:00
|
|
|
|
2019-06-08 13:36:22 +00:00
|
|
|
mkdir -p include/mes
|
2019-07-07 10:17:03 +00:00
|
|
|
rm -f include/mes/config.h
|
2019-06-08 13:36:22 +00:00
|
|
|
if test $mes_libc = system; then
|
|
|
|
cat >> include/mes/config.h <<EOF
|
|
|
|
#define SYSTEM_LIBC 1
|
|
|
|
EOF
|
|
|
|
else
|
|
|
|
cat >> include/mes/config.h <<EOF
|
|
|
|
#undef SYSTEM_LIBC
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
cat >> include/mes/config.h <<EOF
|
2019-07-26 16:20:32 +00:00
|
|
|
#define MES_VERSION "$VERSION"
|
|
|
|
#define MES_PKGDATADIR "$pkgdatadir"
|
2019-06-08 13:36:22 +00:00
|
|
|
EOF
|
|
|
|
|
2018-07-21 22:43:39 +00:00
|
|
|
cat <<EOF
|
2019-06-08 13:36:22 +00:00
|
|
|
GNU Mes is configured for
|
|
|
|
compiler: $compiler
|
|
|
|
cpu: $mes_cpu
|
|
|
|
bits: $mes_bits
|
|
|
|
libc: $mes_libc
|
|
|
|
kernel: $mes_kernel
|
|
|
|
system: $mes_system
|
2018-11-06 19:29:35 +00:00
|
|
|
|
2018-07-21 22:43:39 +00:00
|
|
|
Run:
|
2018-07-25 06:14:13 +00:00
|
|
|
./build.sh to build mes
|
|
|
|
./check.sh to check mes
|
|
|
|
./install.sh to install mes
|
2018-07-21 22:43:39 +00:00
|
|
|
EOF
|