core: Implement stack and frame.
[mes.git] / configure
index 1bf3f64d69d2aa7a952aea587377a539c78f0cba..5cf1789ad1a56b1628b824d6c6ebbb5af70ca17e 100755 (executable)
--- a/configure
+++ b/configure
@@ -61,7 +61,7 @@ exec ${guile} -L . --no-auto-compile -e '(configure)' -s "$0" ${1+"$@"}
 
 (define *shell* "sh")
 (define PACKAGE "mes")
-(define VERSION "0.16.1")
+(define VERSION "0.18")
 
 ;;; Utility
 (define (logf port string . rest)
@@ -216,12 +216,15 @@ exec ${guile} -L . --no-auto-compile -e '(configure)' -s "$0" ${1+"$@"}
             (datadir (value #t))
             (docdir (value #t))
             (libdir (value #t))
+            (srcdir (value #t))
             (sysconfdir (value #t))
             (verbose (single-char #\v))
+            (with-cheating)
             (with-courage)
             (infodir (value #t))
             (mandir (value #t))
             (disable-silent-rules)
+            (enable-silent-rules)
 
             (enable-fast-install)       ; Ignored for Guix
             (includedir (value #t))     ; Ignored for Debian
@@ -255,6 +258,7 @@ Options:
       --host=HOST      cross-compile to build programs to run on HOST [BUILD]
   -v, --verbose        be verbose
   --with-courage       assert being courageous to configure for unsupported platform
+  --with-cheating      cheat using Guile instead of Mes
 
 Installation directories:
   --prefix=DIR         install in prefix DIR [~a]
@@ -277,6 +281,8 @@ Some influential environment variables:
   CC                C compiler command
   CFLAGS            C compiler flags
   CC32              x86 C compiler command
+  CC64_CFLAGS       x86_64 C compiler flags
+  CC64              x86_64 C compiler command
   CC32_CFLAGS       x86 C compiler flags
   GUILE             guile command
   GUILE_TOOLS       guile-tools command
@@ -284,6 +290,7 @@ Some influential environment variables:
   MES_SEED          location of mes-seed
   MESCC_TOOLS_SEED  location of mescc-tools-seed
   TCC               tcc C compiler command
+  TINYCC_PREFIX     location of tinycc [for tests/test2]
   TINYCC_SEED       location of tinycc-seed
 " PACKAGE VERSION (getenv "prefix")))
 
@@ -300,11 +307,12 @@ Some influential environment variables:
          (mandir (option-ref options 'infodir "${prefix}/share/man"))
          (sysconfdir (option-ref options 'sysconfdir "${prefix}/etc"))
 
-         (bindir (option-ref options 'bindir "${prefix}/etc"))
+         (bindir (option-ref options 'bindir "${prefix}/bin"))
          (datadir (option-ref options 'datadir "${prefix}/share"))
          (docdir (option-ref options 'docdir "${datadir}/doc/mes-${VERSION}"))
          (libdir (option-ref options 'libdir "${prefix}/lib"))
          (moduledir "${datadir}/mes/module")
+         (moduledir/ (gulp-pipe (string-append "echo " prefix "/share/mes/module/")))
          (guile-effective-version (effective-version))
          (guile-site-dir (if (equal? prefix ".") (canonicalize-path ".")
                              (string-append "${prefix}/share/guile/site/" guile-effective-version)))
@@ -312,21 +320,19 @@ Some influential environment variables:
                                     (string-append "${prefix}/lib/guile/" guile-effective-version "/site-ccache")))
 
          (srcdir (dirname (car (command-line))))
+         (srcdest (if (equal? srcdir ".") ""
+                      (string-append srcdir "/")))
          (abs-top-srcdir (canonicalize-path srcdir))
          (abs-top-builddir (canonicalize-path (getcwd)))
          (top-builddir (if (equal? srcdir ".") "."
                            abs-top-builddir))
-         (top-builddest (if (equal? srcdir ".") ""
-                        (string-append abs-top-builddir "/")))
-
 
+         (with-cheating? (option-ref options 'with-cheating #f))
          (with-courage? (option-ref options 'with-courage #f))
          (disable-silent-rules? (option-ref options 'disable-silent-rules #f))
+         (enable-silent-rules? (option-ref options 'enable-silent-rules #f))
          (vars (filter (cut string-index <> #\=) (option-ref options '() '())))
          (help? (option-ref options 'help #f)))
-    (define (srcdir-relative file-name)
-      (if (equal? srcdir ".") file-name
-          (string-append srcdir "/" file-name)))
     (when help?
       (print-help)
       (exit 0))
@@ -335,11 +341,13 @@ Some influential environment variables:
       (stderr "configure args=~s\n" args))
     (for-each (lambda (v) (apply setenv (string-split v #\=))) vars)
     (let* ((mes-seed (or (getenv "MES_SEED")
-                         (srcdir-relative "../mes-seed")))
+                         (string-append srcdest "../mes-seed")))
+           (tinycc-prefix (or (getenv "TINYCC_PREFIX")
+                              (string-append srcdest "../tinycc-prefix")))
            (tinycc-seed (or (getenv "TINYCC_SEED")
-                            (srcdir-relative "../tinycc-seed")))
+                            (string-append srcdest "../tinycc-seed")))
            (mescc-tools-seed (or (getenv "MESCC_TOOLS_SEED")
-                                 (srcdir-relative "../mescc-tools-seed")))
+                                 (string-append srcdest "../mescc-tools-seed")))
            (deps (fold (lambda (program results)
                          (cons (check-program-version program) results))
                        '()
@@ -347,10 +355,10 @@ Some influential environment variables:
                              (make-dep "guix" '(0 13) #:optional? #t)
                              (make-dep "bash" '(2 0) #:optional? #t)
                              (make-dep "guile-tools" '(2 0))
-                             (make-dep "mes-seed" '(0 16 1) #:optional? #t
+                             (make-dep "mes-seed" '(0 18) #:optional? #t
                                        #:commands (list (string-append mes-seed "/refresh.sh"))
                                        #:file-name mes-seed)
-                             (make-dep "tinycc-seed" '(0 16) #:optional? #t
+                             (make-dep "tinycc-seed" '(0 18) #:optional? #t
                                        #:commands (list (string-append tinycc-seed "/refresh.sh"))
                                        #:file-name tinycc-seed)
                              (make-dep "cc" '(2 95) #:commands '("gcc"))
@@ -358,16 +366,19 @@ Some influential environment variables:
                              (make-dep "cc32" '(2 95)
                                        #:optional? #t
                                        #:commands '("i686-unknown-linux-gnu-gcc"))
+                             (make-dep "cc64" '(2 95)
+                                       #:optional? #t
+                                       #:commands '("gcc"))
                              (make-dep "M1" '(0 3))
                              (make-dep "blood-elf" '(0 1))
                              (make-dep "hex2" '(0 3))
                              (make-dep "tcc" '(0 9 26) #:optional? #t #:version-option "-v")
                              (make-dep "makeinfo" '(5) #:optional? #t)
-                             (make-dep "dot" '(2) #:version-option "-V")
+                             (make-dep "dot" '(2) #:version-option "-V" #:optional? #t)
                              (make-dep "help2man" '(1 47) #:optional? #t)
                              (make-dep "perl" '(5) #:optional? #t)
                              (make-dep "git" '(2) #:optional? #t))))
-           (deps (cons (check-program-version (make-dep "nyacc" '(0 80 41) #:commands (list (string-append (file-name "guile" deps) " -c '(use-modules (nyacc lalr)) (display *nyacc-version*)'")) #:file-name #t))
+           (deps (cons (check-program-version (make-dep "nyacc" '(0 86 0) #:commands (list (string-append (file-name "guile" deps) " -c '(use-modules (nyacc lalr)) (display *nyacc-version*)'")) #:file-name #t))
                        deps))
            (deps (if (file-name "cc" deps)
                      (cons* (check-header-c (make-dep "stdio.h"))
@@ -377,6 +388,9 @@ Some influential environment variables:
            (deps (cons (check-file (make-dep "mescc-tools-seed" '(0) #:optional? #t
                                              #:file-name mescc-tools-seed))
                        deps))
+           (deps (cons (check-file (make-dep "tinycc-prefix" '(0) #:optional? #t
+                                             #:file-name tinycc-prefix))
+                       deps))
            (missing (filter (conjoin (negate dependency-file-name)
                                      (negate dependency-optional?)) deps)))
 
@@ -409,15 +423,15 @@ Some influential environment variables:
           (stdout "PACKAGE:=~a\n" PACKAGE)
           (stdout "VERSION:=~a\n" VERSION)
 
-          (stdout "ARCH:=~a\n" arch)
+          (stdout "arch:=~a\n" arch)
           (stdout "build:=~a\n" build-type)
           (stdout "host:=~a\n" host-type)
 
-          (stdout "top_builddest:=~a\n" top-builddest)
           (stdout "top_builddir:=~a\n" top-builddir)
           (stdout "abs_top_builddir:=~a\n" abs-top-builddir)
           (stdout "abs_top_srcdir:=~a\n" abs-top-srcdir)
 
+          (stdout "srcdest:=~a\n" srcdest)
           (stdout "srcdir:=~a\n" srcdir)
 
           (stdout "prefix:=~a\n" (gulp-pipe (string-append "echo " prefix)))
@@ -439,47 +453,57 @@ Some influential environment variables:
           (stdout "GUILE_EFFECTIVE_VERSION:=~a\n" (effective-version))
 
           (when disable-silent-rules?
-            (stdout "BUILD_DEBUG:=1\n"))
+            (stdout "V:=1\n"))
+
+          (when with-cheating?
+            (stdout "MES:=guile\n"))
 
           (for-each (lambda (o)
                       (stdout "~a:=~a\n" o (or (getenv o) "")))
                     '(
                       "CFLAGS"
                       "CC32_CFLAGS"
+                      "CC64_CFLAGS"
                       "HEX2FLAGS"
                       "M1FLAGS"
-                      "CC32_CFLAGS"
                       "MES_CFLAGS"
                       ))))
 
-      (let ((pairs `(("@srcdir@" . ,abs-top-srcdir)
+      (let ((pairs `(("@srcdest@" . ,srcdest)
+                     ("@srcdir@" . ,srcdir)
                      ("@abs_top_srcdir@" . ,abs-top-srcdir)
                      ("@abs_top_builddir@" . ,abs-top-builddir)
                      ("@top_builddir@" . ,top-builddir)
-                     ("@top_builddest@" . ,top-builddest)
                      ("@BASH@" . ,(file-name "bash" deps))
                      ("@GUILE@" . ,(file-name "guile" deps))
+                     ("@MES@" . ,(file-name "guile" deps))
+                     ("@prefix@" . ,prefix)
                      ("@guile_site_dir@" . ,guile-site-dir)
                      ("@guile_site_ccache_dir@" . ,guile-site-ccache-dir)
                      ("@VERSION@" . ,VERSION)
-                     ("mes/module/" . ,(string-append moduledir "/")))))
+                     ("@arch@" . ,arch)
+                     ("mes/module/" . ,(string-append moduledir/)))))
         (for-each (lambda (o)
-                    (let* ((src (srcdir-relative o))
+                    (let* ((src (string-append srcdest o))
                            (target (string-drop-right o 3))
                            (target (if (not (string-prefix? "build-aux/" target)) target
                                        (string-drop target (string-length "build-aux/")))))
                       (substitute src pairs #:target target)))
                   '(
+                    "build-aux/GNUmakefile.in"
+                    "build-aux/build.sh.in"
+                    "build-aux/check.sh.in"
+                    "build-aux/install.sh.in"
                     "build-aux/pre-inst-env.in"
+                    "build-aux/uninstall.sh.in"
                     "mes/module/mes/boot-0.scm.in"
                     "scripts/mescc.in"
-                    ))
-        (when (not (equal? srcdir "."))
-          (substitute (string-append srcdir "/build-aux/GNUmakefile.in")
-                      pairs
-                      #:target "GNUmakefile")
-          (system (string-append "cd mes/module/mes && ln -sf " abs-top-srcdir "/mes/module/mes/*.mes ."))))
+                    )))
+      (chmod "build.sh" #o755)
+      (chmod "check.sh" #o755)
+      (chmod "install.sh" #o755)
       (chmod "pre-inst-env" #o755)
+      (chmod "uninstall.sh" #o755)
       (chmod "scripts/mescc" #o755)
       (let ((make (and=> (file-name "make" deps) basename)))
         (format (current-output-port)