diff --git a/build-aux/bootstrap.sh.in b/build-aux/bootstrap.sh.in index 67d920dc..b2d56c50 100644 --- a/build-aux/bootstrap.sh.in +++ b/build-aux/bootstrap.sh.in @@ -35,6 +35,11 @@ MES_PREFIX=${MES_PREFIX-$PWD} . ${srcdest}build-aux/configure-lib.sh . ${srcdest}build-aux/cflags.sh +if test -n "@M2_PLANET@"; then + echo " KAEM kaem.run" + kaem --strict --verbose +fi + CPPFLAGS="-D HAVE_CONFIG_H=1 -I include" libdir=$PWD/lib export libdir diff --git a/build-aux/build.sh.in b/build-aux/build.sh.in index db6184b5..d4120128 100644 --- a/build-aux/build.sh.in +++ b/build-aux/build.sh.in @@ -1,7 +1,7 @@ #! /bin/sh # GNU Mes --- Maxwell Equations of Software -# Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen +# Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen # # This file is part of GNU Mes. # @@ -38,6 +38,25 @@ set -u . ./config.sh . ${srcdest}build-aux/cflags.sh +case "$mes_cpu" in + arm) + stage0_arch=40 + stage0_cpu=armv7l + ;; + x86_64) + stage0_arch=2 + stage0_cpu=amd64 + ;; + x86) + stage0_arch=1 + stage0_cpu=x86 + ;; + *) + stage0_arch=1 + stage0_cpu=$mes_cpu + ;; +esac + if $courageous; then echo "Applying courage" set +e @@ -97,11 +116,27 @@ fi -I ${srcdest}include -I ${srcdest}include/$mes_kernel/$mes_cpu " - if test $compiler = gcc; then + if test "$compiler" != bootstrap; then ${SHELL} ${srcdest}build-aux/build-mes.sh fi ) +if test -n "$M2_PLANET" && test "$mes_cpu" == "x86"; then + ( + . ${srcdest}build-aux/trace.sh + if [ -z "$V" -o "$V" = 0 ]; then + __verbose= + else + __verbose=--verbose + fi + trace "KAEM scaffold/main.kaem" kaem --strict $__verbose -f scaffold/main.kaem + trace "KAEM scaffold/hello.kaem" kaem --strict $__verbose -f scaffold/hello.kaem + trace "KAEM scaffold/argv.kaem" kaem --strict $__verbose -f scaffold/argv.kaem + trace "KAEM scaffold/read.kaem" kaem --strict $__verbose -f scaffold/read.kaem + trace "KAEM kaem.run" kaem --strict $__verbose + ) +fi + ( mkdir -p mescc-lib cp config.sh mescc-lib diff --git a/build-aux/config.sh.in b/build-aux/config.sh.in index 2e821903..8b271423 100644 --- a/build-aux/config.sh.in +++ b/build-aux/config.sh.in @@ -35,8 +35,10 @@ GUIX="@GUIX@" HELP2MAN="@HELP2MAN@" HEX2="@HEX2@" LDFLAGS=${LDFLAGS-"@LDFLAGS@"} +KAEM="@KAEM@" MAKEINFO="@MAKEINFO@" M1="@M1@" +M2_PLANET="@M2_PLANET@" MES_FOR_BUILD="@MES_FOR_BUILD@" NYACC="@NYACC@" PACKAGE="@PACKAGE@" @@ -99,8 +101,10 @@ export V export colors export compiler export courageous +export mes_cpu export srcdest export srcdir +export stage0_cpu export GUILE_AUTO_COMPILE export MES_PREFIX export TESTS diff --git a/build-aux/export.make b/build-aux/export.make index 505d5a6e..3bfb0bff 100644 --- a/build-aux/export.make +++ b/build-aux/export.make @@ -50,6 +50,7 @@ export mes_cpu export mes_bits export mes_libc export mes_kernel +export stage0_cpu ifdef V export V diff --git a/build-aux/install.sh.in b/build-aux/install.sh.in index db4c6436..340faf5f 100644 --- a/build-aux/install.sh.in +++ b/build-aux/install.sh.in @@ -47,6 +47,9 @@ cp $_v bin/mes ${DESTDIR}${bindir}/mes if test -f bin/mes-gcc; then cp $_v bin/mes-gcc ${DESTDIR}${bindir}/mes-gcc fi +if test -f bin/mes-m2; then + cp $_v bin/mes-m2 ${DESTDIR}${bindir}/mes-m2 +fi if test -f bin/mes-mescc; then cp $_v bin/mes-mescc ${DESTDIR}${bindir}/mes-mescc fi diff --git a/configure b/configure index b5eeb204..bf0d1d7f 100755 --- a/configure +++ b/configure @@ -457,6 +457,8 @@ Some influential environment variables: (list (make-dep "hex2" #:version '(1 0 0)) (make-dep "M1" #:version '(1 0 0)) (make-dep "blood-elf" #:version '(1 0 0)) + (make-dep "kaem" #:version '(1 0 0) #:optional? #t) + (make-dep "M2-Planet" #:version '(0 1 3) #:optional? #t) (make-dep "diff" #:optional? #t) (make-dep "guile" #:version '(2 0) #:commands '("guile-3.0" "guile-3" "guile-2.2" "guile-2.0" "guile-2" "guile") #:optional? #t) (make-dep "mes" #:version '(0 22) #:optional? #t) @@ -514,7 +516,7 @@ Some influential environment variables: ")) deps) deps)) - (mesc? (file-name "cc is MES C" deps)) + (mescc? (file-name "cc is Mes C" deps)) (deps (if cc (cons (check-compile-c cc (make-dep "cc is Tiny C" #:data "#if !defined (__TINYC__) #error no tinycc @@ -543,7 +545,7 @@ Some influential environment variables: (cut member <> '("pc" "portbld" "unknown"))) (cdr host-type-list)))) (mes-kernel (if (string-prefix? "freebsd" mes-kernel) "freebsd" mes-kernel)) - (mes-compiler (cond (gcc? "gcc") (tcc? "gcc") (else "mescc"))) + (mes-compiler (cond (gcc? "gcc") (tcc? "gcc") (mescc? "mescc") (else "bootstrap"))) (mes-system (string-join (list mes-cpu mes-kernel "mes") "-")) (bash (or (and (file-exists? "/bin/bash") "/bin/bash") (file-name "bash" deps) @@ -637,6 +639,8 @@ See \"Porting GNU Mes\" in the manual, or try --with-courage\n" mes-system) ("@GUILE_LOAD_PATH@" . ,(string-join guile-load-path ":")) ("@GUIX@" . ,(or (file-name "guix" deps) "")) ("@HELP2MAN@" . ,(or (file-name "help2man" deps) "")) + ("@KAEM@" . ,(or (file-name "kaem" deps) "")) + ("@M2_PLANET@" . ,(or (file-name "M2-Planet" deps) "")) ("@MAKEINFO@" . ,(or (file-name "makeinfo" deps) "")) ("@MES_FOR_BUILD@" . ,(or (file-name "mes" deps) guile)) @@ -657,8 +661,8 @@ See \"Porting GNU Mes\" in the manual, or try --with-courage\n" mes-system) (cons (string-append "@" (variable-name o) "@") (or (format #f "~a" (dependency-file-name o)) ""))) deps)))) - (unless cc - (format (current-error-port) "must supply a C compiler") + (unless (or cc m2-planet) + (format (current-error-port) "must supply C compiler or M2-Planet\n") (exit 2)) (for-each (lambda (o) (let* ((src (string-append srcdest o)) diff --git a/configure.sh b/configure.sh index fa7b8b29..8f802877 100755 --- a/configure.sh +++ b/configure.sh @@ -77,6 +77,8 @@ GUILE=${GUILE-$(command -v guile)} || true HEX2=${HEX2-$(command -v hex2)} LDPFLAGS=${LDFLAGS-} M1=${M1-$(command -v M1)} +M2_PLANET=${M1-$(command -v M2-Planet)} +KAEM=${KAEM-$(command -v kaem)} MES_FOR_BUILD=${MES_FOR_BUILD-$(command -v mes || command -v guile || echo mes)} GIT=${GIT-$(command -v git)} || true PERL=${PERL-$(command -v perl)} || true @@ -167,6 +169,8 @@ subst () { -e s,"@HEX2FLAGS@,$HEX2FLAGS,"\ -e s,"@M1@,$M1,"\ -e s,"@M1FLAGS@,$M1FLAGS,"\ + -e s,"@M2_PLANET@,$M2_PLANET,"\ + -e s,"@KAEM@,$KAEM,"\ -e s,"@MES_FOR_BUILD@,$MES_FOR_BUILD,"\ -e s,"@numbered_arch@,$numbered_arch,"\ -e s,"@SHELL@,$SHELL,"\ diff --git a/kaem.run b/kaem.run index b9ef84d2..bd9c1ea4 100644 --- a/kaem.run +++ b/kaem.run @@ -22,6 +22,8 @@ mes_cpu=${mes_cpu:-x86} stage0_cpu=${stage0_cpu:-x86} +mkdir -p m2 + M2-Planet \ --debug \ --architecture ${stage0_cpu} \ @@ -112,9 +114,9 @@ M2-Planet \ -f src/struct.c \ -f src/symbol.c \ -f src/vector.c \ - -o bin/mes.M1 + -o m2/mes.M1 -blood-elf -f bin/mes.M1 -o bin/mes.blood-elf-M1 +blood-elf -f m2/mes.M1 -o m2/mes.blood-elf-M1 M1 \ --architecture ${stage0_cpu} \ @@ -122,17 +124,19 @@ M1 \ -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 \ - -f bin/mes.M1 \ - -f bin/mes.blood-elf-M1 \ - -o bin/mes.hex2 + -f m2/mes.M1 \ + -f m2/mes.blood-elf-M1 \ + -o m2/mes.hex2 +mkdir -p bin hex2 \ --architecture ${stage0_cpu} \ --little-endian \ --base-address 0x1000000 \ -f lib/m2/${mes_cpu}/ELF-${mes_cpu}.hex2 \ - -f bin/mes.hex2 \ + -f m2/mes.hex2 \ -o bin/mes-m2 echo Running mes-m2 ./bin/mes-m2 -c "(display 'Hello,M2-mes!) (newline)" +cp bin/mes-m2 bin/mes diff --git a/simple.make b/simple.make index 60069414..5dfb7c68 100644 --- a/simple.make +++ b/simple.make @@ -180,6 +180,7 @@ gc-m2: bin/gc-m2 bin/mes-gcc: simple.make $(GCC_SOURCES) $(MES_SOURCES) $(INCLUDES) | bin $(CC) $(CFLAGS) $(GCC_SOURCES) $(MES_SOURCES) -o $@ + cp -f $@ bin/mes bin/gc-gcc: simple.make $(GCC_SOURCES) $(TEST_GC_SOURCES) $(INCLUDES) | bin $(CC) $(CFLAGS) -D GC_TEST=1 $(GCC_SOURCES) $(TEST_GC_SOURCES) -o $@ @@ -197,32 +198,33 @@ 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/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 +m2/mes-m2.blood-elf.M1: m2/mes-m2.M1 # blood-elf --32 -f $< -o $@ blood-elf -f $< -o $@ -bin/mes-m2.hex2: bin/mes-m2.blood-elf.M1 +m2/mes-m2.hex2: m2/mes-m2.blood-elf.M1 M1 \ --architecture $(M2_PLANET_ARCH) \ --little-endian \ -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 \ + -f m2/mes-m2.M1 \ + -f m2/mes-m2.blood-elf.M1 \ -o $@ -bin/mes-m2: bin/mes-m2.hex2 +bin/mes-m2: m2/mes-m2.hex2 hex2 \ --architecture $(M2_PLANET_ARCH) \ --little-endian \ --base-address 0x1000000 \ -f lib/x86-mes/elf32-header.hex2 \ - -f bin/mes-m2.hex2 \ + -f m2/mes-m2.hex2 \ -o $@ + cp -f $@ bin/mes # Clean up after ourselves .PHONY: clean