build-system/gnu: Support parallel builds and tests.
[guix.git] / guix / build-system / gnu.scm
blob20b7fbe897a76bb1dce8c41b81c1cf81fe65000a
1 ;;; Guix --- Nix package management from Guile.         -*- coding: utf-8 -*-
2 ;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org>
3 ;;;
4 ;;; This file is part of Guix.
5 ;;;
6 ;;; Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with Guix.  If not, see <http://www.gnu.org/licenses/>.
19 (define-module (guix build-system gnu)
20   #:use-module (guix store)
21   #:use-module (guix utils)
22   #:use-module (guix derivations)
23   #:use-module (guix build-system)
24   #:use-module (srfi srfi-1)
25   #:export (gnu-build
26             gnu-build-system))
28 ;; Commentary:
30 ;; Standard build procedure for packages using the GNU Build System or
31 ;; something compatible ("./configure && make && make install").
33 ;; Code:
35 (define %standard-inputs
36   (compile-time-value
37    (map (lambda (name)
38           (list name (nixpkgs-derivation name)))
39         '("gnutar" "gzip" "bzip2" "xz" "diffutils" "patch"
40           "coreutils" "gnused" "gnugrep" "bash"
41           "gawk"                                  ; used by `config.status'
42           "gcc" "binutils" "gnumake" "glibc"))))
44 (define* (gnu-build store name source inputs
45                     #:key (outputs '("out")) (configure-flags ''())
46                     (make-flags ''())
47                     (patches ''()) (patch-flags ''("--batch" "-p1"))
48                     (parallel-build? #t) (parallel-tests? #t)
49                     (phases '%standard-phases)
50                     (system (%current-system))
51                     (modules '((guix build gnu-build-system)
52                                (guix build utils))))
53   "Return a derivation called NAME that builds from tarball SOURCE, with
54 input derivation INPUTS, using the usual procedure of the GNU Build System."
55   (define builder
56     `(begin
57        (use-modules ,@modules)
58        (gnu-build #:source ,(if (derivation-path? source)
59                                 (derivation-path->output-path source)
60                                 source)
61                   #:outputs %outputs
62                   #:inputs %build-inputs
63                   #:patches ,patches
64                   #:patch-flags ,patch-flags
65                   #:phases ,phases
66                   #:configure-flags ,configure-flags
67                   #:make-flags ,make-flags
68                   #:parallel-build? ,parallel-build?
69                   #:parallel-tests? ,parallel-tests?)))
71   (build-expression->derivation store name system
72                                 builder
73                                 `(("source" ,source)
74                                   ,@inputs
75                                   ,@%standard-inputs)
76                                 #:outputs outputs
77                                 #:modules modules))
79 (define gnu-build-system
80   (build-system (name 'gnu)
81                 (description
82                  "The GNU Build System—i.e., ./configure && make && make install")
83                 (build gnu-build)))             ; TODO: add `gnu-cross-build'