Commit | Line | Data |
---|---|---|
08fd1ebe | 1 | ;;; GNU Guix --- Functional package management for GNU |
bb42c78a | 2 | ;;; Copyright © 2013, 2014, 2015 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-system perl) | |
20 | #:use-module (guix store) | |
21 | #:use-module (guix utils) | |
22 | #:use-module (guix derivations) | |
e89431bf | 23 | #:use-module (guix search-paths) |
08fd1ebe LC |
24 | #:use-module (guix build-system) |
25 | #:use-module (guix build-system gnu) | |
26 | #:use-module (guix packages) | |
27 | #:use-module (ice-9 match) | |
bb42c78a LC |
28 | #:export (%perl-build-system-modules |
29 | perl-build | |
08fd1ebe LC |
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 | ||
bb42c78a LC |
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 | ||
b421cebd LC |
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 | ||
0d5a559f | 52 | (define* (lower name |
d3d337d2 LC |
53 | #:key source inputs native-inputs outputs |
54 | system target | |
0d5a559f LC |
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) | |
d3d337d2 | 65 | (system system) |
0d5a559f LC |
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 | |
08fd1ebe | 80 | #:key |
a18eda27 | 81 | (search-paths '()) |
08fd1ebe | 82 | (tests? #t) |
384de552 AE |
83 | (parallel-build? #t) |
84 | (parallel-tests? #t) | |
2d2a53fc | 85 | (make-maker? #f) |
08fd1ebe | 86 | (make-maker-flags ''()) |
2d2a53fc | 87 | (module-build-flags ''()) |
08fd1ebe LC |
88 | (phases '(@ (guix build perl-build-system) |
89 | %standard-phases)) | |
90 | (outputs '("out")) | |
91 | (system (%current-system)) | |
92 | (guile #f) | |
bb42c78a | 93 | (imported-modules %perl-build-system-modules) |
08fd1ebe | 94 | (modules '((guix build perl-build-system) |
08fd1ebe LC |
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 | |
0d5a559f LC |
102 | #:source ,(match (assoc-ref inputs "source") |
103 | (((? derivation? source)) | |
104 | (derivation->output-path source)) | |
105 | ((source) | |
106 | source) | |
107 | (source | |
108 | source)) | |
a18eda27 | 109 | #:search-paths ',(map search-path-specification->sexp |
0d5a559f | 110 | search-paths) |
2d2a53fc | 111 | #:make-maker? ,make-maker? |
08fd1ebe | 112 | #:make-maker-flags ,make-maker-flags |
2d2a53fc | 113 | #:module-build-flags ,module-build-flags |
9200c110 | 114 | #:phases ,phases |
08fd1ebe LC |
115 | #:system ,system |
116 | #:test-target "test" | |
117 | #:tests? ,tests? | |
384de552 AE |
118 | #:parallel-build? ,parallel-build? |
119 | #:parallel-tests? ,parallel-tests? | |
08fd1ebe LC |
120 | #:outputs %outputs |
121 | #:inputs %build-inputs))) | |
122 | ||
123 | (define guile-for-build | |
124 | (match guile | |
125 | ((? package?) | |
05962f29 | 126 | (package-derivation store guile system #:graft? #f)) |
08fd1ebe | 127 | (#f ; the default |
bdb36958 | 128 | (let* ((distro (resolve-interface '(gnu packages commencement))) |
08fd1ebe | 129 | (guile (module-ref distro 'guile-final))) |
05962f29 | 130 | (package-derivation store guile system #:graft? #f))))) |
08fd1ebe | 131 | |
0d5a559f LC |
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)) | |
08fd1ebe LC |
138 | |
139 | (define perl-build-system | |
0d5a559f LC |
140 | (build-system |
141 | (name 'perl) | |
142 | (description "The standard Perl build system") | |
143 | (lower lower))) | |
08fd1ebe LC |
144 | |
145 | ;;; perl.scm ends here |