The following commit has been merged in the master branch:
commit 850645ee948563eeebc6d369145554bc72da5416
Author: Raphaël Hertzog <[email protected]>
Date: Sun Apr 11 18:37:07 2010 +0200
dpkg-buildpackage: use Dpkg::BuildFlags to retrieve the compiler flags
Document that debian/rules should not rely on environment variables
set by dpkg-buildpackage and should instead use
dpkg-buildflags/dpkg-architecture to retrieve the corresponding values.
diff --git a/man/dpkg-buildpackage.1 b/man/dpkg-buildpackage.1
index 764e4df..6e7437e 100644
--- a/man/dpkg-buildpackage.1
+++ b/man/dpkg-buildpackage.1
@@ -229,80 +229,18 @@ Show the usage message and exit.
Show the version and exit.
.
.SH ENVIRONMENT
+Even if \fBdpkg\-buildpackage\fP export some variables, \fBdebian/rules\fP
+should not rely on their presence and should instead use the
+respective interface to retrieve the needed values.
.SS Variables set by dpkg-architecture
\fBdpkg\-architecture\fP is called with the \fB\-a\fP and \fB\-t\fP
parameters forwarded. Any variable that is output by its \fB\-s\fP
option is integrated in the build environment.
.SS Compiler flags
-Some environment variables defining compiler and linker options are
-set to default values unless already present in the environment. Note that
-this mechanism was only introduced in version 1.14.17 of dpkg-dev and
-not all \fIrules\fP files and build tools will honour these variables,
-yet.
-.TP
-.B CFLAGS
-Optimization options which are passed to the Debian build system and
-can/should be overridden by the package build if needed (default value:
-.BR "\-g \-O2" ,
-or
-.BR \-g\ \-O0
-if
-.BR noopt
-is specified in DEB_BUILD_OPTIONS). Overriding options can be
-used to explicitly set a
-higher optimization level, or work around compiler bugs, which only
-can be seen with some optimization levels (the last opt level "wins").
-.TP
-.B CFLAGS_APPEND
-Optimization options appended to the compiler flags, which must not be
-overwritten by the package (mostly used to for test builds). Default
-value: empty.
-.TP
-.B CXXFLAGS
-Same as
-.B CFLAGS
-for C++ sources.
-.TP
-.B CXXFLAGS_APPEND
-Same as
-.B CFLAGS_APPEND
-for C++ sources.
-.TP
-.B FFLAGS
-Same as
-.B CFLAGS
-for Fortran sources.
-.TP
-.B FFLAGS_APPEND
-Same as
-.B CFLAGS_APPEND
-for Fortran sources.
-.TP
-.B CPPFLAGS
-Preprocessor flags which are passed to the Debian build system and
-can/should be overridden by the package build if needed (default:
-empty). This macro is seldom used (most build systems just use
-.B CFLAGS
-instead of
-.BR CPPFLAGS ).
-.TP
-.B CPPFLAGS_APPEND
-Preprocessor flags appended to the preprocessor flags, which must not
-be overwritten by the package (mostly used to for test
-builds). Default value: empty.
-.TP
-.B LDFLAGS
-Options passed to the compiler when linking executables or shared
-objects (if the linker is called directly, then
-.B -Wl
-and
-.B ,
-have to be stripped from these options). Default value: empty.
-.TP
-.B LDFLAGS_APPEND
-Optimization options appended to the compiler flags when linking code,
-which must not be overwritten by the package (mostly used to for test
-builds). Default value: empty.
+The \fBCFLAGS\fP, \fBCXXFLAGS\fP, \fBFFLAGS\fP, \fBCPPFLAGS\fP
+and \fBLDFLAGS\fP environment variables are set to the values
+that \fBdpkg\-buildflags\fP returned. See its manual page for more
+information.
.
.SH BUGS
It should be possible to specify spaces and shell metacharacters in
@@ -323,7 +261,7 @@ Copyright \(co 2000 Wichert Akkerman
.br
Copyright \(co 2007 Frank Lichtenheld
.br
-Copyright \(co 2008 Rapha\[:e]l Hertzog
+Copyright \(co 2008-2010 Rapha\[:e]l Hertzog
.sp
This is free software; see the GNU General Public Licence version 2 or later
for copying conditions. There is NO WARRANTY.
diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl
index 35cdc7f..5d5b3e3 100755
--- a/scripts/dpkg-buildpackage.pl
+++ b/scripts/dpkg-buildpackage.pl
@@ -25,6 +25,7 @@ use POSIX;
use Dpkg;
use Dpkg::Gettext;
use Dpkg::ErrorHandling;
+use Dpkg::BuildFlags;
use Dpkg::BuildOptions;
use Dpkg::Compression;
use Dpkg::Version;
@@ -267,26 +268,12 @@ if (defined $parallel) {
$build_opts->export();
}
-my $default_flags = $build_opts->has("noopt") ? "-g -O0" : "-g -O2";
-my %flags = ( CPPFLAGS => '',
- CFLAGS => $default_flags,
- CXXFLAGS => $default_flags,
- FFLAGS => $default_flags,
- LDFLAGS => '',
- );
-
-foreach my $flag (keys %flags) {
- if ($ENV{$flag}) {
- printf(_g("%s: use %s from environment: %s\n"), $progname,
- $flag, $ENV{$flag});
- } else {
- $ENV{$flag} = $flags{$flag};
- printf(_g("%s: set %s to default value: %s\n"), $progname,
- $flag, $ENV{$flag});
- }
- if ($ENV{"${flag}_APPEND"}) {
- $ENV{$flag} .= " ".$ENV{"${flag}_APPEND"};
- }
+my $build_flags = Dpkg::BuildFlags->new();
+$build_flags->load_config();
+foreach my $flag ("CPPFLAGS", "CFLAGS", "CXXFLAGS", "FFLAGS", "LDFLAGS") {
+ $ENV{$flag} = $build_flags->get($flag);
+ printf(_g("%s: export %s from dpkg-buildflags (origin: %s): %s\n"),
+ $progname, $flag, $build_flags->get_origin($flag), $ENV{$flag});
}
my $cwd = cwd();
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]