perl-build-system.scm 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2013, 2015, 2018 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2018 Mark H Weaver <mhw@netris.org>
  4. ;;;
  5. ;;; This file is part of GNU Guix.
  6. ;;;
  7. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  8. ;;; under the terms of the GNU General Public License as published by
  9. ;;; the Free Software Foundation; either version 3 of the License, or (at
  10. ;;; your option) any later version.
  11. ;;;
  12. ;;; GNU Guix is distributed in the hope that it will be useful, but
  13. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;;; GNU General Public License for more details.
  16. ;;;
  17. ;;; You should have received a copy of the GNU General Public License
  18. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  19. (define-module (guix build perl-build-system)
  20. #:use-module ((guix build gnu-build-system) #:prefix gnu:)
  21. #:use-module (guix build utils)
  22. #:use-module (ice-9 match)
  23. #:export (%standard-phases
  24. perl-build))
  25. ;; Commentary:
  26. ;;
  27. ;; Builder-side code of the standard Perl package build procedure.
  28. ;;
  29. ;; Code:
  30. (define* (configure #:key outputs make-maker?
  31. (make-maker-flags '()) (module-build-flags '())
  32. #:allow-other-keys)
  33. "Configure the given Perl package."
  34. (let* ((out (assoc-ref outputs "out"))
  35. (args (cond
  36. ;; Prefer to use Module::Build unless otherwise told
  37. ((and (file-exists? "Build.PL")
  38. (not make-maker?))
  39. `("Build.PL" ,(string-append "--prefix=" out)
  40. "--installdirs=site" ,@module-build-flags))
  41. ((file-exists? "Makefile.PL")
  42. `("Makefile.PL" ,(string-append "PREFIX=" out)
  43. ;; Prevent installation of 'perllocal.pod' files for
  44. ;; determinism. These are typically used to build a
  45. ;; catalogue of installed packages, but does not provide
  46. ;; any useful information when installed with a module.
  47. "INSTALLDIRS=site" "NO_PERLLOCAL=1" ,@make-maker-flags))
  48. (else (error "no Build.PL or Makefile.PL found")))))
  49. (format #t "running `perl' with arguments ~s~%" args)
  50. (apply invoke "perl" args)))
  51. (define-syntax-rule (define-w/gnu-fallback* (name args ...) body ...)
  52. (define* (name args ... #:rest rest)
  53. (if (access? "Build" X_OK)
  54. (begin body ...)
  55. (apply (assoc-ref gnu:%standard-phases 'name) rest))))
  56. (define-w/gnu-fallback* (build)
  57. (invoke "./Build"))
  58. (define-w/gnu-fallback* (check #:key target
  59. (tests? (not target)) (test-flags '())
  60. #:allow-other-keys)
  61. (if tests?
  62. (apply invoke "./Build" "test" test-flags)
  63. (format #t "test suite not run~%"))
  64. #t)
  65. (define-w/gnu-fallback* (install)
  66. (invoke "./Build" "install"))
  67. (define %standard-phases
  68. ;; Everything is as with the GNU Build System except for the `configure',
  69. ;; `build', `check', and `install' phases.
  70. (modify-phases gnu:%standard-phases
  71. (delete 'bootstrap)
  72. (replace 'install install)
  73. (replace 'check check)
  74. (replace 'build build)
  75. (replace 'configure configure)))
  76. (define* (perl-build #:key inputs (phases %standard-phases)
  77. #:allow-other-keys #:rest args)
  78. "Build the given Perl package, applying all of PHASES in order."
  79. (apply gnu:gnu-build
  80. #:inputs inputs #:phases phases
  81. args))
  82. ;;; perl-build-system.scm ends here