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.

83 lines
3.4 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. "gawk" ; used by `config.status'
  39. "gcc" "binutils" "gnumake" "glibc"))))
  40. (define* (gnu-build store name source inputs
  41. #:key (outputs '("out")) (configure-flags ''())
  42. (make-flags ''())
  43. (patches ''()) (patch-flags ''("--batch" "-p1"))
  44. (parallel-build? #t) (parallel-tests? #t)
  45. (phases '%standard-phases)
  46. (system (%current-system))
  47. (modules '((guix build gnu-build-system)
  48. (guix build utils))))
  49. "Return a derivation called NAME that builds from tarball SOURCE, with
  50. input derivation INPUTS, using the usual procedure of the GNU Build System."
  51. (define builder
  52. `(begin
  53. (use-modules ,@modules)
  54. (gnu-build #:source ,(if (derivation-path? source)
  55. (derivation-path->output-path source)
  56. source)
  57. #:outputs %outputs
  58. #:inputs %build-inputs
  59. #:patches ,patches
  60. #:patch-flags ,patch-flags
  61. #:phases ,phases
  62. #:configure-flags ,configure-flags
  63. #:make-flags ,make-flags
  64. #:parallel-build? ,parallel-build?
  65. #:parallel-tests? ,parallel-tests?)))
  66. (build-expression->derivation store name system
  67. builder
  68. `(("source" ,source)
  69. ,@inputs
  70. ,@%standard-inputs)
  71. #:outputs outputs
  72. #:modules modules))
  73. (define gnu-build-system
  74. (build-system (name 'gnu)
  75. (description
  76. "The GNU Build System—i.e., ./configure && make && make install")
  77. (build gnu-build))) ; TODO: add `gnu-cross-build'