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

commit 8c502888065865f5ef20134518271cd51a20f661
Author: Jan Nieuwenhuizen <jann...@gnu.org>
Date:   Thu Aug 23 21:05:26 2018 +0200

    gnu: tcc-boot: Use gnu-build-system.
    
    * gnu/packages/mes.scm (tcc-boot): Use gnu-build-system.
---
 gnu/packages/mes.scm | 143 ++++++++++++++++++++++++++++-----------------------
 1 file changed, 78 insertions(+), 65 deletions(-)

diff --git a/gnu/packages/mes.scm b/gnu/packages/mes.scm
index c357d47..94f57e0 100644
--- a/gnu/packages/mes.scm
+++ b/gnu/packages/mes.scm
@@ -492,77 +492,90 @@ standard.")
                (sha256
                 (base32
                  "177bdhwzrnqgyrdv1dwvpd04fcxj68s5pm1dzwny6359ziway8yy"))))
-     (build-system trivial-build-system)
+     (build-system gnu-build-system)
      (supported-systems '("i686-linux" "x86_64-linux"))
-
      (native-inputs
       `(("coreutils" , %bootstrap-coreutils&co)
         ("mes" ,mes-boot)
         ("tcc" ,tcc-boot0)))
      (arguments
-      `(#:modules ((guix build utils))
-        #:builder
-        (begin
-          (use-modules (guix build utils))
-          (let* ((coreutils (assoc-ref %build-inputs "coreutils"))
-                 (source (assoc-ref %build-inputs "source"))
-                 (mes (assoc-ref %build-inputs "mes"))
-                 (tcc (assoc-ref %build-inputs "tcc"))
-                 (out (assoc-ref %outputs "out"))
-                 (libc (assoc-ref %build-inputs "libc"))
-                 (interpreter (if libc
-                                  (string-append libc ,(glibc-dynamic-linker))
-                                  (string-append mes "/lib/mes-loader"))))
-            ;; unpack
-            (setenv "PATH" (string-append
-                            coreutils "/bin"
-                            ":" tcc "/bin"))
-            (format (current-error-port) "PATH=~s\n" (getenv "PATH"))
-            (mkdir-p "source")
-            (system* "tar" "--strip=1" "-C" "source" "-xvf" source)
-            (chdir "source")
-
-            ;; configure
-            (and
-             (zero? (system* "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")))
-             ;; make
-             (zero? (system* "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\"")
-                             "-I" (string-append tcc "/out")
-                             "-L" (string-append tcc "/lib")
-                             "-o" "tcc"
-                             "tcc.c"))
-             (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"))
-             (zero? (system* "tcc" "-D" "TCC_TARGET_I386=1" "-c" "-o" 
"libtcc1.o" "lib/libtcc1.c"))
-             (zero? (system* "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"))))))))))
+      `(#:strip-binaries? #f  ; binutil's strip b0rkes MesCC/M1/hex2 binaries,
+                                        ; tcc-boot also comes with 
MesCC/M1/hex2-built
+                                        ; binaries
+        #:phases
+        (modify-phases %standard-phases
+          (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
+                                      (string-append libc 
,(glibc-dynamic-linker))
+                                      (string-append mes "/lib/mes-loader"))))
+                ;; unpack
+                (setenv "PATH" (string-append
+                                coreutils "/bin"
+                                ":" tcc "/bin"))
+                (format (current-error-port) "PATH=~s\n" (getenv "PATH"))
+                (zero? (system* "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
+                                      (string-append libc 
,(glibc-dynamic-linker))
+                                      (string-append mes "/lib/mes-loader"))))
+                (zero? (system* "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\"")
+                                "-I" (string-append tcc "/out")
+                                "-L" (string-append tcc "/lib")
+                                "-o" "tcc"
+                                "tcc.c")))))
+          (replace 'check
+            (lambda* (#:key outputs #:allow-other-keys)
+              ;; 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"))
+                 (zero? (system* "tcc" "-D" "TCC_TARGET_I386=1" "-c" "-o" 
"libtcc1.o" "lib/libtcc1.c"))
+                 (zero? (system* "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"))))))))))))
 
 (define-public m4-mesboot
   (package-with-bootstrap-guile

Reply via email to