guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

15/15: Scheme-only bootstrap: WIP


From: guix-commits
Subject: 15/15: Scheme-only bootstrap: WIP
Date: Thu, 10 Jan 2019 17:31:50 -0500 (EST)

janneke pushed a commit to branch wip-bootstrap
in repository guix.

commit b6edf6446167fde1d91ad2a64151870857a1fcd4
Author: Jan Nieuwenhuizen <address@hidden>
Date:   Tue Dec 4 23:20:18 2018 +0100

    Scheme-only bootstrap: WIP
---
 gnu/packages/commencement.scm | 2882 +++++++++++++++++++++++++++++++++++++----
 1 file changed, 2612 insertions(+), 270 deletions(-)

diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index d015976..7b849ef 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -85,25 +85,31 @@
   (package
     (inherit mes)
     (name "mes-boot0")
-    ;; (source (origin
-    ;;           (method url-fetch)
-    ;;           (uri (string-append
-    ;;                 "http://lilypond.org/janneke/mes/";
-    ;;                 "mes-0.19-20-g5913a812.tar.Z"))
-    ;;           (sha256
-    ;;            (base32
-    ;;             "1n8lp9sx7rwj36dnabn9l8x8y8svb4r47401v3ddgwd2sm9mw6ba"))))
     (source (origin
               (method url-fetch)
               (uri (string-append
                     "http://lilypond.org/janneke/mes/";
-                    "mes-0.19-22-g2654869b.tar"))
+                    "mes-0.19-46-g4b921d1b.tar"))
               (sha256
                (base32
-                "0lyn53aynqz98b6nvbgxr61hws27bm06gdqs1qsvy08q9wydlc3s"))))
+                "1ar217kzl59cx9bk0jw9xw0ql3jsrmps3f0qqbqidr9k0vaa7jmp"))))
     (native-inputs '())
     (propagated-inputs '())))
 
+(define nyacc-boot
+  (package
+    (inherit nyacc)
+    (name "nyacc-boot")
+    (version "0.86.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "http://lilypond.org/janneke/mes/";
+                    "nyacc-" version ".tar"))
+              (sha256
+               (base32
+                "1912yx1vr9l97gr0wddm9j7f0p3wvfc410dmvdmg11jvjssvmdjp"))))))
+
 (define-public mes-boot
   (package-with-bootstrap-guile
    (package
@@ -185,7 +191,9 @@
                ;; fail fast tests
                ;; (invoke "sh" "-x" "build-aux/test.sh" "scaffold/tests/t")
                ;; (invoke "sh" "-x" "build-aux/test.sh" 
"scaffold/tests/63-struct-cell")
+               (setenv "V" "0")
                (setenv "MES_PREFIX" "mes")
+               (setenv "MES_DEBUG" "1")
                (invoke "sh" "check.sh"))))
           (replace 'install
             (lambda _
@@ -225,7 +233,7 @@
   ;; mature, this package should use the 0.9.27 sources (or later).
   (let ((version "0.9.26")
         (revision "6")
-        (commit "c004e9a34fb026bb44d211ab98bb768e79900eef"))
+        (commit "337acca2b8666375f97c0522ebc318bdce8bfe81"))
     (package-with-bootstrap-guile
      (package
        (inherit tcc)
@@ -242,11 +250,11 @@
        (source (origin
                  (method url-fetch)
                  (uri (string-append
-                       "http://lilypond.org/janneke/tinycc/";
+                       "http://lilypond.org/janneke/mes/";
                        "tinycc-" commit ".tar"))
                  (sha256
                   (base32
-                   "1hmzn1pq0x22ppd80hyrn5qzqq94mxd0ychzj6vrr2vnj2frjv5b"))))
+                   "1336cbnpq6g8gyhznrn8hlicn63g2xn7znzdmm298jiyrxca0gmd"))))
        (build-system gnu-build-system)
        (supported-systems '("i686-linux" "x86_64-linux"))
        (inputs '())
@@ -262,7 +270,10 @@
        (arguments
         `(#:implicit-inputs? #f
           #:guile ,%bootstrap-guile
-          #:strip-binaries? #f ; binutil's strip b0rkes MesCC/M1/hex2 binaries
+          
;;/gnu/store/ang6n8d9yz86zfiy0arsydh6pp9fwk97-tcc-boot0-0.9.26-6.337acca/lib/tests/string/70-strchr:
 error: offset + size of segment 2 (type 1) exceeds total size
+          #:validate-runpath? #f ; no dynamic executables
+          #:strip-binaries? #f   ; no strip yet
+          ;;#:system "i686-linux"
           #:phases
           (modify-phases %standard-phases
             (add-before 'unpack 'setenv
@@ -277,7 +288,7 @@
                        (bootstrap-mes (assoc-ref %build-inputs 
"bootstrap-mes")))
                   (with-directory-excursion ".."
                     (and
-                   ;; FIXME: tar --strip broken?
+                     ;; FIXME: tar --strip broken?
                      ;; (mkdir-p "nyacc-source")
                      ;; (invoke "tar" "--strip=1" "-C" "nyacc-source"
                      ;;         "-xvf" nyacc-source)
@@ -314,28 +325,53 @@
                   (setenv "MES" "mes")
                   (setenv "GUILE_LOAD_PATH" "nyacc")
 
-                  ;; (invoke "sh" "configure"
-                  ;;         "--prefix=$PREFIX"
-                  ;;         (string-append "--elfinterp=" interpreter)
-                  ;;         "--crtprefix=."
-                  ;;         "--tccdir=.")
+                  (if #f ;; needs at least Gash' 100-test-false.sh to pass.
+                      (invoke "sh" "-x" "configure"
+                              "--prefix=$PREFIX"
+                              (string-append "--elfinterp=" interpreter)
+                              "--crtprefix=."
+                              "--tccdir=.")
 
-                  (with-output-to-file "config.h"
-                    (lambda _
-                      (display (string-append "
+                      (with-output-to-file "config.h"
+                        (lambda _
+                          (display (string-append "
 #ifndef CONFIG_TCCDIR
 #define CONFIG_TCCDIR \"" out "/lib/tcc\"
 #endif
 #define GCC_MAJOR 0
 #define GCC_MINOR 0
 #define TCC_VERSION \"0.9.26\"
-"))))
+")))))
                   )))
             (replace 'build
               (lambda _
                 (substitute* "bootstrap.sh"
-                  (("^    cmp") "#    cmp"))
-                (invoke "sh" "bootstrap.sh")))
+                  (("^( *)cmp" all indent) (string-append indent "#cmp")))
+
+              (let ((bootstrap.sh (open-file "bootstrap.sh" "a")))
+                (display "
+./tcc -c -I $MES_PREFIX/include -I $MES_PREFIX/lib $MES_PREFIX/lib/libc+gnu.c
+./tcc -ar rc libc-new.a libc+gnu.o
+"
+                         bootstrap.sh)
+                (close bootstrap.sh))
+
+;;               (let ((boot.sh (open-file "boot.sh" "a")))
+;;                 (display "
+;; rm -f libc.a libc+gnu.o
+;; ./${PROGRAM_PREFIX}tcc -c -I $MES_PREFIX/include -I $MES_PREFIX/lib 
$MES_PREFIX/lib/libc+gnu.c
+;; ./${PROGRAM_PREFIX}tcc -ar rc libc.a libc+gnu.o
+;; "
+;;                          boot.sh)
+;;                 (close boot.sh))
+
+              ;; Show some progress
+              (substitute* "bootstrap.sh"
+                (("^( 
*)((cp|ls|mkdir|rm|[.]/tcc|[.]/[$][{PROGRAM_PREFIX[}]tcc) [^\"]*[^\\])\n" all 
space cmd)
+                 (string-append space "echo \"" cmd "\"\n"
+                                space cmd "\n")))
+
+                (invoke "sh"  "bootstrap.sh")))
             (replace 'check
               (lambda _
                 (setenv "DIFF" "diff.scm")
@@ -349,6 +385,18 @@
             (replace 'install
               (lambda _
 
+              (let ((install.sh (open-file "install.sh" "a")))
+                (display "
+chmod +w $PREFIX/lib
+cp $PREFIX/lib/libc.a $PREFIX/lib/libc-boot.a
+chmod +w $PREFIX/lib/libc.a
+rm -f $PREFIX/lib/libc.a
+cp libc-new.a $PREFIX/lib/libc-new.a
+cp libc-new.a $PREFIX/lib/libc.a
+"
+                         install.sh)
+                (close install.sh))
+
                 ;; Show some progress
                 (substitute* "install.sh"
                   (("^( *)((cp|ls|mkdir|rm|tar|./[$][{PROGRAM_PREFIX[}]tcc) 
[^\"]*[^\\])\n" all space cmd)
@@ -369,290 +417,1934 @@
                (variable "LIBRARY_PATH")
                (files '("lib")))))))))
 
-(define tcc-boot
+(define-public make-mesboot0
   (package-with-bootstrap-guile
    (package
-     (inherit tcc-boot0)
-     (name "tcc-boot")
-     (version "0.9.27")
+     (inherit gnu-make)
+     (name "make-mesboot0")
+     (version "3.80")
      (source (origin
-               (inherit (package-source tcc))
-               (patches (search-patches "tcc-boot-0.9.27.patch"))))
-     (build-system gnu-build-system)
+               (method url-fetch)
+               (uri (string-append "http://lilypond.org/janneke/mes/make-";
+                                   version ".tar"))
+               (sha256
+                (base32
+                 "0x1jwszfq9gv798flh6mj99vrp3l57wc366xw84x14vb0n5i80cg"))))
+     (supported-systems '("i686-linux" "x86_64-linux"))
      (inputs '())
      (propagated-inputs '())
-     (native-inputs
-      `(("mes" ,mes-boot)
-        ("tcc" ,tcc-boot0)
+     (native-inputs `(("tcc" ,tcc-boot0)
 
-        ("coreutils" , %bootstrap-coreutils&co)))
+                      ("guile" ,%bootstrap-guile)
+                      ("gash" ,%bootstrap-gash)))
      (arguments
       `(#:implicit-inputs? #f
         #:guile ,%bootstrap-guile
-        #:strip-binaries? #f            ; binutil's strip b0rkes MesCC/M1/hex2
-                                        ; binaries, tcc-boot also comes with
-                                        ; MesCC/M1/hex2-built binaries
+        #:configure-flags `("CC=tcc"
+                            "CPP=tcc -E"
+                            "LD=tcc"
+                            "--build=i686-unknown-linux-gnu"
+                            "--host=i686-unknown-linux-gnu"
+                            "--disable-nls")
+        #:modules ((guix build gnu-build-system)
+                   (guix build utils)
+                   (srfi srfi-1)
+                   (srfi srfi-26))
+        #:strip-binaries? #f            ; no strip yet
         #:phases
         (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append gash "/libexec/gash:" (getenv 
"PATH")))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                (setenv "CONFIG_SHELL" (string-append gash "/bin/gash"))
+                (setenv "SHELL" (string-append gash "/bin/gash"))
+                #t)))
+          (delete 'patch-generated-file-shebangs) ; no perl
+          (add-after 'unpack 'patch-configure
+            (lambda _
+              (substitute* "configure"
+                ;; Gash temporarily lacks job control support
+                (("[(] sleep [)] &" all)
+                 (string-append "# " all)))
+              (substitute* "build.sh.in"
+                (("@REMOTE@") "stub"))
+              (setenv "CPPFLAGS" "-D__alloca=alloca")
+              (setenv "make_cv_union_wait" "no")
+              ;; avoid Gash(?) bug
+              ;; tcc: error: file './getloadavg$U.c' not found
+              (setenv "ac_cv_objext" ".o")
+              #t))
           (replace 'configure
-            (lambda* (#:key outputs #:allow-other-keys)
+            (lambda* (#:key configure-flags #:allow-other-keys)
               (let* ((out (assoc-ref %outputs "out"))
-                     (coreutils (assoc-ref %build-inputs "coreutils"))
-                     (mes (assoc-ref %build-inputs "mes"))
-                     (tcc (assoc-ref %build-inputs "tcc"))
-                     (libc (assoc-ref %build-inputs "libc"))
-                     (interpreter (if libc
-                                      ;; also for x86_64-linux, we are still 
on i686-linux
-                                      (string-append libc 
,(glibc-dynamic-linker "i686-linux"))
-                                      (string-append mes "/lib/mes-loader"))))
-                ;; unpack
-                (setenv "PATH" (string-append
-                                coreutils "/bin"
-                                ":" tcc "/bin"))
-                (format (current-error-port) "PATH=~s\n" (getenv "PATH"))
-                (invoke "sh" "configure"
-                        (string-append "--cc=tcc")
-                        (string-append "--cpu=i386")
-                        (string-append "--prefix=" out)
-                        (string-append "--elfinterp=" interpreter)
-                        (string-append "--crtprefix=" tcc "/lib")
-                        (string-append "--sysincludepaths=" tcc "/include")
-                        (string-append "--libpaths=" tcc "/lib")))))
-          (replace 'build
-            (lambda* (#:key outputs #:allow-other-keys)
+                     (gash (assoc-ref %build-inputs "gash"))
+                     (configure-flags `(,@configure-flags
+                                        ,(string-append "--prefix=" out))))
+                (format (current-error-port)
+                        "running ./configure ~a\n" (string-join 
configure-flags))
+                (apply invoke "./configure" configure-flags))))
+          (add-after 'configure 'configure-fixups
+            (lambda _
               (let* ((out (assoc-ref %outputs "out"))
-                     (mes (assoc-ref %build-inputs "mes"))
-                     (tcc (assoc-ref %build-inputs "tcc"))
-                     (libc (assoc-ref %build-inputs "libc"))
-                     (interpreter (if libc
-                                      ;; also for x86_64-linux, we are still 
on i686-linux
-                                      (string-append libc 
,(glibc-dynamic-linker "i686-linux"))
-                                      (string-append mes "/lib/mes-loader"))))
-                (invoke "tcc"
-                        "-vvv"
-                        "-D" "BOOTSTRAP=1"
-                        "-D" "ONE_SOURCE=1"
-                        "-D" "TCC_TARGET_I386=1"
-                        "-D" "CONFIG_TCC_STATIC=1"
-                        "-D" "CONFIG_USE_LIBGCC=1"
-                        "-D" (string-append "CONFIG_TCCDIR=\"" out 
"/lib/tcc\"")
-                        "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out 
"/lib:{B}/lib:.\"")
-                        "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out 
"/lib:{B}/lib:.\"")
-                        "-D" (string-append "CONFIG_TCC_ELFINTERP=\"" 
interpreter "\"")
-                        "-D" (string-append "CONFIG_TCC_LIBPATHS=\"" tcc 
"/lib:{B}/lib:.\"")
-                        "-D" (string-append "CONFIG_TCC_SYSINCLUDEPATHS=\"" 
tcc "/include" ":/include:{B}/include\"")
-                        "-D" (string-append "TCC_LIBGCC=\"" tcc 
"/lib/libc.a\"")
-                        "-o" "tcc"
-                        "tcc.c"))))
+                     (localedir (string-append out "/share/locale")))
+                (substitute* "config.h"
+                  (("^/[*] #undef 
(HAVE_(ALLOCA_H|DIRENT_H|FCNTL_H|STRING_H|UNISTD_H)) [*]/" all have)
+                   (string-append "#define " have " 1"))
+                  ;; ... so we also need these
+                  ;; (("^[*] #undef 
(HAVE_(ALLOCA_H|DIRENT_H|FCNTL_H|INTTYPES_H|LIMITS_H|LOCALE_H|MEMORY_H|STDINT_H|STDLIB_H|STRINGS_H|STRING_H|SYS_PARAM_H|SYS_STAT_H|SYS_TIMEB_H|SYS_TIME_H|SYS_TYPES_H|SYS_WAIT_H|UNISTD_H))
 [*]/"
+                  ;;   all have) (string-append "#define " have " 1"))
+                  ;; (("^#undef 
(HAVE_(ALLOCA|DUP2|FDOPEN|FORK|GETCWD|GETTIMEOFDAY|MEMCPY|MEMMOVE|MKTEMP|PIPE|SA_RESTART|SETLOCALE|SETVBUF|SIGACTION|SIGSETMASK|STRCHR|STRDUP|STRERROR|VPRINTF|WAITPID|WORKING_FORK))
 [*]/")
+                  ;;  (string-append "#define " have " 1"))
+                  )
+                (let ((config.h (open-file "config.h" "a")))
+                  (display (string-append "
+#define LOCALEDIR \"" localedir"\"
+#define PROTOTYPES 1
+#define __STDC__ 1
+#include <fcntl.h>
+")
+                           config.h)
+                  (close config.h))
+                (substitute* "build.sh"
+                  (("^LOADLIBES=.*$") "LOADLIBES=\n")
+                  (("[.][$]U[.][.]o") ".o"))
+                (substitute* "make.h"
+                  (("^extern long int lseek.*" all) (string-append "// " all)))
+                #t)))
+          (replace 'build
+            (lambda _
+              (invoke "sh" "-x" "./build.sh")))
+          ;; proper check needs awk
           (replace 'check
             (lambda _
-              ;; FIXME: add sensible check target (without depending on make)
-              ;; ./check.sh ?
-              (= 1 (status:exit-val (system* "./tcc" "--help")))))
+              (invoke "./make" "--version")
+              #t))
           (replace 'install
             (lambda* (#:key outputs #:allow-other-keys)
-              (let ((out (assoc-ref %outputs "out"))
-                    (tcc (assoc-ref %build-inputs "tcc")))
-                (and
-                 (mkdir-p (string-append out "/bin"))
-                 (copy-file "tcc" (string-append out "/bin/tcc"))
-                 (mkdir-p (string-append out "/lib/tcc"))
-                 (copy-recursively (string-append tcc "/include")
-                                   (string-append out "/include"))
-                 (copy-recursively (string-append tcc "/lib")
-                                   (string-append out "/lib"))
-                 (invoke "tcc" "-D" "TCC_TARGET_I386=1" "-c" "-o" "libtcc1.o" 
"lib/libtcc1.c")
-                 (invoke "tcc" "-ar" "rc" "libtcc1.a" "libtcc1.o")
-                 (copy-file "libtcc1.a" (string-append out "/lib/libtcc1.a"))
-                 (delete-file (string-append out "/lib/tcc/libtcc1.a"))
-                 (copy-file "libtcc1.a" (string-append out 
"/lib/tcc/libtcc1.a"))
-                 #t))))))))))
+              (let* ((out (assoc-ref outputs "out"))
+                     (bin (string-append out "/bin")))
+                (install-file "make" bin)
+                #t)))))))))
 
-(define make-mesboot0
+;; Only used for development -- fast check
+(define-public make-mesboot0-scripted
   (package-with-bootstrap-guile
    (package
      (inherit gnu-make)
-     (name "make-mesboot0")
+     (name "make-mesboot0-scripted")
      (version "3.80")
      (source (origin
                (method url-fetch)
-               (uri (string-append "mirror://gnu/make/make-"
-                                   version ".tar.gz"))
+               (uri (string-append "http://lilypond.org/janneke/mes/make-";
+                                   version ".tar"))
                (sha256
                 (base32
-                 "1pb7fb7fqf9wz9najm85qdma1xhxzf1rhj5gwrlzdsz2zm0hpcv4"))))
+                 "0x1jwszfq9gv798flh6mj99vrp3l57wc366xw84x14vb0n5i80cg"))))
      (supported-systems '("i686-linux" "x86_64-linux"))
      (inputs '())
      (propagated-inputs '())
-     (native-inputs `(("tcc" ,tcc-boot)
+     (native-inputs `(("tcc" ,tcc-boot0)
 
-                      ("bash" ,%bootstrap-coreutils&co)
-                      ("coreutils" ,%bootstrap-coreutils&co)))
+                      ("guile" ,%bootstrap-guile)
+                      ("gash" ,%bootstrap-gash)))
      (arguments
       `(#:implicit-inputs? #f
-        #:tests? #f                     ; check depends on perl
         #:guile ,%bootstrap-guile
         #:configure-flags `("CC=tcc -DO_RDONLY=0"
                             "LD=tcc"
                             "--disable-nls")
+        #:modules ((guix build gnu-build-system)
+                   (guix build utils)
+                   (srfi srfi-1)
+                   (srfi srfi-26))
+        #:strip-binaries? #f            ; no strip yet
         #:phases
         (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append gash "/libexec/gash:" (getenv 
"PATH")))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                #t)))
+          (replace 'configure
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (includedir (string-append out "/include"))
+                     (libdir (string-append out "/lib"))
+                     (localedir (string-append out "/share/locale"))
+                     (host "i686-unknown-linux-gnu")
+                     (version ,(package-version make-mesboot0)))
+                (with-output-to-file "config.h"
+                  (lambda _ (display (string-append "
+#define ALIASPATH \""localedir"\":.
+#define INCLUDEDIR \""includedir"\"
+#define LIBDIR \""libdir"\"
+#define LOCALEDIR \""localedir"\"
+
+#define C_GETLOADAVG 1
+#define FILE_TIMESTAMP_HI_RES 0
+#define HAVE_ALLOCA 1
+#define HAVE_ALLOCA_H 1
+#define HAVE_DIRENT_H 1
+#define HAVE_DUP2 1
+#define HAVE_FCNTL_H 1
+#define HAVE_FDOPEN 1
+#define HAVE_FORK 1
+#define HAVE_GETCWD 1
+#define HAVE_GETTIMEOFDAY 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_LIMITS_H 1
+#define HAVE_LOCALE_H 1
+#define HAVE_MEMCPY 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MEMORY_H 1
+#define HAVE_MKTEMP 1
+#define HAVE_PIPE 1
+#define HAVE_SA_RESTART 1
+#define HAVE_SETLOCALE 1
+#define HAVE_SETVBUF 1
+#define HAVE_SIGACTION 1
+#define HAVE_SIGSETMASK 1
+#define HAVE_STDINT_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRCHR 1
+#define HAVE_STRDUP 1
+#define HAVE_STRERROR 1
+#define HAVE_STRINGS_H 1
+#define HAVE_STRING_H 1
+#define HAVE_SYS_PARAM_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_SYS_TIMEB_H 1
+#define HAVE_SYS_TIME_H 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_SYS_WAIT_H 1
+#define HAVE_UNISTD_H 1
+#define HAVE_VPRINTF 1
+#define HAVE_WAITPID 1
+#define HAVE_WORKING_FORK 1
+#define MAKE_HOST \"" host "\"
+#define MAKE_JOBSERVER 1
+#define PACKAGE \"make\"
+#define PACKAGE_BUGREPORT \"address@hidden"
+#define PACKAGE_NAME \"GNU make\"
+#define PACKAGE_STRING \"GNU make "version"\"
+#define PACKAGE_TARNAME \"make\"
+#define PACKAGE_VERSION \""version"\"
+#define PROTOTYPES 1
+#define RETSIGTYPE void
+#define SCCS_GET \"get\"
+#define STDC_HEADERS 1
+#define TIME_WITH_SYS_TIME 1
+#define VERSION \"" version" \"
+#define __PROTOTYPES 1
+#define vfork fork
+")))))
+              #t))
+          (delete 'patch-generated-file-shebangs) ; no perl
           (add-after 'configure 'configure-fixup
             (lambda _
-              (substitute* "build.sh"
-                (("^REMOTE=.*") "REMOTE=stub\n")
-                (("^extras=.*") "extras=getloadavg.c\n"))
               (substitute* "make.h"
                 (("^extern long int lseek.*" all) (string-append "// " all)))
               #t))
-          (delete 'patch-generated-file-shebangs) ; no perl
           (replace 'build
             (lambda _
-              (invoke "sh" "./build.sh")))
+              (let ((files '(
+                             "ar"
+                             "arscan"
+                             "commands"
+                             "default"
+                             "dir"
+                             "expand"
+                             "file"
+                             "function"
+                             "getopt"
+                             "getopt1"
+                             "implicit"
+                             "job"
+                             "main"
+                             "misc"
+                             "read"
+                             "remake"
+                             "rule"
+                             "signame"
+                             "variable"
+                             "version"
+                             "vpath"
+                             "hash"
+                             "remote-stub"
+                             "getloadavg"
+                             "glob/fnmatch"
+                             "glob/glob"
+                             )))
+                (and (fold-right
+                      (lambda (file status)
+                        (and status (invoke "tcc"
+                                            "-D" "HAVE_CONFIG_H"
+                                            "-I" "."
+                                            "-I" "glob"
+                                            "-c" (string-append file ".c")
+                                            "-o" (string-append file ".o"))))
+                      #t
+                      files)
+                     (apply invoke `("tcc" "-o" "make"
+                                     ,@(map (cut string-append <> ".o")
+                                            files)))))))
+          (replace 'check
+            (lambda _
+              (invoke "./make" "--version")))
           (replace 'install
             (lambda* (#:key outputs #:allow-other-keys)
               (let* ((out (assoc-ref outputs "out"))
                      (bin (string-append out "/bin")))
-                (install-file "make" bin))))))))))
+                (install-file "make" bin)
+                #t)))))))))
 
-(define diffutils-mesboot
+(define-public gawk-mesboot0
   (package-with-bootstrap-guile
    (package
-     (inherit diffutils)
-     (name "diffutils-mesboot")
-     (version "2.7")
+     (inherit gawk)
+     (name "gawk-mesboot0")
+     (version "3.0.0")
      (source (origin
                (method url-fetch)
-               (uri (string-append "mirror://gnu/diffutils/diffutils-"
-                                   version ".tar.gz"))
+               (uri (string-append "http://lilypond.org/janneke/mes/gawk-";
+                                   version ".tar"))
                (sha256
                 (base32
-                 "1mirn5i825bn5w7rh6mgn0r8aj9xqanav95dwcl1b8sn82f4iwnm"))))
+                 "0bwagw36rnkm63nlqxviy8vqx0n5p80476jimw5xx1kzsba7z883"))))
      (supported-systems '("i686-linux" "x86_64-linux"))
      (inputs '())
      (propagated-inputs '())
-     (native-inputs `(("mes" ,mes-boot)
-                      ("tcc" ,tcc-boot)
+     (native-inputs `(("tcc" ,tcc-boot0)
+                      ("make" ,make-mesboot0)
 
-                      ("bash" ,%bootstrap-coreutils&co)
-                      ("coreutils" ,%bootstrap-coreutils&co)
-                      ("make" ,make-mesboot0)))
+                      ("guile" ,%bootstrap-guile)
+                      ("gash" ,%bootstrap-gash)
+                      ;; hack around broken gawk
+                      ;;("coreutils" ,%bootstrap-coreutils&co)
+                      ))
      (arguments
       `(#:implicit-inputs? #f
         #:guile ,%bootstrap-guile
-        #:parallel-build? #f
-        #:tests? #f           ; check is naive, also checks non-built PROGRAMS
-        #:strip-binaries? #f  ; no strip yet
+        #:configure-flags '("--build=i686-unknown-linux-gnu"
+                            "--host=i686-unknown-linux-gnu"
+                            "--disable-nls")
+        #:make-flags '("gawk")
+        #:strip-binaries? #f            ; no strip yet
         #:phases
         (modify-phases %standard-phases
-          ;; diffutils-2.7 needs more traditional configure
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append gash "/libexec/gash:" (getenv 
"PATH")))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                (setenv "CONFIG_SHELL" (string-append gash "/bin/gash"))
+                (setenv "SHELL" (string-append gash "/bin/gash"))
+                #t)))
+          (add-after 'unpack 'patch-out-date,autoheader,-lm
+            (lambda _
+              (substitute* "Makefile.in"
+                (("date ") "echo today ")
+                ((" autoheader") "true")
+                ((" -lm ") " "))
+             (substitute* "test/Makefile.in"
+               (("^bigtest:.*") "bigtest: basic\n")
+               (("( |\t)(childin|convfmt|fflush|longwrds|math|negexp)" all 
sep) sep))))
           (replace 'configure
+            (lambda* (#:key configure-flags #:allow-other-keys)
+              (let* ((out (assoc-ref %outputs "out"))
+                     (gash (assoc-ref %build-inputs "gash"))
+                     (shell (string-append gash "/bin/gash")))
+                (substitute* "configure"
+                  ((" /bin/sh") (string-append " " shell)))
+                (let ((configure-flags
+                       `(,@configure-flags
+                         ,(string-append "--prefix=" out))))
+                  (setenv "CC" "tcc")
+                  (setenv "CPP" "tcc -E")
+                  (setenv "LD" "tcc")
+
+                  (format (current-error-port) "running ./configure ~a\n" 
(string-join configure-flags))
+                  (apply invoke (cons "./configure" configure-flags))))))
+          (add-after 'configure 'configure-fixups
+            (lambda _
+              (let ((config.h (open-file "config.h" "a")))
+                (display (string-append "
+#define __STDC__ 1
+#define HAVE_MKTIME 1
+#define HAVE_TZSET 1
+#define tzset() 0
+#define GETPGRP_VOID 1
+
+#define atan2(x,y) (x/y)
+#define ceil(x) ((int)(x+1))
+#define cos(x) x
+#define exp(x) (3*(int)x)
+#define floor(x) ((int)x)
+#define log(x) ((int)x)
+#define modf(x,y) 0
+#define pow(x,y) 0
+#define sin(x) 0
+#define sqrt(x) 0
+")
+                         config.h)
+                (close config.h))
+              #t))
+          (replace 'install
             (lambda* (#:key outputs #:allow-other-keys)
-              (let ((out (assoc-ref outputs "out"))
-                    (bash (assoc-ref %build-inputs "bash")))
-                (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
-                (setenv "CC" "tcc")
-                (setenv "LD" "tcc")
-                (invoke "./configure" (string-append "--prefix=" out)))))
-          (add-before 'configure 'remove-diff3-sdiff
-            (lambda* (#:key outputs #:allow-other-keys)
-              (substitute* "Makefile.in"
-                (("PROGRAMS = .*" all) "PROGRAMS = cmp diff"))))))))))
-
+              (let* ((out (assoc-ref outputs "out"))
+                     (bin (string-append out "/bin")))
+                (install-file "gawk" bin)
+                (symlink "gawk" (string-append bin "/awk"))
+                #t)))))))))
 
-(define binutils-mesboot0
+(define-public gawk-mesboot1
   (package-with-bootstrap-guile
    (package
-     (inherit binutils)
-     (name "binutils-mesboot0")
-     (version "2.20.1a")
+     (inherit gawk)
+     (name "gawk-mesboot1")
+     (version "3.1.6")
      (source (origin
                (method url-fetch)
-               (uri (string-append "mirror://gnu/binutils/binutils-"
-                                   version ".tar.bz2"))
-               (patches (search-patches "binutils-boot-2.20.1a.patch"))
+               (uri (string-append "http://lilypond.org/janneke/mes/gawk-";
+                                   version ".tar"))
                (sha256
                 (base32
-                 "0r7dr0brfpchh5ic0z9r4yxqn4ybzmlh25sbp30cacqk8nb7rlvi"))))
+                 "14brw5i061j3my66sgxcyy49z9baw3ccry4fyhw7pbzq6q4ihysj"))))
+     (supported-systems '("i686-linux" "x86_64-linux"))
      (inputs '())
      (propagated-inputs '())
-     (native-inputs `(("tcc" ,tcc-boot)
+     (native-inputs `(("tcc" ,tcc-boot0)
+                      ("make" ,make-mesboot0)
 
-                      ("bash" ,%bootstrap-coreutils&co)
-                      ("coreutils" ,%bootstrap-coreutils&co)
-                      ("diffutils" ,diffutils-mesboot)
-                      ("make" ,make-mesboot0)))
-     (supported-systems '("i686-linux" "x86_64-linux"))
+                      ("guile" ,%bootstrap-guile)
+                      ("gash" ,%bootstrap-gash)))
      (arguments
       `(#:implicit-inputs? #f
         #:guile ,%bootstrap-guile
-        #:tests? #f                     ; runtest: command not found
-        #:parallel-build? #f
+        #:configure-flags '("--build=i686-unknown-linux-gnu"
+                            "--host=i686-unknown-linux-gnu"
+                            "--disable-nls")
+        #:make-flags '("gawk")
         #:strip-binaries? #f            ; no strip yet
-        #:configure-flags
-        (let ((cppflags (string-append " -D __GLIBC_MINOR__=6"
-                                       " -D MES_BOOTSTRAP=1"))
-              (bash (assoc-ref %build-inputs "bash")))
-          `(,(string-append "CONFIG_SHELL=" bash "/bin/sh")
-            ,(string-append "CPPFLAGS=" cppflags)
-            "AR=tcc -ar"
-            "CXX=false"
-            "RANLIB=true"
-            ,(string-append "CC=tcc" cppflags)
-            "--disable-nls"
-            "--disable-shared"
-            "--disable-werror"
-            "--build=i686-unknown-linux-gnu"
-            "--host=i686-unknown-linux-gnu"
-            "--with-sysroot=/")))))))
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append gash "/libexec/gash:" (getenv 
"PATH")))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                (setenv "CONFIG_SHELL" (string-append gash "/bin/gash"))
+                (setenv "SHELL" (string-append gash "/bin/gash"))
+                #t)))
+          (add-after 'unpack 'patch-out-date,autoheader,-lm
+            (lambda _
+              (substitute* "Makefile.in"
+                (("date ") "echo today ")
+                ((" autoheader") "true")
+                ((" -lm ") " "))
+             (substitute* "test/Makefile.in"
+               (("^bigtest:.*") "bigtest: basic\n")
+               (("( |\t)(childin|convfmt|fflush|longwrds|math|negexp)" all 
sep) sep))))
+          (replace 'configure
+            (lambda* (#:key configure-flags #:allow-other-keys)
+              (let* ((out (assoc-ref %outputs "out"))
+                     (gash (assoc-ref %build-inputs "gash"))
+                     (shell (string-append gash "/bin/gash")))
+                (substitute* "configure"
+                  ((" /bin/sh") (string-append " " shell)))
+                (let ((configure-flags
+                       `(,@configure-flags
+                         ,(string-append "--prefix=" out))))
+                  (setenv "CC" "tcc")
+                  (setenv "CPP" "tcc -E")
+                  (setenv "LD" "tcc")
+                  (setenv "ac_cv_header_dlfcn_h" "no")
+
+                  (format (current-error-port) "running ./configure ~a\n" 
(string-join configure-flags))
+                  (apply invoke (cons "./configure" configure-flags))))))
+          (add-after 'configure 'configure-fixups
+            (lambda _
+              (substitute* "config.h"
+                (("#define HAVE_LOCALE_H 1") "#undef HAVE_LOCALE_H"))
+              (let ((config.h (open-file "config.h" "a")))
+                (display (string-append "
+#define __STDC__ 1
+#define HAVE_MKTIME 1
+#define HAVE_TZSET 1
+#define tzset() 0
+#define GETPGRP_VOID 1
+
+#define atan2(x,y) (x/y)
+#define ceil(x) ((int)(x+1))
+#define cos(x) x
+#define exp(x) (3*(int)x)
+#define floor(x) ((int)x)
+#define log(x) ((int)x)
+#define modf(x,y) 0
+#define pow(x,y) 0
+#define sin(x) 0
+#define sqrt(x) 0
+
+#define endpwent() 0
+#define getpwent() 0
+")
+                         config.h)
+                (close config.h))
+              #t))
+          (replace 'check
+            (lambda _
+              (invoke "./gawk" "--version")))
+          (replace 'install
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (bin (string-append out "/bin")))
+                (install-file "gawk" bin)
+                (symlink "gawk" (string-append bin "/awk"))
+                #t)))))))))
 
-(define gcc-core-mesboot
-  ;; Gcc-2.95.3 is the most recent GCC that is supported by what the Mes C
-  ;; Library v0.16 offers.  Gcc-3.x (and 4.x) place higher demands on a C
-  ;; library, such as dir.h/struct DIR/readdir, locales, signals...  Also,
-  ;; with gcc-2.95.3, binutils-boot-2.20.1a and glibc-2.2.5 we found a GNU
-  ;; toolchain triplet "that works".
+(define-public gzip-mesboot0
   (package-with-bootstrap-guile
    (package
-     (inherit gcc)
-     (name "gcc-core-mesboot")
-     (version "2.95.3")
+     (inherit gzip)
+     (version "1.2.4")
+     (name "gzip-mesboot0")
      (source (origin
                (method url-fetch)
-               (uri (string-append "mirror://gnu/gcc/gcc-2.95.3/gcc-core-"
-                                   version
-                                   ".tar.gz"))
-               (patches (search-patches "gcc-boot-2.95.3.patch"))
+               (uri (string-append
+                     "http://lilypond.org/janneke/mes/";
+                     "gzip-1.2.4.tar"))
                (sha256
                 (base32
-                 "1xvfy4pqhrd5v2cv8lzf63iqg92k09g6z9n2ah6ndd4h17k1x0an"))))
+                 "0bk71r26ixlkvmb7wrmxsafiqhf4c4hmczbp9mi55814psiv1q23"))))
      (supported-systems '("i686-linux" "x86_64-linux"))
      (inputs '())
      (propagated-inputs '())
-     (native-inputs `(("binutils" ,binutils-mesboot0)
-                      ("tcc" ,tcc-boot)
+     (native-inputs `(("make" ,make-mesboot0)
+                      ("tcc" ,tcc-boot0)
 
-                      ("bash" ,%bootstrap-coreutils&co)
-                      ("coreutils" ,%bootstrap-coreutils&co)
-                      ("diffutils" ,diffutils-mesboot)
-                      ("make" ,make-mesboot0)))
-     (outputs '("out"))
+                      ("gash" ,%bootstrap-gash)))
      (arguments
       `(#:implicit-inputs? #f
         #:guile ,%bootstrap-guile
-        #:tests? #f
         #:parallel-build? #f
-        #:strip-binaries? #f
-        #:configure-flags
-        (let ((out (assoc-ref %outputs "out")))
-          `("--enable-static"
-            "--disable-shared"
-            "--disable-werror"
-            "--build=i686-unknown-linux-gnu"
-            "--host=i686-unknown-linux-gnu"
-            ,(string-append "--prefix=" out)))
-        #:make-flags (list
-                      "CC=tcc -static -D __GLIBC_MINOR__=6"
+        #:tests? #f           ; check is naive, also checks non-built PROGRAMS
+        #:strip-binaries? #f  ; no strip yet
+        #:configure-flags '("TIME_T_32_BIT_OK=yes")
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append (getenv "PATH") ":" gash 
"/libexec/gash" ))
+                (setenv "CONFIG_SHELL" (string-append gash "/bin/gash"))
+                (setenv "SHELL" (string-append gash "/bin/gash"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                (setenv "CC" "tcc")
+                (setenv "LD" "tcc")
+                (setenv "gl_cv_func_gettimeofday_clobber" "y")
+                #t)))
+          (add-after 'unpack 'patch-Makfile,patch-out-strlwr
+            (lambda _
+              (substitute* "Makefile.in"
+                (("\tln ") "   cp ")
+                ((" ln ") " cp ")
+                (("\tmkdir") " mkdir -p ")
+                ((" mkdir") " mkdir -p "))
+              (substitute* "util.c"
+                (("^char [*]strlwr" all) (string-append all 
"_tcc_cannot_handle_dupe")))
+              #t))
+          (replace 'configure
+            (lambda* (#:key configure-flags #:allow-other-keys)
+              (let* ((out (assoc-ref %outputs "out"))
+                     (gash (assoc-ref %build-inputs "gash"))
+                     (configure-flags `(,@configure-flags
+                                        ,(string-append "--prefix=" out))))
+                (format (current-error-port)
+                        "running ./configure ~a\n" (string-join 
configure-flags))
+                (apply system* "./configure" configure-flags)
+                (invoke "sh" "-x" "./config.status"))))
+          ;; no gzip yet
+          (delete 'compress-documentation)))))))
+
+(define-public bash-mesboot0
+  ;; The initial Bash
+  (package-with-bootstrap-guile
+   (package
+     (inherit static-bash)
+     (name "bash-mesboot0")
+     (version "2.05b")
+     (source (origin
+               (method url-fetch)
+               (uri (string-append
+                     "http://lilypond.org/janneke/mes/bash-";
+                     version ".tar"))
+               (sha256
+                (base32
+                 "0xb26xks1mm0m4mq525w11nxdb2wwgs373h0pj34r8w05cv1zhij"))))
+     (inputs '())
+     (propagated-inputs '())
+     (native-inputs
+      `(("make" ,make-mesboot0)
+        ("tcc" ,tcc-boot0)
+
+        ("guile" ,%bootstrap-guile)
+        ("gash" , %bootstrap-gash)))
+     (outputs '("out"))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:parallel-build? #f
+        #:strip-binaries? #f   ; no strip yet
+        #:configure-flags (list "--build=i686-unknown-linux-gnu"
+                                "--host=i686-unknown-linux-gnu"
+
+                                "--without-bash-malloc"
+                                "--disable-readline"
+                                "--disable-history"
+                                "--disable-help-builtin"
+                                "--disable-progcomp"
+                                "--disable-net-redirections"
+                                "--disable-nls"
+
+                                ;; Pretend 'dlopen' is missing so we don't 
build loadable
+                                ;; modules and related code.
+                                "ac_cv_func_dlopen=no")
+        #:make-flags '("bash")
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append gash "/libexec/gash:" (getenv 
"PATH")))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                (setenv "CONFIG_SHELL" (string-append gash "/bin/gash"))
+                (setenv "SHELL" (string-append gash "/bin/gash"))
+                (setenv "CC" "tcc")
+                (setenv "LD" "tcc")
+                (setenv "AR" "tcc -ar")
+                (setenv "CFLAGS" "-D _POSIX_VERSION=1")
+                #t)))
+          (add-after 'unpack 'patch
+            (lambda _
+              (substitute* "Makefile.in"
+                (("mksyntax\\.c\n") "mksyntax.c -lgetopt\n")
+                (("buildversion[.]o\n") "buildversion.o -lgetopt\n")
+                ;; No size in Gash
+                (("\tsize ") "#\tsize"))
+              (substitute* "lib/sh/oslib.c"
+                (("int name, namelen;") "char *name; int namelen;"))
+              (substitute* "lib/sh/snprintf.c"
+                (("^#if (defined [(]HAVE_LOCALE_H[)])" all define) 
(string-append "#if 0 //" define)))
+              #t))
+          (replace 'configure
+            (lambda* (#:key configure-flags #:allow-other-keys)
+              (let ((configure-flags (filter (lambda (x)
+                                               (and (not (string-prefix? 
"CONFIG_SHELL=" x))
+                                                    (not (string-prefix? 
"SHELL=" x))))
+                                             configure-flags)))
+                (format (current-error-port)
+                        "running ./configure ~a\n" (string-join 
configure-flags)))
+              (apply invoke (cons "./configure" configure-flags))))
+          (add-after 'configure 'configure-fixups
+            (lambda _
+              (substitute* "config.h"
+                (("#define GETCWD_BROKEN 1") "#undef GETCWD_BROKEN"))
+              (let ((config.h (open-file "config.h" "a")))
+                (display (string-append "
+// tcc: error: undefined symbol 'enable_hostname_completion'
+#define enable_hostname_completion(on_or_off) 0
+
+// 
/gnu/store/cq0cmv35s9dhilx14zaghlc08gpc0hwr-tcc-boot0-0.9.26-6.c004e9a/lib/libc.a:
 error: 'sigprocmask' defined twice
+#define HAVE_POSIX_SIGNALS 1
+#define endpwent(x) 0
+")
+                         config.h)
+                (close config.h))
+              #t))
+          (replace 'check
+            (lambda _
+              (invoke "./bash" "--version")))
+          (replace 'install
+            (lambda _
+              (let* ((out (assoc-ref %outputs "out"))
+                     (bin (string-append out "/bin")))
+                (mkdir-p bin)
+                (copy-file "bash" (string-append bin "/bash"))
+                (copy-file "bash" (string-append bin "/sh"))
+                #t)))))))))
+
+(define-public bash-mesboot
+  ;; The initial Bash
+  (package-with-bootstrap-guile
+   (package
+     (inherit static-bash)
+     (version "4.4")
+     (name "bash-mesboot")
+     ;; (source (origin
+     ;;           (method url-fetch)
+     ;;           (uri (string-append "mirror://gnu/bash/bash-"
+     ;;                               version ".tar.gz"))
+     ;;           (sha256
+     ;;            (base32
+     ;;             "1jyz6snd63xjn6skk7za6psgidsd53k05cr3lksqybi0q6936syq"))))
+     (source (origin
+               (method url-fetch)
+               (uri (string-append
+                     "http://lilypond.org/janneke/mes/";
+                     "bash-4.4.tar"))
+               (sha256
+                (base32
+                 "1p0ixbf04bbbdrzsd1y1ibzvk3iwwihmrkfh6irwqcaz93xi7rxb"))))
+     (inputs '())
+     (propagated-inputs '())
+     (native-inputs
+      `(("gawk" ,gawk-mesboot0)
+        ("make" ,make-mesboot0)
+        ("tcc" ,tcc-boot0)
+
+        ("guile" ,%bootstrap-guile)
+        ("gash" , %bootstrap-gash)))
+     (outputs '("out"))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:parallel-build? #f
+        #:strip-binaries? #f   ; no strip yet
+        #:configure-flags (list "--build=i686-unknown-linux-gnu"
+                                "--host=i686-unknown-linux-gnu"
+
+                                "--without-bash-malloc"
+                                "--disable-readline"
+                                "--disable-history"
+                                "--disable-help-builtin"
+                                "--disable-progcomp"
+                                "--disable-net-redirections"
+                                "--disable-nls"
+
+                                ;; Pretend 'dlopen' is missing so we don't 
build loadable
+                                ;; modules and related code.
+                                "ac_cv_func_dlopen=no")
+        #:make-flags '("bash")
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append gash "/libexec/gash:" (getenv 
"PATH")))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                (setenv "CC" "tcc")
+                (setenv "CONFIG_SHELL" (string-append gash "/bin/gash"))
+                (setenv "SHELL" (string-append gash "/bin/gash"))
+                ;; (setenv "CPPNAME" "tcc -E")
+                ;; (setenv "CPP" "tcc -E")
+                (setenv "AWK" "gawk")
+                (setenv "CC" "tcc")
+                (setenv "LD" "tcc")
+                (setenv "AR" "tcc -ar")
+                (setenv "CFLAGS" "-D _POSIX_VERSION=1")
+                #t)))
+          (add-before 'configure 'subst
+            (lambda _
+              (let ((tcc (assoc-ref %build-inputs "tcc")))
+                (setenv "LIBS_FOR_BUILD" (string-append tcc 
"/lib/x86-mes-gcc/libgetopt.o"))
+                (substitute* "Makefile.in"
+                  (("^LIBS_FOR_BUILD = ") (string-append "LIBS_FOR_BUILD = " 
tcc "/lib/x86-mes-gcc/libgetopt.o"))))))
+          (replace 'configure
+            (lambda* (#:key configure-flags #:allow-other-keys)
+              (let ((configure-flags (filter (lambda (x)
+                                               (and (not (string-prefix? 
"CONFIG_SHELL=" x))
+                                                    (not (string-prefix? 
"SHELL=" x))))
+                                             configure-flags)))
+                (format (current-error-port)
+                        "running ./configure ~a\n" (string-join 
configure-flags)))
+              (apply invoke (cons "./configure" configure-flags))))
+          (add-after 'configure 'configure-fixups
+            (lambda _
+              (let ((config.h (open-file "config.h" "a")))
+                (display (string-append "
+// tcc: error: undefined symbol 'enable_hostname_completion'
+#define enable_hostname_completion(on_or_off) 0
+
+// 
/gnu/store/cq0cmv35s9dhilx14zaghlc08gpc0hwr-tcc-boot0-0.9.26-6.c004e9a/lib/libc.a:
 error: 'sigprocmask' defined twice
+#define HAVE_POSIX_SIGNALS 1
+")
+                         config.h)
+                (close config.h))
+              #t))
+          (replace 'check
+            (lambda _
+              (invoke "./bash" "--version")))
+          (replace 'install
+            (lambda _
+              (let* ((out (assoc-ref %outputs "out"))
+                     (bin (string-append out "/bin")))
+                (mkdir-p bin)
+                (copy-file "bash" (string-append bin "/bash"))
+                (copy-file "bash" (string-append bin "/sh"))
+                #t)))))))))
+
+(define-public tar-mesboot0
+  (package-with-bootstrap-guile
+   (package
+     (inherit tar)
+     (name "tar-mesboot0")
+     (version  "1.12")
+     (source (origin
+               (method url-fetch)
+               (uri (string-append
+                     "http://lilypond.org/janneke/mes/";
+                     "tar" "-" version ".tar"))
+               (sha256
+                (base32
+                 "0hhjsxzvj4hb1pwigsybgr76x01xwa8vdkih132na8mm3mn3lpnw"))))
+     (supported-systems '("i686-linux" "x86_64-linux"))
+     (inputs '())
+     (propagated-inputs '())
+     (native-inputs `(("bash" ,bash-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ("mes" ,mes-boot)
+                      ("tcc" ,tcc-boot0)
+                      
+                      ("gash" ,%bootstrap-gash)))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:parallel-build? #f
+        #:tests? #f           ; check is naive, also checks non-built PROGRAMS
+        #:strip-binaries? #f  ; no strip yet
+        #:configure-flags '("--build=i686-unknown-linux-gnu"
+                            "--host=i686-unknown-linux-gnu"
+                            "--disable-nls")
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append  (getenv "PATH")
+                                               ":" gash "/libexec/gash"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                #t)))
+          (replace 'configure
+            (lambda* (#:key configure-flags #:allow-other-keys)
+              (let* ((out (assoc-ref %outputs "out"))
+                     (bash (assoc-ref %build-inputs "bash"))
+                     (shell (string-append bash "/bin/bash")))
+                (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
+                (setenv "SHELL" (string-append bash "/bin/sh"))
+                (setenv "CC" "tcc")
+                (setenv "LD" "tcc")
+                (substitute* "configure"
+                  ((" /bin/sh") shell))
+                (substitute* "Makefile.in"
+                  ((" lib intl ") " lib "))
+                (substitute* "lib/Makefile.in"
+                  (("\\$\\(AR\\) cru ") "tcc -ar cr "))
+                (format (current-error-port)
+                        "running ./configure ~a\n" (string-join 
configure-flags))
+                (apply invoke (cons "./configure" configure-flags)))))
+          (add-after 'configure 'fixup-configure
+            (lambda _
+              (substitute* "config.h"
+                (("/[*] #undef HAVE_DIRENT_H [*]/") "#define HAVE_DIRENT_H 1")
+                (("/[*] #undef HAVE_FCNTL_H [*]/") "#define HAVE_FCNTL_H 1")
+                (("/[*] #undef HAVE_UNISTD_H [*]/") "#define HAVE_UNISTD_H 1")
+
+                (("/[*] #undef HAVE_GETCWD [*]/") "#define HAVE_GETCWD 1")
+                (("/[*] #undef HAVE_MKTIME [*]/") "#define HAVE_MKTIME 1")
+
+                (("#undef HAVE_DIRENT_H") "#define HAVE_DIRENT_H 1")
+                (("#undef HAVE_FCNTL_H") "#define HAVE_FCNTL_H 1")
+                (("#undef HAVE_UNISTD_H") "#define HAVE_UNISTD_H 1"))
+
+              (let ((config.h (open-file "config.h" "a")))
+                (display (string-append "
+#include \"dirent.h\"
+")
+                         config.h)
+                (close config.h))
+              #t))
+          (replace 'install
+            (lambda _
+              (let* ((out (assoc-ref %outputs "out"))
+                     (bin (string-append out "/bin")))
+                (install-file "src/tar" bin)
+                #t)))))))))
+
+;; version 1.15 - Sergey Poznyakoff, 2004-12-20
+
+;; * Compressed archives are recognised automatically, it is no longer
+;; necessary to specify -Z, -z, or -j options to read them.  Thus, you can
+;; now run 'tar tf archive.tar.gz'.
+
+;; version 1.22 - Sergey Poznyakoff, 2009-03-05
+
+;; * Support for xz compression
+
+(define-public tar-mesboot1-WIPdoesnt-work-yet
+  (package-with-bootstrap-guile
+   (package
+     (inherit tar)
+     (name "tar-mesboot1-wont-work")
+     ;; (version  "1.15")
+     ;; (source (origin
+     ;;           (method url-fetch)
+     ;;           (uri (string-append
+     ;;                 "http://lilypond.org/janneke/mes/";
+     ;;                 "tar" "-" version ".tar"))
+     ;;           (sha256
+     ;;            (base32
+     ;;             "0cz53piqv27qgix1n6cpfdyz0mmbamy26bba9gqj94hghsi9f54w"))))
+     (version  "1.22")
+     (source (origin
+               (method url-fetch)
+               (uri (string-append
+                     "http://lilypond.org/janneke/mes/";
+                     "tar" "-" version ".tar"))
+               (sha256
+                (base32
+                 "1gkilfwnbjqb35vn6978lby4gmp74q0dzhrrsfix8cg1qnlwd2b3"))))
+     (supported-systems '("i686-linux" "x86_64-linux"))
+     (inputs '())
+     (propagated-inputs '())
+     (native-inputs `(("bash" ,bash-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ("mes" ,mes-boot)
+                      ("sed" ,sed-mesboot0)
+
+                      ;; Tar 1.15 needs floats:
+                      ;; Floating point exception with tar-mesboot0
+                      ("tcc" ,tcc-boot)
+
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:parallel-build? #f
+        #:tests? #f           ; check is naive, also checks non-built PROGRAMS
+        #:strip-binaries? #f  ; no strip yet
+        #:configure-flags '("--build=i686-unknown-linux-gnu"
+                            "--host=i686-unknown-linux-gnu"
+                            "--disable-nls")
+        #:make-flags '("AR=tcc -ar")
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'set-path
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append  (getenv "PATH")
+                                               ":" gash "/libexec/gash"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                #t)))
+          (replace 'configure
+            (lambda* (#:key configure-flags #:allow-other-keys)
+              (let* ((out (assoc-ref %outputs "out"))
+                     (bash (assoc-ref %build-inputs "bash"))
+                     (shell (string-append bash "/bin/bash"))
+                     ;;(gash (assoc-ref %build-inputs "gash"))
+                     ;;(shell (string-append gash "/bin/gash"))
+                     )
+                (setenv "CONFIG_SHELL" shell)
+                (setenv "SHELL" shell)
+                (setenv "CC" "tcc")
+                ;; does not work
+                ;; (setenv "AR" "tcc -ar")
+                (setenv "LD" "tcc")
+                (format (current-error-port)
+                        "running ./configure ~a\n" (string-join 
configure-flags))
+                (apply invoke (cons "./configure" configure-flags)))))
+          (add-after 'unpack 'patch
+            (lambda _
+              (let* ((bash (assoc-ref %build-inputs "bash"))
+                     (shell (string-append bash "/bin/bash"))
+                     ;;(gash (assoc-ref %build-inputs "gash"))
+                     ;;(shell (string-append gash "/bin/gash"))
+                     )
+                (substitute* "configure"
+                  ((" /bin/sh") shell)))
+              (substitute* "Makefile.in"
+                ((" lib intl ") " lib ")
+                (("^SUBDIRS = doc") "SUBDIRS ="))
+              (substitute* "lib/Makefile.in"
+                (("\\$\\(AR\\) cru ") "tcc -ar cr "))
+              (substitute* "lib/Makefile.in"
+                (("\\$\\(AR\\) cru ") "tcc -ar cr "))
+              (substitute* "lib/rtapelib.c"
+                (("DEFAULT_RMT_COMMAND;") "\"rmt\";"))
+              (substitute* "lib/argp-eexst.c"
+                (("#include <sysexits.h>") "//#include <sysexits.h>"))
+              (substitute* "lib/argp-parse.c"
+                (("#define N_[(]msgid[)] [(]msgid[)]") "#define N_(msgid) 
msgid"))
+              (substitute* "lib/human.c"
+                (("l->decimal_point") "\".\"")
+                (("l->grouping") "\"\"")
+                (("l->thousands_sep") "\",\""))
+              (substitute* "lib/modechange.h"
+                (("# include <sys/types.h>" all)
+                 (string-append all "\n#include <sys/stat.h>")))
+              (substitute* "lib/mktime.c"
+                (("^time_t") "int"))
+              #t))
+          (add-after 'configure 'fixup-configure
+            (lambda _
+              (substitute* "config.h"
+                (("/[*] #undef HAVE_DIRENT_H [*]/") "#define HAVE_DIRENT_H 1")
+                (("/[*] #undef HAVE_FCNTL_H [*]/") "#define HAVE_FCNTL_H 1")
+                (("/[*] #undef HAVE_UNISTD_H [*]/") "#define HAVE_UNISTD_H 1")
+
+                (("/[*] #undef HAVE_GETCWD [*]/") "#define HAVE_GETCWD 1")
+                (("/[*] #undef HAVE_MKTIME [*]/") "#define HAVE_MKTIME 1")
+
+                (("#undef HAVE_DIRENT_H") "#define HAVE_DIRENT_H 1")
+                (("#undef HAVE_FCNTL_H") "#define HAVE_FCNTL_H 1")
+                (("#undef HAVE_UNISTD_H") "#define HAVE_UNISTD_H 1"))
+
+              (let ((config.h (open-file "config.h" "a")))
+                (display (string-append "
+#include \"dirent.h\"
+#define MB_LEN_MAX 16
+#define localeconv(x) 0
+#define EX_USAGE 1
+
+#ifndef O_NONBLOCK
+#define O_NONBLOCK 00004000
+#endif
+#ifndef O_NOCTTY
+#define O_NOCTTY 00000400
+#endif
+
+#define        EPERM 1
+#define CLOCK_REALTIME 1
+#define LC_ALL 0
+
+#define asctime(x) 0
+#define getpagesize(x) 0
+#define strtok(x,y) 0
+#define asctime(x) 0
+")
+                         config.h)
+                (close config.h))
+              #t))
+          (replace 'install
+            (lambda _
+              (let* ((out (assoc-ref %outputs "out"))
+                     (bin (string-append out "/bin")))
+                (install-file "src/tar" bin)
+                #t)))))))))
+
+(define-public sed-mesboot0
+  (package-with-bootstrap-guile
+   (package
+     (inherit sed)
+     (name "sed-mesboot0")
+     (version "1.18")
+     (source (origin
+               (method url-fetch)
+               (uri (string-append "mirror://gnu/sed/sed-"
+                                   version ".tar.gz"))
+               (sha256
+                (base32
+                 "1hyv7i82jd0q18xcql51ylc8jwadp3gb3irgcqlis3v61p35jsv2"))))
+     (supported-systems '("i686-linux" "x86_64-linux"))
+     (inputs '())
+     (propagated-inputs '())
+     (native-inputs `(("bash" ,bash-mesboot0)
+                      ("gzip" ,gzip-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ("tar" ,tar-mesboot0)
+                      ("tcc" ,tcc-boot0)
+
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:parallel-build? #f
+        #:make-flags '("CC=tcc")
+        #:strip-binaries? #f            ; no strip yet
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((bash (assoc-ref %build-inputs "bash"))
+                    (gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append  (getenv "PATH") ":" gash 
"/libexec/gash:"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
+                (setenv "SHELL" (string-append bash "/bin/sh"))
+                (setenv "CC" "tcc")
+                #t)))
+          (replace 'unpack
+            (lambda* (#:key source #:allow-other-keys)
+              (invoke "tar" "zxvf" source)
+              ;;(chdir (first-subdirectory "."))
+              (chdir (string-append "sed-" ,version))
+              #t))
+          (add-after 'unpack 'patch
+            (lambda _
+              (let* ((out (assoc-ref %outputs "out"))
+                     (bash (assoc-ref %build-inputs "bash"))
+                     (shell (string-append bash "/bin/bash")))
+                (substitute* "configure"
+                  (("/bin/sh") shell))
+                #t)))
+          (add-after 'configure 'fixup-configure
+            (lambda _
+              (substitute* "Makefile"
+                (("HAVE_bcopy") "HAVE_BCOPY")
+                (("HAVE_memcpy") "HAVE_MEMCPY")
+                (("HAVE_string_h") "HAVE_STRING_H"))
+              #t))
+          (replace 'check
+            (lambda _
+              (invoke "./sed" "--version")))
+          (replace 'install
+            (lambda _
+              (let* ((out (assoc-ref %outputs "out"))
+                     (bin (string-append out "/bin")))
+                (install-file "sed" bin)
+                #t)))))))))
+
+(define-public sed-mesboot1
+  (package-with-bootstrap-guile
+   (package
+     (inherit sed)
+     (name "sed-mesboot1")
+     ;;(version "4.0.9") ; 4.0.6 2003-04
+     (version "4.0.6") ; 4.0.6 2003-04
+     (source (origin
+               (method url-fetch)
+               (uri (string-append "mirror://gnu/sed/sed-"
+                                   version ".tar.gz"))
+               (sha256
+                (base32
+                 "0861ij94cqc4vaaki6r2wlapwcmhpx4ggp4r70f46mb21a8fkvf1"))))
+     (supported-systems '("i686-linux" "x86_64-linux"))
+     (inputs '())
+     (propagated-inputs '())
+     (native-inputs `(("bash" ,bash-mesboot0)
+                      ("gzip" ,gzip-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ("tar" ,tar-mesboot0)
+                      ("tcc" ,tcc-boot0)
+
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:parallel-build? #f
+        #:make-flags '("CC=tcc" "AR=tcc -ar")
+        #:strip-binaries? #f            ; no strip yet
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((bash (assoc-ref %build-inputs "bash"))
+                    (gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append  (getenv "PATH") ":" gash 
"/libexec/gash:"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
+                (setenv "SHELL" (string-append bash "/bin/sh"))
+                (setenv "CC" "tcc")
+                ;; does not work
+                ;;(setenv "AR" "tcc -ar")
+                #t)))
+          (replace 'unpack
+            (lambda* (#:key source #:allow-other-keys)
+              (invoke "tar" "zxvf" source)
+              ;;(chdir (first-subdirectory "."))
+              (chdir (string-append "sed-" ,version))
+              #t))
+          (add-after 'unpack 'patch
+            (lambda _
+              (let* ((out (assoc-ref %outputs "out"))
+                     (bash (assoc-ref %build-inputs "bash"))
+                     (shell (string-append bash "/bin/bash")))
+                (substitute* "configure"
+                  (("/bin/sh") shell))
+                #t)))
+          (add-after 'configure 'fixup-configure
+            (lambda _
+              (substitute* "Makefile"
+                (("HAVE_bcopy") "HAVE_BCOPY")
+                (("HAVE_memcpy") "HAVE_MEMCPY")
+                (("HAVE_string_h") "HAVE_STRING_H"))
+              (let ((config.h (open-file "config.h" "a")))
+                (display (string-append "
+// mkstemp.c:63: error: 'O_CREAT' undeclared
+#include <fcntl.h>
+")
+                         config.h)
+                (close config.h))              
+              #t))
+          (replace 'check
+            (lambda _
+              (invoke "sed/sed" "--version")))
+          (replace 'install
+            (lambda _
+              (let* ((out (assoc-ref %outputs "out"))
+                     (bin (string-append out "/bin")))
+                (install-file "sed/sed" bin)
+                #t)))))))))
+
+(define-public patch-mesboot0
+  (package-with-bootstrap-guile
+   (package
+     (inherit patch)
+     (name "patch-mesboot0")
+     (version "2.5.9")
+     (source (origin
+               (method url-fetch)
+               (uri (string-append "mirror://gnu/patch/patch-"
+                                   version ".tar.gz"))
+               (sha256
+                (base32
+                 "12nv7jx3gxfp50y11nxzlnmqqrpicjggw6pcsq0wyavkkm3cddgc"))))
+     (supported-systems '("i686-linux" "x86_64-linux"))
+     (inputs '())
+     (propagated-inputs '())
+     (native-inputs `(("bash" ,bash-mesboot0)
+                      ("gzip" ,gzip-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ("mes" ,mes-boot)
+                      ("tar" ,tar-mesboot0)
+                      ("tcc" ,tcc-boot0)
+
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:parallel-build? #f
+        #:tests? #f           ; check is naive, also checks non-built PROGRAMS
+        #:strip-binaries? #f  ; no strip yet
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash"))
+                    (bash (assoc-ref %build-inputs "bash")))
+                (setenv "PATH" (string-append  (getenv "PATH") ":" gash 
"/libexec/gash:"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
+                (setenv "AR" "tcc -ar")
+                (setenv "CC" "tcc")
+                (setenv "LD" "tcc")
+                #t)))
+          (replace 'unpack
+            (lambda* (#:key source #:allow-other-keys)
+              (invoke "tar" "zxvf" source)
+              ;;(chdir (first-subdirectory "."))
+              (chdir (string-append "patch-" ,version))
+              #t))
+          (add-after 'unpack 'patch
+            (lambda _
+              ;; avoid calling Mes C Libary localtime stub
+              ;; (substitute* "util.c"
+              ;;   (("if [(]set_time [|] set_utc[)]" all)
+              ;;    (string-append "if (1); else\n" all)))
+              ;; avoid another segfault
+              (substitute* "pch.c"
+                (("while [(]p_end >= 0[)]" all)
+                 "p_end = -1;\nwhile (0)"))
+              #t))
+          (add-after 'configure 'fixup-configure
+            (lambda _
+              (let ((config.h (open-file "config.h" "a")))
+                (display (string-append "
+#define        EXDEV 18
+")
+                         config.h)
+                (close config.h))
+              #t))))))))
+
+(define-public patch-mesboot1
+  (package-with-bootstrap-guile
+   (package
+     (inherit patch)
+     (name "patch-mesboot1")
+     (version "2.5.9.1")
+     (source (origin
+               (method url-fetch)
+               (uri (string-append
+                     "http://lilypond.org/janneke/mes/";
+                     "patch" "-" version ".tar"))
+               (sha256
+                (base32
+                 "1qj6fshxbn5bqr5nqjm2vf46fvy63r3s8x7g9ik41c3csv4m9j9a"))))
+     (supported-systems '("i686-linux" "x86_64-linux"))
+     (inputs '())
+     (propagated-inputs '())
+     (native-inputs `(("bash" ,bash-mesboot0)
+                      ("gzip" ,gzip-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ("mes" ,mes-boot)
+                      ("sed" ,sed-mesboot0)
+                      ("tar" ,tar-mesboot0)
+                      ("tcc" ,tcc-boot0)
+
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:parallel-build? #f
+        #:tests? #f           ; check is naive, also checks non-built PROGRAMS
+        #:strip-binaries? #f  ; no strip yet
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash"))
+                    (bash (assoc-ref %build-inputs "bash")))
+                (setenv "PATH" (string-append  (getenv "PATH") ":" gash 
"/libexec/gash:"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
+                ;;(setenv "AR" "tcc -ar")
+                (setenv "CC" "tcc")
+                ;;(setenv "LD" "tcc")
+                #t)))
+          (replace 'unpack
+            (lambda* (#:key source #:allow-other-keys)
+              (invoke "tar" "zxvf" source)
+              ;;(chdir (first-subdirectory "."))
+              (chdir (string-append "patch-" ,version))
+              #t))
+
+          (add-after 'unpack 'patch
+            (lambda _
+              ;; avoid calling Mes C Libary localtime stub
+              ;; (substitute* "util.c"
+              ;;   (("if [(]set_time [|] set_utc[)]" all)
+              ;;    (string-append "if (1); else\n" all)))
+
+              ;; avoid another segfault
+              (substitute* "pch.c"
+                (("while [(]p_end >= 0[)]" all)
+                 "p_end = -1;\nwhile (0)"))
+
+              #t))
+          (add-after 'configure 'fixup-configure
+            (lambda _
+              (let ((config.h (open-file "config.h" "a")))
+                (display (string-append "
+#define        EXDEV 18
+")
+                         config.h)
+                (close config.h))
+              #t))
+          (replace 'install
+            (lambda _
+              (let* ((out (assoc-ref %outputs "out"))
+                     (bin (string-append out "/bin")))
+                (install-file "patch" bin)
+                #t)))))))))
+
+(define-public bzip2-mesboot0
+  (package-with-bootstrap-guile
+   (package
+     (inherit bzip2)
+     (name "bzip2-mesboot0")
+     (version (package-version bzip2))
+     (supported-systems '("i686-linux" "x86_64-linux"))
+     (inputs '())
+     (propagated-inputs '())
+     (native-inputs `(("bash" ,bash-mesboot0)
+                      ("gzip" ,gzip-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ("mes" ,mes-boot)
+                      ("tar" ,tar-mesboot0)
+                      ("tcc" ,tcc-boot0)
+
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)))
+     (outputs '("out"))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:parallel-build? #f
+        #:tests? #f           ; check is naive, also checks non-built PROGRAMS
+        #:strip-binaries? #f  ; no strip yet
+        #:make-flags (list "CC=tcc -I ." "AR=tcc -ar" "bzip2"
+                           (string-append "PREFIX="
+                                          (assoc-ref %outputs "out")))
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash"))
+                    (bash (assoc-ref %build-inputs "bash")))
+                (setenv "PATH" (string-append  (getenv "PATH") ":" gash 
"/libexec/gash:"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                #t)))
+          (replace 'unpack
+            (lambda* (#:key source #:allow-other-keys)
+              (invoke "tar" "zxvf" source)
+              ;;(chdir (first-subdirectory "."))
+              (chdir (string-append "bzip2-" ,version))
+              #t))
+          (add-after 'unpack 'patch
+            (lambda _
+              (substitute* "Makefile"
+                (("\tln " all)
+                 (string-append "\t#" all)))
+              (substitute* "bzip2.c"
+                (("struct utimbuf uTimBuf;" all)
+                 (string-append "// " all))
+                (("uTimBuf[.]" all)
+                 (string-append "// " all))
+                (("retVal = utime [(] dstName, &uTimBuf [)];" all)
+                 (string-append "retVal = 0; // " all)))
+              #t))
+          (replace 'configure
+            (lambda _
+              (with-output-to-file "utime.h"
+                (lambda _ (display "
+#define fchown(filedes, owner, group) 0
+#define fchmod(filedes, mode) 0
+")))
+              #t))
+          (replace 'check
+            (lambda _
+              (invoke "./bzip2" "--help")))))))))
+
+;; XZ's configure refuses to build with tcc
+(define-public xz-mesboot0 ;; WIP
+  (package-with-bootstrap-guile
+   (package
+     (inherit xz)
+     (name "xz-mesboot0")
+     ;; needs poll.h etc
+     ;; file_io.c:20: error: include file 'poll.h' not found
+     ;; (version (package-version xz))
+     (version "5.0.0")
+     ;; check/crc32_fast.c:38: error: cannot use pointers here
+     ;; while ((uintptr_t)(buf) & 7) {
+     (source (origin
+               (method url-fetch)
+               (uri (list (string-append "http://tukaani.org/xz/xz-"; version
+                                         ".tar.gz")
+                          (string-append "http://multiprecision.org/guix/xz-";
+                                         version ".tar.gz")))
+               (sha256
+                (base32
+                 "0kf40ggbs1vaaj5s9k4csycahzqcf65n20pa6lngqhm6j0cj3agb"))))
+     (supported-systems '("i686-linux" "x86_64-linux"))
+     (inputs '())
+     (propagated-inputs '())
+     (native-inputs `(("bash" ,bash-mesboot0)
+                      ("gawk" ,gawk-mesboot0)
+                      ("gzip" ,gzip-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ("mes" ,mes-boot)
+                      ("sed" ,sed-mesboot0)
+                      ("tar" ,tar-mesboot0)
+                      ("tcc" ,tcc-boot0)
+
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:parallel-build? #f
+        #:tests? #f           ; check is naive, also checks non-built PROGRAMS
+        #:strip-binaries? #f  ; no strip yet
+        #:configure-flags '("--disable-assembler"
+                            "--enable-small"
+                            "--disable-threads"
+                            "--disable-xzdec"
+                            "--disable-lzmadec"
+                            "--disable-lzmainfo"
+                            "--disable-lzma-links"
+                            "--disable-scripts"
+                            "--disable-doc"
+                            "--disable-nls"
+                            "--disable-symbol-versions")
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash"))
+                    (bash (assoc-ref %build-inputs "bash")))
+                (setenv "PATH" (string-append  (getenv "PATH") ":" gash 
"/libexec/gash:"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
+                (setenv "AR" "tcc -ar")
+                (setenv "CC" "tcc")
+                (setenv "CPP" "tcc -E")
+                (setenv "LD" "tcc")
+                (setenv "ac_cv_prog_cc_c99" "-std=c99")
+                (setenv "gl_cv_posix_shell" "bash")
+                #t)))
+          (replace 'unpack
+            (lambda* (#:key source #:allow-other-keys)
+              (invoke "tar" "zxvf" source)
+              ;;(chdir (first-subdirectory "."))
+              (chdir (string-append "xz-" ,version))
+              #t))
+          (add-after 'unpack 'patch
+            (lambda _
+              (substitute* "src/liblzma/check/crc32_fast.c"
+                (("while [(][(]uintptr_t[)][(]buf[)] & 7[)]")
+                 "while ((long)(buf) & 7) {"))
+              (substitute* "src/liblzma/check/sha256.c"
+                (("[[]static 8[]]") "[8]")
+                (("[[]static 16[]]") "[16]"))
+              (substitute* "src/xz/signals.h"
+                (("extern volatile sig_atomic_t user_abort;")
+                 "extern volatile long user_abort;"))
+              #t))))))))
+
+(define-public tcc-boot
+  (package-with-bootstrap-guile
+   (package
+     (inherit tcc-boot0)
+     (name "tcc-boot")
+     (version "0.9.27")
+     ;; Upstream only provides bz2 -- Look, Ma how many wonderful
+     ;; non-bootstrappable compressors we can choose from!
+     (source (origin
+               (inherit (package-source tcc))
+               ;; patches needs XZ
+               ;; (patches (search-patches "tcc-boot-0.9.27.patch"))
+               ))
+     (build-system gnu-build-system)
+     (inputs '())
+     (propagated-inputs '())
+     (native-inputs `(("boot-patch" ,(search-patch "tcc-boot-0.9.27.patch"))
+                      ("bash" ,bash-mesboot0)
+                      ("bzip2" ,bzip2-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ("mes" ,mes-boot)
+                      ("patch" ,patch-mesboot0)
+                      ("tar" ,tar-mesboot0)
+                      ("tcc" ,tcc-boot0)
+
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:validate-runpath? #f ; no dynamic executables
+        #:strip-binaries? #f            ; no strip yet
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append (getenv "PATH") ":" gash 
"/libexec/gash" ))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                #t)))
+          (replace 'unpack
+            (lambda* (#:key source #:allow-other-keys)
+              (with-output-to-file "tarball"
+                (lambda _ (invoke "bzip2" "-dc" source)))
+              (invoke "tar" "xvf" "tarball")
+              ;;(chdir (first-subdirectory "."))
+              (chdir (string-append "tcc-" ,version))
+              #t))
+          (add-after 'unpack 'patch
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((patch-file (assoc-ref inputs "boot-patch")))
+                (invoke "patch" "-p1" "-i" patch-file))))
+          (replace 'configure
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let* ((out (assoc-ref %outputs "out"))
+                     (coreutils (assoc-ref %build-inputs "coreutils"))
+                     (mes (assoc-ref %build-inputs "mes"))
+                     (tcc (assoc-ref %build-inputs "tcc"))
+                     (libc (assoc-ref %build-inputs "libc"))
+                     (interpreter (if libc
+                                      ;; also for x86_64-linux, we are still 
on i686-linux
+                                      (string-append libc 
,(glibc-dynamic-linker "i686-linux"))
+                                      (string-append mes "/lib/mes-loader"))))
+                (invoke "sh" "configure"
+                        (string-append "--cc=tcc")
+                        (string-append "--cpu=i386")
+                        (string-append "--prefix=" out)
+                        (string-append "--elfinterp=" interpreter)
+                        (string-append "--crtprefix=" tcc "/lib")
+                        (string-append "--sysincludepaths=" tcc "/include")
+                        (string-append "--libpaths=" tcc "/lib")))))
+          (replace 'build
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let* ((out (assoc-ref %outputs "out"))
+                     (mes (assoc-ref %build-inputs "mes"))
+                     (tcc (assoc-ref %build-inputs "tcc"))
+                     (libc (assoc-ref %build-inputs "libc"))
+                     (interpreter (if libc
+                                      ;; also for x86_64-linux, we are still 
on i686-linux
+                                      (string-append libc 
,(glibc-dynamic-linker "i686-linux"))
+                                      (string-append mes "/lib/mes-loader"))))
+                (invoke "tcc"
+                        "-vvv"
+                        "-D" "BOOTSTRAP=1"
+                        "-D" "ONE_SOURCE=1"
+                        "-D" "TCC_TARGET_I386=1"
+                        "-D" "CONFIG_TCC_STATIC=1"
+                        "-D" "CONFIG_USE_LIBGCC=1"
+                        "-D" (string-append "CONFIG_TCCDIR=\"" out 
"/lib/tcc\"")
+                        "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out 
"/lib:{B}/lib:.\"")
+                        "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out 
"/lib:{B}/lib:.\"")
+                        "-D" (string-append "CONFIG_TCC_ELFINTERP=\"" 
interpreter "\"")
+                        "-D" (string-append "CONFIG_TCC_LIBPATHS=\"" tcc 
"/lib:{B}/lib:.\"")
+                        "-D" (string-append "CONFIG_TCC_SYSINCLUDEPATHS=\"" 
tcc "/include" ":/include:{B}/include\"")
+                        "-D" (string-append "TCC_LIBGCC=\"" tcc 
"/lib/libc.a\"")
+                        "-o" "tcc"
+                        "tcc.c"))))
+          (replace 'check
+            (lambda _
+              ;; FIXME: add sensible check target (without depending on make)
+              ;; ./check.sh ?
+              (= 1 (status:exit-val (system* "./tcc" "--help")))))
+          (replace 'install
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let ((out (assoc-ref %outputs "out"))
+                    (tcc (assoc-ref %build-inputs "tcc")))
+                (and
+                 (mkdir-p (string-append out "/bin"))
+                 (copy-file "tcc" (string-append out "/bin/tcc"))
+                 (mkdir-p (string-append out "/lib/tcc"))
+                 (copy-recursively (string-append tcc "/include")
+                                   (string-append out "/include"))
+                 (copy-recursively (string-append tcc "/lib")
+                                   (string-append out "/lib"))
+                 (invoke "tcc" "-D" "TCC_TARGET_I386=1" "-c" "-o" "libtcc1.o" 
"lib/libtcc1.c")
+                 (invoke "tcc" "-ar" "rc" "libtcc1.a" "libtcc1.o")
+                 (copy-file "libtcc1.a" (string-append out "/lib/libtcc1.a"))
+                 (delete-file (string-append out "/lib/tcc/libtcc1.a"))
+                 (copy-file "libtcc1.a" (string-append out 
"/lib/tcc/libtcc1.a"))
+                 #t))))))))))
+
+(define-public diffutils-mesboot0
+  (package-with-bootstrap-guile
+   (package
+     (inherit diffutils)
+     (name "diffutils-mesboot0")
+     (version "2.7")
+     (source (origin
+               (method url-fetch)
+               (uri (string-append "mirror://gnu/diffutils/diffutils-"
+                                   version ".tar.gz"))
+               (sha256
+                (base32
+                 "1mirn5i825bn5w7rh6mgn0r8aj9xqanav95dwcl1b8sn82f4iwnm"))))
+     (supported-systems '("i686-linux" "x86_64-linux"))
+     (inputs '())
+     (propagated-inputs '())
+     (native-inputs `(("bash" ,bash-mesboot0)
+                      ("gzip" ,gzip-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ;;("mes" ,mes-boot)
+                      ("sed" ,sed-mesboot0)
+                      ("tar" ,tar-mesboot0)
+                      ("tcc" ,tcc-boot)
+
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:parallel-build? #f
+        #:tests? #f           ; check is naive, also checks non-built PROGRAMS
+        #:strip-binaries? #f  ; no strip yet
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append  (getenv "PATH") ":" gash 
"/libexec/gash:"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                #t)))
+          (replace 'unpack
+            (lambda* (#:key source #:allow-other-keys)
+              (invoke "tar" "zxvf" source)
+              ;;(chdir (first-subdirectory "."))
+              (chdir (string-append "diffutils-" ,version))
+              #t))
+          ;; diffutils-2.7 needs more traditional configure
+          (replace 'configure
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let ((out (assoc-ref outputs "out"))
+                    (bash (assoc-ref %build-inputs "bash")))
+                (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
+                (setenv "CC" "tcc")
+                (setenv "LD" "tcc")
+                (invoke "./configure" (string-append "--prefix=" out)))))
+          (add-before 'configure 'remove-diff3-sdiff
+            (lambda* (#:key outputs #:allow-other-keys)
+              (substitute* "Makefile.in"
+                (("PROGRAMS = .*" all) "PROGRAMS = cmp diff"))))
+          (add-after 'configure 'configure-fixups
+            (lambda _
+              (let* ((out (assoc-ref %outputs "out"))
+                     (localedir (string-append out "/share/locale")))
+                (substitute* "config.h"
+                  (("^/[*] #undef 
(HAVE_(ALLOCA_H|DIRENT_H|FCNTL_H|STRING_H|UNISTD_H)) [*]/" all have)
+                   (string-append "#define " have " 1")))
+                #t)))))))))
+
+(define-public binutils-mesboot0
+  (package-with-bootstrap-guile
+   (package
+     (inherit binutils)
+     (name "binutils-mesboot0")
+     (version "2.14")
+     (source (origin
+               (method url-fetch)
+               ;; Upstream only provides bz2 -- Look, Ma how many wonderful
+               ;; non-bootstrappable compressors we can choose from!
+               (uri (string-append "mirror://gnu/binutils/binutils-"
+                                   version ".tar.gz"))
+               ;; Patch needs XZ
+               ;; (patches (search-patches "binutils-boot-2.20.1a.patch"))
+               (sha256
+                (base32
+                 "1w8xp7k44bkijr974x9918i4p1sw4g2fcd5mxvspkjpg38m214ds"))))
+     (inputs '())
+     (propagated-inputs '())
+     (native-inputs `(("bash" ,bash-mesboot)
+                      ("gzip" ,gzip-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ("mes" ,mes-boot)
+                      ("patch" ,patch-mesboot0)
+                      ("sed" ,sed-mesboot0)
+                      ("tar" ,tar-mesboot0)
+                      ("tcc" ,tcc-boot0)
+
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)))
+     (supported-systems '("i686-linux" "x86_64-linux"))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:tests? #f                     ; runtest: command not found
+        #:parallel-build? #f
+        #:strip-binaries? #f            ; no strip yet
+        #:configure-flags
+        (let ((out (assoc-ref %outputs "out"))
+              (cppflags (string-append " -D __GLIBC_MINOR__=6"
+                                       " -D MES_BOOTSTRAP=1"))
+              (bash (assoc-ref %build-inputs "bash")))
+          `("--disable-nls"
+            "--disable-shared"
+            "--disable-werror"
+            "--build=i386-unknown-linux"
+            "--host=i386-unknown-linux"
+            "--target=i386-unknown-linux"
+            "--with-sysroot=/"
+            ,(string-append "--prefix=" out)))
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((out (assoc-ref %outputs "out"))
+                    (bash (assoc-ref %build-inputs "bash"))
+                    (gash (assoc-ref %build-inputs "gash"))
+                    (cppflags (string-append " -D __GLIBC_MINOR__=6"
+                                             " -D MES_BOOTSTRAP=1")))
+                (setenv "PATH" (string-append (getenv "PATH") ":" gash 
"/libexec/gash:"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+
+                (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
+                (setenv "CPPFLAGS" cppflags)
+                (setenv "AR" "tcc -ar")
+                (setenv "RANLIB" "true")
+                (setenv "CC" (string-append "tcc" cppflags))
+                #t)))
+          (replace 'unpack
+            (lambda* (#:key source #:allow-other-keys)
+              (invoke "tar" "zxvf" source)
+              ;;(chdir (first-subdirectory "."))
+              (chdir (string-append "binutils-" ,version))
+              #t))
+          (add-after 'unpack 'patch
+            (lambda* (#:key inputs #:allow-other-keys)
+              ;; Must use Gash' sed in top configure to avoid Mes C Lib bug
+              (let* ((gash (assoc-ref %build-inputs "gash"))
+                     (sed (string-append gash "/libexec/gash/sed")))
+                (substitute* "configure"
+                  (("( |\|)sed " all sep) (string-append sep sed " "))))
+              (substitute* "intl/configure"
+                ((" ln ") " cp "))
+              (substitute* "bfd/configure"
+                (("^sed -e '/SRC-POTFILES.*" all)
+                 "echo -e 'all:\\n\\ttrue\\n\\ninstall:\\n\\ttrue\\n' > 
po/Makefile\n"))
+              #t))
+          ;; binutils-2.14 needs a more classic invocation of configure
+          ;; configure: warning: 
CONFIG_SHELL=/gnu/store/28ziymi92vqbw6sh80f0s4frbls1s4zp-bash-mesboot0-2.05b/bin/bash:
 invalid host type
+          ;; configure: warning: 
SHELL=/gnu/store/28ziymi92vqbw6sh80f0s4frbls1s4zp-bash-mesboot0-2.05b/bin/bash: 
invalid host type
+          ;; configure: error: can only configure for one host and one target 
at a time
+          (replace 'configure
+            (lambda* (#:key configure-flags #:allow-other-keys)
+              (format (current-error-port)
+                      "running ./configure ~a\n" (string-join configure-flags))
+              ;; No such file or directory: ".//dev/null"
+              ;;(apply invoke "./configure" configure-flags)
+
+              (apply system* "./configure" configure-flags)
+              (substitute* "config.status"
+                (("[.]//dev/null") "/dev/null"))
+              (invoke "sh" "./config.status")
+              ))))))))
+
+;; binutils-2.20.1a needs AWK
+;;... hmm
+;; config.status: creating Makefile
+;; gawk: ./conf1838-3317/subs.awk:8: S["LTLIBOBJS"]=
+;; gawk: ./conf1838-3317/subs.awk:8:                ^ unexpected newline or 
end of string
+(define-public binutils-mesboot1
+  (package-with-bootstrap-guile
+   (package
+     (inherit binutils)
+     (name "binutils-mesboot1")
+     (version "2.20.1a")
+     (source (origin
+               (method url-fetch)
+               ;; Upstream only provides bz2 -- Look, Ma how many wonderful
+               ;; non-bootstrappable compressors we can choose from!
+               (uri (string-append "mirror://gnu/binutils/binutils-"
+                                   version ".tar.bz2"))
+               ;; Patch needs XZ
+               ;; (patches (search-patches "binutils-boot-2.20.1a.patch"))
+               (sha256
+                (base32
+                 "0r7dr0brfpchh5ic0z9r4yxqn4ybzmlh25sbp30cacqk8nb7rlvi"))))
+     (inputs '())
+     (propagated-inputs '())
+     (native-inputs `(("boot-patch" ,(search-patch 
"binutils-boot-2.20.1a.patch"))
+                      ;;("boot-patch" ,(search-patch 
"binutils-boot-2.20.1a-no-strncmp.patch"))
+                      ;;("bash" ,bash-mesboot0)
+                      ("bash" ,bash-mesboot)
+                      ("bzip2" ,bzip2-mesboot0)
+                      ("gawk" ,gawk-mesboot1)
+                      ("diffutils" ,diffutils-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ("mes" ,mes-boot)
+                      ("patch" ,patch-mesboot0)
+                      ("sed" ,sed-mesboot1)
+                      ("tar" ,tar-mesboot0)
+                      ("tcc" ,tcc-boot0)
+
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)))
+     (supported-systems '("i686-linux" "x86_64-linux"))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:tests? #f                     ; runtest: command not found
+        #:parallel-build? #f
+        #:strip-binaries? #f            ; no strip yet
+        #:configure-flags
+        (let ((cppflags (string-append " -D __GLIBC_MINOR__=6"
+                                       " -D MES_BOOTSTRAP=1"))
+              (bash (assoc-ref %build-inputs "bash")))
+          `(,(string-append "CONFIG_SHELL=" bash "/bin/sh")
+            ,(string-append "CPPFLAGS=" cppflags)
+            "AR=tcc -ar"
+            "CXX=false"
+            "RANLIB=true"
+            ,(string-append "CC=tcc" cppflags)
+            "--disable-nls"
+            "--disable-shared"
+            "--disable-werror"
+            "--build=i686-unknown-linux-gnu"
+            "--host=i686-unknown-linux-gnu"
+            "--with-sysroot=/"))
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append  (getenv "PATH") ":" gash 
"/libexec/gash:"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                #t)))
+          (replace 'unpack
+            (lambda* (#:key source #:allow-other-keys)
+              (with-output-to-file "tarball"
+                (lambda _ (invoke "bzip2" "-dc" source)))
+              (invoke "tar" "xvf" "tarball")
+              ;;(chdir (first-subdirectory "."))
+              ;; The tarball name does not match its content
+              ;; (chdir (string-append "binutils-" ,version))
+              (chdir (string-append "binutils-2.20.1"))
+              #t))
+          (add-after 'unpack 'patch
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((patch-file (assoc-ref inputs "boot-patch")))
+              (let ((libiberty/strncmp.c (open-file "libiberty/strncmp.c" 
"a")))
+                (display (string-append "
+#endif
+// Give hanging patch-2.5.9 some more context
+")
+                         libiberty/strncmp.c)
+                (close libiberty/strncmp.c))
+              ;; sed-mesboot0 cannot build this
+              ;; (substitute* "opcodes/Makefile.in"
+              ;;   (("^SUBDIRS = [.] po") "SUBDIRS = ."))
+              ;; (substitute* "opcodes/Makefile.in"
+              ;;   (("^SUBDIRS = doc po") "SUBDIRS ="))
+              (system* "patch" "--force" "-p1" "-i" patch-file)
+              #t)))))))))
+
+(define-public gcc-core-mesboot
+  ;; Gcc-2.95.3 is the most recent GCC that is supported by what the Mes C
+  ;; Library v0.16 offers.  Gcc-3.x (and 4.x) place higher demands on a C
+  ;; library, such as dir.h/struct DIR/readdir, locales, signals...  Also,
+  ;; with gcc-2.95.3, binutils-boot-2.20.1a and glibc-2.2.5 we found a GNU
+  ;; toolchain triplet "that works".
+  (package-with-bootstrap-guile
+   (package
+     (inherit gcc)
+     (name "gcc-core-mesboot")
+     (version "2.95.3")
+     (source (origin
+               (method url-fetch)
+               (uri (string-append "mirror://gnu/gcc/gcc-2.95.3/gcc-core-"
+                                   version
+                                   ".tar.gz"))
+               ;; Patch needs XZ
+               ;; (patches (search-patches "gcc-boot-2.95.3.patch"))
+               (sha256
+                (base32
+                 "1xvfy4pqhrd5v2cv8lzf63iqg92k09g6z9n2ah6ndd4h17k1x0an"))))
+     (supported-systems '("i686-linux" "x86_64-linux"))
+     (inputs '())
+     (propagated-inputs '())
+     (native-inputs `(("boot-patch" ,(search-patch "gcc-boot-2.95.3.patch"))
+                      ("binutils" ,binutils-mesboot0)
+                      ("bash" ,bash-mesboot0)
+                      ("gzip" ,gzip-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ("mes" ,mes-boot)
+                      ("tcc" ,tcc-boot)
+                      ("patch" ,patch-mesboot0)
+                      ("sed" ,sed-mesboot0)
+                      ("tar" ,tar-mesboot0)
+
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)))
+     (outputs '("out"))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:tests? #f
+        #:parallel-build? #f
+        #:strip-binaries? #f
+        #:configure-flags
+        (let ((out (assoc-ref %outputs "out")))
+          `("--enable-static"
+            "--disable-shared"
+            "--disable-werror"
+            "--build=i686-unknown-linux-gnu"
+            "--host=i686-unknown-linux-gnu"
+            ,(string-append "--prefix=" out)))
+        #:make-flags (list
+                      "CC=tcc -static -D __GLIBC_MINOR__=6"
                       "OLDCC=tcc -static -D __GLIBC_MINOR__=6"
                       "CC_FOR_BUILD=tcc -static -D __GLIBC_MINOR__=6"
                       "AR=ar"
@@ -669,7 +2361,23 @@
                    (srfi srfi-1))
         #:phases
         (modify-phases %standard-phases
-          ;; gcc-2.95.3 needs more traditional configure
+          (add-before 'unpack 'set-path
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append  (getenv "PATH") ":" gash 
"/libexec/gash:"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                #t)))
+          (replace 'unpack
+            (lambda* (#:key source #:allow-other-keys)
+              (invoke "tar" "zxvf" source)
+              ;;(chdir (first-subdirectory "."))
+              (chdir (string-append "gcc-" ,version))
+              #t))
+          (add-after 'unpack 'patch
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((patch-file (assoc-ref inputs "boot-patch")))
+                (system* "patch" "--force" "-p1" "-i" patch-file)
+                #t)))
           (add-before 'configure 'setenv
             (lambda* (#:key outputs #:allow-other-keys)
               (let ((out (assoc-ref outputs "out"))
@@ -686,6 +2394,7 @@
                     (display "
 ac_cv_c_float_format='IEEE (little-endian)'
 "))))))
+          ;; gcc-2.95.3 needs more traditional configure
           (replace 'configure
             (lambda* (#:key configure-flags  #:allow-other-keys)
               (format (current-error-port)
@@ -733,7 +2442,7 @@ ac_cv_c_float_format='IEEE (little-endian)'
              (variable "LIBRARY_PATH")
              (files '("lib"))))))))
 
-(define mesboot-headers
+(define-public mesboot-headers
   (package-with-bootstrap-guile
    (package
      (inherit mes-boot)
@@ -741,8 +2450,9 @@ ac_cv_c_float_format='IEEE (little-endian)'
      (supported-systems '("i686-linux" "x86_64-linux"))
      (inputs '())
      (propagated-inputs '())
-     (native-inputs `(("coreutils" ,%bootstrap-coreutils&co)
-                      ("headers" ,%bootstrap-linux-libre-headers)))
+     (native-inputs `(("headers" ,%bootstrap-linux-libre-headers)
+
+                      ("gash" ,%bootstrap-gash)))
      (arguments
       `(#:implicit-inputs? #f
         #:guile ,%bootstrap-guile
@@ -750,6 +2460,12 @@ ac_cv_c_float_format='IEEE (little-endian)'
         #:strip-binaries? #f
         #:phases
         (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append  (getenv "PATH") ":" gash 
"/libexec/gash:"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                #t)))
           (delete 'configure)
           (delete 'build)
           (replace 'install
@@ -771,7 +2487,7 @@ ac_cv_c_float_format='IEEE (little-endian)'
              (variable "C_INCLUDE_PATH")
              (files '("include"))))))))
 
-(define glibc-mesboot0
+(define-public glibc-mesboot0
   ;; GNU C Library 2.2.5 is the most recent glibc that we managed to build
   ;; using gcc-2.95.3.  Newer versions (2.3.x, 2.6, 2.1x) seem to need a newer
   ;; gcc.
@@ -785,27 +2501,39 @@ ac_cv_c_float_format='IEEE (little-endian)'
                (uri (string-append "mirror://gnu/glibc/glibc-"
                                    version
                                    ".tar.gz"))
-               (patches (search-patches "glibc-boot-2.2.5.patch"))
+               ;; Patch needs XZ
+               ;; (patches (search-patches "glibc-boot-2.2.5.patch"))
                (sha256
                 (base32
                  "1vl48i16gx6h68whjyhgnn1s57vqq32f9ygfa2fls7pdkbsqvp2q"))))
      (supported-systems '("i686-linux" "x86_64-linux"))
      (inputs '())
      (propagated-inputs '())
-     (native-inputs `(("binutils" ,binutils-mesboot0)
+     (native-inputs `(("boot-patch" ,(search-patch "glibc-boot-2.2.5.patch"))
+                      ("binutils" ,binutils-mesboot0)
+                      ;;("bash" ,bash-mesboot0)
+                      ("bash" ,bash-mesboot)
+                      ("diffutils" ,diffutils-mesboot0)
+                      ("gawk" ,gawk-mesboot0)
                       ("gcc" ,gcc-core-mesboot)
-
-                      ("bash" ,%bootstrap-coreutils&co)
-                      ("coreutils" ,%bootstrap-coreutils&co)
-                      ("diffutils" ,diffutils-mesboot)
+                      ("gzip" ,gzip-mesboot0)
                       ("headers" ,mesboot-headers)
-                      ("make" ,make-mesboot0)))
+                      ("make" ,make-mesboot0)
+                      ("mes" ,mes-boot)
+                      ("tcc" ,tcc-boot)
+                      ("patch" ,patch-mesboot0)
+                      ("sed" ,sed-mesboot0)
+                      ("tar" ,tar-mesboot0)
+
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)))
      (outputs '("out"))
      (arguments
       `(#:implicit-inputs? #f
         #:guile ,%bootstrap-guile
         #:tests? #f
         #:strip-binaries? #f
+        #:validate-runpath? #f ; no dynamic executables
         #:parallel-build? #f    ; gcc-2.95.3 ICEs on massively parallel builds
         #:make-flags (list (string-append
                             "SHELL="
@@ -829,6 +2557,23 @@ ac_cv_c_float_format='IEEE (little-endian)'
            (string-append "--prefix=" out)))
         #:phases
         (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append  (getenv "PATH") ":" gash 
"/libexec/gash:"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                #t)))
+          (replace 'unpack
+            (lambda* (#:key source #:allow-other-keys)
+              (invoke "tar" "zxvf" source)
+              ;;(chdir (first-subdirectory "."))
+              (chdir (string-append "glibc-" ,version))
+              #t))
+          (add-after 'unpack 'patch
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((patch-file (assoc-ref inputs "boot-patch")))
+                (system* "patch" "--force" "-p1" "-i" patch-file)
+                #t)))
           (add-before 'configure 'setenv
             (lambda* (#:key outputs #:allow-other-keys)
               (let* ((out (assoc-ref outputs "out"))
@@ -847,11 +2592,17 @@ ac_cv_c_float_format='IEEE (little-endian)'
                 #t)))
           ;; glibc-2.2.5 needs a more classic invocation of configure
           ;; configure: warning: 
CONFIG_SHELL=/gnu/store/kpxi8h3669afr9r1bgvaf9ij3y4wdyyn-bash-minimal-4.4.12/bin/bash:
 invalid host type
+          ;; configure: error: *** A pwd binary could not be found.
           (replace 'configure
             (lambda* (#:key configure-flags #:allow-other-keys)
               (format (current-error-port)
                       "running ./configure ~a\n" (string-join configure-flags))
-              (apply invoke "./configure" configure-flags))))))
+              (apply invoke "./configure" configure-flags)))
+          (add-after 'configure 'fixup-configure
+            (lambda _
+              (substitute* "config.make"
+                (("INSTALL = scripts/") "INSTALL = $(..)./scripts/"))
+              #t)))))
      (native-search-paths
       ;; Use the language-specific variables rather than 'CPATH' because they
       ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'.
@@ -873,15 +2624,22 @@ ac_cv_c_float_format='IEEE (little-endian)'
    (package
      (inherit gcc-core-mesboot)
      (name "gcc-mesboot0")
-     (native-inputs `(("binutils" ,binutils-mesboot0)
+
+     (native-inputs `(("boot-patch" ,(search-patch "gcc-boot-2.95.3.patch"))
+                      ("binutils" ,binutils-mesboot0)
+                      ("bash" ,bash-mesboot0)
                       ("gcc" ,gcc-core-mesboot)
+                      ("gzip" ,gzip-mesboot0)
                       ("libc" ,glibc-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ("patch" ,patch-mesboot0)
+                      ("sed" ,sed-mesboot0)
+                      ("tar" ,tar-mesboot0)
+
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)
+                      ("kernel-headers" ,%bootstrap-linux-libre-headers)))
 
-                      ("bash" ,%bootstrap-coreutils&co)
-                      ("coreutils" ,%bootstrap-coreutils&co)
-                      ("diffutils" ,diffutils-mesboot)
-                      ("kernel-headers" ,%bootstrap-linux-libre-headers)
-                      ("make" ,make-mesboot0)))
      (arguments
       (substitute-keyword-arguments (package-arguments gcc-core-mesboot)
         ((#:phases phases)
@@ -936,34 +2694,332 @@ ac_cv_c_float_format='IEEE (little-endian)'
               ,(string-append "LIBGCC2_INCLUDES=-I " gcc "/include")
               "LANGUAGES=c"))))))))
 
+;; version 1.15 - Sergey Poznyakoff, 2004-12-20
+
+;; * Compressed archives are recognised automatically, it is no longer
+;; necessary to specify -Z, -z, or -j options to read them.  Thus, you can
+;; now run 'tar tf archive.tar.gz'.
+(define-public tar-mesboot1
+  (package-with-bootstrap-guile
+   (package
+     (inherit tar)
+     (name "tar-mesboot1")
+     (version  "1.15")
+     (source (origin
+               (method url-fetch)
+               (uri (string-append
+                     "http://lilypond.org/janneke/mes/";
+                     "tar" "-" version ".tar"))
+               (sha256
+                (base32
+                 "0cz53piqv27qgix1n6cpfdyz0mmbamy26bba9gqj94hghsi9f54w"))))
+     (supported-systems '("i686-linux" "x86_64-linux"))
+     (inputs '())
+     (propagated-inputs '())
+     (native-inputs `(("binutils" ,binutils-mesboot0)
+                      ("bash" ,bash-mesboot0)
+                      ("gcc" ,gcc-mesboot0)
+                      ("gzip" ,gzip-mesboot0)
+                      ("libc" ,glibc-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ("patch" ,patch-mesboot0)
+                      ("sed" ,sed-mesboot0)
+                      ("tar" ,tar-mesboot0)
+
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)
+                      ("kernel-headers" ,%bootstrap-linux-libre-headers)))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:parallel-build? #f
+        #:tests? #f           ; check is naive, also checks non-built PROGRAMS
+        #:strip-binaries? #f  ; no strip yet
+        #:configure-flags '("--build=i686-unknown-linux-gnu"
+                            "--host=i686-unknown-linux-gnu"
+                            "--disable-nls")
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'set-path
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append  (getenv "PATH")
+                                               ":" gash "/libexec/gash"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                #t)))
+          (replace 'configure
+            (lambda* (#:key configure-flags #:allow-other-keys)
+              (let* ((out (assoc-ref %outputs "out"))
+                     (bash (assoc-ref %build-inputs "bash"))
+                     (shell (string-append bash "/bin/bash")))
+                (setenv "CONFIG_SHELL" shell)
+                (setenv "SHELL" shell)
+                (setenv "LIBS" "-lc -lnss_files -lnss_dns -lresolv")
+                (format (current-error-port)
+                        "running ./configure ~a\n" (string-join 
configure-flags))
+                (apply invoke (cons "./configure" configure-flags)))))
+          (add-after 'unpack 'patch
+            (lambda _
+              (let* ((bash (assoc-ref %build-inputs "bash"))
+                     (shell (string-append bash "/bin/bash"))
+                     ;;(gash (assoc-ref %build-inputs "gash"))
+                     ;;(shell (string-append gash "/bin/gash"))
+                     )
+                (substitute* "configure"
+                  ((" /bin/sh") shell)))
+              (substitute* "Makefile.in"
+                (("^SUBDIRS = doc") "SUBDIRS ="))
+              #t))
+          (add-after 'configure 'fixup-configure
+            (lambda _
+              (let ((config.h (open-file "config.h" "a")))
+                (display (string-append "
+#define LC_ALL 0
+")
+                         config.h)
+                (close config.h))
+              #t))
+          (replace 'install
+            (lambda _
+              (let* ((out (assoc-ref %outputs "out"))
+                     (bin (string-append out "/bin")))
+                (install-file "src/tar" bin)
+                #t)))))))))
+
+;; version 1.22 - Sergey Poznyakoff, 2009-03-05
+
+;; * Support for xz compression
+(define-public tar-mesboot2
+  (package-with-bootstrap-guile
+   (package
+     (inherit tar)
+     (name "tar-mesboot2")
+     ;; backupfile.c: In function `numbered_backup':
+     ;; backupfile.c:253: parse error before `new_buffer_size'
+     ;; (version  "1.30")
+     ;; (source (origin
+     ;;           (method url-fetch)
+     ;;           (uri (string-append
+     ;;                 "http://lilypond.org/janneke/mes/";
+     ;;                 "tar" "-" version ".tar"))
+     ;;           (sha256
+     ;;            (base32
+     ;;             "04p99wl19wan9h726y9p3ysnp4cm3ndn2iplvnwqalv5767vafpd"))))
+     (version  "1.22")
+     (source (origin
+               (method url-fetch)
+               (uri (string-append
+                     "http://lilypond.org/janneke/mes/";
+                     "tar" "-" version ".tar"))
+               (sha256
+                (base32
+                 "1gkilfwnbjqb35vn6978lby4gmp74q0dzhrrsfix8cg1qnlwd2b3"))))
+     (supported-systems '("i686-linux" "x86_64-linux"))
+     (inputs '())
+     (propagated-inputs '())
+     (native-inputs `(("binutils" ,binutils-mesboot0)
+                      ("bash" ,bash-mesboot0)
+                      ("gawk" ,gawk-mesboot0)
+                      ("gcc" ,gcc-mesboot0)
+                      ("gzip" ,gzip-mesboot0)
+                      ("libc" ,glibc-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ("patch" ,patch-mesboot0)
+                      ("sed" ,sed-mesboot0)
+                      ("tar" ,tar-mesboot0)
+
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)
+                      ("kernel-headers" ,%bootstrap-linux-libre-headers)))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:parallel-build? #f
+        #:tests? #f           ; check is naive, also checks non-built PROGRAMS
+        #:strip-binaries? #f  ; no strip yet
+        #:configure-flags '("--build=i686-unknown-linux-gnu"
+                            "--host=i686-unknown-linux-gnu"
+                            "--disable-nls")
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'set-path
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append  (getenv "PATH")
+                                               ":" gash "/libexec/gash"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                #t)))
+          (replace 'configure
+            (lambda* (#:key configure-flags #:allow-other-keys)
+              (let* ((out (assoc-ref %outputs "out"))
+                     (bash (assoc-ref %build-inputs "bash"))
+                     (shell (string-append bash "/bin/bash")))
+                (setenv "CONFIG_SHELL" shell)
+                (setenv "SHELL" shell)
+                (setenv "LIBS" "-lc -lnss_files -lnss_dns -lresolv")
+                ;; checking whether rename manages existing destinations 
correctly... Backtrace:
+                ;;            4 (apply-smob/1 #<catch-closure 9e5260>)
+                ;; In ice-9/boot-9.scm:
+                ;;     705:2  3 (call-with-prompt _ _ #<procedure 
default-prompt-handle?>)
+                ;; In ice-9/eval.scm:
+                ;;     619:8  2 (_ #(#(#<directory (guile-user) a670a0>)))
+                ;; In ice-9/boot-9.scm:
+                ;;    260:13  1 (for-each #<procedure mkdir (_ #:optional _)> 
_)
+                ;; In unknown file:
+                ;;            0 (mkdir "conftest.d2" #<undefined>)
+                ;; ERROR: In procedure mkdir:
+                ;; In procedure mkdir: File exists
+                ;; configure: error: cannot create temporary files
+                (setenv "gl_cv_func_rename_dest_works" "yes")
+
+                (format (current-error-port)
+                        "running ./configure ~a\n" (string-join 
configure-flags))
+                (apply invoke (cons "./configure" configure-flags)))))
+          (add-after 'unpack 'patch
+            (lambda _
+              (let* ((bash (assoc-ref %build-inputs "bash"))
+                     (shell (string-append bash "/bin/bash"))
+                     ;;(gash (assoc-ref %build-inputs "gash"))
+                     ;;(shell (string-append gash "/bin/gash"))
+                     )
+                (substitute* "configure"
+                  ((" /bin/sh") shell)))
+              (substitute* "Makefile.in"
+                (("^SUBDIRS = doc") "SUBDIRS ="))
+              #t))
+          (add-after 'configure 'fixup-configure
+            (lambda _
+              (let ((config.h (open-file "config.h" "a")))
+                (display (string-append "
+#define LC_ALL 0
+")
+                         config.h)
+                (close config.h))
+              #t))
+          (replace 'install
+            (lambda _
+              (let* ((out (assoc-ref %outputs "out"))
+                     (bin (string-append out "/bin")))
+                (install-file "src/tar" bin)
+                #t)))))))))
+
 (define binutils-mesboot
   (package-with-bootstrap-guile
    (package
      (inherit binutils-mesboot0)
      (name "binutils-mesboot")
      (native-inputs `(("binutils" ,binutils-mesboot0)
-                      ("libc" ,glibc-mesboot0)
+                      ("bash" ,bash-mesboot0)
                       ("gcc" ,gcc-mesboot0)
+                      ("gzip" ,gzip-mesboot0)
+                      ("libc" ,glibc-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ("patch" ,patch-mesboot0)
+                      ("sed" ,sed-mesboot0)
+                      ("tar" ,tar-mesboot0)
 
-                      ("bash" ,%bootstrap-coreutils&co)
-                      ("coreutils" ,%bootstrap-coreutils&co)
-                      ("diffutils" ,diffutils-mesboot)
-                      ("kernel-headers" ,%bootstrap-linux-libre-headers)
-                      ("make" ,make-mesboot0)))
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)
+                      ("kernel-headers" ,%bootstrap-linux-libre-headers)))
      (arguments
       (substitute-keyword-arguments (package-arguments binutils-mesboot0)
         ((#:configure-flags configure-flags)
-         '(list "--disable-nls"
-                "--disable-shared"
-                "--disable-werror"
-                "--build=i686-unknown-linux-gnu"
-                "--host=i686-unknown-linux-gnu"
-                "--with-sysroot=/")))))))
+         '(let ((out (assoc-ref %outputs "out")))
+            `("--disable-nls"
+              "--disable-shared"
+              "--disable-werror"
+              "--build=i686-unknown-linux-gnu"
+              "--host=i686-unknown-linux-gnu"
+              "--with-sysroot=/"
+              ,(string-append "--prefix=" out))))
+        ((#:phases phases)
+         `(modify-phases ,phases
+            (replace 'setenv
+              (lambda _
+                (let ((out (assoc-ref %outputs "out"))
+                      (bash (assoc-ref %build-inputs "bash"))
+                      (gash (assoc-ref %build-inputs "gash")))
+                  (setenv "PATH" (string-append (getenv "PATH") ":" gash 
"/libexec/gash:"))
+                  (format #t "PATH=~s\n" (getenv "PATH"))
+                  (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
+                  #t))))))))))
+
+(define coreutils-mesboot
+  (package-with-bootstrap-guile
+   (package
+     (inherit coreutils)
+     (name "coreutils-mesboot")
+     ;;(version "8.30")
+     ;; most recent .gz release
+     ;; (version "8.13")
+     ;; randperm.c: In function `sparse_swap':
+     ;; randperm.c:117: invalid lvalue in unary `&'
+     (version "5.0") ;; 2003-04
+     ;; No real bootstrap from source yet: Perl dependency
+     ;; WARNING: You don't seem to have perl5.003 or newer installed, or you 
lack
+     ;;          a usable version of the Perl File::Compare module.  As a 
result,
+     ;;          you may be unable to run a few tests or to regenerate certain
+     ;;          files if you modify the sources from which they are derived.
+     (source (origin
+               (method url-fetch)
+               (uri (string-append "mirror://gnu/coreutils/coreutils-"
+                                   version ".tar.gz"))
+               (sha256
+                (base32
+                 "10wq6k66i8adr4k08p0xmg87ff4ypiazvwzlmi7myib27xgffz62"))))
+     (native-inputs `(("bash" ,bash-mesboot0)
+                      ("binutils" ,binutils-mesboot0)
+                      ("diffutils" ,diffutils-mesboot0)
+                      ("gawk" ,gawk-mesboot0)
+                      ("gcc" ,gcc-mesboot0)
+                      ("gzip" ,gzip-mesboot0)
+                      ("libc" ,glibc-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ("sed" ,sed-mesboot0)
+                      ("tar" ,tar-mesboot2)
+
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)
+                      ("kernel-headers" ,%bootstrap-linux-libre-headers)))
+     (supported-systems '("i686-linux" "x86_64-linux"))
+     (inputs '())
+     (propagated-inputs '())
+     (arguments
+      `(#:implicit-inputs? #f
+        #:tests? #f           ; WARNING: `perl' is needed, ...
+        #:strip-binaries? #f  ; strip: unrecognized option `--only-keep-debug'
+        #:guile ,%bootstrap-guile
+        #:configure-flags '("--disable-doc")
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'configure 'set-path
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append (getenv "PATH") ":" gash 
"/libexec/gash:"))
+                #t)))
+          (add-before 'configure 'setenv
+           (lambda _
+             (setenv "LIBS" "-lc -lnss_files -lnss_dns -lresolv")
+             ;; checking whether rename manages existing destinations 
correctly... Backtrace:
+             ;;            4 (apply-smob/1 #<catch-closure 9e5260>)
+             ;; In ice-9/boot-9.scm:
+             ;;     705:2  3 (call-with-prompt _ _ #<procedure 
default-prompt-handle?>)
+             ;; In ice-9/eval.scm:
+             ;;     619:8  2 (_ #(#(#<directory (guile-user) a670a0>)))
+             ;; In ice-9/boot-9.scm:
+             ;;    260:13  1 (for-each #<procedure mkdir (_ #:optional _)> _)
+             ;; In unknown file:
+             ;;            0 (mkdir "conftest.d2" #<undefined>)
+             ;; ERROR: In procedure mkdir:
+             ;; In procedure mkdir: File exists
+             ;; configure: error: cannot create temporary files
+             (setenv "gl_cv_func_rename_dest_works" "yes")
+             #t))))))))
 
 (define make-mesboot
   (package-with-bootstrap-guile
    (package
-     (inherit make-mesboot0)
+     (inherit gnu-make)
      (name "make-mesboot")
      (version "3.82")
      (source (origin
@@ -973,25 +3029,50 @@ ac_cv_c_float_format='IEEE (little-endian)'
                (sha256
                 (base32
                  "1rs2f9hmvy3q6zkl15jnlmnpgffm0bhw5ax0h5c7q604wqrip69x"))))
-     (native-inputs `(("binutils" ,binutils-mesboot0)
-                      ("libc" ,glibc-mesboot0)
+     (native-inputs `(("bash" ,bash-mesboot)
+                      ("binutils" ,binutils-mesboot)
+                      ("diffutils" ,diffutils-mesboot0)
+                      ("gawk" ,gawk-mesboot0)
                       ("gcc" ,gcc-mesboot0)
+                      ("gzip" ,gzip-mesboot0)
+                      ("libc" ,glibc-mesboot0)
                       ("make" ,make-mesboot0)
+                      ("sed" ,sed-mesboot0)
+                      ("tar" ,tar-mesboot2)
 
-                      ("bash" ,%bootstrap-coreutils&co)
-                      ("coreutils" ,%bootstrap-coreutils&co)
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)
                       ("kernel-headers" ,%bootstrap-linux-libre-headers)))
+     (supported-systems '("i686-linux" "x86_64-linux"))
+     (inputs '())
+     (propagated-inputs '())
      (arguments
-      (substitute-keyword-arguments (package-arguments make-mesboot0)
-        ((#:configure-flags configure-flags)
-         `(let ((out (assoc-ref %outputs "out")))
-            `(,(string-append "--prefix=" out))))
-        ((#:phases phases)
-         `(modify-phases ,phases
-            (delete 'configure-fixup)
-            (add-before 'configure 'setenv
-              (lambda _
-                (setenv "LIBS" "-lc -lnss_files -lnss_dns -lresolv")
+      `(#:implicit-inputs? #f
+        #:parallel-build? #f
+        #:guile ,%bootstrap-guile
+        ;; #:modules ((guix build gnu-build-system)
+        ;;            (guix build utils)
+        ;;            (srfi srfi-1)
+        ;;            (srfi srfi-26))
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'configure 'set-path
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append (getenv "PATH") ":" gash 
"/libexec/gash:"))
+                #t)))
+          (add-before 'configure 'setenv
+            (lambda _
+              (setenv "LIBS" "-lc -lnss_files -lnss_dns -lresolv")
+              #t))
+          (replace 'check
+            (lambda _
+              (invoke "./make" "--version")))
+          (replace 'install
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (bin (string-append out "/bin")))
+                (install-file "make" bin)
                 #t)))))))))
 
 (define gmp-boot
@@ -1034,20 +3115,188 @@ ac_cv_c_float_format='IEEE (little-endian)'
      (inherit gcc-mesboot0)
      (name "gcc-mesboot1")
      (version "4.7.4")
-     (source (origin (inherit (package-source gcc-4.7))
-                     (patches (search-patches "gcc-boot-4.7.4.patch"))))
+     (source (origin ;;(inherit (package-source gcc-4.7))
+               (method url-fetch)
+               (uri (string-append "mirror://gnu/gcc/gcc-"
+                                   version "/gcc-" version ".tar.gz"))
+               (sha256
+                (base32
+                 "06bqygv17f71f7g7pi7ddvhljcr8dimrypgiif9g1r6lqn1sbfnx"))
+               ;; Patch needs XZ
+               ;; (patches (search-patches "gcc-boot-4.7.4.patch"))
+               ))
      (inputs `(("gmp-source" ,(package-source gmp-boot))
                ("mpfr-source" ,(package-source mpfr-boot))
                ("mpc-source" ,(package-source mpc-boot))))
-     (native-inputs `(("binutils" ,binutils-mesboot)
+     (native-inputs `(("boot-patch" ,(search-patch "gcc-boot-4.7.4.patch"))
+                      ("bash" ,bash-mesboot)
+                      ;;("binutils" ,binutils-mesboot1)
+                      ("binutils" ,binutils-mesboot0)
+                      ("coreutils" ,coreutils-mesboot)
+                      ("diffutils" ,diffutils-mesboot0)
+                      ;;("gawk" ,gawk-mesboot0)
+                      ("gawk" ,gawk-mesboot1)
                       ("gcc" ,gcc-mesboot0)
+                      ("gzip" ,gzip-mesboot0)
                       ("libc" ,glibc-mesboot0)
+                      ("make" ,make-mesboot)
+                      ("sed" ,sed-mesboot1)
+                      ("tar" ,tar-mesboot2)
 
-                      ("bash" ,%bootstrap-coreutils&co)
-                      ("coreutils" ,%bootstrap-coreutils&co)
-                      ("diffutils" ,diffutils-mesboot)
-                      ("kernel-headers" ,%bootstrap-linux-libre-headers)
-                      ("make" ,make-mesboot)))
+                      ("gash" ,%bootstrap-gash) ; for grep
+                      ("guile" ,%bootstrap-guile)
+                      ("kernel-headers" ,%bootstrap-linux-libre-headers)))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:tests? #f
+        #:modules ((guix build gnu-build-system)
+                   (guix build utils)
+                   (srfi srfi-1))
+        #:parallel-build? #f ;; added
+        #:make-flags
+        (let* ((libc (assoc-ref %build-inputs "libc"))
+               (ldflags (string-append
+                         "-B" libc "/lib "
+                         "-Wl,-dynamic-linker "
+                         "-Wl," libc
+                         ,(glibc-dynamic-linker "i686-linux"))))
+          (list (string-append "LDFLAGS=" ldflags)
+                (string-append "LDFLAGS_FOR_TARGET=" ldflags)))
+        #:configure-flags
+        (let ((out (assoc-ref %outputs "out"))
+              (glibc (assoc-ref %build-inputs "libc")))
+          (list (string-append "--prefix=" out)
+                "--build=i686-unknown-linux-gnu"
+                "--host=i686-unknown-linux-gnu"
+
+                (string-append "--with-native-system-header-dir=" glibc 
"/include")
+                (string-append "--with-build-sysroot=" glibc "/include")
+
+                "--disable-bootstrap"
+                "--disable-decimal-float"
+                "--disable-libatomic"
+                "--disable-libcilkrts"
+                "--disable-libgomp"
+                "--disable-libitm"
+                "--disable-libmudflap"
+                "--disable-libquadmath"
+                "--disable-libsanitizer"
+                "--disable-libssp"
+                "--disable-libvtv"
+                "--disable-lto"
+                "--disable-lto-plugin"
+                "--disable-multilib"
+                "--disable-plugin"
+                "--disable-threads"
+                "--enable-languages=c,c++"
+
+                "--enable-static"
+                ;; libstdc++.so: error: depends on 'libgcc_s.so.1', which 
cannot be found in RUNPATH ()
+                "--disable-shared"
+                "--enable-threads=single"
+
+                ;; No pre-compiled libstdc++ headers, to save space.
+                "--disable-libstdcxx-pch"
+
+                ;; for libcpp ...
+                "--disable-build-with-cxx"))
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'set-path
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash")))
+                (setenv "PATH" (string-append  (getenv "PATH") ":" gash 
"/libexec/gash:"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                #t)))
+          (add-after 'unpack 'patch
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((patch-file (assoc-ref inputs "boot-patch")))
+                (system* "patch" "--force" "-p1" "-i" patch-file)
+                #t)))
+          ;; c&p from commencement.scm:gcc-boot0
+          (add-after 'unpack 'unpack-gmp&co
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((gmp  (assoc-ref %build-inputs "gmp-source"))
+                    (mpfr (assoc-ref %build-inputs "mpfr-source"))
+                    (mpc  (assoc-ref %build-inputs "mpc-source")))
+
+                ;; To reduce the set of pre-built bootstrap inputs, build
+                ;; GMP & co. from GCC.
+                (for-each (lambda (source)
+                            (or (invoke "tar" "xvf" source)
+                                (error "failed to unpack tarball"
+                                       source)))
+                          (list gmp mpfr mpc))
+
+                ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
+                ,@(map (lambda (lib)
+                         ;; Drop trailing letters, as gmp-6.0.0a unpacks
+                         ;; into gmp-6.0.0.
+                         `(symlink ,(string-trim-right
+                                     (package-full-name lib "-")
+                                     char-set:letter)
+                                   ,(package-name lib)))
+                       (list gmp-boot mpfr-boot mpc-boot))
+                #t)))
+          (add-before 'configure 'setenv
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (binutils (assoc-ref %build-inputs "binutils"))
+                     (bash (assoc-ref %build-inputs "bash"))
+                     (gcc (assoc-ref %build-inputs "gcc"))
+                     (glibc (assoc-ref %build-inputs "libc"))
+                     (kernel-headers (assoc-ref %build-inputs 
"kernel-headers")))
+                (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
+                (setenv "C_INCLUDE_PATH" (string-append
+                                          gcc 
"/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include"
+                                          ":" kernel-headers "/include"
+                                          ":" glibc "/include"
+                                          ":" (getcwd) "/mpfr/src"))
+                (setenv "LIBRARY_PATH" (string-append glibc "/lib"
+                                                      ":" gcc "/lib"))
+                (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv 
"C_INCLUDE_PATH"))
+                (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv 
"LIBRARY_PATH"))
+                #t)))))))))
+
+(define gcc-mesboot12
+  (package-with-bootstrap-guile
+   (package
+     (inherit gcc-mesboot0)
+     (name "gcc-mesboot12")
+     (version "4.7.4")
+     (source (origin ;;(inherit (package-source gcc-4.7))
+               (method url-fetch)
+               (uri (string-append "mirror://gnu/gcc/gcc-"
+                                   version "/gcc-" version ".tar.gz"))
+               (sha256
+                (base32
+                 "06bqygv17f71f7g7pi7ddvhljcr8dimrypgiif9g1r6lqn1sbfnx"))
+               ;; Patch needs XZ
+               ;; (patches (search-patches "gcc-boot-4.7.4.patch"))
+               ))
+     (inputs `(("gmp-source" ,(package-source gmp-boot))
+               ("mpfr-source" ,(package-source mpfr-boot))
+               ("mpc-source" ,(package-source mpc-boot))))
+     (native-inputs `(("boot-patch" ,(search-patch "gcc-boot-4.7.4.patch"))
+                      ;;("bash" ,bash-mesboot0)
+                      ("bash" ,bash-mesboot)
+                      ("binutils" ,binutils-mesboot0)
+                      ;;("binutils" ,binutils-mesboot1)
+                      ;;("coreutils" ,coreutils-mesboot)
+                      ("diffutils" ,diffutils-mesboot0)
+                      ("gawk" ,gawk-mesboot1)
+                      ("gcc" ,gcc-mesboot0)
+                      ("gzip" ,gzip-mesboot0)
+                      ("libc" ,glibc-mesboot0)
+                      ("make" ,make-mesboot)
+                      ("sed" ,sed-mesboot1)
+                      ;;("sed" ,sed-mesboot0)
+                      ("tar" ,tar-mesboot2)
+
+                      ("gash" ,%bootstrap-gash) ; for grep
+                      ("guile" ,%bootstrap-guile)
+                      ("kernel-headers" ,%bootstrap-linux-libre-headers)))
      (arguments
       (substitute-keyword-arguments (package-arguments gcc-core-mesboot)
         ((#:make-flags make-flags)
@@ -1061,6 +3310,13 @@ ac_cv_c_float_format='IEEE (little-endian)'
                   (string-append "LDFLAGS_FOR_TARGET=" ldflags))))
         ((#:phases phases)
          `(modify-phases ,phases
+          (replace 'unpack
+            (lambda* (#:key source #:allow-other-keys)
+              (invoke "tar" "zxvf" source)
+              ;;(chdir (first-subdirectory "."))
+              (chdir (string-append "gcc-" ,version))
+              #t))
+            (delete 'patch)
             ;; c&p from commencement.scm:gcc-boot0
             (add-after 'unpack 'unpack-gmp&co
               (lambda* (#:key inputs #:allow-other-keys)
@@ -1204,6 +3460,92 @@ exec " gcc "/bin/" program
                      (program (string-append bin "/gcc")))
                 (invoke program "--help"))))))))))
 
+(define-public xz-mesboot1
+  (package-with-bootstrap-guile
+   (package
+     (inherit xz)
+     (name "xz-mesboot1")
+     ;;(version (package-version xz))
+     (version "5.0.0")
+     (source (origin
+               (method url-fetch)
+               (uri (list (string-append "http://tukaani.org/xz/xz-"; version
+                                         ".tar.gz")
+                          (string-append "http://multiprecision.org/guix/xz-";
+                                         version ".tar.gz")))
+               (sha256
+                (base32
+                 "0kf40ggbs1vaaj5s9k4csycahzqcf65n20pa6lngqhm6j0cj3agb"))))
+     (supported-systems '("i686-linux" "x86_64-linux"))
+     (inputs '())
+     (propagated-inputs '())
+     (native-inputs `(("bash" ,bash-mesboot0)
+                      ("binutils" ,binutils-mesboot0)
+                      ("gawk" ,gawk-mesboot0)
+                      ("gcc" ,gcc-mesboot1-wrapper)
+                      ("gzip" ,gzip-mesboot0)
+                      ("libc" ,glibc-mesboot0)
+                      ("make" ,make-mesboot0)
+                      ("sed" ,sed-mesboot0)
+                      ("tar" ,tar-mesboot0)
+
+                      ("gash" ,%bootstrap-gash)
+                      ("guile" ,%bootstrap-guile)
+                      ("kernel-headers" ,%bootstrap-linux-libre-headers)))
+     (arguments
+      `(#:implicit-inputs? #f
+        #:guile ,%bootstrap-guile
+        #:parallel-build? #f
+        ;;#:tests? #f           ; check is naive, also checks non-built 
PROGRAMS
+        #:configure-flags '("--disable-assembler"
+                            "--enable-small"
+                            "--disable-threads"
+                            "--disable-xzdec"
+                            "--disable-lzmadec"
+                            "--disable-lzmainfo"
+                            "--disable-lzma-links"
+                            "--disable-scripts"
+                            "--disable-doc"
+                            "--disable-nls"
+                            "--disable-symbol-versions"
+                            "CPP=cpp"
+                            "ac_cv_prog_cc_c99=-std=gnu9x"
+                            "gl_cv_posix_shell=bash")
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'unpack 'setenv
+            (lambda _
+              (let ((gash (assoc-ref %build-inputs "gash"))
+                    (bash (assoc-ref %build-inputs "bash")))
+                (setenv "PATH" (string-append  (getenv "PATH") ":" gash 
"/libexec/gash:"))
+                (format #t "PATH=~s\n" (getenv "PATH"))
+                ;;(setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
+                ;; (setenv "CPP" "cpp")
+                ;; (setenv "ac_cv_prog_cc_c99" "-std=c99")
+                ;; (setenv "gl_cv_posix_shell" "bash")
+                #t)))
+          (replace 'unpack
+            (lambda* (#:key source #:allow-other-keys)
+              (invoke "tar" "zxvf" source)
+              ;;(chdir (first-subdirectory "."))
+              (chdir (string-append "xz-" ,version))
+              #t))
+          (add-after 'configure 'fixup-configure
+            (lambda _
+              (let ((config.h (open-file "config.h" "a")))
+                (display (string-append "
+#define restrict __restrict
+")
+                         config.h)
+                (close config.h))
+              #t))
+          ;; (add-after 'unpack 'patch-configure
+          ;;   (lambda _
+          ;;     (substitute* "configure"
+          ;;       (("wchar_t") "int")
+          ;;       (("#include <wchar.h>" all) (string-append "//" all)))))
+          ))))))
+
 (define glibc-headers-mesboot
   (package-with-bootstrap-guile
    (package
@@ -1227,7 +3569,7 @@ exec " gcc "/bin/" program
 
                       ("bash" ,%bootstrap-coreutils&co)
                       ("coreutils" ,%bootstrap-coreutils&co)
-                      ("diffutils" ,diffutils-mesboot)
+                      ("diffutils" ,diffutils-mesboot0)
                       ("kernel-headers" ,%bootstrap-linux-libre-headers)
                       ("make" ,make-mesboot)))
 
@@ -1320,7 +3662,7 @@ exec " gcc "/bin/" program
 
                       ("bash" ,%bootstrap-coreutils&co)
                       ("coreutils" ,%bootstrap-coreutils&co)
-                      ("diffutils" ,diffutils-mesboot)
+                      ("diffutils" ,diffutils-mesboot0)
                       ("kernel-headers" ,%bootstrap-linux-libre-headers)
                       ("make" ,make-mesboot)))
 
@@ -1370,7 +3712,7 @@ exec " gcc "/bin/" program
 
                       ("bash" ,%bootstrap-coreutils&co)
                       ("coreutils" ,%bootstrap-coreutils&co)
-                      ("diffutils" ,diffutils-mesboot)
+                      ("diffutils" ,diffutils-mesboot0)
                       ("kernel-headers" ,%bootstrap-linux-libre-headers)
                       ("make" ,make-mesboot)))
      (arguments



reply via email to

[Prev in Thread] Current Thread [Next in Thread]