Mirror of GNU Guix
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.6 KiB

  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/>.
  18. (define-module (guix build-system gnu)
  19. #:use-module (guix store)
  20. #:use-module (guix utils)
  21. #:use-module (guix derivations)
  22. #:use-module (guix build-system)
  23. #:use-module (srfi srfi-1)
  24. #:export (gnu-build
  25. gnu-build-system))
  26. ;; Commentary:
  27. ;;
  28. ;; Standard build procedure for packages using the GNU Build System or
  29. ;; something compatible ("./configure && make && make install").
  30. ;;
  31. ;; Code:
  32. (define %standard-inputs
  33. (compile-time-value
  34. (map (lambda (name)
  35. (list name (nixpkgs-derivation name)))
  36. '("gnutar" "gzip" "bzip2" "xz" "diffutils" "patch"
  37. "coreutils" "gnused" "gnugrep" "bash"
  38. "findutils" ; used by `libtool'
  39. "gawk" ; used by `config.status'
  40. "gcc" "binutils" "gnumake" "glibc"))))
  41. (define* (gnu-build store name source inputs
  42. #:key (outputs '("out")) (configure-flags ''())
  43. (make-flags ''())
  44. (patches ''()) (patch-flags ''("--batch" "-p1"))
  45. (tests? #t)
  46. (parallel-build? #t) (parallel-tests? #t)
  47. (patch-shebangs? #t)
  48. (phases '%standard-phases)
  49. (system (%current-system))
  50. (modules '((guix build gnu-build-system)
  51. (guix build utils))))
  52. "Return a derivation called NAME that builds from tarball SOURCE, with
  53. input derivation INPUTS, using the usual procedure of the GNU Build System."
  54. (define builder
  55. `(begin
  56. (use-modules ,@modules)
  57. (gnu-build #:source ,(if (derivation-path? source)
  58. (derivation-path->output-path source)
  59. source)
  60. #:outputs %outputs
  61. #:inputs %build-inputs
  62. #:patches ,patches
  63. #:patch-flags ,patch-flags
  64. #:phases ,phases
  65. #:configure-flags ,configure-flags
  66. #:make-flags ,make-flags
  67. #:tests? ,tests?
  68. #:parallel-build? ,parallel-build?
  69. #:parallel-tests? ,parallel-tests?
  70. #:patch-shebangs? ,patch-shebangs?)))
  71. (build-expression->derivation store name system
  72. builder
  73. `(("source" ,source)
  74. ,@inputs
  75. ,@%standard-inputs)
  76. #:outputs outputs
  77. #:modules modules))
  78. (define gnu-build-system
  79. (build-system (name 'gnu)
  80. (description
  81. "The GNU Build System—i.e., ./configure && make && make install")
  82. (build gnu-build))) ; TODO: add `gnu-cross-build'