diff --git a/.gitignore b/.gitignore
index 28753c14..29fc9994 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,13 +14,17 @@
*.hex2
*.hex2-o
*.log
-*.stderr
-*.stdout
+*.mes-o
+*.mes-stdout
*.mini-M1
*.mini-guile
*.mini-hex2
*.mlibc-gcc
*.mlibc-o
+*.mlibc-out
+*.mlibc-stdout
+*.stderr
+*.stdout
*.tcc-guile
!/stage0/*
!/stage0/*.c
diff --git a/GNUmakefile b/GNUmakefile
index 9025f243..d1b1c3d4 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -3,9 +3,6 @@ GUILE_FLAGS:=--no-auto-compile -L . -L guile -C . -C guile
include .config.make
-export PREFIX
-export VERSION
-
PHONY_TARGETS:= all all-go check clean clean-go default help install
.PHONY: $(PHONY_TARGETS)
@@ -37,3 +34,61 @@ seed:
MES=guile GUILE=guile SEED=1 build-aux/build-mes.sh
cd ../mes-seed && ./bootstrap.sh && cd ../mes
MES=guile GUILE=guile SEED=1 build-aux/build-mes.sh
+
+ifdef PREFIX
+export PREFIX
+endif
+
+ifdef VERSION
+export VERSION
+endif
+
+ifdef CC
+export CC
+endif
+
+ifdef CC32
+export CC32
+endif
+
+ifdef M1
+export M1
+endif
+
+ifdef HEX2
+export HEX2
+endif
+
+ifdef GUILE
+export GUILE
+endif
+
+ifdef GUILE_LOAD_PATH
+export GUILE_LOAD_PATH
+endif
+
+ifdef GUILE_LOAD_COMPILED_PATH
+export GUILE_LOAD_COMPILED_PATH
+endif
+
+ifdef CFLAGS
+export CFLAGS
+endif
+
+ifdef C32FLAGS
+export C32FLAGS
+endif
+
+ifdef HEX2FLAGS
+export HEX2FLAGS
+endif
+
+ifdef M1FLAGS
+export M1FLAGS
+endif
+
+ifdef MESCCFLAGS
+export MESCCFLAGS
+endif
+
+
diff --git a/build-aux/build-cc.sh b/build-aux/build-cc.sh
index 05796972..930c97bd 100755
--- a/build-aux/build-cc.sh
+++ b/build-aux/build-cc.sh
@@ -20,7 +20,23 @@
set -ex
-export CC=${CC-gcc}
+export CC CFLAGS CPPFLAGS
+
+CC=${CC-gcc}
+CFLAGS=${CFLAGS-"
+--std=gnu99
+-O0
+-g
+"}
+
+CPPFLAGS=${CPPFLAGS-"
+-D VERSION=\"$VERSION\"
+-D MODULEDIR=\"$MODULEDIR\"
+-D PREFIX=\"$PREFIX\"
+-I src
+-I lib
+-I include
+"}
build-aux/mes-snarf.scm src/gc.c
build-aux/mes-snarf.scm src/lib.c
@@ -30,21 +46,6 @@ build-aux/mes-snarf.scm src/posix.c
build-aux/mes-snarf.scm src/reader.c
build-aux/mes-snarf.scm src/vector.c
-export CPPFLAGS=${CPPFLAGS-"
--D VERSION=\"$VERSION\"
--D MODULEDIR=\"$MODULEDIR\"
--D PREFIX=\"$PREFIX\"
--I src
--I lib
--I include
-"}
-
-export CFLAGS=${CFLAGS-"
---std=gnu99
--O0
--g
-"}
-
NOLINK=1 sh build-aux/cc.sh lib/libc-gcc
#NOLINK=1 sh build-aux/cc.sh lib/libc+tcc-gcc
diff --git a/build-aux/build-guile.sh b/build-aux/build-guile.sh
index 26ef74ed..73640807 100755
--- a/build-aux/build-guile.sh
+++ b/build-aux/build-guile.sh
@@ -20,7 +20,8 @@
set -ex
-export GUILE=${GUILE-$(type -p guile)}
+export GUILE
+GUILE=${GUILE-$(command -v guile)}
SCM_FILES="
language/c99/compiler.scm
diff --git a/build-aux/build-mes.sh b/build-aux/build-mes.sh
index ee7c5f7c..36524bdd 100755
--- a/build-aux/build-mes.sh
+++ b/build-aux/build-mes.sh
@@ -18,27 +18,47 @@
# You should have received a copy of the GNU General Public License
# along with Mes. If not, see .
-set -ex
+set -x
-export HEX2=${HEX2-hex2}
-export M1=${M1-M1}
-export BLOOD_ELF=${BLOOD_ELF-blood-elf}
-export MES_SEED=${MES_SEED-../mes-seed}
-export MESCC=${MESCC-$(type -p mescc)}
+export BLOOD_ELF GUILE HEX2 M1 MES MESCC
+export M1FLAGS HEX2FLAGS PREPROCESS
+export MES_SEED MES_ARENA
+
+HEX2=${HEX2-hex2}
+M1=${M1-M1}
+BLOOD_ELF=${BLOOD_ELF-blood-elf}
+MES_SEED=${MES_SEED-../mes-seed}
+MESCC=${MESCC-$(command -v mescc)}
[ -z "$MESCC" ] && MESCC=scripts/mescc
-export MES=${MES-$(type -p mes)}
+MES=${MES-$(command -v mes)}
[ -z "$MES" ] && MES=src/mes
+set -e
+
+M1FLAGS=${M1FLAGS-"
+--LittleEndian
+--Architecture=1
+"}
+HEX2FLAGS=${HEX2FLAGS-"
+--LittleEndian
+--Architecture=1
+--BaseAddress=0x1000000
+"}
+
if [ -d "$MES_SEED" ]; then
- $M1 --LittleEndian --Architecture=1\
+ $M1\
+ $M1FLAGS\
-f stage0/x86.M1\
-f $MES_SEED/crt1.M1\
-o lib/crt1.hex2
- $M1 --LittleEndian --Architecture=1\
+ $M1\
+ $M1FLAGS\
-f stage0/x86.M1\
-f $MES_SEED/libc-mes.M1\
-o lib/libc-mes.hex2
- $M1 --LittleEndian --Architecture=1\
+ $M1\
+ --LittleEndian\
+ --Architecture=1\
-f stage0/x86.M1\
-f $MES_SEED/mes.M1\
-o src/mes.hex2
@@ -47,29 +67,33 @@ if [ -d "$MES_SEED" ]; then
-f $MES_SEED/mes.M1\
-f $MES_SEED/libc-mes.M1\
-o src/mes.blood-elf.M1
- $M1 --LittleEndian --Architecture=1\
+ $M1\
+ --LittleEndian\
+ --Architecture=1\
-f src/mes.blood-elf.M1\
-o src/mes.blood-elf.hex2
- $HEX2 --LittleEndian --Architecture=1 --BaseAddress=0x1000000\
- -f stage0/elf32-header.hex2\
- -f lib/crt1.hex2\
- -f lib/libc-mes.hex2\
- -f src/mes.hex2\
- -f src/mes.blood-elf.hex2\
- --exec_enable\
- -o src/mes.seed-out
+ $HEX2\
+ $HEX2FLAGS\
+ -f stage0/elf32-header.hex2\
+ -f lib/crt1.hex2\
+ -f lib/libc-mes.hex2\
+ -f src/mes.hex2\
+ -f src/mes.blood-elf.hex2\
+ --exec_enable\
+ -o src/mes.seed-out
cp src/mes.seed-out src/mes
- $M1 --LittleEndian --Architecture=1 -f\
- stage0/x86.M1\
+ $M1\
+ $M1FLAGS\
+ -f stage0/x86.M1\
-f $MES_SEED/libc+tcc-mes.M1\
-o src/libc+tcc-mes.hex2
fi
[ -n "$SEED" ] && exit 0
-export GUILE=src/mes
-export MES_ARENA=${MES_ARENA-30000000}
+GUILE=src/mes
+MES_ARENA=${MES_ARENA-30000000}
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
@@ -78,7 +102,7 @@ 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
-export PREPROCESS=1
+PREPROCESS=1
NOLINK=1 sh build-aux/cc-mes.sh lib/crt1
NOLINK=1 sh build-aux/cc-mes.sh lib/mini-libc-mes
NOLINK=1 sh build-aux/cc-mes.sh lib/libc-mes
diff --git a/build-aux/build-mlibc.sh b/build-aux/build-mlibc.sh
index a6e40b18..9d10fb5e 100755
--- a/build-aux/build-mlibc.sh
+++ b/build-aux/build-mlibc.sh
@@ -20,7 +20,9 @@
set -ex
-export CC32=${CC32-$(type -p i686-unknown-linux-gnu-gcc)}
+export CC32 CPPFLAGS C32FLAGS
+
+CC32=${CC32-$(command -v i686-unknown-linux-gnu-gcc)}
build-aux/mes-snarf.scm --mes src/gc.c
build-aux/mes-snarf.scm --mes src/lib.c
build-aux/mes-snarf.scm --mes src/math.c
@@ -37,7 +39,7 @@ build-aux/mes-snarf.scm src/posix.c
build-aux/mes-snarf.scm src/reader.c
build-aux/mes-snarf.scm src/vector.c
-export CPPFLAGS=${CPPFLAGS-"
+CPPFLAGS=${CPPFLAGS-"
-D VERSION=\"$VERSION\"
-D MODULEDIR=\"$MODULEDIR\"
-D PREFIX=\"$PREFIX\"
@@ -46,7 +48,7 @@ export CPPFLAGS=${CPPFLAGS-"
-I include
"}
-export C32FLAGS=${C32FLAGS-"
+C32FLAGS=${C32FLAGS-"
--std=gnu99
-O0
-fno-stack-protector
diff --git a/build-aux/cc-mes.sh b/build-aux/cc-mes.sh
index 9c33e966..5836ddb6 100755
--- a/build-aux/cc-mes.sh
+++ b/build-aux/cc-mes.sh
@@ -18,15 +18,19 @@
# You should have received a copy of the GNU General Public License
# along with Mes. If not, see .
-set -ex
+set -x
-export HEX2=${HEX2-hex2}
-export M1=${M1-M1}
-export BLOOD_ELF=${BLOOD_ELF-blood-elf}
-export MES_SEED=${MES_SEED-../mes-seed}
-export MESCC=${MESCC-$(type -p mescc)}
+export BLOOD_ELF GUILE HEX2 M1 MES MESCC
+export M1FLAGS HEX2FLAGS PREPROCESS
+export MES_SEED MES_ARENA
+
+HEX2=${HEX2-hex2}
+M1=${M1-M1}
+BLOOD_ELF=${BLOOD_ELF-blood-elf}
+MES_SEED=${MES_SEED-../mes-seed}
+MESCC=${MESCC-$(command -v mescc)}
[ -z "$MESCC" ] && MESCC=scripts/mescc
-export MES=${MES-$(type -p mes)}
+MES=${MES-$(command -v mes)}
[ -z "$MES" ] && MES=src/mes
CPPFLAGS=${CPPFLAGS-"
@@ -41,9 +45,20 @@ CPPFLAGS=${CPPFLAGS-"
MESCCLAGS=${MESCCFLAGS-"
"}
LIBC=${LIBC-lib/libc}
+M1FLAGS=${M1FLAGS-"
+--LittleEndian
+--Architecture=1
+"}
+HEX2FLAGS=${HEX2FLAGS-"
+--LittleEndian
+--Architecture=1
+--BaseAddress=0x1000000
+"}
c=$1
+set -e
+
if [ -n "$PREPROCESS" ]; then
sh -x $MESCC\
-E\
@@ -64,7 +79,8 @@ else
"$c".c
fi
-$M1 --LittleEndian --Architecture=1\
+$M1\
+ $M1FLAGS\
-f stage0/x86.M1\
-f "$c".M1\
-o "$c".hex2
@@ -75,15 +91,17 @@ if [ -z "$NOLINK" ]; then
-f "$c".M1\
-f $LIBC-mes.M1\
-o "$c".blood-elf-M1
- $M1 --LittleEndian --Architecture=1\
+ $M1\
+ $M1FLAGS\
-f "$c".blood-elf-M1\
-o "$c".blood-elf-hex2
- $HEX2 --LittleEndian --Architecture=1 --BaseAddress=0x1000000\
- -f stage0/elf32-header.hex2\
- -f lib/crt1.hex2\
- -f $LIBC-mes.hex2\
- -f "$c".hex2\
- -f "$c".blood-elf-hex2\
- --exec_enable\
- -o "$c".mes-out
+ $HEX2\
+ $HEX2FLAGS\
+ -f stage0/elf32-header.hex2\
+ -f lib/crt1.hex2\
+ -f $LIBC-mes.hex2\
+ -f "$c".hex2\
+ -f "$c".blood-elf-hex2\
+ --exec_enable\
+ -o "$c".mes-out
fi
diff --git a/build-aux/check-boot.sh b/build-aux/check-boot.sh
index 380611a0..f418c935 100755
--- a/build-aux/check-boot.sh
+++ b/build-aux/check-boot.sh
@@ -20,8 +20,9 @@
set -e
-export GUILE=${GUILE-guile}
-export MES=${MES-./src/mes}
+export GUILE MES
+GUILE=${GUILE-guile}
+MES=${MES-./src/mes}
tests="
diff --git a/build-aux/check-mescc.sh b/build-aux/check-mescc.sh
index 0eb15690..3c87e715 100755
--- a/build-aux/check-mescc.sh
+++ b/build-aux/check-mescc.sh
@@ -18,18 +18,22 @@
# You should have received a copy of the GNU General Public License
# along with Mes. If not, see .
-export MES=${MES-src/mes}
-export MESCC=${MESCC-scripts/mescc}
-export GUILE=${GUILE-guile}
-export MES_PREFIX=${MES_PREFIX-.}
+export BLOOD_ELF GUILE HEX2 M1 MES MESCC
+export M1FLAGS HEX2FLAGS PREPROCESS LIBC
+export MES_ARENA MES_PREFIX MES_SEED
-export HEX2=${HEX2-hex2}
-export M1=${M1-M1}
-export BLOOD_ELF=${BLOOD_ELF-blood-elf}
-export MES_SEED=${MES_SEED-../mes-seed}
-export MESCC=${MESCC-$(type -p mescc)}
+MES=${MES-src/mes}
+MESCC=${MESCC-scripts/mescc}
+GUILE=${GUILE-guile}
+MES_PREFIX=${MES_PREFIX-.}
+
+HEX2=${HEX2-hex2}
+M1=${M1-M1}
+BLOOD_ELF=${BLOOD_ELF-blood-elf}
+MES_SEED=${MES_SEED-../mes-seed}
+MESCC=${MESCC-$(command -v mescc)}
[ -z "$MESCC" ] && MESCC=scripts/mescc
-export MES=${MES-$(type -p mes)}
+MES=${MES-$(command -v mes)}
[ -z "$MES" ] && MES=src/mes
@@ -115,7 +119,7 @@ expect=$(echo $broken | wc -w)
pass=0
fail=0
total=0
-export LIBC=libc/libc
+LIBC=libc/libc
for t in $tests; do
if [ -z "${t/[012][0-9]-*/}" ]; then
LIBC=lib/mini-libc;
diff --git a/build-aux/test.sh b/build-aux/test.sh
index cf9932a7..af01c6c4 100755
--- a/build-aux/test.sh
+++ b/build-aux/test.sh
@@ -18,16 +18,19 @@
# You should have received a copy of the GNU General Public License
# along with Mes. If not, see .
-set -ex
+set -x
GUILE=${GUILE-$MES}
DIFF=${DIFF-$(command -v diff)}
-DIFF=${DIFF-sh build-aux/diff.scm}
+[ -z "$DIFF" ] && DIFF="sh build-aux/diff.scm"
t=${1-scaffold/tests/t}
-#rm -f "$t".i686-unknown-linux-gnu-out
rm -f "$t".mes-out
+shift
+set -e
+
+rm -f "$t".mes-out
sh build-aux/cc-mes.sh "$t"
r=0
diff --git a/build.sh b/build.sh
index df558c07..2e2525ea 100755
--- a/build.sh
+++ b/build.sh
@@ -18,20 +18,59 @@
# You should have received a copy of the GNU General Public License
# along with Mes. If not, see .
-set -ex
+set -x
+# dash does not export foo=${foo-bar} for some values
+export CC CC32 GUILE MESCC MES_SEED
+export MES_ARENA MES_DEBUG
+export PREFIX DATADIR MODULEDIR
+export CPPFLAGS CFLAGS C32FLAGS MESCCFLAGS
-export CC=${CC-$(type -p gcc)}
-export CC32=${CC32-$(type -p i686-unknown-linux-gnu-gcc)}
-export MESCC=${MESCC-$(type -p mescc)}
-export MES_SEED=${MES_SEED-../mes-seed}
-export GUILE=${GUILE-$(type -p guile)}
-export MES_ARENA=${MES_ARENA-300000000}
-export MES_DEBUG=${MES_DEBUG-2}
+CC=${CC-$(command -v gcc)}
+CC32=${CC32-$(command -v i686-unknown-linux-gnu-gcc)}
+MESCC=${MESCC-$(command -v mescc)}
+MES_SEED=${MES_SEED-../mes-seed}
+GUILE=${GUILE-$(command -v guile)}
+MES_ARENA=${MES_ARENA-300000000}
+MES_DEBUG=${MES_DEBUG-2}
-export PREFIX=${PREFIX-/usr/local}
-export DATADIR=${DATADIR-$PREFIX/share/mes}
-export MODULEDIR=${MODULEDIR-$DATADIR/module}
+PREFIX=${PREFIX-/usr/local}
+DATADIR=${DATADIR-$PREFIX/share/mes}
+MODULEDIR=${MODULEDIR-$DATADIR/module}
+set -e
+CPPFLAGS=${CPPFLAGS-"
+-D VERSION=\"$VERSION\"
+-D MODULEDIR=\"$MODULEDIR\"
+-D PREFIX=\"$PREFIX\"
+-I src
+-I lib
+-I include
+"}
+CFLAGS=${CFLAGS-"
+--std=gnu99
+-O0
+-g
+"}
+C32FLAGS=${C32FLAGS-"
+--std=gnu99
+-O0
+-fno-stack-protector
+-g
+-m32
+-nostdinc
+-nostdlib
+"}
+MESCCLAGS=${MESCCFLAGS-"
+"}
+M1FLAGS=${M1FLAGS-"
+--LittleEndian
+--Architecture=1
+"}
+HEX2FLAGS=${HEX2FLAGS-"
+--LittleEndian
+--Architecture=1
+--BaseAddress=0x1000000
+"}
if [ -n "$GUILE" ]; then
sh build-aux/build-guile.sh
diff --git a/check.sh b/check.sh
index 9636c0c3..1eecadf9 100755
--- a/check.sh
+++ b/check.sh
@@ -18,9 +18,10 @@
# You should have received a copy of the GNU General Public License
# along with Mes. If not, see .
-export GUILE=${GUILE-guile}
-export MES=${MES-src/mes}
-export MES_ARENA=${MES_ARENA-100000000}
+export GUILE MES MES_ARENA
+GUILE=${GUILE-guile}
+MES=${MES-src/mes}
+MES_ARENA=${MES_ARENA-100000000}
set -e
bash build-aux/check-boot.sh
diff --git a/configure b/configure
index dc802c18..2a5f8619 100755
--- a/configure
+++ b/configure
@@ -2,7 +2,7 @@
# -*- scheme -*-
unset LANG LC_ALL
echo -n "checking for guile..."
-GUILE=$(type -p ${GUILE-guile} 2>/dev/null|tail -n 1|sed 's,^.* ,,')
+GUILE=$(command -v ${GUILE-guile} 2>/dev/null|tail -n 1|sed 's,^.* ,,')
export GUILE
if [ -x "$GUILE" ]; then
echo " $GUILE"
@@ -175,6 +175,11 @@ exec ${GUILE} --no-auto-compile -L $(pwd) -C $(pwd) -e 'main' -s "$0" ${1+"$@"}
"i686-unknown-linux-gnu-gcc")))
(define HEX2 (or (getenv "HEX2") "hex2"))
(define M1 (or (getenv "M1") "M1"))
+(define CFLAGS (getenv "CFLAGS"))
+(define C32FLAGS (getenv "C32FLAGS"))
+(define HEX2FLAGS (getenv "HEX2FLAGS"))
+(define M1FLAGS (getenv "M1FLAGS"))
+(define MESCCFLAGS (getenv "MESCCFLAGS"))
(define (parse-opts args)
(let* ((option-spec
@@ -261,10 +266,15 @@ Usage: ./configure [OPTION]...
(stdout "PACKAGE:=~a\n" PACKAGE)
(stdout "VERSION:=~a\n" VERSION)
(stdout "PREFIX:=~a\n" (gulp-pipe (string-append "echo " prefix)))
- (stdout "SYSCONFDIR:=~a\n" sysconfdir)))
+ (stdout "SYSCONFDIR:=~a\n" sysconfdir)
+ (when CFLAGS (stdout "CFLAGS:=~a\n" CFLAGS))
+ (when C32FLAGS (stdout "C32FLAGS:=~a\n" C32FLAGS))
+ (when HEX2FLAGS (stdout "HEX2FLAGS:=~a\n" HEX2FLAGS))
+ (when M1FLAGS (stdout "M1FLAGS:=~a\n" M1FLAGS))
+ (when MESCCFLAGS (stdout "MESCCFLAGS:=~a\n" MESCCFLAGS))))
(format (current-output-port)
"\nRun:
~a to build mes
~a help for help on other targets\n"
- (if make? "make" "./make.scm")
- (if make? "make" "./make.scm"))))
+ (if make? "make" "./build.sh")
+ (if make? "make" "./build.sh"))))
diff --git a/install.sh b/install.sh
index 1c80a8b8..b3036ab0 100755
--- a/install.sh
+++ b/install.sh
@@ -2,7 +2,8 @@
set -e
-export PREFIX=${PREFIX-/usr/local}
+export PREFIX
+PREFIX=${PREFIX-/usr/local}
MES_PREFIX=${MES_PREFIX-$PREFIX/share/mes}
MES_SEED=${MES_SEED-../mes-seed}
TINYCC_SEED=${TINYCC_SEED-../tinycc-seed}
diff --git a/scripts/mescc b/scripts/mescc
index b37de93f..4baf7cc5 100755
--- a/scripts/mescc
+++ b/scripts/mescc
@@ -1,6 +1,6 @@
#! /bin/sh
# -*-scheme-*-
-mes_p=$(type -p mes)
+mes_p=$(command -v mes)
if [ '(' -z "$mes_p" -a -z "$MES" ')' -o "$MES" = "guile" -o "$MES" = "mes.guile" ]; then
GODIR=${GODIR-@GODIR@}
GUILEDIR=${GUILEDIR-@GUILEDIR@}