diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-01-11 16:01:49 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-01-11 16:01:49 +0100 |
commit | 01e354eb83299d00ddd6ba4beb73bac8130beeae (patch) | |
tree | 03368edd8462d818334bec458cd04dc1de4750a1 /guix/build/gnu-build-system.scm | |
parent | bfe384cc4c7e56ac1eceff8b5d92e916507436eb (diff) | |
parent | 28e55604212c01884a77a4f5eb66294c4957c48a (diff) | |
download | gnu-guix-01e354eb83299d00ddd6ba4beb73bac8130beeae.tar gnu-guix-01e354eb83299d00ddd6ba4beb73bac8130beeae.tar.gz |
Merge branch 'core-updates'
Conflicts:
guix/build/union.scm
Diffstat (limited to 'guix/build/gnu-build-system.scm')
-rw-r--r-- | guix/build/gnu-build-system.scm | 90 |
1 files changed, 77 insertions, 13 deletions
diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm index 2b7d1c180e..b7b9fdac95 100644 --- a/guix/build/gnu-build-system.scm +++ b/guix/build/gnu-build-system.scm @@ -1,25 +1,26 @@ -;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*- -;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org> +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org> ;;; -;;; This file is part of Guix. +;;; This file is part of GNU Guix. ;;; -;;; Guix is free software; you can redistribute it and/or modify it +;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; -;;; Guix is distributed in the hope that it will be useful, but +;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License -;;; along with Guix. If not, see <http://www.gnu.org/licenses/>. +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (guix build gnu-build-system) #:use-module (guix build utils) #:use-module (ice-9 ftw) #:use-module (ice-9 match) + #:use-module (ice-9 format) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:export (%standard-phases @@ -82,6 +83,28 @@ (and (zero? (system* "tar" "xvf" source)) (chdir (first-subdirectory ".")))) +(define* (patch-source-shebangs #:key source #:allow-other-keys) + "Patch shebangs in all source files; this includes non-executable +files such as `.in' templates. Most scripts honor $SHELL and +$CONFIG_SHELL, but some don't, such as `mkinstalldirs' or Automake's +`missing' script." + (for-each patch-shebang + (remove file-is-directory? (find-files "." ".*")))) + +(define (patch-generated-file-shebangs . rest) + "Patch shebangs in generated files, including `SHELL' variables in +makefiles." + ;; Patch executable files, some of which might have been generated by + ;; `configure'. + (for-each patch-shebang + (filter (lambda (file) + (and (executable-file? file) + (not (file-is-directory? file)))) + (find-files "." ".*"))) + + ;; Patch `SHELL' in generated makefiles. + (for-each patch-makefile-SHELL (find-files "." "^(GNU)?[mM]akefile$"))) + (define* (patch #:key (patches '()) (patch-flags '("--batch" "-p1")) #:allow-other-keys) (every (lambda (p) @@ -90,23 +113,51 @@ (append patch-flags (list "--input" p))))) patches)) -(define* (configure #:key outputs (configure-flags '()) out-of-source? +(define* (configure #:key inputs outputs (configure-flags '()) out-of-source? #:allow-other-keys) + (define (package-name) + (let* ((out (assoc-ref outputs "out")) + (base (basename out)) + (dash (string-rindex base #\-))) + ;; XXX: We'd rather use `package-name->name+version' or similar. + (if dash + (substring base 0 dash) + base))) + (let* ((prefix (assoc-ref outputs "out")) + (bindir (assoc-ref outputs "bin")) (libdir (assoc-ref outputs "lib")) (includedir (assoc-ref outputs "include")) - (flags `(,(string-append "--prefix=" prefix) + (docdir (assoc-ref outputs "doc")) + (bash (or (and=> (assoc-ref inputs "bash") + (cut string-append <> "/bin/bash")) + "/bin/sh")) + (flags `(,(string-append "CONFIG_SHELL=" bash) + ,(string-append "SHELL=" bash) + ,(string-append "--prefix=" prefix) "--enable-fast-install" ; when using Libtool ;; Produce multiple outputs when specific output names ;; are recognized. + ,@(if bindir + (list (string-append "--bindir=" bindir "/bin")) + '()) ,@(if libdir - (list (string-append "--libdir=" libdir "/lib")) + (cons (string-append "--libdir=" libdir "/lib") + (if includedir + '() + (list + (string-append "--includedir=" + libdir "/include")))) '()) ,@(if includedir (list (string-append "--includedir=" includedir "/include")) '()) + ,@(if docdir + (list (string-append "--docdir=" docdir + "/doc/" (package-name))) + '()) ,@configure-flags)) (abs-srcdir (getcwd)) (srcdir (if out-of-source? @@ -121,10 +172,15 @@ (format #t "build directory: ~s~%" (getcwd)) (format #t "configure flags: ~s~%" flags) + ;; Use BASH to reduce reliance on /bin/sh since it may not always be + ;; reliable (see + ;; <http://thread.gmane.org/gmane.linux.distributions.nixos/9748> + ;; for a summary of the situation.) + ;; ;; Call `configure' with a relative path. Otherwise, GCC's build system ;; (for instance) records absolute source file names, which typically ;; contain the hash part of the `.drv' file, leading to a reference leak. - (zero? (apply system* + (zero? (apply system* bash (string-append srcdir "/configure") flags)))) @@ -221,7 +277,9 @@ ;; Standard build phases, as a list of symbol/procedure pairs. (let-syntax ((phases (syntax-rules () ((_ p ...) `((p . ,p) ...))))) - (phases set-paths unpack patch configure build check install + (phases set-paths unpack patch + patch-source-shebangs configure patch-generated-file-shebangs + build check install patch-shebangs strip))) @@ -232,11 +290,17 @@ "Build from SOURCE to OUTPUTS, using INPUTS, and by running all of PHASES in order. Return #t if all the PHASES succeeded, #f otherwise." (setvbuf (current-output-port) _IOLBF) + (setvbuf (current-error-port) _IOLBF) ;; The trick is to #:allow-other-keys everywhere, so that each procedure in ;; PHASES can pick the keyword arguments it's interested in. (every (match-lambda ((name . proc) - (format #t "starting phase `~a'~%" name) - (apply proc args))) + (let ((start (gettimeofday))) + (format #t "starting phase `~a'~%" name) + (let ((result (apply proc args)) + (end (gettimeofday))) + (format #t "phase `~a' ~:[failed~;succeeded~] after ~a seconds~%" + name result (- (car end) (car start))) + result)))) phases)) |