build-system/gnu: Add 'bootstrap' phase.
[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>
08fd1ebe
LC
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
19(define-module (guix build perl-build-system)
b5b73a82 20 #:use-module ((guix build gnu-build-system) #:prefix gnu:)
08fd1ebe
LC
21 #:use-module (guix build utils)
22 #:use-module (ice-9 match)
23 #:export (%standard-phases
24 perl-build))
25
26;; Commentary:
27;;
28;; Builder-side code of the standard Perl package build procedure.
29;;
30;; Code:
31
2d2a53fc
EB
32(define* (configure #:key outputs make-maker?
33 (make-maker-flags '()) (module-build-flags '())
08fd1ebe
LC
34 #:allow-other-keys)
35 "Configure the given Perl package."
2d2a53fc
EB
36 (let* ((out (assoc-ref outputs "out"))
37 (args (cond
38 ;; Prefer to use Module::Build unless otherwise told
39 ((and (file-exists? "Build.PL")
40 (not make-maker?))
41 `("Build.PL" ,(string-append "--prefix=" out)
42 "--installdirs=site" ,@module-build-flags))
43 ((file-exists? "Makefile.PL")
44 `("Makefile.PL" ,(string-append "PREFIX=" out)
be12f4e2
MB
45 ;; Prevent installation of 'perllocal.pod' files for
46 ;; determinism. These are typically used to build a
47 ;; catalogue of installed packages, but does not provide
48 ;; any useful information when installed with a module.
49 "INSTALLDIRS=site" "NO_PERLLOCAL=1" ,@make-maker-flags))
2d2a53fc
EB
50 (else (error "no Build.PL or Makefile.PL found")))))
51 (format #t "running `perl' with arguments ~s~%" args)
52 (zero? (apply system* "perl" args))))
53
54(define-syntax-rule (define-w/gnu-fallback* (name args ...) body ...)
55 (define* (name args ... #:rest rest)
56 (if (access? "Build" X_OK)
57 (begin body ...)
58 (apply (assoc-ref gnu:%standard-phases 'name) rest))))
59
60(define-w/gnu-fallback* (build)
61 (zero? (system* "./Build")))
62
63(define-w/gnu-fallback* (check #:key target
64 (tests? (not target)) (test-flags '())
65 #:allow-other-keys)
66 (if tests?
67 (zero? (apply system* "./Build" "test" test-flags))
68 (begin
69 (format #t "test suite not run~%")
70 #t)))
71
72(define-w/gnu-fallback* (install)
73 (zero? (system* "./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