build: Fixes for Debian and /bin/sh == dash.

* build.sh: Use separate export stanzas.  Use command -v (WAS: type
  -p).  Fixes sh, /bin/sh == dash.
* build-aux/build-cc.sh: Likewise.
* build-aux/build-guile.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/build-mlibc.sh: Likewise.
* build-aux/cc-mes.sh: Likewise.
* build-aux/check-mescc.sh: Likewise.
* check.sh: Likewise.
* install.sh: Likewise.
* scripts/mescc: Likewise.
This commit is contained in:
Jan Nieuwenhuizen 2018-05-03 20:32:06 +02:00
parent ad88aaa5be
commit ba17eeeefe
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
15 changed files with 266 additions and 102 deletions

8
.gitignore vendored
View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -18,27 +18,47 @@
# You should have received a copy of the GNU General Public License
# along with Mes. If not, see <http://www.gnu.org/licenses/>.
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

View file

@ -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

View file

@ -18,15 +18,19 @@
# You should have received a copy of the GNU General Public License
# along with Mes. If not, see <http://www.gnu.org/licenses/>.
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

View file

@ -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="

View file

@ -18,18 +18,22 @@
# You should have received a copy of the GNU General Public License
# along with Mes. If not, see <http://www.gnu.org/licenses/>.
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;

View file

@ -18,16 +18,19 @@
# You should have received a copy of the GNU General Public License
# along with Mes. If not, see <http://www.gnu.org/licenses/>.
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

View file

@ -18,20 +18,59 @@
# You should have received a copy of the GNU General Public License
# along with Mes. If not, see <http://www.gnu.org/licenses/>.
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

View file

@ -18,9 +18,10 @@
# You should have received a copy of the GNU General Public License
# along with Mes. If not, see <http://www.gnu.org/licenses/>.
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

18
configure vendored
View file

@ -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"))))

View file

@ -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}

View file

@ -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@}