[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: Eric Bavier
Subject: 01/06: build-system/perl: Use Build.PL for builds if present.
Date: Thu, 19 Feb 2015 05:54:20 +0000

bavier pushed a commit to branch master
in repository guix.

commit 2d2a53fc24a3feb723772dfc45bb438256de41f9
Author: Eric Bavier <address@hidden>
Date:   Thu Jan 22 23:18:57 2015 -0600

    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 
    * doc/guix.texi (Build Systems)[perl-build-system]: Document behavior rsp.
      Build.PL and new arguments.
 doc/guix.texi                    |   20 +++++++++----
 guix/build-system/perl.scm       |    4 ++
 guix/build/perl-build-system.scm |   59 ++++++++++++++++++++++++++++++--------
 3 files changed, 65 insertions(+), 18 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 50a7084..ccb87c9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -1894,12 +1894,20 @@ parameter.
 @defvr {Scheme Variable} perl-build-system
 This variable is exported by @code{(guix build-system perl)}.  It
-implements the standard build procedure for Perl packages, which
-consists in running @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}},
-followed by @code{make} and @code{make install}.
-The initial @code{perl Makefile.PL} invocation passes flags specified by
-the @code{#:make-maker-flags} parameter.
+implements the standard build procedure for Perl packages, which either
+consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
+followed by @code{Build} and @code{Build install}; or in running
address@hidden Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
address@hidden and @code{make install}; depending on which of
address@hidden 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
address@hidden:make-maker?} parameter.
+The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
+passes flags specified by the @code{#:make-maker-flags} or
address@hidden:module-build-flags} parameter, respectively.
 Which Perl package is used can be specified with @code{#:perl}.
 @end defvr
diff --git a/guix/build-system/perl.scm b/guix/build-system/perl.scm
index c488adb..e0f8643 100644
--- a/guix/build-system/perl.scm
+++ b/guix/build-system/perl.scm
@@ -75,7 +75,9 @@
                      (tests? #t)
                      (parallel-build? #t)
                      (parallel-tests? #t)
+                     (make-maker? #f)
                      (make-maker-flags ''())
+                     (module-build-flags ''())
                      (phases '(@ (guix build perl-build-system)
                      (outputs '("out"))
@@ -101,7 +103,9 @@ provides a `Makefile.PL' file as its build system."
                    #:search-paths ',(map search-path-specification->sexp
+                   #:make-maker? ,make-maker?
                    #:make-maker-flags ,make-maker-flags
+                   #:module-build-flags ,module-build-flags
                    #:phases ,phases
                    #:system ,system
                    #:test-target "test"
diff --git a/guix/build/perl-build-system.scm b/guix/build/perl-build-system.scm
index 904daf7..7eb944c 100644
--- a/guix/build/perl-build-system.scm
+++ b/guix/build/perl-build-system.scm
@@ -29,22 +29,57 @@
 ;; Code:
-(define* (configure #:key outputs (make-maker-flags '())
+(define* (configure #:key outputs make-maker?
+                    (make-maker-flags '()) (module-build-flags '())
   "Configure the given Perl package."
-  (let ((out (assoc-ref outputs "out")))
-    (if (file-exists? "Makefile.PL")
-        (let ((args `("Makefile.PL" ,(string-append "PREFIX=" out)
-                      "INSTALLDIRS=site" ,@make-maker-flags)))
-          (format #t "running `perl' with arguments ~s~%" args)
-          (zero? (apply system* "perl" args)))
-        (error "no Makefile.PL found"))))
+  (let* ((out (assoc-ref outputs "out"))
+         (args (cond
+                ;; Prefer to use Module::Build unless otherwise told
+                ((and (file-exists? "Build.PL")
+                      (not make-maker?))
+                 `("Build.PL" ,(string-append "--prefix=" out)
+                   "--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
-  ;; Everything is as with the GNU Build System except for the `configure'
-  ;; phase.
-  (alist-replace 'configure configure
-                 gnu:%standard-phases))
+  ;; Everything is as with the GNU Build System except for the `configure',
+  ;; `build', `check', and `install' phases.
+  (alist-replace
+   '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)
                      #:allow-other-keys #:rest args)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]