summaryrefslogtreecommitdiff
path: root/Debian
diff options
context:
space:
mode:
Diffstat (limited to 'Debian')
-rw-r--r--Debian/Debhelper/Dh_Buildsystems.pm1
-rw-r--r--Debian/Debhelper/Dh_Lib.pm33
2 files changed, 33 insertions, 1 deletions
diff --git a/Debian/Debhelper/Dh_Buildsystems.pm b/Debian/Debhelper/Dh_Buildsystems.pm
index 22f80f9e..9c3fc059 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 51b53d3e..51f16a6f 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