2020-04-22 06:05:37 +00:00
|
|
|
# GNU Mes --- Maxwell Equations of Software
|
|
|
|
# Copyright © 2019 Jeremiah Orians <jeremiah@pdp10.guru>
|
|
|
|
# Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
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 \
|
|
|
|
-fno-builtin \
|
|
|
|
-Wno-discarded-qualifiers \
|
|
|
|
-Wno-discarded-array-qualifiers \
|
|
|
|
-Wno-ignored-qualifiers \
|
|
|
|
-Wno-incompatible-pointer-types \
|
|
|
|
-Wno-int-conversion
|
|
|
|
|
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 \
|
2020-07-25 18:00:44 +00:00
|
|
|
lib/m2/exit.c \
|
|
|
|
lib/mes/write.c \
|
|
|
|
lib/linux/x86-mes-m2/syscall.c \
|
|
|
|
lib/linux/brk.c \
|
|
|
|
lib/stdlib/malloc.c \
|
|
|
|
lib/string/memset.c \
|
|
|
|
\
|
|
|
|
lib/m2/read.c \
|
|
|
|
lib/mes/fdgetc.c \
|
|
|
|
lib/stdio/getchar.c \
|
|
|
|
lib/stdio/putchar.c \
|
|
|
|
lib/m2/open.c \
|
|
|
|
lib/m2/mes_open.c \
|
|
|
|
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 \
|
|
|
|
lib/m2/ntoab.c \
|
|
|
|
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 \
|
|
|
|
lib/m2/chmod.c \
|
|
|
|
lib/m2/ioctl.c \
|
|
|
|
lib/m2/isatty.c \
|
|
|
|
lib/linux/fork.c \
|
|
|
|
lib/m2/execve.c \
|
|
|
|
lib/m2/execv.c \
|
|
|
|
lib/m2/waitpid.c \
|
|
|
|
lib/linux/gettimeofday.c \
|
|
|
|
lib/m2/clock_gettime.c \
|
|
|
|
lib/m2/time.c \
|
|
|
|
lib/linux/_getcwd.c \
|
|
|
|
lib/m2/getcwd.c \
|
|
|
|
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
|
|
|
|
|
|
|
M2_TODO = \
|
|
|
|
lib/m2/file_print.c \
|
|
|
|
lib/m2/ntoab.c \
|
|
|
|
lib/mes/fdgetc.c \
|
|
|
|
lib/mes/fdungetc.c
|
|
|
|
|
|
|
|
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 \
|
|
|
|
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 \
|
|
|
|
src/cc.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
|
|
|
|
$(CC) $(CFLAGS) $(GCC_SOURCES) $(MES_SOURCES) -o $@
|
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
|
|
|
|
$(CC) $(CFLAGS) -D GC_TEST=1 $(GCC_SOURCES) $(TEST_GC_SOURCES) -o $@
|
|
|
|
|
2020-04-22 06:05:37 +00:00
|
|
|
M2_PLANET_INCLUDES = \
|
2020-07-25 18:00:44 +00:00
|
|
|
include/m2/lib.h \
|
|
|
|
include/linux/x86/syscall.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)
|
|
|
|
|
|
|
|
bin/mes-m2.M1: simple.make $(M2_PLANET_SOURCES) $(MES_SOURCES) $(M2_PLANET_INCLUDES) | bin
|
|
|
|
$(M2_PLANET) $(M2_PLANET_FLAGS) $(M2_PLANET_SOURCES:%=-f %) $(MES_SOURCES:%.c=-f %.c) -o $@ || rm -f $@
|
|
|
|
|
|
|
|
bin/mes-m2.blood-elf.M1: bin/mes-m2.M1
|
|
|
|
# blood-elf --32 -f $< -o $@
|
|
|
|
blood-elf -f $< -o $@
|
|
|
|
|
|
|
|
bin/mes-m2.hex2: bin/mes-m2.blood-elf.M1
|
|
|
|
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 \
|
|
|
|
-f bin/mes-m2.M1 \
|
|
|
|
-f bin/mes-m2.blood-elf.M1 \
|
|
|
|
-o $@
|
|
|
|
|
|
|
|
bin/mes-m2: bin/mes-m2.hex2
|
|
|
|
hex2 \
|
|
|
|
--architecture $(M2_PLANET_ARCH) \
|
2020-08-09 17:25:25 +00:00
|
|
|
--little-endian \
|
|
|
|
--base-address 0x1000000 \
|
2020-07-25 18:00:44 +00:00
|
|
|
-f lib/x86-mes/elf32-header.hex2 \
|
|
|
|
-f bin/mes-m2.hex2 \
|
|
|
|
-o $@
|
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
|
|
|
|
# MES_DEBUG=1 MES_PREFIX=mes MES=$(MES) sh -x scripts/mescc -- -I include -nostdlib lib/string/strlen.c lib/mes/eputs.c scaffold/hello.c
|
|
|
|
MES_DEBUG=1 MES_PREFIX=mes MES=$(MES) sh -x scripts/mescc -- -m 32 -I include -nostdlib lib/linux/$(MESCC_CPU)-mes-mescc/crt1.c scaffold/main.c
|
|
|
|
./a.out; r=$$?; if [ $$r != 42 ]; then exit 1; fi
|
|
|
|
|
|
|
|
|
|
|
|
# Directories
|
|
|
|
bin:
|
|
|
|
mkdir -p bin
|
|
|
|
|
|
|
|
TAGS:
|
|
|
|
etags $(shell find . -name '*.c' -o -name '*.h') --language=scheme $(shell find mes module -name '*.mes' -o -name '*.scm')
|