summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2011-06-14 17:25:24 -0400
committerJoey Hess <joey@kitenet.net>2011-06-14 17:25:24 -0400
commit0f2969a41c07f0435ddac202a858ab914fd7eff7 (patch)
tree291b7141ef78eb101ee72000d8d9aa329bd0fd21
parentc64ed6af2930e40666aa3069d4e40a7dcd1bc1dd (diff)
parente8c799129672d5b7dbac58a06fadd175cffaa7ed (diff)
Merge branch 'master' into smarter-targets
Conflicts: dh
-rw-r--r--Debian/Debhelper/Dh_Buildsystems.pm1
-rw-r--r--Debian/Debhelper/Dh_Lib.pm33
-rw-r--r--debhelper.pod4
-rw-r--r--debian/changelog6
-rwxr-xr-xdh5
5 files changed, 47 insertions, 2 deletions
diff --git a/Debian/Debhelper/Dh_Buildsystems.pm b/Debian/Debhelper/Dh_Buildsystems.pm
index 22f80f9..9c3fc05 100644
--- a/Debian/Debhelper/Dh_Buildsystems.pm
+++ b/Debian/Debhelper/Dh_Buildsystems.pm
@@ -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);
}
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 51b53d3..51f16a6 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -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
diff --git a/debhelper.pod b/debhelper.pod
index d54bf4e..fbb76de 100644
--- a/debhelper.pod
+++ b/debhelper.pod
@@ -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.
diff --git a/debian/changelog b/debian/changelog
index d22e50e..9bf728a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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 8d8c920..aba8c27 100755
--- 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