diff options
Diffstat (limited to 'lib/Debian/Debhelper/Buildsystem')
-rw-r--r-- | lib/Debian/Debhelper/Buildsystem/autoconf.pm | 4 | ||||
-rw-r--r-- | lib/Debian/Debhelper/Buildsystem/cmake.pm | 61 | ||||
-rw-r--r-- | lib/Debian/Debhelper/Buildsystem/makefile.pm | 17 | ||||
-rw-r--r-- | lib/Debian/Debhelper/Buildsystem/meson.pm | 38 | ||||
-rw-r--r-- | lib/Debian/Debhelper/Buildsystem/ninja.pm | 44 | ||||
-rw-r--r-- | lib/Debian/Debhelper/Buildsystem/python_distutils.pm | 7 | ||||
-rw-r--r-- | lib/Debian/Debhelper/Buildsystem/qmake.pm | 64 | ||||
-rw-r--r-- | lib/Debian/Debhelper/Buildsystem/qmake_qt4.pm | 6 |
8 files changed, 129 insertions, 112 deletions
diff --git a/lib/Debian/Debhelper/Buildsystem/autoconf.pm b/lib/Debian/Debhelper/Buildsystem/autoconf.pm index e31951b0..142c27ea 100644 --- a/lib/Debian/Debhelper/Buildsystem/autoconf.pm +++ b/lib/Debian/Debhelper/Buildsystem/autoconf.pm @@ -47,10 +47,10 @@ sub configure { if (! compat(8)) { if (defined $multiarch) { push @opts, "--libdir=\${prefix}/lib/$multiarch"; - push @opts, "--libexecdir=\${prefix}/lib/$multiarch"; + push(@opts, "--libexecdir=\${prefix}/lib/$multiarch") if not compat(11); } else { - push @opts, "--libexecdir=\${prefix}/lib"; + push(@opts, "--libexecdir=\${prefix}/lib") if not compat(11); } } else { diff --git a/lib/Debian/Debhelper/Buildsystem/cmake.pm b/lib/Debian/Debhelper/Buildsystem/cmake.pm index 5e3ce082..c732ba41 100644 --- a/lib/Debian/Debhelper/Buildsystem/cmake.pm +++ b/lib/Debian/Debhelper/Buildsystem/cmake.pm @@ -9,7 +9,7 @@ package Debian::Debhelper::Buildsystem::cmake; use strict; use warnings; use Debian::Debhelper::Dh_Lib qw(compat dpkg_architecture_value error is_cross_compiling); -use parent qw(Debian::Debhelper::Buildsystem::makefile); +use parent qw(Debian::Debhelper::Buildsystem); my @STANDARD_CMAKE_FLAGS = qw( -DCMAKE_INSTALL_PREFIX=/usr @@ -27,16 +27,35 @@ my %DEB_HOST2CMAKE_SYSTEM = ( 'hurd' => 'GNU', ); +my %TARGET_BUILD_SYSTEM2CMAKE_GENERATOR = ( + 'makefile' => 'Unix Makefiles', + 'ninja' => 'Ninja', +); + sub DESCRIPTION { "CMake (CMakeLists.txt)" } +sub IS_GENERATOR_BUILD_SYSTEM { + return 1; +} + +sub SUPPORTED_TARGET_BUILD_SYSTEMS { + return qw(makefile ninja); +} + sub check_auto_buildable { my $this=shift; my ($step)=@_; if (-e $this->get_sourcepath("CMakeLists.txt")) { my $ret = ($step eq "configure" && 1) || - $this->SUPER::check_auto_buildable(@_); + $this->get_targetbuildsystem->check_auto_buildable(@_); + if ($this->check_auto_buildable_clean_oos_buildir(@_)) { + # Assume that the package can be cleaned (i.e. the build directory can + # be removed) as long as it is built out-of-source tree and can be + # configured. + $ret++ if not $ret; + } # Existence of CMakeCache.txt indicates cmake has already # been used by a prior build step, so should be used # instead of the parent makefile class. @@ -57,11 +76,22 @@ sub configure { my $this=shift; # Standard set of cmake flags my @flags = @STANDARD_CMAKE_FLAGS; + my $backend = $this->get_targetbuildsystem->NAME; if (not compat(10)) { push(@flags, '-DCMAKE_INSTALL_RUNSTATEDIR=/run'); } + if (exists($TARGET_BUILD_SYSTEM2CMAKE_GENERATOR{$backend})) { + my $generator = $TARGET_BUILD_SYSTEM2CMAKE_GENERATOR{$backend}; + push(@flags, "-G${generator}"); + } + if ($ENV{CC}) { + push @flags, "-DCMAKE_C_COMPILER=" . $ENV{CC}; + } + if ($ENV{CXX}) { + push @flags, "-DCMAKE_CXX_COMPILER=" . $ENV{CXX}; + } if (is_cross_compiling()) { my $deb_host = dpkg_architecture_value("DEB_HOST_ARCH_OS"); if (my $cmake_system = $DEB_HOST2CMAKE_SYSTEM{$deb_host}) { @@ -70,20 +100,16 @@ sub configure { error("Cannot cross-compile - CMAKE_SYSTEM_NAME not known for ${deb_host}"); } push @flags, "-DCMAKE_SYSTEM_PROCESSOR=" . dpkg_architecture_value("DEB_HOST_GNU_CPU"); - if ($ENV{CC}) { - push @flags, "-DCMAKE_C_COMPILER=" . $ENV{CC}; - } else { + if (not $ENV{CC}) { push @flags, "-DCMAKE_C_COMPILER=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-gcc"; } - if ($ENV{CXX}) { - push @flags, "-DCMAKE_CXX_COMPILER=" . $ENV{CXX}; - } else { + if (not $ENV{CXX}) { push @flags, "-DCMAKE_CXX_COMPILER=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-g++"; } push(@flags, "-DPKG_CONFIG_EXECUTABLE=/usr/bin/" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-pkg-config"); push(@flags, "-DPKGCONFIG_EXECUTABLE=/usr/bin/" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-pkg-config"); - push(@flags, "-DCMAKE_INSTALL_LIBDIR=lib/" . dpkg_architecture_value("DEB_HOST_MULTIARCH")); } + push(@flags, "-DCMAKE_INSTALL_LIBDIR=lib/" . dpkg_architecture_value("DEB_HOST_MULTIARCH")); # CMake doesn't respect CPPFLAGS, see #653916. if ($ENV{CPPFLAGS} && ! compat(8)) { @@ -93,7 +119,7 @@ sub configure { $this->mkdir_builddir(); eval { - $this->doit_in_builddir("cmake", $this->get_source_rel2builddir(), @flags, @_); + $this->doit_in_builddir("cmake", @flags, @_, $this->get_source_rel2builddir()); }; if (my $err = $@) { if (-e $this->get_buildpath("CMakeCache.txt")) { @@ -111,13 +137,16 @@ sub configure { sub test { my $this=shift; - - # Unlike make, CTest does not have "unlimited parallel" setting (-j implies - # -j1). So in order to simulate unlimited parallel, allow to fork a huge - # number of threads instead. - my $parallel = ($this->get_parallel() > 0) ? $this->get_parallel() : 999; + my $target = $this->get_targetbuildsystem; $ENV{CTEST_OUTPUT_ON_FAILURE} = 1; - return $this->SUPER::test(@_, "ARGS+=-j$parallel"); + if ($target->NAME eq 'makefile') { + # Unlike make, CTest does not have "unlimited parallel" setting (-j implies + # -j1). So in order to simulate unlimited parallel, allow to fork a huge + # number of threads instead. + my $parallel = ($this->get_parallel() > 0) ? $this->get_parallel() : 999; + push(@_, "ARGS+=-j$parallel") + } + return $this->SUPER::test(@_); } 1 diff --git a/lib/Debian/Debhelper/Buildsystem/makefile.pm b/lib/Debian/Debhelper/Buildsystem/makefile.pm index 49a368db..052af0b4 100644 --- a/lib/Debian/Debhelper/Buildsystem/makefile.pm +++ b/lib/Debian/Debhelper/Buildsystem/makefile.pm @@ -80,7 +80,14 @@ sub do_make { clean_jobserver_makeflags(); # Note that this will override any -j settings in MAKEFLAGS. - unshift @_, "-j" . ($this->get_parallel() > 0 ? $this->get_parallel() : ""); + my $parallel = $this->get_parallel(); + if ($parallel == 0 or $parallel > 1) { + # We have to use the empty string for "unlimited" + $parallel = '' if $parallel == 0; + unshift(@_, "-j${parallel}"); + } else { + unshift(@_, '-j1'); + } my @root_cmd; if (exists($this->{_run_make_as_root}) and $this->{_run_make_as_root}) { @@ -124,9 +131,8 @@ sub check_auto_buildable { # This is always called in the source directory, but generally # Makefiles are created (or live) in the build directory. return 1; - } elsif ($step eq "clean" && defined $this->get_builddir() && - $this->check_auto_buildable("configure")) - { + } elsif ($this->check_auto_buildable_clean_oos_buildir(@_) + and $this->check_auto_buildable('configure')) { # Assume that the package can be cleaned (i.e. the build directory can # be removed) as long as it is built out-of-source tree and can be # configured. This is useful for derivative buildsystems which @@ -139,7 +145,8 @@ sub check_auto_buildable { sub build { my $this=shift; if (ref($this) eq 'Debian::Debhelper::Buildsystem::makefile' and is_cross_compiling()) { - while (my ($var, $tool) = each %DEB_DEFAULT_TOOLS) { + for my $var (sort(keys(%DEB_DEFAULT_TOOLS))) { + my $tool = $DEB_DEFAULT_TOOLS{$var}; if ($ENV{$var}) { unshift @_, $var . "=" . $ENV{$var}; } else { diff --git a/lib/Debian/Debhelper/Buildsystem/meson.pm b/lib/Debian/Debhelper/Buildsystem/meson.pm index dcad89f9..890112bd 100644 --- a/lib/Debian/Debhelper/Buildsystem/meson.pm +++ b/lib/Debian/Debhelper/Buildsystem/meson.pm @@ -8,12 +8,21 @@ package Debian::Debhelper::Buildsystem::meson; use strict; use warnings; use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value is_cross_compiling doit warning error generated_file); -use parent qw(Debian::Debhelper::Buildsystem::ninja); +use parent qw(Debian::Debhelper::Buildsystem); sub DESCRIPTION { "Meson (meson.build)" } +sub IS_GENERATOR_BUILD_SYSTEM { + return 1; +} + +sub SUPPORTED_TARGET_BUILD_SYSTEMS { + return qw(ninja); +} + + sub check_auto_buildable { my $this=shift; my ($step)=@_; @@ -22,7 +31,14 @@ sub check_auto_buildable { # Handle configure explicitly; inherit the rest return 1 if $step eq "configure"; - return $this->SUPER::check_auto_buildable(@_); + my $ret = $this->get_targetbuildsystem->check_auto_buildable(@_); + if ($ret == 0 and $this->check_auto_buildable_clean_oos_buildir(@_)) { + # Assume that the package can be cleaned (i.e. the build directory can + # be removed) as long as it is built out-of-source tree and can be + # configured. + $ret++; + } + return $ret; } sub new { @@ -45,7 +61,7 @@ sub configure { push @opts, "--localstatedir=/var"; my $multiarch=dpkg_architecture_value("DEB_HOST_MULTIARCH"); push @opts, "--libdir=lib/$multiarch"; - push @opts, "--libexecdir=lib/$multiarch"; + push(@opts, "--libexecdir=lib/$multiarch") if not compat(11); if (is_cross_compiling()) { # http://mesonbuild.com/Cross-compilation.html @@ -57,7 +73,11 @@ sub configure { error("Cannot cross-compile: Please use meson (>= 0.42.1) or provide a cross file via DH_MESON_CROSS_FILE"); } my $filename = generated_file('_source', 'meson-cross-file.conf'); - doit({ stdout => '/dev/null' }, $debcrossgen, "-o${filename}"); + my %options = ( + stdout => '/dev/null', + update_env => { LC_ALL => 'C.UTF-8'}, + ); + doit(\%options, $debcrossgen, "-o${filename}"); $cross_file = $filename; } if ($cross_file !~ m{^/}) { @@ -71,7 +91,10 @@ sub configure { $this->mkdir_builddir(); eval { - $this->doit_in_builddir("meson", $this->get_source_rel2builddir(), @opts, @_); + my %options = ( + update_env => { LC_ALL => 'C.UTF-8'}, + ); + $this->doit_in_builddir(\%options, "meson", $this->get_source_rel2builddir(), @opts, @_); }; if ($@) { if (-e $this->get_buildpath("meson-logs/meson-log.txt")) { @@ -81,9 +104,4 @@ sub configure { } } -sub test { - my $this=shift; - return $this->SUPER::test(@_); -} - 1 diff --git a/lib/Debian/Debhelper/Buildsystem/ninja.pm b/lib/Debian/Debhelper/Buildsystem/ninja.pm index 5d6c874d..c08ff166 100644 --- a/lib/Debian/Debhelper/Buildsystem/ninja.pm +++ b/lib/Debian/Debhelper/Buildsystem/ninja.pm @@ -30,52 +30,60 @@ sub check_auto_buildable { # This is always called in the source directory, but generally # Ninja files are created (or live) in the build directory. return 1; - } elsif ($step eq "clean" && defined $this->get_builddir() && - $this->check_auto_buildable("configure")) - { - # Assume that the package can be cleaned (i.e. the build directory can - # be removed) as long as it is built out-of-source tree and can be - # configured. This is useful for derivative buildsystems which - # generate Ninja files. - return 1; } return 0; } sub build { my $this=shift; - + my %options = ( + update_env => { + 'LC_ALL' => 'C.UTF-8', + } + ); if (!$dh{QUIET}) { unshift @_, "-v"; } if ($this->get_parallel() > 0) { unshift @_, "-j" . $this->get_parallel(); } - $this->doit_in_builddir($this->{buildcmd}, @_); + $this->doit_in_builddir(\%options, $this->{buildcmd}, @_); } sub test { my $this=shift; - + my %options = ( + update_env => { + 'LC_ALL' => 'C.UTF-8', + } + ); if ($this->get_parallel() > 0) { - $ENV{MESON_TESTTHREADS}=$this->get_parallel(); + $options{update_env}{MESON_TESTTHREADS} = $this->get_parallel(); } - $this->doit_in_builddir($this->{buildcmd}, "test", @_); + $this->doit_in_builddir(\%options, $this->{buildcmd}, "test", @_); } sub install { my $this=shift; my $destdir=shift; - - $ENV{DESTDIR}=$destdir; - $this->doit_in_builddir($this->{buildcmd}, "install", @_); + my %options = ( + update_env => { + 'LC_ALL' => 'C.UTF-8', + 'DESTDIR' => $destdir, + } + ); + $this->doit_in_builddir(\%options, $this->{buildcmd}, "install", @_); } sub clean { my $this=shift; - if (!$this->rmdir_builddir()) { - $this->doit_in_builddir($this->{buildcmd}, "clean", @_); + my %options = ( + update_env => { + 'LC_ALL' => 'C.UTF-8', + } + ); + $this->doit_in_builddir(\%options, $this->{buildcmd}, "clean", @_); } } diff --git a/lib/Debian/Debhelper/Buildsystem/python_distutils.pm b/lib/Debian/Debhelper/Buildsystem/python_distutils.pm index 4c2a5f8d..e5fe7edc 100644 --- a/lib/Debian/Debhelper/Buildsystem/python_distutils.pm +++ b/lib/Debian/Debhelper/Buildsystem/python_distutils.pm @@ -10,11 +10,11 @@ package Debian::Debhelper::Buildsystem::python_distutils; use strict; use warnings; use Cwd (); -use Debian::Debhelper::Dh_Lib qw(error); +use Debian::Debhelper::Dh_Lib qw(error deprecated_functionality); use parent qw(Debian::Debhelper::Buildsystem); sub DESCRIPTION { - "Python Distutils (setup.py)" + "Python Distutils (setup.py) [DEPRECATED]" } sub DEFAULT_BUILD_DIRECTORY { @@ -60,6 +60,9 @@ sub pre_building_step { my $this=shift; my $step=shift; + deprecated_functionality('Please use the third-party "pybuild" build system instead of python-distutils', + 12); + return unless grep /$step/, qw(build install clean); if ($this->get_buildpath() ne $this->DEFAULT_BUILD_DIRECTORY()) { diff --git a/lib/Debian/Debhelper/Buildsystem/qmake.pm b/lib/Debian/Debhelper/Buildsystem/qmake.pm index 6e7f87f1..18b896d8 100644 --- a/lib/Debian/Debhelper/Buildsystem/qmake.pm +++ b/lib/Debian/Debhelper/Buildsystem/qmake.pm @@ -8,11 +8,9 @@ package Debian::Debhelper::Buildsystem::qmake; use strict; use warnings; -use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value error generated_file is_cross_compiling); +use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value error is_cross_compiling); use parent qw(Debian::Debhelper::Buildsystem::makefile); -our $qmake="qmake"; - my %OS_MKSPEC_MAPPING = ( 'linux' => 'linux-g++', 'kfreebsd' => 'gnukfreebsd-g++', @@ -65,38 +63,6 @@ sub configure { } else { error("Cannot cross-compile: Missing entry for HOST OS ${host_os} for qmake's -spec option"); } - - my $filename = generated_file('_source', 'qmake-cross.conf'); - my $host_multiarch = dpkg_architecture_value("DEB_HOST_MULTIARCH"); - open(my $fh, '>', $filename) or error("open($filename) failed: $!"); - - $fh->print("[Paths]\n"); - $fh->print("Prefix=/usr\n"); - $fh->print("ArchData=lib/$host_multiarch/qt5\n"); - $fh->print("Binaries=lib/qt5/bin\n"); - $fh->print("Data=share/qt5\n"); - $fh->print("Documentation=share/qt5/doc\n"); - $fh->print("Examples=lib/$host_multiarch/qt5/examples\n"); - $fh->print("Headers=include/$host_multiarch/qt5\n"); - $fh->print("HostBinaries=lib/qt5/bin\n"); - $fh->print("HostData=lib/$host_multiarch/qt5\n"); - $fh->print("HostLibraries=lib/$host_multiarch\n"); - $fh->print("Imports=lib/$host_multiarch/qt5/imports\n"); - $fh->print("Libraries=lib/$host_multiarch\n"); - $fh->print("LibraryExecutables=lib/$host_multiarch/qt5/libexec\n"); - $fh->print("Plugins=lib/$host_multiarch/qt5/plugins\n"); - $fh->print("Qml2Imports=lib/$host_multiarch/qt5/qml\n"); - $fh->print("Settings=/etc/xdg\n"); - $fh->print("Translations=share/qt5/translations\n"); - - close($fh) or error("close($filename) failed: $!"); - if ($filename !~ m{^/}) { - # Make the file name absolute (just in case qmake cares). - require Cwd; - $filename =~ s{^\./}{}; - $filename = Cwd::cwd() . "/${filename}"; - } - push @options, ("-qtconf", $filename); } if ($ENV{CFLAGS}) { @@ -114,27 +80,8 @@ sub configure { push @flags, "QMAKE_STRIP=:"; push @flags, "PREFIX=/usr"; - if (is_cross_compiling()) { - # qmake calls $$QMAKE_CXX in toolchain.prf to get a list of library/include paths, - # we need -early flag to make sure $$QMAKE_CXX is already properly set on that step. - push @flags, "-early"; - if ($ENV{CC}) { - push @flags, "QMAKE_CC=" . $ENV{CC}; - } else { - push @flags, "QMAKE_CC=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-gcc"; - } - if ($ENV{CXX}) { - push @flags, "QMAKE_CXX=" . $ENV{CXX}; - push @flags, "QMAKE_LINK=" . $ENV{CXX}; - } else { - push @flags, "QMAKE_CXX=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-g++"; - push @flags, "QMAKE_LINK=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-g++"; - } - push @flags, "PKG_CONFIG=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-pkg-config"; - } - $this->mkdir_builddir(); - $this->doit_in_builddir($qmake, @options, @flags, @_); + $this->doit_in_builddir($this->_qmake(), @options, @flags, @_); } sub install { @@ -146,4 +93,11 @@ sub install { $this->SUPER::install($destdir, "INSTALL_ROOT=$destdir", @_); } +sub _qmake { + if (is_cross_compiling()) { + return dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-qmake"; + } + return 'qmake'; +} + 1 diff --git a/lib/Debian/Debhelper/Buildsystem/qmake_qt4.pm b/lib/Debian/Debhelper/Buildsystem/qmake_qt4.pm index ac7ce98a..60d9084c 100644 --- a/lib/Debian/Debhelper/Buildsystem/qmake_qt4.pm +++ b/lib/Debian/Debhelper/Buildsystem/qmake_qt4.pm @@ -8,10 +8,8 @@ sub DESCRIPTION { "qmake for QT 4 (*.pro)"; } -sub configure { - my $this=shift; - $Debian::Debhelper::Buildsystem::qmake::qmake="qmake-qt4"; - $this->SUPER::configure(@_); +sub _qmake { + return 'qmake-qt4'; } 1 |