gnu: r-igraph: Move to (gnu packages cran).
[jackhill/guix/guix.git] / guix / build / perl-build-system.scm
CommitLineData
08fd1ebe 1;;; GNU Guix --- Functional package management for GNU
189be331 2;;; Copyright © 2013, 2015, 2018 Ludovic Courtès <ludo@gnu.org>
9e58fd9d 3;;; Copyright © 2018 Mark H Weaver <mhw@netris.org>
08fd1ebe
LC
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
20(define-module (guix build perl-build-system)
b5b73a82 21 #:use-module ((guix build gnu-build-system) #:prefix gnu:)
08fd1ebe
LC
22 #:use-module (guix build utils)
23 #:use-module (ice-9 match)
24 #:export (%standard-phases
25 perl-build))
26
27;; Commentary:
28;;
29;; Builder-side code of the standard Perl package build procedure.
30;;
31;; Code:
32
2d2a53fc
EB
33(define* (configure #:key outputs make-maker?
34 (make-maker-flags '()) (module-build-flags '())
08fd1ebe
LC
35 #:allow-other-keys)
36 "Configure the given Perl package."
2d2a53fc
EB
37 (let* ((out (assoc-ref outputs "out"))
38 (args (cond
39 ;; Prefer to use Module::Build unless otherwise told
40 ((and (file-exists? "Build.PL")
41 (not make-maker?))
42 `("Build.PL" ,(string-append "--prefix=" out)
43 "--installdirs=site" ,@module-build-flags))
44 ((file-exists? "Makefile.PL")
45 `("Makefile.PL" ,(string-append "PREFIX=" out)
be12f4e2
MB
46 ;; Prevent installation of 'perllocal.pod' files for
47 ;; determinism. These are typically used to build a
48 ;; catalogue of installed packages, but does not provide
49 ;; any useful information when installed with a module.
50 "INSTALLDIRS=site" "NO_PERLLOCAL=1" ,@make-maker-flags))
2d2a53fc
EB
51 (else (error "no Build.PL or Makefile.PL found")))))
52 (format #t "running `perl' with arguments ~s~%" args)
9e58fd9d 53 (apply invoke "perl" args)))
2d2a53fc
EB
54
55(define-syntax-rule (define-w/gnu-fallback* (name args ...) body ...)
56 (define* (name args ... #:rest rest)
57 (if (access? "Build" X_OK)
58 (begin body ...)
59 (apply (assoc-ref gnu:%standard-phases 'name) rest))))
60
61(define-w/gnu-fallback* (build)
9e58fd9d 62 (invoke "./Build"))
2d2a53fc
EB
63
64(define-w/gnu-fallback* (check #:key target
65 (tests? (not target)) (test-flags '())
66 #:allow-other-keys)
67 (if tests?
9e58fd9d
MW
68 (apply invoke "./Build" "test" test-flags)
69 (format #t "test suite not run~%"))
70 #t)
2d2a53fc
EB
71
72(define-w/gnu-fallback* (install)
9e58fd9d 73 (invoke "./Build" "install"))
08fd1ebe
LC
74
75(define %standard-phases
2d2a53fc
EB
76 ;; Everything is as with the GNU Build System except for the `configure',
77 ;; `build', `check', and `install' phases.
f84218ac 78 (modify-phases gnu:%standard-phases
189be331 79 (delete 'bootstrap)
f8503e2b
LC
80 (replace 'install install)
81 (replace 'check check)
82 (replace 'build build)
83 (replace 'configure configure)))
08fd1ebe
LC
84
85(define* (perl-build #:key inputs (phases %standard-phases)
86 #:allow-other-keys #:rest args)
87 "Build the given Perl package, applying all of PHASES in order."
08fd1ebe
LC
88 (apply gnu:gnu-build
89 #:inputs inputs #:phases phases
90 args))
91
92;;; perl-build-system.scm ends here