+2008-02-17 Frank Lichtenheld <djpig@debian.org>
+ Matthias Klose <doko@cs.tu-berlin.de>
+
+ * scripts/dpkg-buildpackage.pl: Set a set of environment variables
+ for setting compiler and linker options, unless already set in the
+ environment. See https://wiki.ubuntu.com/DistCompilerFlags for
+ background information.
+
2008-02-13 Raphael Hertzog <hertzog@debian.org>
* scripts/Dpkg/Version.pm: Import Dpkg::Gettext since we use _g().
satisfied during -S. Closes: #445552
* Add a missing space in the German scripts translation. Closes: #463398
* Add improved deb-shlibs.5 manual page by Zack Weinberg. Closes: #466135
+ * dpkg-buildpackage exports some build related environment variables
+ now. Based on a patch by Matthias Klose. Closes: #465282
+ (See dpkg-buildpackage(1) and https://wiki.ubuntu.com/DistCompilerFlags
+ for details)
[ Updated dpkg translations ]
* Korean (Changwoo Ryu).
* po/dpkg-man.pot: Regenerated.
* po/*.po: Merged with dpkg-man.pot.
+2008-02-17 Frank Lichtenheld <djpig@debian.org>
+ Matthias Klose <doko@cs.tu-berlin.de>
+
+ * man/dpkg-buildpackage.1: Document the new
+ behaviour for build related environment variables.
+
2008-02-17 Zack Weinberg <zackw@panix.com>
* deb-shlibs.5: Make this manual page a bit
.BR \-\-version
Show the version and exit.
.
+.SH ENVIRONMENT
+A set of environment variables for setting compiler and linker options are
+set to default values unless already set in the environment. Note that
+this mechanism was only introduced in dpkg-dev, version 1.14.17 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 overriden 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 explicitely 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 FFLAGS
+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 overriden by the package build if needed (default:
+empty). This macro is seldom used (most build systems just use
+.B CFLAGS
+instead of
+.B 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.
+.
.SH BUGS
It should be possible to specify spaces and shell metacharacters in
and initial arguments for
}
}
+my $build_opts = Dpkg::BuildOptions::parse();
if ($parallel) {
- my $build_opts = Dpkg::BuildOptions::parse();
-
$parallel = $build_opts->{parallel} if (defined $build_opts->{parallel});
$ENV{MAKEFLAGS} ||= '';
if ($parallel eq '-1') {
Dpkg::BuildOptions::set($build_opts);
}
+my $default_flags = defined $build_opts->{noopt} ? "-g -O0" : "-g -O2";
+my %flags = ( CPPFLAGS => '',
+ CFLAGS => $default_flags,
+ CXXFLAGS => $default_flags,
+ FFLAGS => $default_flags,
+ LDFLAGS => "-Wl,-Bsymbolic-functions",
+ );
+
+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 $cwd = cwd();
my $dir = basename($cwd);