]> git.donarmstrong.com Git - debhelper.git/commitdiff
Merge branch 'master' into smarter-targets origin/smarter-targets
authorJoey Hess <joey@kitenet.net>
Tue, 14 Jun 2011 21:25:24 +0000 (17:25 -0400)
committerJoey Hess <joey@kitenet.net>
Tue, 14 Jun 2011 21:25:24 +0000 (17:25 -0400)
Conflicts:
dh

Debian/Debhelper/Dh_Buildsystems.pm
Debian/Debhelper/Dh_Lib.pm
debhelper.pod
debian/changelog
dh

index 22f80f9ebdacb39435e8a952ccd9d753199a2c03..9c3fc0597c969b6639d8355c46a2ad21b266584d 100644 (file)
@@ -159,6 +159,7 @@ sub buildsystems_init {
        );
        $args{options}{$_} = $options{$_} foreach keys(%options);
        Debian::Debhelper::Dh_Lib::init(%args);
+       Debian::Debhelper::Dh_Lib::set_buildflags();
        set_parallel($max_parallel);
 }
 
index 51b53d3e600b158223f6b32ec68eab16abb4556e..51f16a6f8226fc29b9258d3ec3b084b85fd1be5e 100644 (file)
@@ -18,7 +18,7 @@ use vars qw(@ISA @EXPORT %dh);
            &inhibit_log &load_log &write_log &commit_override_log
            &dpkg_architecture_value &sourcepackage
            &is_make_jobserver_unavailable &clean_jobserver_makeflags
-           &cross_command);
+           &cross_command &set_buildflags);
 
 my $max_compat=9;
 
@@ -900,4 +900,35 @@ sub cross_command {
        }
 }
 
+# Sets environment variables from dpkg-buildflags. Avoids changing
+# any existing environment variables. Supports DEB_BUILD_OPTIONS=noopt.
+sub set_buildflags {
+       # optimisation
+       return if $ENV{DH_INTERNAL_BUILDFLAGS};
+       $ENV{DH_INTERNAL_BUILDFLAGS}=1;
+
+       my $noopt=$ENV{DEB_BUILD_OPTIONS}=~/noopt/;
+
+       my @shell=`dpkg-buildflags --export`;
+       foreach my $line (@shell) {
+               chomp $line;
+               if ($line=~/^export\s+([^=]+)=(["'])(.*)\2$/) {
+                       my $var=$1;
+                       my $val=$3;
+                       if ($noopt) {
+                               $val=$ENV{$var} if exists $ENV{$var};
+                               $val=~s/-O\d+/-O0/;
+                               $ENV{$var}=$val;
+                               next;
+                       }
+                       elsif (! exists $ENV{$var}) {
+                               $ENV{$var}=$val;
+                       }
+               }
+               else {
+                       warning "unparsable line from dpkg-buildflags: $line";
+               }
+       }
+}
+
 1
index d54bf4e1daf1bb909067a9b1fc63d35c64d29c25..fbb76deb8f9bb8703efa1a7b31a2782001649b39 100644 (file)
@@ -191,6 +191,10 @@ in ALL packages acted on, not just the first.
 
 =head1 BUILD SYSTEM OPTIONS
 
+All of the B<dh_auto_>I<*> debhelper programs sets environment variables
+listed by B<dpkg-buildflags>, unless they are already set. They
+support DEB_BUILD_OPTIONS=noopt too.
+
 The following command line options are supported by all of the B<dh_auto_>I<*>
 debhelper programs. These programs support a variety of build systems,
 and normally heuristically determine which to use, and how to use them.
index d22e50eac02de62b76701cb9936604d671351a1d..9bf728aff09ddb474a4dd6eca618f5c8550b3714 100644 (file)
@@ -10,6 +10,12 @@ debhelper (8.1.7) UNRELEASED; urgency=low
     (Thanks, Roger Leigh)
   * dh_auto_configure: In v9, does not include the source package name
     in --libexecdir when using autoconf. Closes: #541458
+  * dh_auto_build, dh_auto_configure, dh: Set environment variables
+    listed by dpkg-buildflags --export. Any environment variables that
+    are already set to other values will not be changed.
+    Closes: #544844
+  * Also, support DEB_BUILD_OPTIONS=noopt, by changing -O2 to -O0
+    in any variables listed by dpkg-buildflags.
 
  -- Joey Hess <joeyh@debian.org>  Sat, 21 May 2011 15:24:19 -0400
 
diff --git a/dh b/dh
index 8d8c920a18d69e67854a8aa299098a4926e987d2..aba8c270efb29d8bc9c4ebbcec67e14775d63b58 100755 (executable)
--- a/dh
+++ b/dh
@@ -278,6 +278,9 @@ options can override this behavior.
 A sequence can also run dependent targets in debian/rules.  For
 example, the "binary" sequence runs the "install" target.
 
+B<dh> sets environment variables listed by B<dpkg-buildflags>, unless
+they are already set. It supports DEB_BUILD_OPTIONS=noopt too.
+
 B<dh> uses the B<DH_INTERNAL_OPTIONS> environment variable to pass information
 through to debhelper commands that are run inside override targets. The
 contents (and indeed, existence) of this environment variable, as the name
@@ -315,7 +318,7 @@ init(options => {
        bundling => 0,
 );
 inhibit_log();
-
+set_buildflags();
 
 # If make is using a jobserver, but it is not available
 # to this process, clean out MAKEFLAGS. This avoids