build: Support Debian build, install.
* scripts/mescc: Support Debian build, install. * lib/libmes.c (fdgetc): Allow Nyacc/ungetc conflict. * build-aux/export.make (ARCH): Export. * build-aux/build-mes.sh: Disable full build for non-bootstrap x86-only. * check.sh (total): Use bash to invoke build-aux/check-mescc.sh. * build-aux/build-guile.sh (SCM_FILES): Support guile-2.0. * module/mes/guile.scm (guile-2.0): Support guile-2.0. * build-aux/build-mes.sh: Use bash. * build-aux/setup-mes.sh: New file.
This commit is contained in:
parent
a25653e7f1
commit
69813a6da3
|
@ -47,13 +47,17 @@ guile/mescc/preprocess.scm
|
|||
export srcdir=.
|
||||
export host=$($GUILE -c "(display %host-type)")
|
||||
|
||||
if [ "$GUILE_EFFECTIVE_VERSION" = "2.0" ]; then
|
||||
abs=$PWD/
|
||||
fi
|
||||
|
||||
#$GUILE --no-auto-compile -L guile -C guile -s build-aux/compile-all.scm $SCM_FILES
|
||||
|
||||
for i in $SCM_FILES; do
|
||||
go=${i%%.scm}.go
|
||||
if [ $i -nt $go ]; then
|
||||
echo " GUILEC $i"
|
||||
$GUILE_TOOLS compile -L guile -L scripts -o $go $i
|
||||
$GUILE_TOOLS compile -L ${abs}guile -L ${abs}scripts -o $go $i
|
||||
fi
|
||||
done
|
||||
|
||||
|
@ -65,6 +69,6 @@ for i in $SCRIPTS; do
|
|||
go=${i%%.scm}.go
|
||||
if [ $i -nt $go ]; then
|
||||
echo " GUILEC $i"
|
||||
$GUILE_TOOLS compile -L guile -L scripts -o $go $i
|
||||
$GUILE_TOOLS compile -L ${abs}guile -L ${abs}scripts -o $go $i
|
||||
fi
|
||||
done
|
||||
|
|
|
@ -97,34 +97,44 @@ if [ -d "$MES_SEED" ]; then
|
|||
fi
|
||||
|
||||
PREPROCESS=1
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/crt0
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/crt1
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/crti
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/crtn
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/libc-mini
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/libc
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/libgetopt
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/libc+tcc
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/libc+gnu
|
||||
if [ ! -d "$MES_SEED" ] \
|
||||
&& [ "$ARCH" = "i386" \
|
||||
-o "$ARCH" = "i586" \
|
||||
-o "$ARCH" = "i686" ]; then
|
||||
MES_ARENA=100000000
|
||||
fi
|
||||
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/crt0
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/crt1
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/crt1
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/crti
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/crtn
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/libc-mini
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/libc
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/libgetopt
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/libc+tcc
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/libc+gnu
|
||||
|
||||
[ -n "$SEED" ] && exit 0
|
||||
|
||||
MES_ARENA=${MES_ARENA-10000000}
|
||||
sh build-aux/mes-snarf.scm --mes src/gc.c
|
||||
sh build-aux/mes-snarf.scm --mes src/lib.c
|
||||
sh build-aux/mes-snarf.scm --mes src/math.c
|
||||
sh build-aux/mes-snarf.scm --mes src/mes.c
|
||||
sh build-aux/mes-snarf.scm --mes src/posix.c
|
||||
sh build-aux/mes-snarf.scm --mes src/reader.c
|
||||
sh build-aux/mes-snarf.scm --mes src/vector.c
|
||||
MES_ARENA=${MES_ARENA-100000000}
|
||||
bash build-aux/mes-snarf.scm --mes src/gc.c
|
||||
bash build-aux/mes-snarf.scm --mes src/lib.c
|
||||
bash build-aux/mes-snarf.scm --mes src/math.c
|
||||
bash build-aux/mes-snarf.scm --mes src/mes.c
|
||||
bash build-aux/mes-snarf.scm --mes src/posix.c
|
||||
bash build-aux/mes-snarf.scm --mes src/reader.c
|
||||
bash build-aux/mes-snarf.scm --mes src/vector.c
|
||||
|
||||
sh build-aux/cc-mes.sh scaffold/main
|
||||
sh build-aux/cc-mes.sh scaffold/hello
|
||||
sh build-aux/cc-mes.sh scaffold/argv
|
||||
sh build-aux/cc-mes.sh scaffold/malloc
|
||||
echo MES_ARENA=$MES_ARENA
|
||||
bash build-aux/cc-mes.sh scaffold/main
|
||||
|
||||
bash build-aux/cc-mes.sh scaffold/main
|
||||
bash build-aux/cc-mes.sh scaffold/hello
|
||||
bash build-aux/cc-mes.sh scaffold/argv
|
||||
bash build-aux/cc-mes.sh scaffold/malloc
|
||||
##sh build-aux/cc-mes.sh scaffold/micro-mes
|
||||
##sh build-aux/cc-mes.sh scaffold/tiny-mes
|
||||
# sh build-aux/cc-mes.sh scaffold/mini-mes
|
||||
|
||||
sh build-aux/cc-mes.sh src/mes
|
||||
# bash build-aux/cc-mes.sh scaffold/mini-mes
|
||||
bash build-aux/cc-mes.sh src/mes
|
||||
cp src/mes.mes-out src/mes
|
||||
|
|
|
@ -63,20 +63,20 @@ else
|
|||
fi
|
||||
|
||||
if [ -n "$PREPROCESS" ]; then
|
||||
sh $MESCC $MESCCFLAGS $CPPFLAGS -E -o "$o.E" "$c".c
|
||||
sh $MESCC $MESCCFLAGS -S "$o".E
|
||||
sh $MESCC $MESCCFLAGS -c -o "$o".${p}o "$o".S
|
||||
bash $MESCC $MESCCFLAGS $CPPFLAGS -E -o "$o.E" "$c".c
|
||||
bash $MESCC $MESCCFLAGS -S "$o".E
|
||||
bash $MESCC $MESCCFLAGS -c -o "$o".${p}o "$o".S
|
||||
if [ -z "$NOLINK" ]; then
|
||||
sh $MESCC $MESCCFLAGS -o "$o".${p}out "$o".${p}o $MESCCLIBS
|
||||
bash $MESCC $MESCCFLAGS -o "$o".${p}out "$o".${p}o $MESCCLIBS
|
||||
fi
|
||||
elif [ -n "$COMPILE" ]; then
|
||||
sh $MESCC $MESCCFLAGS $CPPFLAGS -S -o "$o.S" "$c".c
|
||||
sh $MESCC $MESCCFLAGS -c -o "$o".${p}o "$o".S
|
||||
bash $MESCC $MESCCFLAGS $CPPFLAGS -S -o "$o.S" "$c".c
|
||||
bash $MESCC $MESCCFLAGS -c -o "$o".${p}o "$o".S
|
||||
if [ -z "$NOLINK" ]; then
|
||||
sh $MESCC $MESCCFLAGS -o "$o".${p}out "$o".${p}o $MESCCLIBS
|
||||
bash $MESCC $MESCCFLAGS -o "$o".${p}out "$o".${p}o $MESCCLIBS
|
||||
fi
|
||||
elif [ -z "$NOLINK" ]; then
|
||||
sh $MESCC $MESCCFLAGS $CPPFLAGS -o "$o".${p}out "$c".c $MESCCLIBS
|
||||
bash $MESCC $MESCCFLAGS $CPPFLAGS -o "$o".${p}out "$c".c $MESCCLIBS
|
||||
else
|
||||
sh $MESCC $MESCCFLAGS $CPPFLAGS -c -o "$o".${p}out "$c".c
|
||||
bash $MESCC $MESCCFLAGS $CPPFLAGS -c -o "$o".${p}o "$c".c
|
||||
fi
|
||||
|
|
|
@ -10,6 +10,10 @@ ifdef VERSION
|
|||
export VERSION
|
||||
endif
|
||||
|
||||
ifdef ARCH
|
||||
export ARCH
|
||||
endif
|
||||
|
||||
ifdef CC
|
||||
export CC
|
||||
endif
|
||||
|
|
62
build-aux/setup-mes.sh
Normal file
62
build-aux/setup-mes.sh
Normal file
|
@ -0,0 +1,62 @@
|
|||
#! /bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
if [ -n "$BUILD_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
mkdir -p src
|
||||
cd src
|
||||
|
||||
GUILE_EFFECTIVE_VERSION=2.2
|
||||
GUILE_SITE_DIR=/usr/local/share/guile/site/$GUILE_EFFECTIVE_VERSION
|
||||
GUILE_SITE_CCACHE_DIR=/usr/local/lib/guile/$GUILE_EFFECTIVE_VERSION/site-ccache
|
||||
GUILE_LOAD_PATH=$GUILE_SITE_DIR
|
||||
GUILE_LOAD_COMPILED_PATH=$GUILE_SITE_CCACHE_DIR
|
||||
export GUILE_LOAD_PATH
|
||||
export GUILE_LOAD_COMPILED_PATH
|
||||
|
||||
sudo apt-get install --no-install-recommends build-essential ca-certificates gcc-i686-linux-gnu guile-$GUILE_EFFECTIVE_VERSION-dev help2man texinfo
|
||||
echo checking for M1
|
||||
if ! command -v M1; then
|
||||
if sudo apt-get install mescc-tools; then
|
||||
echo yay
|
||||
else
|
||||
wget -O mescc-tools-Release_0.5.1.tar.gz https://github.com/oriansj/mescc-tools/archive/Release_0.5.1.tar.gz
|
||||
tar xf mescc-tools-Release_0.5.1.tar.gz
|
||||
cd mescc-tools-Release_0.5.1
|
||||
make
|
||||
make check
|
||||
sudo make install
|
||||
cd ..
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking for Nyacc
|
||||
if ! guile -c '(use-modules (nyacc lalr)) (display *nyacc-version*) (newline)'; then
|
||||
if sudo apt-get install --no-install-recommends nyacc; then
|
||||
echo yay
|
||||
else
|
||||
wget -O nyacc-v0.80.43.tar.gz https://gitlab.com/janneke/nyacc/-/archive/v0.80.43/nyacc-v0.80.43.tar.gz
|
||||
tar xf nyacc-v0.80.43.tar.gz
|
||||
cd nyacc-v0.80.43
|
||||
./configure --prefix=/usr/local
|
||||
make
|
||||
make check
|
||||
sudo make install
|
||||
cd ..
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking for mes
|
||||
if ! command -v mes; then
|
||||
sudo apt-get install --no-install-recommends git
|
||||
git clone http://gitlab.com/janneke/mes
|
||||
cd mes
|
||||
git checkout wip-gnu
|
||||
./configure
|
||||
make
|
||||
make check
|
||||
make install
|
||||
fi
|
4
check.sh
4
check.sh
|
@ -18,10 +18,12 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
export BASH
|
||||
export CC32
|
||||
export GUILE MES MES_ARENA
|
||||
export BUILD_DEBUG
|
||||
|
||||
BASH=${BASH-bash}
|
||||
CC32=${CC32-$(command -v i686-unknown-linux-gnu-gcc)}
|
||||
GUILE=${GUILE-guile}
|
||||
MES=${MES-src/mes}
|
||||
|
@ -95,4 +97,4 @@ else
|
|||
echo PASS: $total
|
||||
fi
|
||||
|
||||
sh build-aux/check-mescc.sh
|
||||
$BASH build-aux/check-mescc.sh
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
#! /bin/sh
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
if [ -n "$BUILD_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
# use bash or lose if pipes fail
|
||||
[ -n "$BASH" ] && set -o pipefail
|
||||
|
||||
SHELL=${SHELL-$(command -v sh)}
|
||||
PREFIX=${PREFIX-/usr/local}
|
||||
MES_PREFIX=${MES_PREFIX-$PREFIX/share/mes}
|
||||
|
|
15
lib/libmes.c
15
lib/libmes.c
|
@ -148,12 +148,23 @@ fdgetc (int fd)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (_ungetc_fd != fd)
|
||||
i = _ungetc_buf[_ungetc_pos];
|
||||
if (_ungetc_fd != fd && i == 10)
|
||||
{
|
||||
// FIXME: Nyacc's ungetc exposes harmless libmec.c bug
|
||||
// we need one unget position per FD
|
||||
_ungetc_pos = -1;
|
||||
_ungetc_fd = -1;
|
||||
return fdgetc (fd);
|
||||
}
|
||||
else if (_ungetc_fd != fd)
|
||||
{
|
||||
eputs (" ***MES LIB C*** fdgetc ungetc conflict unget-fd=");
|
||||
eputs (itoa (_ungetc_fd));
|
||||
eputs (", fdgetc-fd=");
|
||||
eputs (itoa (fd));
|
||||
eputs (", c=");
|
||||
eputs (itoa ( _ungetc_buf[_ungetc_pos]));
|
||||
eputs ("\n");
|
||||
exit (1);
|
||||
}
|
||||
|
@ -186,6 +197,8 @@ fdputs (char const* s, int fd)
|
|||
int
|
||||
fdungetc (int c, int fd)
|
||||
{
|
||||
if (c == -1)
|
||||
return c;
|
||||
if (_ungetc_pos == -1)
|
||||
_ungetc_fd = fd;
|
||||
else if (_ungetc_fd != fd)
|
||||
|
|
|
@ -89,22 +89,7 @@
|
|||
|
||||
(cond-expand
|
||||
(guile-2.2)
|
||||
(guile-2
|
||||
(eval-when (compile load eval)
|
||||
(define-syntax include-from-path
|
||||
(lambda (x)
|
||||
(syntax-case x ()
|
||||
((k filename)
|
||||
(let ((fn (syntax->datum #'filename)))
|
||||
(with-syntax ((fn (datum->syntax
|
||||
#'filename
|
||||
(canonicalize-path
|
||||
(or (%search-load-path fn)
|
||||
(syntax-violation 'include-from-path
|
||||
"file not found in path"
|
||||
x #'filename))))))
|
||||
#'(include fn))))))))
|
||||
(export include-from-path))
|
||||
(guile-2)
|
||||
(guile
|
||||
(use-modules (ice-9 syncase))
|
||||
(define (compose proc . rest)
|
||||
|
|
|
@ -228,10 +228,10 @@
|
|||
(if (string-null? prefix) o (string-append prefix "/" o)))
|
||||
(prefix-file file-name)))
|
||||
|
||||
(define (assert-system* . commands)
|
||||
(let ((status (apply system* commands)))
|
||||
(define (assert-system* . args)
|
||||
(let ((status (apply system* args)))
|
||||
(when (not (zero? status))
|
||||
(stderr "mescc: failed: ~a\n" (string-join command))
|
||||
(stderr "mescc: failed: ~a\n" (string-join args))
|
||||
(exit status))
|
||||
status))
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ if [ -n "$BUILD_DEBUG" ]; then
|
|||
set -x
|
||||
fi
|
||||
PREFIX=${PREFIX-@PREFIX@}
|
||||
if [ "$PREFIX" = @PREFIX""@ -o ! -d "$PREFIX" ]
|
||||
if [ "@PREFIX@" = @PREFIX""@ -o ! -d "$PREFIX/share/mes/module" ]
|
||||
then
|
||||
MES_PREFIX=${MES_PREFIX-$(cd $(dirname $0)/.. && pwd)}
|
||||
else
|
||||
|
@ -22,8 +22,6 @@ if [ '(' -z "$mes_p" -a -z "$MES" ')' -o "$MES" = "guile" -o "$MES" = "mes.guile
|
|||
exec ${GUILE-guile} -L $GUILEDIR -e '(mescc)' -s "$0" "$@"
|
||||
else
|
||||
MES=${MES-$(dirname $0)/mes}
|
||||
MES_MODULEDIR=${MES_MODULEDIR-$MES_PREFIX/"module"}
|
||||
export MES_MODULEDIR
|
||||
exec ${MES-mes} -e '(mescc)' -s $0 "$@"
|
||||
fi
|
||||
!#
|
||||
|
|
Loading…
Reference in a new issue