2019-08-09 07:56:16 -04:00
|
|
|
#!/bin/sh
|
|
|
|
set -eu
|
2019-08-09 16:12:19 -04:00
|
|
|
os="$(uname | tr A-Z- a-z_)"
|
2019-08-28 04:52:00 -04:00
|
|
|
case $os in
|
2019-10-14 10:53:37 -04:00
|
|
|
cygwin*|msys*)
|
2019-08-28 04:52:00 -04:00
|
|
|
os=linux
|
|
|
|
;;
|
|
|
|
esac
|
2019-08-13 16:41:43 -04:00
|
|
|
o_files=""
|
2019-08-14 13:02:48 -04:00
|
|
|
o_files="$o_files algo_color.o"
|
2019-08-26 15:12:15 -04:00
|
|
|
o_files="$o_files argcount.o"
|
2019-08-13 16:41:43 -04:00
|
|
|
o_files="$o_files bitvector-ops.o"
|
|
|
|
o_files="$o_files bitvector.o"
|
2019-08-27 03:31:31 -04:00
|
|
|
o_files="$o_files boot_image.o"
|
2019-08-13 16:41:43 -04:00
|
|
|
o_files="$o_files buf.o"
|
|
|
|
o_files="$o_files builtins.o"
|
2019-09-29 05:32:57 -04:00
|
|
|
o_files="$o_files char.o"
|
2019-08-13 16:41:43 -04:00
|
|
|
o_files="$o_files dump.o"
|
2019-10-17 12:25:49 -04:00
|
|
|
o_files="$o_files env.o"
|
2019-10-14 12:15:45 -04:00
|
|
|
o_files="$o_files env_build.o"
|
|
|
|
o_files="$o_files env_release.o"
|
2019-08-13 16:41:43 -04:00
|
|
|
o_files="$o_files env_unix.o"
|
|
|
|
o_files="$o_files equalhash.o"
|
|
|
|
o_files="$o_files flisp.o"
|
2019-10-13 16:15:01 -04:00
|
|
|
o_files="$o_files main.o"
|
2019-08-13 16:41:43 -04:00
|
|
|
o_files="$o_files hashing.o"
|
|
|
|
o_files="$o_files htable.o"
|
|
|
|
o_files="$o_files int2str.o"
|
|
|
|
o_files="$o_files ios.o"
|
|
|
|
o_files="$o_files iostream.o"
|
|
|
|
o_files="$o_files libraries.o"
|
|
|
|
o_files="$o_files lltinit.o"
|
2019-08-14 06:48:53 -04:00
|
|
|
o_files="$o_files os_$os.o"
|
|
|
|
o_files="$o_files os_unix.o"
|
2019-08-14 13:31:39 -04:00
|
|
|
o_files="$o_files os_unix_process.o"
|
2019-08-13 16:41:43 -04:00
|
|
|
o_files="$o_files ptrhash.o"
|
|
|
|
o_files="$o_files random.o"
|
|
|
|
o_files="$o_files socket.o"
|
|
|
|
o_files="$o_files string.o"
|
|
|
|
o_files="$o_files table.o"
|
2019-08-14 06:49:56 -04:00
|
|
|
o_files="$o_files text_ini.o"
|
2019-08-13 16:41:43 -04:00
|
|
|
o_files="$o_files time_unix.o"
|
|
|
|
o_files="$o_files utf8.o"
|
2019-08-28 05:45:21 -04:00
|
|
|
o_files="$o_files util.o"
|
2019-08-28 13:51:15 -04:00
|
|
|
default_cflags="-Wall -Werror -Wextra -O2 -D NDEBUG -D USE_COMPUTED_GOTO -std=gnu99 -Wno-strict-aliasing"
|
2019-08-13 17:05:10 -04:00
|
|
|
default_lflags="-lm"
|
2019-08-09 18:43:47 -04:00
|
|
|
case "$os" in
|
|
|
|
darwin)
|
|
|
|
default_cc="clang"
|
|
|
|
;;
|
|
|
|
dragonfly)
|
|
|
|
default_cc="gcc"
|
|
|
|
;;
|
|
|
|
freebsd)
|
|
|
|
default_cc="clang"
|
|
|
|
;;
|
|
|
|
haiku)
|
|
|
|
default_cc="gcc"
|
2019-08-13 17:05:10 -04:00
|
|
|
default_cflags="-Wall -O2 -D NDEBUG -D USE_COMPUTED_GOTO"
|
2019-10-13 20:52:46 -04:00
|
|
|
default_lflags="$default_lflags -lsocket"
|
2019-08-09 18:43:47 -04:00
|
|
|
;;
|
|
|
|
linux)
|
|
|
|
default_cc="gcc"
|
2019-08-13 17:05:10 -04:00
|
|
|
default_cflags="$default_cflags -D _GNU_SOURCE"
|
2019-08-13 11:30:27 -04:00
|
|
|
;;
|
|
|
|
minix)
|
|
|
|
default_cc="clang"
|
2019-08-09 18:43:47 -04:00
|
|
|
;;
|
|
|
|
netbsd)
|
|
|
|
default_cc="gcc"
|
|
|
|
;;
|
|
|
|
openbsd)
|
|
|
|
default_cc="clang"
|
|
|
|
;;
|
|
|
|
sunos)
|
|
|
|
default_cc="gcc"
|
2019-08-13 17:05:10 -04:00
|
|
|
default_lflags="$default_lflags -lsocket -lnsl"
|
2019-08-09 18:43:47 -04:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown operating system: $os" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
CC="${CC:-$default_cc}"
|
2019-08-13 17:05:10 -04:00
|
|
|
CFLAGS="${CFLAGS:-$default_cflags}"
|
|
|
|
LFLAGS="${LFLAGS:-$default_lflags}"
|
2019-10-14 12:15:45 -04:00
|
|
|
revision="$(git describe --dirty --always 2>/dev/null || echo unknown)"
|
|
|
|
builddate="$(date -u '+%Y-%m-%d')"
|
2019-08-21 15:18:01 -04:00
|
|
|
builddir="build-$os-$(uname -m | tr A-Z- a-z_)-$(basename "$CC")"
|
2019-08-09 07:56:16 -04:00
|
|
|
cd "$(dirname "$0")"/..
|
|
|
|
echo "Entering directory '$PWD'"
|
|
|
|
set -x
|
2019-08-13 17:56:31 -04:00
|
|
|
|
2019-10-14 12:15:45 -04:00
|
|
|
cat >c/env_build.c <<EOF
|
|
|
|
// Generated from scratch at each build.
|
2019-10-14 12:40:37 -04:00
|
|
|
const char env_build_cc[] = "$CC";
|
|
|
|
const char env_build_cflags[] = "$CFLAGS";
|
|
|
|
const char env_build_lflags[] = "$LFLAGS";
|
|
|
|
const char env_build_revision[] = "$revision";
|
|
|
|
const char env_build_date[] = "$builddate";
|
2019-10-14 12:15:45 -04:00
|
|
|
EOF
|
|
|
|
|
2019-08-09 07:56:16 -04:00
|
|
|
mkdir -p "$builddir"
|
|
|
|
find "$builddir" -mindepth 1 -delete
|
2019-08-13 17:56:31 -04:00
|
|
|
|
2019-08-09 07:56:16 -04:00
|
|
|
{ set +x; } 2>/dev/null
|
|
|
|
cd "$builddir"
|
|
|
|
echo "Entering directory '$PWD'"
|
|
|
|
set -x
|
2019-08-13 17:56:31 -04:00
|
|
|
|
2019-08-14 13:02:48 -04:00
|
|
|
$CC $CFLAGS -c ../c/algo_color.c
|
2019-08-26 15:12:15 -04:00
|
|
|
$CC $CFLAGS -c ../c/argcount.c
|
2019-08-09 08:02:58 -04:00
|
|
|
$CC $CFLAGS -c ../c/bitvector-ops.c
|
|
|
|
$CC $CFLAGS -c ../c/bitvector.c
|
2019-08-11 15:32:55 -04:00
|
|
|
$CC $CFLAGS -c ../c/buf.c
|
2019-08-09 10:30:49 -04:00
|
|
|
$CC $CFLAGS -c ../c/builtins.c
|
2019-09-29 05:32:57 -04:00
|
|
|
$CC $CFLAGS -c ../c/char.c
|
2019-08-09 08:02:58 -04:00
|
|
|
$CC $CFLAGS -c ../c/dump.c
|
2019-10-17 12:25:49 -04:00
|
|
|
$CC $CFLAGS -c ../c/env.c
|
2019-10-14 12:15:45 -04:00
|
|
|
$CC $CFLAGS -c ../c/env_build.c
|
|
|
|
$CC $CFLAGS -c ../c/env_release.c
|
2019-08-09 17:35:16 -04:00
|
|
|
$CC $CFLAGS -c ../c/env_unix.c
|
2019-08-09 10:30:49 -04:00
|
|
|
$CC $CFLAGS -c ../c/equalhash.c
|
2019-08-27 03:31:31 -04:00
|
|
|
$CC $CFLAGS -c ../c/flisp.c
|
2019-08-09 08:02:58 -04:00
|
|
|
$CC $CFLAGS -c ../c/hashing.c
|
|
|
|
$CC $CFLAGS -c ../c/htable.c
|
|
|
|
$CC $CFLAGS -c ../c/int2str.c
|
|
|
|
$CC $CFLAGS -c ../c/ios.c
|
2019-08-09 10:30:49 -04:00
|
|
|
$CC $CFLAGS -c ../c/iostream.c
|
2019-08-11 15:32:55 -04:00
|
|
|
$CC $CFLAGS -c ../c/libraries.c
|
2019-08-09 08:02:58 -04:00
|
|
|
$CC $CFLAGS -c ../c/lltinit.c
|
2019-10-14 11:59:47 -04:00
|
|
|
$CC $CFLAGS -c ../c/main.c
|
2019-08-14 06:48:53 -04:00
|
|
|
$CC $CFLAGS -c ../c/os_"$os".c
|
|
|
|
$CC $CFLAGS -c ../c/os_unix.c
|
2019-08-14 13:31:39 -04:00
|
|
|
$CC $CFLAGS -c ../c/os_unix_process.c
|
2019-08-09 08:02:58 -04:00
|
|
|
$CC $CFLAGS -c ../c/ptrhash.c
|
|
|
|
$CC $CFLAGS -c ../c/random.c
|
|
|
|
$CC $CFLAGS -c ../c/socket.c
|
2019-08-09 10:30:49 -04:00
|
|
|
$CC $CFLAGS -c ../c/string.c
|
|
|
|
$CC $CFLAGS -c ../c/table.c
|
2019-08-14 06:49:56 -04:00
|
|
|
$CC $CFLAGS -c ../c/text_ini.c
|
2019-08-09 16:56:18 -04:00
|
|
|
$CC $CFLAGS -c ../c/time_unix.c
|
2019-08-09 08:02:58 -04:00
|
|
|
$CC $CFLAGS -c ../c/utf8.c
|
2019-08-28 05:45:21 -04:00
|
|
|
$CC $CFLAGS -c ../c/util.c
|
2019-08-13 16:07:44 -04:00
|
|
|
|
2019-08-27 03:31:31 -04:00
|
|
|
$CC $CFLAGS -c ../c/boot_image.c
|
2019-08-27 17:29:20 -04:00
|
|
|
$CC -o upscheme $o_files $LFLAGS
|
2019-08-13 16:07:44 -04:00
|
|
|
|
2019-08-09 07:56:16 -04:00
|
|
|
{ set +x; } 2>/dev/null
|
2019-08-09 08:21:56 -04:00
|
|
|
cd ../scheme-core
|
2019-08-09 07:56:16 -04:00
|
|
|
echo "Entering directory '$PWD'"
|
|
|
|
echo "Creating stage 0 boot file..."
|
|
|
|
set -x
|
2019-08-13 17:56:31 -04:00
|
|
|
|
2019-08-13 17:44:24 -04:00
|
|
|
../"$builddir"/upscheme mkboot0.scm >../scheme-boot/boot_image.h.new
|
2019-08-13 16:20:47 -04:00
|
|
|
mv ../scheme-boot/boot_image.h.new ../scheme-boot/boot_image.h
|
2019-08-13 16:07:44 -04:00
|
|
|
|
|
|
|
{ set +x; } 2>/dev/null
|
|
|
|
cd ../"$builddir"
|
|
|
|
echo "Entering directory '$PWD'"
|
|
|
|
set -x
|
2019-08-13 17:56:31 -04:00
|
|
|
|
2019-08-27 03:31:31 -04:00
|
|
|
$CC $CFLAGS -c ../c/boot_image.c
|
2019-08-27 17:29:20 -04:00
|
|
|
$CC -o upscheme $o_files $LFLAGS
|
2019-08-13 16:07:44 -04:00
|
|
|
|
2019-08-09 07:56:16 -04:00
|
|
|
{ set +x; } 2>/dev/null
|
2019-08-13 16:07:44 -04:00
|
|
|
cd ../scheme-core
|
|
|
|
echo "Entering directory '$PWD'"
|
2019-08-09 07:56:16 -04:00
|
|
|
echo "Creating stage 1 boot file..."
|
|
|
|
set -x
|
2019-08-13 17:56:31 -04:00
|
|
|
|
2019-08-13 17:44:24 -04:00
|
|
|
../"$builddir"/upscheme mkboot1.scm >../scheme-boot/boot_image.h.new
|
2019-08-13 16:20:47 -04:00
|
|
|
mv ../scheme-boot/boot_image.h.new ../scheme-boot/boot_image.h
|
2019-08-13 16:07:44 -04:00
|
|
|
|
|
|
|
{ set +x; } 2>/dev/null
|
|
|
|
cd ../"$builddir"
|
|
|
|
echo "Entering directory '$PWD'"
|
|
|
|
set -x
|
2019-08-13 17:56:31 -04:00
|
|
|
|
2019-08-27 03:31:31 -04:00
|
|
|
$CC $CFLAGS -c ../c/boot_image.c
|
2019-08-27 17:29:20 -04:00
|
|
|
$CC -o upscheme $o_files $LFLAGS
|
2019-08-13 16:07:44 -04:00
|
|
|
|
2019-08-09 07:56:16 -04:00
|
|
|
{ set +x; } 2>/dev/null
|
2019-08-09 08:21:56 -04:00
|
|
|
cd ../scheme-tests
|
2019-08-09 07:56:16 -04:00
|
|
|
echo "Entering directory '$PWD'"
|
2019-08-13 17:58:52 -04:00
|
|
|
set -x
|
2019-08-13 17:56:31 -04:00
|
|
|
|
2019-08-10 05:26:51 -04:00
|
|
|
../"$builddir"/upscheme unittest.scm
|