perl.scm 5.2 KB

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