Richard W.M. Jones
2015-Oct-23 14:04 UTC
[Libguestfs] [PATCH] perl: Switch to using Module::Build.
Switch from 'ExtUtils::MakeMaker' to 'Module::Build'. There's not really a huge difference here. The interfacing gymnastics that we have to do to make Makefile.am and Module::Build talk to each other is probably a little bit simpler. I compared the output of 'make install' before and after, and there's not much difference. 'perllocal.pod' is not installed (see recent bug report), and 'bindtests.pl' is also not installed. However the empty file 'Guestfs.bs' is now copied in, but in Fedora we were already removing any '*.bs' files. This is good reading (make sure to read the comments too): http://blogs.perl.org/users/rurban/2011/01/why-modulebuild-sucks.html Rich.
Richard W.M. Jones
2015-Oct-23 14:04 UTC
[Libguestfs] [PATCH] perl: Switch to using Module::Build.
Replace ExtUtils::MakeMaker with Module::Build. 'perllocal.pod' and 'bindtests.pl' are no longer incorrectly installed. This change also removes the following phony deps: appliance src_deps test_images. No other language binding needs explicit dependencies for their tests, they just rely on the top level build order being correct (ie. SUBDIRS in /Makefile.am). --- .gitignore | 12 ++++++------ README | 2 ++ configure.ac | 2 +- generator/main.ml | 2 +- perl/Build.PL.in | 44 +++++++++++++++++++++++++++++++++++++++++++ perl/MANIFEST | 38 +++++++++++++++++++++++++++++++++++++ perl/Makefile.am | 54 ++++++++++++++++------------------------------------- perl/run-perl-tests | 2 +- po/POTFILES | 2 +- 9 files changed, 110 insertions(+), 48 deletions(-) create mode 100755 perl/Build.PL.in create mode 100644 perl/MANIFEST diff --git a/.gitignore b/.gitignore index d5c5d1e..d17f53f 100644 --- a/.gitignore +++ b/.gitignore @@ -371,17 +371,17 @@ Makefile.in /p2v/virt-p2v-make-disk.1 /p2v/virt-p2v-make-kickstart /p2v/virt-p2v-make-kickstart.1 +/perl/_build /perl/bindtests.pl /perl/blib +/perl/Build +/perl/Build.PL /perl/examples/guestfs-perl.3 /perl/examples/stamp-guestfs-perl.pod -/perl/Guestfs.bs -/perl/Guestfs.c -/perl/Guestfs.xs +/perl/lib/Sys/Guestfs.bs +/perl/lib/Sys/Guestfs.c +/perl/lib/Sys/Guestfs.xs /perl/lib/Sys/Guestfs.pm -/perl/Makefile-pl -/perl/Makefile.PL -/perl/Makefile-pl.old /perl/MYMETA.json /perl/MYMETA.yml /perl/pm_to_blib diff --git a/README b/README index 19a1fb2..2c79c0d 100644 --- a/README +++ b/README @@ -192,6 +192,8 @@ The full requirements are described below. +--------------+-------------+---+-----------------------------------------+ | ocaml-gettext| | O | For localizing OCaml virt-* tools. | +--------------+-------------+---+-----------------------------------------+ +| Module::Build| 0.19 | O | To build the Perl bindings. | ++--------------+-------------+---+-----------------------------------------+ | Python | 2.2 | O | For the Python bindings. | +--------------+-------------+---+-----------------------------------------+ | Ruby | | O | >= 1.9 is better than 1.8. | diff --git a/configure.ac b/configure.ac index 4f6650e..6b5b47e 100644 --- a/configure.ac +++ b/configure.ac @@ -1774,8 +1774,8 @@ AC_CONFIG_FILES([Makefile ocaml/Makefile ocaml/examples/Makefile p2v/Makefile + perl/Build.PL perl/Makefile - perl/Makefile.PL perl/examples/Makefile php/Makefile po-docs/Makefile diff --git a/generator/main.ml b/generator/main.ml index 1e0e7d6..35511ce 100644 --- a/generator/main.ml +++ b/generator/main.ml @@ -127,7 +127,7 @@ Run it from the top source directory using the command output_to "ocaml/guestfs-c-actions.c" generate_ocaml_c; output_to "ocaml/guestfs-c-errnos.c" generate_ocaml_c_errnos; output_to "ocaml/bindtests.ml" generate_ocaml_bindtests; - output_to "perl/Guestfs.xs" generate_perl_xs; + output_to "perl/lib/Sys/Guestfs.xs" generate_perl_xs; output_to "perl/lib/Sys/Guestfs.pm" generate_perl_pm; output_to "perl/bindtests.pl" generate_perl_bindtests; output_to "python/guestfs-py.c" generate_python_c; diff --git a/perl/Build.PL.in b/perl/Build.PL.in new file mode 100755 index 0000000..91da6fe --- /dev/null +++ b/perl/Build.PL.in @@ -0,0 +1,44 @@ +#!/usr/bin/env perl +# libguestfs Perl bindings +# Copyright (C) 2009-2015 Red Hat Inc. +# @configure_input@ +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Module::Build; + +my $build = Module::Build->new ( + module_name => 'Sys::Guestfs', + license => 'lgpl', # See COPYING.LIB + + build_requires => { + 'ExtUtils::CBuilder' => 0, + 'Module::Build' => '0.19', # xs support + 'Test::More' => 0, + }, + + requires => { + perl => '5.6.0', + }, + + extra_compiler_flags => '-DGUESTFS_PRIVATE=1 @CFLAGS@', + include_dirs => [ + '@abs_top_builddir@/src', + '@abs_top_srcdir@/src', + ], + extra_linker_flags => '-L@top_builddir@/src/.libs -lguestfs', +); + +$build->create_build_script; diff --git a/perl/MANIFEST b/perl/MANIFEST new file mode 100644 index 0000000..a3d6167 --- /dev/null +++ b/perl/MANIFEST @@ -0,0 +1,38 @@ +bindtests.pl +Build.PL +Build.PL.in +examples/create_disk.pl +examples/guestfs-perl.3 +examples/guestfs-perl.pod +examples/inspect_vm.pl +examples/LICENSE +examples/Makefile.am +examples/Makefile.in +examples/README +examples/stamp-guestfs-perl.pod +lib/Sys/Guestfs.c +lib/Sys/Guestfs.o +lib/Sys/Guestfs.pm +lib/Sys/Guestfs.xs +Makefile.am +Makefile.in +Makefile.PL.in +MANIFEST This list of files +README +run-bindtests +run-perl-tests +t/010-load.t +t/020-create.t +t/030-create-flags.t +t/040-create-multiple.t +t/060-handle-properties.t +t/070-optargs.t +t/100-launch.t +t/410-close-event.t +t/420-log-messages.t +t/800-explicit-close.t +t/810-mkdir-eexist.t +t/900-introspection.t +t/910-pod.t +t/920-pod-coverage.t +typemap diff --git a/perl/Makefile.am b/perl/Makefile.am index 1eb0469..50c6aca 100644 --- a/perl/Makefile.am +++ b/perl/Makefile.am @@ -1,5 +1,5 @@ # libguestfs Perl bindings -# Copyright (C) 2009 Red Hat Inc. +# Copyright (C) 2009-2015 Red Hat Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ generator_built = \ EXTRA_DIST = \ $(generator_built) \ - Makefile.PL.in \ + Build.PL.in \ examples/README \ examples/LICENSE \ examples/*.pl \ @@ -33,54 +33,32 @@ EXTRA_DIST = \ t/*.t \ typemap +CLEANFILES = \ + Build + +clean-local: + rm -rf _build blib + if HAVE_PERL -# Interfacing automake and ExtUtils::MakeMaker known to be -# a nightmare, news at 11. +all: Build + ./Build -# src/ dependencies -src_deps: $(top_builddir)/src/libguestfs.la $(generator_built) +Build: Build.PL + $(PERL) Build.PL --prefix "@prefix@" -# Images used by tests. -test_images: - $(MAKE) -C $(top_builddir)/tests/data - -# Build the appliance. -appliance: - $(MAKE) -C $(top_builddir)/appliance +TESTS_ENVIRONMENT = $(top_builddir)/run --test TESTS = run-bindtests -test_prereq = src_deps all test_images if ENABLE_APPLIANCE -test_prereq += appliance TESTS += run-perl-tests endif -$(TESTS): $(test_prereq) - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - +# Packagers may override this, eg using 'make install INSTALLDIRS=vendor' INSTALLDIRS = site -all: Makefile-pl src_deps - $(MAKE) -f Makefile-pl - -Makefile-pl: Makefile.PL - -[ $(srcdir) != $(builddir) ] && cp -rsu $(abs_srcdir)/. $(builddir)/. - perl Makefile.PL INSTALLDIRS=$(INSTALLDIRS) PREFIX=$(prefix) - -# No! Otherwise it is deleted before the clean-local rule runs. -#CLEANFILES = Makefile-pl - -clean-local: - -$(MAKE) -f Makefile-pl clean - rm -f Makefile-pl - -install-data-hook: - $(MAKE) -C $(srcdir) -f $(abs_builddir)/Makefile-pl \ - DESTDIR=$(DESTDIR) install +install-data-hook: Build + ./Build install --destdir "$(DESTDIR)" --installdirs $(INSTALLDIRS) endif - -.PHONY: appliance src_deps test_images diff --git a/perl/run-perl-tests b/perl/run-perl-tests index 0e7e9ab..8b816b1 100755 --- a/perl/run-perl-tests +++ b/perl/run-perl-tests @@ -18,4 +18,4 @@ set -e -make -f Makefile-pl test "$@" +./Build test diff --git a/po/POTFILES b/po/POTFILES index d90772a..32f88a1 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -278,8 +278,8 @@ p2v/main.c p2v/miniexpect.c p2v/ssh.c p2v/utils.c -perl/Guestfs.c perl/bindtests.pl +perl/lib/Sys/Guestfs.c perl/lib/Sys/Guestfs.pm php/extension/guestfs_php.c python/guestfs-py-byhand.c -- 2.5.0