From 53dcd5eea1479ad5bde7e6d17793687c83c54ad8 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 5 Nov 2012 23:50:05 +0100 Subject: build-system/gnu: Add `static-libgcc-package' & supporting procedure. * guix/build-system/gnu.scm (package-with-extra-configure-variable, static-libgcc-package): New procedures. --- guix/build-system/gnu.scm | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm index 994b386e5c..9d94680d93 100644 --- a/guix/build-system/gnu.scm +++ b/guix/build-system/gnu.scm @@ -27,7 +27,9 @@ (define-module (guix build-system gnu) #:use-module (ice-9 match) #:export (gnu-build gnu-build-system - package-with-explicit-inputs)) + package-with-explicit-inputs + package-with-extra-configure-variable + static-libgcc-package)) ;; Commentary: ;; @@ -77,6 +79,45 @@ (define (filtered-inputs inputs) ,@(map rewritten-input (filtered-inputs (package-inputs p))))))) +(define (package-with-extra-configure-variable p variable value) + "Return a version of P with VARIABLE=VALUE specified as an extra +`configure' flag. An example is LDFLAGS=-static. If P already has +configure flags for VARIABLE, the associated value is augmented." + (let loop ((p p)) + (define (rewritten-inputs inputs) + (map (match-lambda + ((name (? package? p) sub ...) + `(,name ,(loop p) ,@sub)) + (input input)) + inputs)) + + (package (inherit p) + (arguments + (lambda (system) + (let ((args (match (package-arguments p) + ((? procedure? proc) + (proc system)) + (x x)))) + (substitute-keyword-arguments args + ((#:configure-flags flags) + (let* ((var= (string-append variable "=")) + (len (string-length var=))) + `(cons ,(string-append var= value) + (map (lambda (flag) + (if (string-prefix? ,var= flag) + (string-append + ,(string-append var= value " ") + (substring flag ,len)) + flag)) + ,flags)))))))) + (inputs (rewritten-inputs (package-inputs p))) + (propagated-inputs (rewritten-inputs (package-propagated-inputs p)))))) + +(define (static-libgcc-package p) + "A version of P linked with `-static-gcc'." + (package-with-extra-configure-variable p "LDFLAGS" "-static-libgcc")) + + (define %store ;; Store passed to STANDARD-INPUTS. (make-parameter #f)) -- cgit v1.2.3