diff options
Diffstat (limited to 'Debian/Debhelper/Buildsystem')
-rw-r--r-- | Debian/Debhelper/Buildsystem/autotools.pm | 54 | ||||
-rw-r--r-- | Debian/Debhelper/Buildsystem/cmake.pm | 49 | ||||
-rw-r--r-- | Debian/Debhelper/Buildsystem/makefile.pm | 84 | ||||
-rw-r--r-- | Debian/Debhelper/Buildsystem/perl_build.pm | 67 | ||||
-rw-r--r-- | Debian/Debhelper/Buildsystem/perl_makefile.pm | 38 | ||||
-rw-r--r-- | Debian/Debhelper/Buildsystem/python_distutils.pm | 62 |
6 files changed, 354 insertions, 0 deletions
diff --git a/Debian/Debhelper/Buildsystem/autotools.pm b/Debian/Debhelper/Buildsystem/autotools.pm new file mode 100644 index 00000000..65694b36 --- /dev/null +++ b/Debian/Debhelper/Buildsystem/autotools.pm @@ -0,0 +1,54 @@ +# A buildsystem plugin for handling autotools based projects +# +# Copyright: © 2008 Joey Hess +# © 2008-2009 Modestas Vainius +# License: GPL-2+ + +package Debian::Debhelper::Buildsystem::autotools; + +use strict; +use File::Spec; +use Debian::Debhelper::Dh_Lib; +use base 'Debian::Debhelper::Buildsystem::makefile'; + +sub DESCRIPTION { + "support for building GNU Autotools based packages" +} + +sub is_buildable { + my $self=shift; + my ($action) = @_; + if ($action eq "configure") { + return -x "configure"; + } else { + return $self->SUPER::is_buildable(@_); + } +} + +sub configure_impl { + my $self=shift; + + # Standard set of options for configure. + my @opts; + push @opts, "--build=" . dpkg_architecture_value("DEB_BUILD_GNU_TYPE"); + push @opts, "--prefix=/usr"; + push @opts, "--includedir=\${prefix}/include"; + push @opts, "--mandir=\${prefix}/share/man"; + push @opts, "--infodir=\${prefix}/share/info"; + push @opts, "--sysconfdir=/etc"; + push @opts, "--localstatedir=/var"; + push @opts, "--libexecdir=\${prefix}/lib/" . $self->exec_in_topdir(\&sourcepackage); + push @opts, "--disable-maintainer-mode"; + push @opts, "--disable-dependency-tracking"; + # Provide --host only if different from --build, as recommended in + # autotools-dev README.Debian: When provided (even if equal) autotools + # 2.52+ switches to cross-compiling mode. + if (dpkg_architecture_value("DEB_BUILD_GNU_TYPE") + ne dpkg_architecture_value("DEB_HOST_GNU_TYPE")) { + push @opts, "--host=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE"); + } + + doit($self->get_toppath("configure"), @opts, @_); +} + +1; diff --git a/Debian/Debhelper/Buildsystem/cmake.pm b/Debian/Debhelper/Buildsystem/cmake.pm new file mode 100644 index 00000000..d7504d18 --- /dev/null +++ b/Debian/Debhelper/Buildsystem/cmake.pm @@ -0,0 +1,49 @@ +# A buildsystem plugin for handling CMake based projects. +# It enforces outside-source building. +# +# Copyright: © 2008-2009 Modestas Vainius +# License: GPL-2+ + +package Debian::Debhelper::Buildsystem::cmake; + +use strict; +use Debian::Debhelper::Dh_Lib; +use base 'Debian::Debhelper::Buildsystem::makefile'; + +sub _add_cmake_flag { + my ($self, $name, $val) = @_; + push @{$self->{cmake_flags}}, "-D$name=$val"; +} + +sub DESCRIPTION { + "support for building CMake based packages (outside-source tree only)" +} + +sub is_buildable { + return -e "CMakeLists.txt"; +} + +sub new { + my $cls=shift; + my $self=$cls->SUPER::new(@_); + # Enfore outside-source tree builds. + $self->enforce_outside_source_building(); + $self->{cmake_flags} = []; + return $self; +} + +sub configure_impl { + my $self=shift; + + # Standard set of cmake flags + $self->_add_cmake_flag("CMAKE_INSTALL_PREFIX", "/usr"); + $self->_add_cmake_flag("CMAKE_C_FLAGS", $ENV{CFLAGS}) if (exists $ENV{CFLAGS}); + $self->_add_cmake_flag("CMAKE_CXX_FLAGS", $ENV{CXXFLAGS}) if (exists $ENV{CXXFLAGS}); + $self->_add_cmake_flag("CMAKE_SKIP_RPATH", "ON"); + $self->_add_cmake_flag("CMAKE_VERBOSE_MAKEFILE", "ON"); + # TODO: LDFLAGS + + doit("cmake", $self->get_topdir(), @{$self->{cmake_flags}}, @_); +} + +1; diff --git a/Debian/Debhelper/Buildsystem/makefile.pm b/Debian/Debhelper/Buildsystem/makefile.pm new file mode 100644 index 00000000..91a6341c --- /dev/null +++ b/Debian/Debhelper/Buildsystem/makefile.pm @@ -0,0 +1,84 @@ +# A buildsystem plugin for handling simple Makefile based projects. +# +# Copyright: © 2008 Joey Hess +# © 2008-2009 Modestas Vainius +# License: GPL-2+ + +package Debian::Debhelper::Buildsystem::makefile; + +use strict; +use Debian::Debhelper::Dh_Lib; +use Debian::Debhelper::Dh_Buildsystem_Bases; +use base 'Debian::Debhelper::Dh_Buildsystem_Chdir'; + +sub _exists_make_target { + my ($cls, $target) = @_; + # Use make -n to check to see if the target would do + # anything. There's no good way to test if a target exists. + my $ret=`$ENV{MAKE} -s -n $target 2>/dev/null`; + chomp $ret; + return length($ret); +} + +sub _make_first_existing_target { + my $cls = shift; + my $targets = shift; + + $ENV{MAKE}="make" unless exists $ENV{MAKE}; + foreach my $target (@$targets) { + if ($cls->_exists_make_target($target)) { + doit($ENV{MAKE}, $target, @_); + return $target; + } + } + return undef; +} + +sub DESCRIPTION { + "support for building Makefile based packages (make && make install)" +} + +sub is_buildable { + my $self=shift; + my ($action) = @_; + if (grep /^\Q$action\E$/, qw{build test install clean}) { + return -e $self->get_buildpath("Makefile") || + -e $self->get_buildpath("makefile") || + -e $self->get_buildpath("GNUmakefile"); + } else { + return 1; + } +} + +sub build_impl { + my $self=shift; + doit(exists $ENV{MAKE} ? $ENV{MAKE} : "make", @_); +} + +sub test_impl { + my $self=shift; + $self->_make_first_existing_target(['test', 'check'], @_); +} + +sub install_impl { + my $self=shift; + my $destdir=shift; + + $ENV{MAKE}="make" unless exists $ENV{MAKE}; + my @params="DESTDIR=$destdir"; + + # Special case for MakeMaker generated Makefiles. + if (-e "Makefile" && + system('grep -q "generated automatically by MakeMaker" Makefile') == 0) { + push @params, "PREFIX=/usr"; + } + + $self->_make_first_existing_target(['install'], @params, @_); +} + +sub clean_impl { + my $self=shift; + $self->_make_first_existing_target(['distclean', 'realclean', 'clean'], @_); +} + +1; diff --git a/Debian/Debhelper/Buildsystem/perl_build.pm b/Debian/Debhelper/Buildsystem/perl_build.pm new file mode 100644 index 00000000..74106d9b --- /dev/null +++ b/Debian/Debhelper/Buildsystem/perl_build.pm @@ -0,0 +1,67 @@ +# A buildsystem plugin for handling Perl Build based projects. +# +# Copyright: © 2008-2009 Joey Hess +# © 2008-2009 Modestas Vainius +# License: GPL-2+ + +package Debian::Debhelper::Buildsystem::perl_build; + +use strict; +use Debian::Debhelper::Dh_Lib; +use Debian::Debhelper::Dh_Buildsystem_Bases; +use base 'Debian::Debhelper::Dh_Buildsystem_Basic'; + +sub DESCRIPTION { + "support for building Perl Build.PL based packages (in-source only)" +} + +sub is_buildable { + my ($self, $action) = @_; + my $ret = (-e "Build.PL"); + if ($action ne "configure") { + $ret &= (-e "Build"); + } + return $ret; +} + +sub invoke_impl { + my $self=shift; + $ENV{MODULEBUILDRC} = "/dev/null"; + return $self->SUPER::invoke_impl(@_); +} + +sub new { + my $cls=shift; + my $self= $cls->SUPER::new(@_); + $self->enforce_in_source_building(); + return $self; +} + +sub configure_impl { + my $self=shift; + $ENV{PERL_MM_USE_DEFAULT}=1; # Module::Build can also use this. + doit("perl", "Build.PL", "installdirs=vendor", @_); +} + +sub build_impl { + my $self=shift; + doit("perl", "Build", @_); +} + +sub test_impl { + my $self=shift; + doit(qw/perl Build test/, @_); +} + +sub install_impl { + my $self=shift; + my $destdir=shift; + doit("perl", "Build", "install", "destdir=$destdir", "create_packlist=0", @_); +} + +sub clean_impl { + my $self=shift; + doit("perl", "Build", "--allow_mb_mismatch", 1, "distclean", @_); +} + +1; diff --git a/Debian/Debhelper/Buildsystem/perl_makefile.pm b/Debian/Debhelper/Buildsystem/perl_makefile.pm new file mode 100644 index 00000000..67a6f441 --- /dev/null +++ b/Debian/Debhelper/Buildsystem/perl_makefile.pm @@ -0,0 +1,38 @@ +# A buildsystem plugin for handling Perl Build based projects. +# +# Copyright: © 2008-2009 Joey Hess +# © 2008-2009 Modestas Vainius +# License: GPL-2+ + +package Debian::Debhelper::Buildsystem::perl_makefile; + +use strict; +use Debian::Debhelper::Dh_Lib; +use Debian::Debhelper::Dh_Buildsystem_Bases; +use base 'Debian::Debhelper::Dh_Buildsystem_Basic'; + +sub DESCRIPTION { + "support for building Perl Makefile.PL based packages (in-source only)" +} + +sub is_buildable { + my ($self, $action) = @_; + return ($action eq "configure") && (-e "Makefile.PL"); +} + +sub new { + my $cls=shift; + my $self=$cls->SUPER::new(@_); + $self->enforce_in_source_building(); + return $self; +} + +sub configure_impl { + my $self=shift; + # If set to a true value then MakeMaker's prompt function will + # # always return the default without waiting for user input. + $ENV{PERL_MM_USE_DEFAULT}=1; + doit("perl", "Makefile.PL", "INSTALLDIRS=vendor", @_); +} + +1; diff --git a/Debian/Debhelper/Buildsystem/python_distutils.pm b/Debian/Debhelper/Buildsystem/python_distutils.pm new file mode 100644 index 00000000..2a6df37b --- /dev/null +++ b/Debian/Debhelper/Buildsystem/python_distutils.pm @@ -0,0 +1,62 @@ +# A buildsystem plugin for building Python Distutils based +# projects. +# +# Copyright: © 2008 Joey Hess +# © 2008-2009 Modestas Vainius +# License: GPL-2+ + +package Debian::Debhelper::Buildsystem::python_distutils; + +use strict; +use Debian::Debhelper::Dh_Lib; +use Debian::Debhelper::Dh_Buildsystem_Bases; +use base 'Debian::Debhelper::Dh_Buildsystem_Option'; + +sub DESCRIPTION { + "support for building Python distutils based packages" +} + +sub is_buildable { + return -e "setup.py"; +} + +sub get_builddir_option { + my $self=shift; + if ($self->get_builddir()) { + return "--build-base=". $self->get_builddir(); + } + return; +} + +sub configure_impl { + # Do nothing + 1; +} + +sub build_impl { + my $self=shift; + doit("python", "setup.py", "build", @_); +} + +sub test_impl { + 1; +} + +sub install_impl { + my $self=shift; + my $destdir=shift; + + doit("python", "setup.py", "install", + "--root=$destdir", + "--no-compile", "-O0", @_); +} + +sub clean_impl { + my $self=shift; + doit("python", "setup.py", "clean", "-a", @_); + # The setup.py might import files, leading to python creating pyc + # files. + doit('find', '.', '-name', '*.pyc', '-exec', 'rm', '{}', ';'); +} + +1; |