perl.scm 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  6. ;;; GNU 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. ;;; GNU 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (guix build-system perl)
  19. #:use-module (guix store)
  20. #:use-module (guix utils)
  21. #:use-module (guix derivations)
  22. #:use-module (guix search-paths)
  23. #:use-module (guix build-system)
  24. #:use-module (guix build-system gnu)
  25. #:use-module (guix packages)
  26. #:use-module (ice-9 match)
  27. #:export (%perl-build-system-modules
  28. perl-build
  29. perl-build-system))
  30. ;; Commentary:
  31. ;;
  32. ;; Standard build procedure for Perl packages using the "makefile
  33. ;; maker"---i.e., "perl Makefile.PL". This is implemented as an extension of
  34. ;; `gnu-build-system'.
  35. ;;
  36. ;; Code:
  37. (define %perl-build-system-modules
  38. ;; Build-side modules imported by default.
  39. `((guix build perl-build-system)
  40. ,@%gnu-build-system-modules))
  41. (define (default-perl)
  42. "Return the default Perl package."
  43. ;; Do not use `@' to avoid introducing circular dependencies.
  44. (let ((module (resolve-interface '(gnu packages perl))))
  45. (module-ref module 'perl)))
  46. (define* (lower name
  47. #:key source inputs native-inputs outputs
  48. system target
  49. (perl (default-perl))
  50. #:allow-other-keys
  51. #:rest arguments)
  52. "Return a bag for NAME."
  53. (define private-keywords
  54. '(#:source #:target #:perl #:inputs #:native-inputs))
  55. (and (not target) ;XXX: no cross-compilation
  56. (bag
  57. (name name)
  58. (system system)
  59. (host-inputs `(,@(if source
  60. `(("source" ,source))
  61. '())
  62. ,@inputs
  63. ;; Keep the standard inputs of 'gnu-build-system'.
  64. ,@(standard-packages)))
  65. (build-inputs `(("perl" ,perl)
  66. ,@native-inputs))
  67. (outputs outputs)
  68. (build perl-build)
  69. (arguments (strip-keyword-arguments private-keywords arguments)))))
  70. (define* (perl-build store name inputs
  71. #:key
  72. (search-paths '())
  73. (tests? #t)
  74. (parallel-build? #t)
  75. (parallel-tests? #t)
  76. (make-maker? #f)
  77. (make-maker-flags ''())
  78. (module-build-flags ''())
  79. (phases '(@ (guix build perl-build-system)
  80. %standard-phases))
  81. (outputs '("out"))
  82. (system (%current-system))
  83. (guile #f)
  84. (imported-modules %perl-build-system-modules)
  85. (modules '((guix build perl-build-system)
  86. (guix build utils))))
  87. "Build SOURCE using PERL, and with INPUTS. This assumes that SOURCE
  88. provides a `Makefile.PL' file as its build system."
  89. (define builder
  90. `(begin
  91. (use-modules ,@modules)
  92. (perl-build #:name ,name
  93. #:source ,(match (assoc-ref inputs "source")
  94. (((? derivation? source))
  95. (derivation->output-path source))
  96. ((source)
  97. source)
  98. (source
  99. source))
  100. #:search-paths ',(map search-path-specification->sexp
  101. search-paths)
  102. #:make-maker? ,make-maker?
  103. #:make-maker-flags ,make-maker-flags
  104. #:module-build-flags ,module-build-flags
  105. #:phases ,phases
  106. #:system ,system
  107. #:test-target "test"
  108. #:tests? ,tests?
  109. #:parallel-build? ,parallel-build?
  110. #:parallel-tests? ,parallel-tests?
  111. #:outputs %outputs
  112. #:inputs %build-inputs)))
  113. (define guile-for-build
  114. (match guile
  115. ((? package?)
  116. (package-derivation store guile system #:graft? #f))
  117. (#f ; the default
  118. (let* ((distro (resolve-interface '(gnu packages commencement)))
  119. (guile (module-ref distro 'guile-final)))
  120. (package-derivation store guile system #:graft? #f)))))
  121. (build-expression->derivation store name builder
  122. #:system system
  123. #:inputs inputs
  124. #:modules imported-modules
  125. #:outputs outputs
  126. #:guile-for-build guile-for-build))
  127. (define perl-build-system
  128. (build-system
  129. (name 'perl)
  130. (description "The standard Perl build system")
  131. (lower lower)))
  132. ;;; perl.scm ends here