);
$args{options}{$_} = $options{$_} foreach keys(%options);
Debian::Debhelper::Dh_Lib::init(%args);
+ Debian::Debhelper::Dh_Lib::set_buildflags();
set_parallel($max_parallel);
}
&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;
}
}
+# 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
=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.
(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
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
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