summaryrefslogtreecommitdiff
path: root/Debian/Debhelper/Dh_Lib.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2011-06-14 17:22:34 -0400
committerJoey Hess <joey@kitenet.net>2011-06-14 17:24:27 -0400
commite8c799129672d5b7dbac58a06fadd175cffaa7ed (patch)
tree646fc7c78883971fbddb6aaa8d05bd4f4317248f /Debian/Debhelper/Dh_Lib.pm
parentcbe68c8579e8abc03aeff939306b2d34cb1fe8ac (diff)
dpkg-buildflags support
* 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.
Diffstat (limited to 'Debian/Debhelper/Dh_Lib.pm')
-rw-r--r--Debian/Debhelper/Dh_Lib.pm33
1 files changed, 32 insertions, 1 deletions
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