2020-04-22 06:05:37 +00:00
|
|
|
# GNU Mes --- Maxwell Equations of Software
|
|
|
|
# Copyright © 2019 Jeremiah Orians <jeremiah@pdp10.guru>
|
2022-05-03 20:51:21 +00:00
|
|
|
# Copyright © 2018,2019,2020,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
2020-04-22 06:05:37 +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/>.
|
|
|
|
|
|
|
|
CC = gcc
|
|
|
|
MES_CPU=x86_64
|
|
|
|
MES = bin/mes-gcc
|
|
|
|
|
|
|
|
MESCC_CPU=x86
|
|
|
|
MES = bin/mes-gcc
|
|
|
|
|
|
|
|
#CC = i686-unknown-linux-gnu-gcc
|
|
|
|
#MES_CPU = x86
|
|
|
|
|
|
|
|
M2_PLANET = M2-Planet
|
2020-07-25 18:00:44 +00:00
|
|
|
M2_PLANET_ARCH = x86
|
|
|
|
M2_PLANET_FUBAR = i386
|
|
|
|
|
|
|
|
#M2_PLANET_ARCH = amd64
|
|
|
|
#M2_PLANET_FUBAR = amd64
|
2022-11-14 04:25:55 +00:00
|
|
|
M2_PLANET_FLAGS = --debug --architecture $(M2_PLANET_ARCH)
|
2020-04-22 06:05:37 +00:00
|
|
|
|
|
|
|
CFLAGS:= \
|
|
|
|
$(CFLAGS) \
|
|
|
|
-D _GNU_SOURCE \
|
|
|
|
-D const= \
|
|
|
|
-ggdb \
|
|
|
|
-D SYSTEM_LIBC=1 \
|
|
|
|
-D 'MES_VERSION="git"' \
|
|
|
|
-D 'MES_PKGDATADIR="/usr/local/share/mes"' \
|
|
|
|
-I include \
|
2020-10-18 12:55:24 +00:00
|
|
|
-fno-builtin
|
2020-04-22 06:05:37 +00:00
|
|
|
|
2020-08-16 06:56:56 +00:00
|
|
|
LIBMES_SOURCES = \
|
2020-04-19 08:49:48 +00:00
|
|
|
src/builtins.c \
|
core: Split-out core.c.
* src/mes.c (assoc_string, car, cdr, list, null_p, eq_p, values, acons,
length__, length, error, append2, append_reverse, reverse_x_, assq,
assoc): Move to ...
* src/core.c: New file.
* build-aux/configure-lib.sh (mes_SOURCES): Add it.
* simple.make (MES_SOURCES): Likewise.
* build-aux/snarf.sh: Likewise.
* include/mes/builtins.h: Update.
* src/builtins.c (mes_builtins): Update.
2020-07-19 06:49:23 +00:00
|
|
|
src/core.c \
|
2020-05-17 18:42:48 +00:00
|
|
|
src/display.c \
|
core: Split-out eval-apply.c.
* src/mes.c (check_formals, check_apply, pairlis, set_car_x, set_cdr_x,
set_env_x, call_lambda, make_closure_, make_variable_, macro_get_handle,
get_macro, macro_set_x, push_cc, add_formals, formal_p,
expand_variable_, expand_variable, apply_builtin, eval_apply, apply):
Move to ..
* src/eval-apply.c: New file.
* build-aux/configure-lib.sh (mes_SOURCES): Add it.
* simple.make: Likewise.
* src/eval.c (assert_defined): Likewise.
2020-05-17 18:14:08 +00:00
|
|
|
src/eval-apply.c \
|
2020-04-22 06:05:37 +00:00
|
|
|
src/gc.c \
|
|
|
|
src/hash.c \
|
|
|
|
src/lib.c \
|
|
|
|
src/math.c \
|
|
|
|
src/module.c \
|
|
|
|
src/posix.c \
|
|
|
|
src/reader.c \
|
|
|
|
src/string.c \
|
2020-07-19 06:53:46 +00:00
|
|
|
src/stack.c \
|
2020-04-22 06:05:37 +00:00
|
|
|
src/struct.c \
|
2020-05-17 18:50:12 +00:00
|
|
|
src/symbol.c \
|
2020-04-22 06:05:37 +00:00
|
|
|
src/vector.c
|
|
|
|
|
2020-08-16 06:56:56 +00:00
|
|
|
MES_SOURCES = \
|
|
|
|
$(LIBMES_SOURCES) \
|
|
|
|
src/mes.c
|
|
|
|
|
|
|
|
TEST_GC_SOURCES = \
|
|
|
|
$(LIBMES_SOURCES) \
|
|
|
|
src/test/gc.c
|
|
|
|
|
2020-07-25 18:00:44 +00:00
|
|
|
M2_SOURCES = \
|
|
|
|
lib/linux/x86-mes-m2/crt1.c \
|
2020-08-09 17:25:25 +00:00
|
|
|
lib/linux/x86-mes-m2/_exit.c \
|
|
|
|
lib/linux/x86-mes-m2/_write.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
lib/mes/globals.c \
|
2020-10-18 12:55:24 +00:00
|
|
|
lib/m2/cast.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
lib/stdlib/exit.c \
|
|
|
|
lib/stub/__buffered_read.c \
|
2020-07-25 18:00:44 +00:00
|
|
|
lib/linux/x86-mes-m2/syscall.c \
|
2022-05-03 20:51:21 +00:00
|
|
|
lib/stub/__raise.c \
|
2020-07-25 18:00:44 +00:00
|
|
|
lib/linux/brk.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
lib/linux/malloc.c \
|
2020-07-25 18:00:44 +00:00
|
|
|
lib/string/memset.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
lib/linux/read.c \
|
2020-07-25 18:00:44 +00:00
|
|
|
lib/mes/fdgetc.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
lib/linux/lseek.c \
|
|
|
|
lib/posix/write.c \
|
|
|
|
\
|
2020-07-25 18:00:44 +00:00
|
|
|
lib/stdio/getchar.c \
|
|
|
|
lib/stdio/putchar.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
lib/stub/__buffered_read.c \
|
|
|
|
lib/linux/_open3.c \
|
|
|
|
lib/linux/open.c \
|
|
|
|
lib/mes/mes_open.c \
|
2020-07-25 18:00:44 +00:00
|
|
|
lib/string/strlen.c \
|
2020-04-22 06:05:37 +00:00
|
|
|
lib/mes/eputs.c \
|
2020-07-25 18:00:44 +00:00
|
|
|
lib/mes/fdputc.c \
|
|
|
|
lib/mes/eputc.c \
|
|
|
|
\
|
|
|
|
lib/mes/__assert_fail.c \
|
2020-05-17 14:07:04 +00:00
|
|
|
lib/mes/assert_msg.c \
|
2020-07-25 18:00:44 +00:00
|
|
|
\
|
|
|
|
lib/mes/fdputc.c \
|
|
|
|
lib/string/strncmp.c \
|
|
|
|
lib/posix/getenv.c \
|
|
|
|
lib/mes/fdputs.c \
|
2020-12-29 14:39:33 +00:00
|
|
|
lib/mes/ntoab.c \
|
2020-07-25 18:00:44 +00:00
|
|
|
lib/ctype/isdigit.c \
|
|
|
|
lib/ctype/isxdigit.c \
|
|
|
|
lib/ctype/isspace.c \
|
|
|
|
lib/ctype/isnumber.c \
|
|
|
|
lib/mes/abtol.c \
|
|
|
|
lib/stdlib/atoi.c \
|
|
|
|
lib/string/memcpy.c \
|
|
|
|
lib/stdlib/free.c \
|
|
|
|
lib/stdlib/realloc.c \
|
|
|
|
lib/string/strcpy.c \
|
|
|
|
lib/mes/itoa.c \
|
2020-08-16 12:45:18 +00:00
|
|
|
lib/mes/ltoa.c \
|
2020-07-25 18:00:44 +00:00
|
|
|
lib/mes/fdungetc.c \
|
|
|
|
lib/posix/setenv.c \
|
|
|
|
lib/linux/access.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
lib/linux/chmod.c \
|
2020-12-29 17:41:45 +00:00
|
|
|
lib/linux/ioctl3.c \
|
2020-07-25 18:00:44 +00:00
|
|
|
lib/m2/isatty.c \
|
|
|
|
lib/linux/fork.c \
|
2021-01-02 09:00:35 +00:00
|
|
|
lib/m2/execve.c \
|
2020-07-25 18:00:44 +00:00
|
|
|
lib/m2/execv.c \
|
2022-11-15 05:36:07 +00:00
|
|
|
lib/linux/wait4.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
lib/linux/waitpid.c \
|
2020-07-25 18:00:44 +00:00
|
|
|
lib/linux/gettimeofday.c \
|
2022-11-14 04:25:55 +00:00
|
|
|
lib/linux/clock_gettime.c \
|
2020-07-25 18:00:44 +00:00
|
|
|
lib/m2/time.c \
|
|
|
|
lib/linux/_getcwd.c \
|
2021-01-01 14:54:13 +00:00
|
|
|
lib/m2/getcwd.c \
|
2020-07-25 18:00:44 +00:00
|
|
|
lib/linux/dup.c \
|
|
|
|
lib/linux/dup2.c \
|
|
|
|
lib/string/strcmp.c \
|
|
|
|
lib/string/memcmp.c \
|
2020-08-18 21:01:53 +00:00
|
|
|
lib/linux/unlink.c \
|
|
|
|
src/m2.c
|
2020-04-22 06:05:37 +00:00
|
|
|
|
|
|
|
INCLUDES = \
|
|
|
|
include/mes/builtins.h \
|
|
|
|
include/mes/constants.h \
|
|
|
|
include/mes/mes.h \
|
|
|
|
include/mes/lib.h \
|
|
|
|
include/mes/lib-mini.h
|
|
|
|
|
|
|
|
MES_LIBC = \
|
|
|
|
lib/linux/$(MES_CPU)-mes-gcc/syscall.c \
|
|
|
|
lib/linux/_read.c \
|
|
|
|
lib/linux/_read.c \
|
|
|
|
lib/mes/__buffered_read.c
|
|
|
|
|
|
|
|
GCC_SOURCES = \
|
|
|
|
lib/mes/__mes_debug.c \
|
2020-10-18 12:55:24 +00:00
|
|
|
lib/mes/cast.c \
|
2020-04-22 06:05:37 +00:00
|
|
|
lib/mes/eputc.c \
|
2020-07-25 18:00:44 +00:00
|
|
|
lib/mes/eputs.c \
|
2020-04-22 06:05:37 +00:00
|
|
|
lib/mes/fdgetc.c \
|
|
|
|
lib/mes/fdputc.c \
|
|
|
|
lib/mes/fdputs.c \
|
|
|
|
lib/mes/fdungetc.c \
|
|
|
|
lib/mes/mes_open.c \
|
|
|
|
lib/mes/ntoab.c \
|
2020-07-25 18:00:44 +00:00
|
|
|
lib/mes/itoa.c \
|
2020-08-16 12:45:18 +00:00
|
|
|
lib/mes/ltoa.c \
|
2020-08-18 21:01:53 +00:00
|
|
|
lib/mes/assert_msg.c \
|
2022-05-03 20:51:21 +00:00
|
|
|
src/cc.c \
|
|
|
|
src/globals.c
|
2020-04-22 06:05:37 +00:00
|
|
|
|
|
|
|
mes-gcc: bin/mes-gcc
|
|
|
|
mes-m2: bin/mes-m2
|
|
|
|
|
2020-08-16 06:56:56 +00:00
|
|
|
gc-gcc: bin/gc-gcc
|
|
|
|
gc-m2: bin/gc-m2
|
|
|
|
|
2020-07-25 18:00:44 +00:00
|
|
|
bin/mes-gcc: simple.make $(GCC_SOURCES) $(MES_SOURCES) $(INCLUDES) | bin
|
2022-05-03 20:51:21 +00:00
|
|
|
$(CC) $(CFLAGS) -o $@ $(GCC_SOURCES) $(MES_SOURCES)
|
2020-10-18 21:15:11 +00:00
|
|
|
cp -f $@ bin/mes
|
2020-04-22 06:05:37 +00:00
|
|
|
|
2020-08-16 06:56:56 +00:00
|
|
|
bin/gc-gcc: simple.make $(GCC_SOURCES) $(TEST_GC_SOURCES) $(INCLUDES) | bin
|
2022-05-03 20:51:21 +00:00
|
|
|
$(CC) $(CFLAGS) -D GC_TEST=1 -o $@ $(GCC_SOURCES) $(TEST_GC_SOURCES)
|
2020-08-16 06:56:56 +00:00
|
|
|
|
2020-04-22 06:05:37 +00:00
|
|
|
M2_PLANET_INCLUDES = \
|
2022-11-14 04:25:55 +00:00
|
|
|
include/mes/config.h \
|
|
|
|
include/mes/lib-mini.h \
|
|
|
|
include/mes/lib.h \
|
2020-07-25 18:00:44 +00:00
|
|
|
include/linux/x86/syscall.h \
|
2022-11-14 04:25:55 +00:00
|
|
|
include/time.h \
|
|
|
|
include/sys/time.h \
|
2022-11-15 05:36:07 +00:00
|
|
|
include/m2/types.h \
|
2022-11-14 04:25:55 +00:00
|
|
|
include/sys/types.h \
|
|
|
|
include/stdio.h \
|
|
|
|
include/limits.h \
|
|
|
|
include/sys/stat.h \
|
|
|
|
include/fcntl.h \
|
|
|
|
include/signal.h \
|
2022-11-15 05:36:07 +00:00
|
|
|
include/sys/resource.h \
|
2020-04-22 06:05:37 +00:00
|
|
|
include/mes/mes.h \
|
2020-04-19 11:18:09 +00:00
|
|
|
include/mes/builtins.h \
|
2020-05-17 18:50:12 +00:00
|
|
|
include/mes/constants.h \
|
2020-07-25 18:00:44 +00:00
|
|
|
include/mes/symbols.h \
|
|
|
|
include/linux/$(M2_PLANET_ARCH)/syscall.h
|
|
|
|
|
|
|
|
M2_PLANET_SOURCES = \
|
|
|
|
$(M2_PLANET_INCLUDES:%.h=%.h) \
|
|
|
|
$(M2_SOURCES)
|
|
|
|
|
2022-05-03 20:51:21 +00:00
|
|
|
m2/mes-m2.M1: simple.make $(M2_PLANET_SOURCES) $(MES_SOURCES) $(M2_PLANET_INCLUDES) | m2
|
2020-07-25 18:00:44 +00:00
|
|
|
$(M2_PLANET) $(M2_PLANET_FLAGS) $(M2_PLANET_SOURCES:%=-f %) $(MES_SOURCES:%.c=-f %.c) -o $@ || rm -f $@
|
|
|
|
|
2022-05-03 20:51:21 +00:00
|
|
|
m2/mes-m2.blood-elf.M1: m2/mes-m2.M1 | m2
|
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 $< -o $@
|
2020-07-25 18:00:44 +00:00
|
|
|
|
2020-10-18 21:15:11 +00:00
|
|
|
m2/mes-m2.hex2: m2/mes-m2.blood-elf.M1
|
2020-07-25 18:00:44 +00:00
|
|
|
M1 \
|
|
|
|
--architecture $(M2_PLANET_ARCH) \
|
2020-08-09 17:25:25 +00:00
|
|
|
--little-endian \
|
2020-07-25 18:00:44 +00:00
|
|
|
-f lib/m2/x86/x86_defs.M1 \
|
|
|
|
-f lib/x86-mes/x86.M1 \
|
|
|
|
-f lib/linux/x86-mes-m2/crt1.M1 \
|
2020-10-18 21:15:11 +00:00
|
|
|
-f m2/mes-m2.M1 \
|
|
|
|
-f m2/mes-m2.blood-elf.M1 \
|
2020-07-25 18:00:44 +00:00
|
|
|
-o $@
|
|
|
|
|
2022-05-03 20:51:21 +00:00
|
|
|
bin/mes-m2: m2/mes-m2.hex2 | bin
|
|
|
|
hex2 \
|
|
|
|
--architecture $(M2_PLANET_ARCH) \
|
|
|
|
--little-endian \
|
|
|
|
--base-address 0x1000000 \
|
|
|
|
-f lib/linux/x86-mes/elf32-header.hex2 \
|
|
|
|
-f m2/mes-m2.hex2 \
|
2020-07-25 18:00:44 +00:00
|
|
|
-o $@
|
2020-10-18 21:15:11 +00:00
|
|
|
cp -f $@ bin/mes
|
2020-04-22 06:05:37 +00:00
|
|
|
|
|
|
|
# Clean up after ourselves
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
rm -rf bin/
|
|
|
|
|
|
|
|
.PHONY: check check-gcc check-m2 check-hello check-base check-gc check-mescc
|
|
|
|
check-gcc:
|
|
|
|
$(MAKE) -f simple.make check MES=bin/mes-gcc
|
|
|
|
check-m2:
|
|
|
|
$(MAKE) -f simple.make check MES=bin/mes-m2
|
|
|
|
|
|
|
|
check: check-hello check-base check-gc check-mescc
|
|
|
|
|
|
|
|
check-hello: $(MES)
|
|
|
|
echo '(display "hello\n")' | MES_BOOT=boot-01.scm $(MES)
|
|
|
|
|
|
|
|
check-base: $(MES)
|
|
|
|
MES_DEBUG=4 MES_PREFIX=mes MES=$(MES) tests/base.test
|
|
|
|
|
|
|
|
check-gc: $(MES)
|
|
|
|
MES_DEBUG=3 MES_ARENA=10000 MES_MAX_ARENA=10000 MES_BOOT=tests/gc.test $(MES)
|
|
|
|
|
|
|
|
check-mescc: $(MES)
|
|
|
|
rm -f a.out
|
|
|
|
# this already needs succesful GC
|
2022-05-03 20:51:21 +00:00
|
|
|
# LIBRARY_PATH=lib MES_DEBUG=1 MES_PREFIX=mes MES=$(MES) sh -x scripts/mescc -- -I include -nostdlib lib/mes/globals.c lib/string/strlen.c lib/mes/eputs.c scaffold/hello.c
|
|
|
|
LIBRARY_PATH=lib MES_DEBUG=1 MES_PREFIX=mes MES=$(MES) sh -x scripts/mescc -- -m 32 -I include -nostdlib lib/mes/globals.c lib/linux/$(MESCC_CPU)-mes-mescc/crt1.c scaffold/main.c
|
2020-04-22 06:05:37 +00:00
|
|
|
./a.out; r=$$?; if [ $$r != 42 ]; then exit 1; fi
|
|
|
|
|
|
|
|
|
|
|
|
# Directories
|
|
|
|
bin:
|
2022-05-03 20:51:21 +00:00
|
|
|
mkdir -p $@
|
|
|
|
|
|
|
|
m2:
|
|
|
|
mkdir -p $@
|
2020-04-22 06:05:37 +00:00
|
|
|
|
|
|
|
TAGS:
|
|
|
|
etags $(shell find . -name '*.c' -o -name '*.h') --language=scheme $(shell find mes module -name '*.mes' -o -name '*.scm')
|