2020-08-09 17:25:25 +00:00
|
|
|
#! /bin/sh
|
2022-04-30 08:17:23 +00:00
|
|
|
# Copyright © 2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
2020-08-09 17:25:25 +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/>.
|
|
|
|
|
|
|
|
# Usage:
|
|
|
|
# kaem --verbose --strict
|
|
|
|
|
|
|
|
mes_cpu=${mes_cpu:-x86}
|
|
|
|
stage0_cpu=${stage0_cpu:-x86}
|
|
|
|
|
2020-10-18 21:15:11 +00:00
|
|
|
mkdir -p m2
|
|
|
|
|
2020-08-09 17:25:25 +00:00
|
|
|
M2-Planet \
|
|
|
|
--debug \
|
|
|
|
--architecture ${stage0_cpu} \
|
2022-11-14 04:25:55 +00:00
|
|
|
-D __linux__=1 \
|
|
|
|
-f include/mes/config.h \
|
|
|
|
-f include/mes/lib-mini.h \
|
|
|
|
-f include/mes/lib.h \
|
2020-08-09 17:25:25 +00:00
|
|
|
-f lib/linux/${mes_cpu}-mes-m2/crt1.c \
|
|
|
|
-f lib/linux/${mes_cpu}-mes-m2/_exit.c \
|
|
|
|
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
|
|
|
-f lib/mes/globals.c \
|
2020-10-18 12:55:24 +00:00
|
|
|
-f lib/m2/cast.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
-f lib/stdlib/exit.c \
|
2022-11-04 19:00:47 +00:00
|
|
|
-f lib/mes/write.c \
|
2020-08-09 17:25:25 +00:00
|
|
|
-f include/linux/${mes_cpu}/syscall.h \
|
2022-11-14 04:25:55 +00:00
|
|
|
-f lib/linux/${mes_cpu}-mes-m2/syscall.c \
|
2019-11-10 15:04:25 +00:00
|
|
|
-f lib/stub/__raise.c \
|
2020-08-09 17:25:25 +00:00
|
|
|
-f lib/linux/brk.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
-f lib/linux/malloc.c \
|
2020-08-09 17:25:25 +00:00
|
|
|
-f lib/string/memset.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
-f lib/linux/read.c \
|
2020-08-09 17:25:25 +00:00
|
|
|
-f lib/mes/fdgetc.c \
|
|
|
|
-f lib/stdio/getchar.c \
|
|
|
|
-f lib/stdio/putchar.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
-f lib/stub/__buffered_read.c \
|
|
|
|
-f lib/linux/_open3.c \
|
|
|
|
-f lib/linux/open.c \
|
|
|
|
-f lib/mes/mes_open.c \
|
2020-08-09 17:25:25 +00:00
|
|
|
-f lib/string/strlen.c \
|
|
|
|
-f lib/mes/eputs.c \
|
|
|
|
-f lib/mes/fdputc.c \
|
|
|
|
-f lib/mes/eputc.c \
|
|
|
|
\
|
2022-11-14 04:25:55 +00:00
|
|
|
-f include/time.h \
|
|
|
|
-f include/sys/time.h \
|
lib: stat: Use SYS_stat64 for 32bit platforms.
This fixes <https://debbugs.gnu.org/41264>.
* include/linux/arm/syscall.h (SYS_stat64, SYS_lstat64,
SYS_fstat64)[__SIZEOF_LONG_LONG__ == 8]:
New defines.
(SYS_stat, SYS_lstat, SYS_fstat)[__SIZEOF_LONG_LONG__ == 8]: Redefine them.
* include/linux/x86/syscall.h (SYS_stat64, SYS_lstat64,
SYS_fstat64)[__SIZEOF_LONG_LONG__ == 8]:
New defines.
(SYS_stat, SYS_lstat, SYS_fstat)[__SIZEOF_LONG_LONG__ == 8]: Redefine them.
* include/sys/stat.h (struct stat): Move definition to...
* include/linux/arm/kernel-stat.h,
include/linux/m2/kernel-stat.h,
include/linux/x86/kernel-stat.h,
include/linux/x86_64/kernel-stat.h: These new files.
* include/gnu/x86/kernel-stat.h: New file.
* configure (main): Copy <srcdest>include/<kernel>/<arch>/*.h to
include/.
* configure.sh: Likewise.
* .gitignore: Ignore them. Add copyright header.
* build-aux/GNUmakefile.in (X86_ARCH_HEADERS, ARCH_HEADERS): New
variables.
(build): Use them.
(include/arch/%.h, arch-dir): New targets.
* build-aux/bootstrap.sh.in (AM_CPPFLAGS): Replace
<srcdest>include/<kernel>/<cpu> with built ../include.
* build-aux/build.sh.in (AM_CPPFLAGS): Likewise.
* build-aux/install.sh.in: Also install built include.
* include/m2/types.h: New file.
* kaem.run: Use it.
* simple.sh: Copy kernel-stat.h, syscall.h for kernel/cpu to
include/arch.
2022-10-29 11:17:58 +00:00
|
|
|
-f include/m2/types.h \
|
2022-11-14 04:25:55 +00:00
|
|
|
-f include/sys/types.h \
|
2020-08-09 17:25:25 +00:00
|
|
|
-f include/mes/mes.h \
|
|
|
|
-f include/mes/builtins.h \
|
|
|
|
-f include/mes/constants.h \
|
|
|
|
-f include/mes/symbols.h \
|
|
|
|
\
|
|
|
|
-f lib/mes/__assert_fail.c \
|
|
|
|
-f lib/mes/assert_msg.c \
|
|
|
|
\
|
|
|
|
-f lib/mes/fdputc.c \
|
|
|
|
-f lib/string/strncmp.c \
|
|
|
|
-f lib/posix/getenv.c \
|
|
|
|
-f lib/mes/fdputs.c \
|
2020-12-29 14:39:33 +00:00
|
|
|
-f lib/mes/ntoab.c \
|
2020-08-09 17:25:25 +00:00
|
|
|
-f lib/ctype/isdigit.c \
|
|
|
|
-f lib/ctype/isxdigit.c \
|
|
|
|
-f lib/ctype/isspace.c \
|
|
|
|
-f lib/ctype/isnumber.c \
|
|
|
|
-f lib/mes/abtol.c \
|
|
|
|
-f lib/stdlib/atoi.c \
|
|
|
|
-f lib/string/memcpy.c \
|
|
|
|
-f lib/stdlib/free.c \
|
|
|
|
-f lib/stdlib/realloc.c \
|
|
|
|
-f lib/string/strcpy.c \
|
|
|
|
-f lib/mes/itoa.c \
|
2020-08-16 12:45:18 +00:00
|
|
|
-f lib/mes/ltoa.c \
|
2020-08-09 17:25:25 +00:00
|
|
|
-f lib/mes/fdungetc.c \
|
|
|
|
-f lib/posix/setenv.c \
|
|
|
|
-f lib/linux/access.c \
|
lib: stat: Use SYS_stat64 for 32bit platforms.
This fixes <https://debbugs.gnu.org/41264>.
* include/linux/arm/syscall.h (SYS_stat64, SYS_lstat64,
SYS_fstat64)[__SIZEOF_LONG_LONG__ == 8]:
New defines.
(SYS_stat, SYS_lstat, SYS_fstat)[__SIZEOF_LONG_LONG__ == 8]: Redefine them.
* include/linux/x86/syscall.h (SYS_stat64, SYS_lstat64,
SYS_fstat64)[__SIZEOF_LONG_LONG__ == 8]:
New defines.
(SYS_stat, SYS_lstat, SYS_fstat)[__SIZEOF_LONG_LONG__ == 8]: Redefine them.
* include/sys/stat.h (struct stat): Move definition to...
* include/linux/arm/kernel-stat.h,
include/linux/m2/kernel-stat.h,
include/linux/x86/kernel-stat.h,
include/linux/x86_64/kernel-stat.h: These new files.
* include/gnu/x86/kernel-stat.h: New file.
* configure (main): Copy <srcdest>include/<kernel>/<arch>/*.h to
include/.
* configure.sh: Likewise.
* .gitignore: Ignore them. Add copyright header.
* build-aux/GNUmakefile.in (X86_ARCH_HEADERS, ARCH_HEADERS): New
variables.
(build): Use them.
(include/arch/%.h, arch-dir): New targets.
* build-aux/bootstrap.sh.in (AM_CPPFLAGS): Replace
<srcdest>include/<kernel>/<cpu> with built ../include.
* build-aux/build.sh.in (AM_CPPFLAGS): Likewise.
* build-aux/install.sh.in: Also install built include.
* include/m2/types.h: New file.
* kaem.run: Use it.
* simple.sh: Copy kernel-stat.h, syscall.h for kernel/cpu to
include/arch.
2022-10-29 11:17:58 +00:00
|
|
|
-f include/linux/m2/kernel-stat.h \
|
|
|
|
-f include/sys/stat.h \
|
2022-11-14 04:25:55 +00:00
|
|
|
-f lib/linux/chmod.c \
|
2020-12-29 17:41:45 +00:00
|
|
|
-f lib/linux/ioctl3.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
-f include/sys/ioctl.h \
|
2020-08-09 17:25:25 +00:00
|
|
|
-f lib/m2/isatty.c \
|
|
|
|
-f lib/linux/fork.c \
|
2021-01-02 09:00:35 +00:00
|
|
|
-f lib/m2/execve.c \
|
2020-08-09 17:25:25 +00:00
|
|
|
-f lib/m2/execv.c \
|
2022-11-15 05:36:07 +00:00
|
|
|
-f include/sys/resource.h \
|
|
|
|
-f lib/linux/wait4.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
-f lib/linux/waitpid.c \
|
2020-08-09 17:25:25 +00:00
|
|
|
-f lib/linux/gettimeofday.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
-f lib/linux/clock_gettime.c \
|
2020-08-09 17:25:25 +00:00
|
|
|
-f lib/m2/time.c \
|
|
|
|
-f lib/linux/_getcwd.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
-f include/limits.h \
|
2021-01-01 14:54:13 +00:00
|
|
|
-f lib/m2/getcwd.c \
|
2020-08-09 17:25:25 +00:00
|
|
|
-f lib/linux/dup.c \
|
|
|
|
-f lib/linux/dup2.c \
|
|
|
|
-f lib/string/strcmp.c \
|
|
|
|
-f lib/string/memcmp.c \
|
|
|
|
-f lib/linux/unlink.c \
|
|
|
|
-f src/builtins.c \
|
|
|
|
-f src/core.c \
|
|
|
|
-f src/display.c \
|
|
|
|
-f src/eval-apply.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
-f include/fcntl.h \
|
2020-08-09 17:25:25 +00:00
|
|
|
-f src/gc.c \
|
|
|
|
-f src/hash.c \
|
|
|
|
-f src/lib.c \
|
2020-08-18 21:01:53 +00:00
|
|
|
-f src/m2.c \
|
2020-08-09 17:25:25 +00:00
|
|
|
-f src/math.c \
|
|
|
|
-f src/mes.c \
|
|
|
|
-f src/module.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
-f include/signal.h \
|
2020-08-09 17:25:25 +00:00
|
|
|
-f src/posix.c \
|
|
|
|
-f src/reader.c \
|
|
|
|
-f src/stack.c \
|
|
|
|
-f src/string.c \
|
|
|
|
-f src/struct.c \
|
|
|
|
-f src/symbol.c \
|
|
|
|
-f src/vector.c \
|
2020-10-18 21:15:11 +00:00
|
|
|
-o m2/mes.M1
|
2020-08-09 17:25:25 +00:00
|
|
|
|
build: Depend on mescc-tools 1.4.0.
* configure (main): Check for hex2, M1 1.4.0, and blood-elf 2.0.0.
* module/mescc/mescc.scm (M1->blood-elf): Use --little-endian with blood-elf call.
* kaem.run,
scaffold/argv.kaem,
scaffold/global-array.kaem,
scaffold/hello.kaem,
scaffold/local-array.kaem,
scaffold/local-static-array.kaem,
scaffold/main.kaem,
scaffold/read.kaem,
simple.make: Likewise.
2022-05-02 05:46:01 +00:00
|
|
|
blood-elf --little-endian -f m2/mes.M1 -o m2/mes.blood-elf-M1
|
2020-08-09 17:25:25 +00:00
|
|
|
|
|
|
|
M1 \
|
|
|
|
--architecture ${stage0_cpu} \
|
|
|
|
--little-endian \
|
|
|
|
-f lib/m2/${mes_cpu}/${mes_cpu}_defs.M1 \
|
|
|
|
-f lib/${mes_cpu}-mes/${mes_cpu}.M1 \
|
|
|
|
-f lib/linux/${mes_cpu}-mes-m2/crt1.M1 \
|
2020-10-18 21:15:11 +00:00
|
|
|
-f m2/mes.M1 \
|
|
|
|
-f m2/mes.blood-elf-M1 \
|
|
|
|
-o m2/mes.hex2
|
2020-08-09 17:25:25 +00:00
|
|
|
|
2020-10-18 21:15:11 +00:00
|
|
|
mkdir -p bin
|
2020-08-09 17:25:25 +00:00
|
|
|
hex2 \
|
|
|
|
--architecture ${stage0_cpu} \
|
|
|
|
--little-endian \
|
|
|
|
--base-address 0x1000000 \
|
|
|
|
-f lib/m2/${mes_cpu}/ELF-${mes_cpu}.hex2 \
|
2020-10-18 21:15:11 +00:00
|
|
|
-f m2/mes.hex2 \
|
2020-08-09 17:25:25 +00:00
|
|
|
-o bin/mes-m2
|
|
|
|
|
|
|
|
echo Running mes-m2
|
|
|
|
./bin/mes-m2 -c "(display 'Hello,M2-mes!) (newline)"
|
2020-10-18 21:15:11 +00:00
|
|
|
cp bin/mes-m2 bin/mes
|