build: Support mescc-tools 0.5.2.
authorJan Nieuwenhuizen <janneke@gnu.org>
Sat, 7 Dec 2019 13:39:19 +0000 (14:39 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sat, 7 Dec 2019 13:39:19 +0000 (14:39 +0100)
* configure: Remove version check for mescc-tools.
Check for stage0 architecture flag type.
* configure.sh: Likewise.
* build-aux/build-scaffold.sh: Add stage0 flag type indirection.
* module/mescc/mescc.scm (arch-get-architecture): Likewise.

build-aux/build-scaffold.sh
build-aux/build.sh.in
build-aux/config.sh.in
configure
configure.sh
module/mescc.scm
module/mescc/mescc.scm
scripts/mescc.in
scripts/mescc.scm.in

index dc07f43245977548895fe98890b65dc3bc1ed430..42c62f468ad19eb3eb06011ad8f7422f32c339ba 100755 (executable)
@@ -44,13 +44,21 @@ fi
 
 case "$mes_cpu" in
     arm)
-        stage0_cpu=armv7l;;
+        stage0_arch=40
+        stage0_cpu=armv7l
+        ;;
     x86_64)
-        stage0_cpu=amd64;;
+        stage0_arch=2
+        stage0_cpu=amd64
+        ;;
     x86)
-        stage0_cpu=x86;;
+        stage0_arch=1
+        stage0_cpu=x86
+        ;;
     *)
-        stage0_cpu=$mes_cpu;;
+        stage0_arch=1
+        stage0_cpu=$mes_cpu
+        ;;
 esac
 
 trace "CCLD       ${srcdest}lib/$mes_cpu-mes-$compiler/exit-42.S" $CC\
@@ -64,9 +72,15 @@ trace "TEST       exit-42"
 [ $r != 42 ] && echo "  => $r"
 [ $r = 42 ]
 
+if $numbered_arch; then
+    stage0_cpu_flag="--Architecture $stage0_arch";
+else
+    stage0_cpu_flag="--architecture $stage0_cpu";
+fi
+
 trace "HEX2       ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-0exit-42.hex2" $HEX2\
       --LittleEndian\
-      --architecture $stage0_cpu\
+      $stage0_cpu_flag\
       --BaseAddress 0x1000000\
       -f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-0header.hex2\
       -f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-0exit-42.hex2\
@@ -80,7 +94,7 @@ trace "TEST       0exit-42"
 
 trace "HEX2       ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-body-exit-42.hex2" $HEX2\
       --LittleEndian\
-      --architecture $stage0_cpu\
+      $stage0_cpu_flag\
       --BaseAddress 0x1000000\
       -f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-header.hex2\
       -f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-body-exit-42.hex2\
@@ -107,7 +121,7 @@ trace "TEST       hello-mes"
 
 trace "HEX2       ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-0hello-mes.hex2" $HEX2\
       --LittleEndian\
-      --architecture $stage0_cpu\
+      $stage0_cpu_flag\
       --BaseAddress 0x1000000\
       -f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-0header.hex2\
       -f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-0hello-mes.hex2\
@@ -121,7 +135,7 @@ trace "TEST       0hello-mes"
 
 trace "HEX2       ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-body-hello-mes.hex2" $HEX2\
       --LittleEndian\
-      --architecture $stage0_cpu\
+      $stage0_cpu_flag\
       --BaseAddress 0x1000000\
       -f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-header.hex2\
       -f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-body-hello-mes.hex2\
index a7d81b629778656f7038db2a3efd9f8ecef5ef56..24b417ef49f9c4b7c604290c2f0362481f72a761 100644 (file)
@@ -116,7 +116,7 @@ fi
     LDFLAGS=
     ${SHELL} ${srcdest}build-aux/build-lib.sh
     ${SHELL} ${srcdest}build-aux/build-source-lib.sh
-    if bootstrap; then
+    if $bootstrap; then
         ${SHELL} ${srcdest}build-aux/build-mes.sh
     fi
 )
index 29006499b95f9c84712eb0f86fa52c5306ed7c0d..0f3783f2a56e84a918552c9abcfcc74da3f0d438 100644 (file)
@@ -54,6 +54,7 @@ abs_top_srcdir="@abs_top_srcdir@"
 arch="@arch@"
 build="@build@"
 host="@host@"
+numbered_arch=${numbered_arch-"@numbered_arch@"}
 
 bootstrap=${bootstrap-@bootstrap@}
 compiler=${compiler-@compiler@}
index f7ce134796950ab928131e92b73fb55d2bb9d47e..fe005f68b646f7fd9dfdeea418e52bcedf5b81f5 100755 (executable)
--- a/configure
+++ b/configure
@@ -448,9 +448,9 @@ Some influential environment variables:
            (deps (fold (lambda (program results)
                          (cons (check-program-version program) results))
                        '()
-                       (list (make-dep "hex2" #:version '(0 6))
-                             (make-dep "M1" #:version '(0 6))
-                             (make-dep "blood-elf" #:version '(0 6))
+                       (list (make-dep "hex2")
+                             (make-dep "M1")
+                             (make-dep "blood-elf")
                              (make-dep "diff" #:optional? #t)
                              (make-dep "guile" #:version '(2 0) #:commands '("guile-2.2" "guile-2.0" "guile-2" "guile") #:optional? #t)
                              (make-dep "mes" #:version '(0 20) #:optional? #t)
@@ -534,7 +534,13 @@ Some influential environment variables:
                       (file-name "bash" deps)
                       (and (file-exists? "/bin/sh") "/bin/sh")
                       (file-name "sh" deps)
-                      "sh")))
+                      "sh"))
+           (hex2 (file-name "hex2" deps))
+           (numbered-arch? (begin
+                             (stdout "checking for stage0 architecture flag... ")
+                             (let ((numbered? (and hex2 (string-contains (gulp-pipe (string-append hex2 " --help 2>&1" )) "--Architecture 12345"))))
+                               (stdout (if numbered? "numbered\n" "named\n"))
+                               numbered?))))
 
       (define* (substitute file-name pairs
                            #:key (target (if (string-suffix? ".in" file-name)
@@ -625,6 +631,7 @@ See \"Porting GNU Mes\" in the manual, or try --with-courage\n" mes-system)
                      ("@LDFLAGS@" . ,(or (getenv "LDFLAGS") "-static -g"))
                      ("@HEX2FLAGS@" . ,(or (getenv "HEX2FLAGS") ""))
                      ("@M1FLAGS@" . ,(or (getenv "M1FLAGS") ""))
+                     ("@numbered_arch@" . ,(if numbered-arch? "true" "false"))
 
                      ,@(map
                         (lambda (o)
@@ -687,6 +694,7 @@ GNU Mes is configured for
    libc:     " mes-libc "
    kernel:   " mes-kernel "
    system:   " mes-system "
+   tools:    " (if numbered-arch? "numbered" "named") " arch
 
 Run:
   " (or make "./build.sh") "           to build mes
index 704be03c1e99eb6645d3cbe88c45c97a0557f41f..8971406f8c6febd406faa2c7686c14a4146d9190 100755 (executable)
@@ -99,6 +99,14 @@ if test -z "$GUILE" -o "$GUILE" = true; then
 else
     GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-$(guile -c '(display (effective-version))')}
 fi
+
+numbered_arch=false
+mes_tools=named
+if ( $HEX2 --help 2>&1 ) | grep -q "\-\-Architecture 12345"; then
+    numbered_arch=true
+    mes_tools=numbered
+fi
+
 bindir=$(eval echo ${bindir-$prefix/bin})
 datadir=$(eval echo ${datadir-$prefix/share})
 docdir=$(eval echo ${docdir-$datadir/doc/mes})
@@ -164,6 +172,7 @@ subst () {
     -e s,"@MES_FOR_BUILD@,$MES_FOR_BUILD,"\
     -e s,"@MES_SEED@,$MES_SEED,"\
     -e s,"@MES_SEED@,$MES_SEED,"\
+    -e s,"@numbered_arch@,$numbered_arch,"\
     -e s,"@SHELL@,$SHELL,"\
     $1 > $2
 }
@@ -259,6 +268,7 @@ GNU Mes is configured for
    libc:     $mes_libc
    kernel:   $mes_kernel
    system:   $mes_system
+   tools:    $mes_tools arch
 
 Run:
   sh build.sh      to build mes
index d3231206f3d9ee86b177c4631f8ebab6fa72eefd..cf4db42cc65a5a6a0277ab02f81a2798cd98cc40 100644 (file)
@@ -41,6 +41,7 @@
 (define %includedir (getenv "%includedir"))
 (define %libdir (getenv "%libdir"))
 (define %version (getenv "%version"))
+(define %numbered-arch? (and=> (getenv "%numbered_arch") (lambda (x) (equal? x "true"))))
 
 (when (and=> (getenv "V") (lambda (v) (and (= (string-length v) 1) (> (string->number v) 1))))
   (format (current-error-port) "mescc[~a]...\n" %scheme))
@@ -75,6 +76,7 @@
             (nostartfiles)
             (nostdinc)
             (nostdlib)
+            (numbered-arch?)
             (preprocess (single-char #\E))
             (static)
             (std (value #t))
@@ -103,6 +105,7 @@ Options:
   -dumpmachine        display the compiler's target machine
   --base-address=ADRRESS
                       use BaseAddress ADDRESS [0x1000000]
+  --numbered-arch     mescc-tools use numbered arch
   -D DEFINE[=VALUE]   define DEFINE [VALUE=1]
   -E                  preprocess only; do not compile, assemble or link
   -g                  add debug info [GDB, objdump] TODO: hex2 footer
@@ -164,6 +167,8 @@ General help using GNU software: <http://gnu.org/gethelp/>
          (options (acons 'libdir %libdir options))
          (arch (option-ref options 'arch %host-arch))
          (options (if arch (acons 'arch arch options) options))
+         (numbered-arch? (option-ref options 'numbered-arch? %numbered-arch?))
+         (options (acons 'numbered-arch? numbered-arch? options))
          (dumpmachine? (option-ref options 'dumpmachine #f))
          (preprocess? (option-ref options 'preprocess #f))
          (compile? (option-ref options 'compile #f))
index 94a7380ffcab2d46b1ac1e30e76ee9838a3cbfb3..3c13f7049db49c73337dea36be0f1c8ce2867f43 100644 (file)
          (M1 (or (getenv "M1") "M1"))
          (command `(,M1
                     "--LittleEndian"
-                    "--architecture" ,(arch-get-architecture options)
+                    ,@(arch-get-architecture options)
                     "-f" ,(arch-find options (arch-get-m1-macros options))
                     ,@(append-map (cut list "-f" <>) M1-files)
                     "-o" ,hex2-file-name)))
                               `("-f" ,(arch-find options "crt1.o"))))
          (command `(,hex2
                     "--LittleEndian"
-                    "--architecture" ,(arch-get-architecture options)
+                    ,@(arch-get-architecture options)
                     "--BaseAddress" ,base-address
                     "-f" ,(arch-find options (string-append "elf" machine "-header.hex2"))
                     ,@start-files
           ((equal? arch "x86_64") "x86_64.M1"))))
 
 (define (arch-get-architecture options)
-  (let ((arch (arch-get options)))
-    (cond ((equal? arch "arm") "armv7l")
-          ((equal? arch "x86") "x86")
-          ((equal? arch "x86_64") "amd64"))))
+  (let* ((arch (arch-get options))
+        (numbered-arch? (option-ref options 'numbered-arch? #f))
+        (flag (if numbered-arch? "--Architecture" "--architecture")))
+    (list flag
+          (cond ((equal? arch "arm") (if numbered-arch? "40" "armv7l"))
+                ((equal? arch "x86") (if numbered-arch? "1" "x86"))
+                ((equal? arch "x86_64") (if numbered-arch? "2" "amd64"))))))
 
 (define (multi-opt option-name) (lambda (o) (and (eq? (car o) option-name) (cdr o))))
 (define (count-opt options option-name)
index 777d3dbdadb7d6bf0e97d7bb461c5c6ac19cbfdf..0780968a1ed2c67f5e7cd9731e1e51d55068807f 100644 (file)
@@ -43,6 +43,8 @@ includedir=${includedir-@includedir@}
 export includedir
 libdir=${libdir-@libdir@}
 export libdir
+numbered_arch=${numbered_arch=@numbered_arch@}
+export numbered_arch
 
 if [ ! -f $bindir/mescc.scm ]; then
    bindir=$(dirname $0)
index c4719d225b28f191d65d6d0e3a895ee540ede26b..e1d91eace483a2e225b664d63f2e6a49a91c4168 100644 (file)
 (define %arch (if (string-prefix? "@mes_cpu" "@mes_cpu@") %arch
                   "@mes_cpu@"))
 
+(define %numbered-arch? (if (getenv "numbered_arch") (and=> (getenv "numbered_arch")
+                                                            (lambda (x) (equal? x "true")))
+                            (if (string-prefix? "@numbered_arch" "@numbered_arch@") #f
+                                (equal? "@numbered_arch@" "true"))))
+
 (setenv "%prefix" %prefix)
 (setenv "%includedir" %includedir)
 (setenv "%libdir" %libdir)
 (setenv "%version" %version)
 (setenv "%arch" %arch)
+(setenv "%numbered_arch" (if %numbered-arch? "true" "false"))
 
 (cond-expand
  (mes