gnu: emacs-org: Update to 9.4.
[jackhill/guix/guix.git] / guix / build-system / perl.scm
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
19 (define-module (guix build-system perl)
20 #:use-module (guix store)
21 #:use-module (guix utils)
22 #:use-module (guix derivations)
23 #:use-module (guix search-paths)
24 #:use-module (guix build-system)
25 #:use-module (guix build-system gnu)
26 #:use-module (guix packages)
27 #:use-module (ice-9 match)
28 #:export (%perl-build-system-modules
29 perl-build
30 perl-build-system))
31
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
40 (define %perl-build-system-modules
41 ;; Build-side modules imported by default.
42 `((guix build perl-build-system)
43 ,@%gnu-build-system-modules))
44
45 (define (default-perl)
46 "Return the default Perl package."
47
48 ;; Do not use `@' to avoid introducing circular dependencies.
49 (let ((module (resolve-interface '(gnu packages perl))))
50 (module-ref module 'perl)))
51
52 (define* (lower name
53 #:key source inputs native-inputs outputs
54 system target
55 (perl (default-perl))
56 #:allow-other-keys
57 #:rest arguments)
58 "Return a bag for NAME."
59 (define private-keywords
60 '(#:source #:target #:perl #:inputs #:native-inputs))
61
62 (and (not target) ;XXX: no cross-compilation
63 (bag
64 (name name)
65 (system system)
66 (host-inputs `(,@(if source
67 `(("source" ,source))
68 '())
69 ,@inputs
70
71 ;; Keep the standard inputs of 'gnu-build-system'.
72 ,@(standard-packages)))
73 (build-inputs `(("perl" ,perl)
74 ,@native-inputs))
75 (outputs outputs)
76 (build perl-build)
77 (arguments (strip-keyword-arguments private-keywords arguments)))))
78
79 (define* (perl-build store name inputs
80 #:key
81 (search-paths '())
82 (tests? #t)
83 (parallel-build? #t)
84 (parallel-tests? #t)
85 (make-maker? #f)
86 (make-maker-flags ''())
87 (module-build-flags ''())
88 (phases '(@ (guix build perl-build-system)
89 %standard-phases))
90 (outputs '("out"))
91 (system (%current-system))
92 (guile #f)
93 (imported-modules %perl-build-system-modules)
94 (modules '((guix build perl-build-system)
95 (guix build utils))))
96 "Build SOURCE using PERL, and with INPUTS. This assumes that SOURCE
97 provides a `Makefile.PL' file as its build system."
98 (define builder
99 `(begin
100 (use-modules ,@modules)
101 (perl-build #:name ,name
102 #:source ,(match (assoc-ref inputs "source")
103 (((? derivation? source))
104 (derivation->output-path source))
105 ((source)
106 source)
107 (source
108 source))
109 #:search-paths ',(map search-path-specification->sexp
110 search-paths)
111 #:make-maker? ,make-maker?
112 #:make-maker-flags ,make-maker-flags
113 #:module-build-flags ,module-build-flags
114 #:phases ,phases
115 #:system ,system
116 #:test-target "test"
117 #:tests? ,tests?
118 #:parallel-build? ,parallel-build?
119 #:parallel-tests? ,parallel-tests?
120 #:outputs %outputs
121 #:inputs %build-inputs)))
122
123 (define guile-for-build
124 (match guile
125 ((? package?)
126 (package-derivation store guile system #:graft? #f))
127 (#f ; the default
128 (let* ((distro (resolve-interface '(gnu packages commencement)))
129 (guile (module-ref distro 'guile-final)))
130 (package-derivation store guile system #:graft? #f)))))
131
132 (build-expression->derivation store name builder
133 #:system system
134 #:inputs inputs
135 #:modules imported-modules
136 #:outputs outputs
137 #:guile-for-build guile-for-build))
138
139 (define perl-build-system
140 (build-system
141 (name 'perl)
142 (description "The standard Perl build system")
143 (lower lower)))
144
145 ;;; perl.scm ends here