build-system/perl: Use Build.PL for builds if present.

* guix/build/perl-build-system.scm (configure): Use Build.PL if present.
  (build, check, install): New procedures.
  (%standard-phases): Replace build, check, and install phases.
* guix/build-system/perl (perl-build): Add make-maker? and module-build-flags
  arguments.
* doc/guix.texi (Build Systems)[perl-build-system]: Document behavior rsp.
  Build.PL and new arguments.
This commit is contained in:
Eric Bavier 2015-01-22 23:18:57 -06:00
parent 0f3d643b0b
commit 2d2a53fc24
3 changed files with 64 additions and 17 deletions

View File

@ -1894,12 +1894,20 @@ parameter.
@defvr {Scheme Variable} perl-build-system @defvr {Scheme Variable} perl-build-system
This variable is exported by @code{(guix build-system perl)}. It This variable is exported by @code{(guix build-system perl)}. It
implements the standard build procedure for Perl packages, which implements the standard build procedure for Perl packages, which either
consists in running @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
followed by @code{make} and @code{make install}. followed by @code{Build} and @code{Build install}; or in running
@code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
@code{make} and @code{make install}; depending on which of
@code{Build.PL} or @code{Makefile.PL} is present in the package
distribution. Preference is given to the former if both @code{Build.PL}
and @code{Makefile.PL} exist in the package distribution. This
preference can be reversed by specifying @code{#t} for the
@code{#:make-maker?} parameter.
The initial @code{perl Makefile.PL} invocation passes flags specified by The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
the @code{#:make-maker-flags} parameter. passes flags specified by the @code{#:make-maker-flags} or
@code{#:module-build-flags} parameter, respectively.
Which Perl package is used can be specified with @code{#:perl}. Which Perl package is used can be specified with @code{#:perl}.
@end defvr @end defvr

View File

@ -75,7 +75,9 @@
(tests? #t) (tests? #t)
(parallel-build? #t) (parallel-build? #t)
(parallel-tests? #t) (parallel-tests? #t)
(make-maker? #f)
(make-maker-flags ''()) (make-maker-flags ''())
(module-build-flags ''())
(phases '(@ (guix build perl-build-system) (phases '(@ (guix build perl-build-system)
%standard-phases)) %standard-phases))
(outputs '("out")) (outputs '("out"))
@ -101,7 +103,9 @@ provides a `Makefile.PL' file as its build system."
source)) source))
#:search-paths ',(map search-path-specification->sexp #:search-paths ',(map search-path-specification->sexp
search-paths) search-paths)
#:make-maker? ,make-maker?
#:make-maker-flags ,make-maker-flags #:make-maker-flags ,make-maker-flags
#:module-build-flags ,module-build-flags
#:phases ,phases #:phases ,phases
#:system ,system #:system ,system
#:test-target "test" #:test-target "test"

View File

@ -29,22 +29,57 @@
;; ;;
;; Code: ;; Code:
(define* (configure #:key outputs (make-maker-flags '()) (define* (configure #:key outputs make-maker?
(make-maker-flags '()) (module-build-flags '())
#:allow-other-keys) #:allow-other-keys)
"Configure the given Perl package." "Configure the given Perl package."
(let ((out (assoc-ref outputs "out"))) (let* ((out (assoc-ref outputs "out"))
(if (file-exists? "Makefile.PL") (args (cond
(let ((args `("Makefile.PL" ,(string-append "PREFIX=" out) ;; Prefer to use Module::Build unless otherwise told
"INSTALLDIRS=site" ,@make-maker-flags))) ((and (file-exists? "Build.PL")
(format #t "running `perl' with arguments ~s~%" args) (not make-maker?))
(zero? (apply system* "perl" args))) `("Build.PL" ,(string-append "--prefix=" out)
(error "no Makefile.PL found")))) "--installdirs=site" ,@module-build-flags))
((file-exists? "Makefile.PL")
`("Makefile.PL" ,(string-append "PREFIX=" out)
"INSTALLDIRS=site" ,@make-maker-flags))
(else (error "no Build.PL or Makefile.PL found")))))
(format #t "running `perl' with arguments ~s~%" args)
(zero? (apply system* "perl" args))))
(define-syntax-rule (define-w/gnu-fallback* (name args ...) body ...)
(define* (name args ... #:rest rest)
(if (access? "Build" X_OK)
(begin body ...)
(apply (assoc-ref gnu:%standard-phases 'name) rest))))
(define-w/gnu-fallback* (build)
(zero? (system* "./Build")))
(define-w/gnu-fallback* (check #:key target
(tests? (not target)) (test-flags '())
#:allow-other-keys)
(if tests?
(zero? (apply system* "./Build" "test" test-flags))
(begin
(format #t "test suite not run~%")
#t)))
(define-w/gnu-fallback* (install)
(zero? (system* "./Build" "install")))
(define %standard-phases (define %standard-phases
;; Everything is as with the GNU Build System except for the `configure' ;; Everything is as with the GNU Build System except for the `configure',
;; phase. ;; `build', `check', and `install' phases.
(alist-replace 'configure configure (alist-replace
gnu:%standard-phases)) 'configure configure
(alist-replace
'build build
(alist-replace
'check check
(alist-replace
'install install
gnu:%standard-phases)))))
(define* (perl-build #:key inputs (phases %standard-phases) (define* (perl-build #:key inputs (phases %standard-phases)
#:allow-other-keys #:rest args) #:allow-other-keys #:rest args)