Author: adam-guest
Date: 2008-04-15 17:06:21 +0000 (Tue, 15 Apr 2008)
New Revision: 1346

Modified:
   trunk/debian/changelog
   trunk/scripts/debuild.1
   trunk/scripts/debuild.pl
Log:
  + Automatically preserve the (C, CPP, CXX, LD and F)FLAGS variables and
    the corresponding *FLAGS_EXTEND variables
  + Add *FLAGS and *FLAGS_EXTEND support to the emulated dpkg-buildpackage

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2008-04-15 16:58:19 UTC (rev 1345)
+++ trunk/debian/changelog      2008-04-15 17:06:21 UTC (rev 1346)
@@ -44,6 +44,9 @@
       does not currently support them.
     + Make it clearer that a particular invocation is using the emulated
       dpkg-buildpackage, and why.
+    + Automatically preserve the (C, CPP, CXX, LD and F)FLAGS variables and
+      the corresponding *FLAGS_EXTEND variables
+    + Add *FLAGS and *FLAGS_EXTEND support to the emulated dpkg-buildpackage
   * licensecheck: Replace a literal copyright symbol with a hex escape
     so that the package builds using etch's po4a (Closes: #476251)
   * mergechanges:

Modified: trunk/scripts/debuild.1
===================================================================
--- trunk/scripts/debuild.1     2008-04-15 16:58:19 UTC (rev 1345)
+++ trunk/scripts/debuild.1     2008-04-15 17:06:21 UTC (rev 1346)
@@ -87,9 +87,10 @@
 As environment variables can affect the building of a package, often
 unintentionally, \fBdebuild\fR sanitises the environment by removing
 all environment variables except for TERM, HOME, LOGNAME, GNUPGHOME,
-PGPPATH, GPG_AGENT_INFO, FAKEROOTKEY, DEB_* and the locale variables
-LANG and LC_*.  TERM is set to `dumb' if it is unset, and PATH is set
-to "/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11".
+PGPPATH, GPG_AGENT_INFO, FAKEROOTKEY, DEB_*, the
+(C, CPP, CXX, LD and F)FLAGS variables and their _EXTEND counterparts
+and the locale variables LANG and LC_*.  TERM is set to `dumb' if it
+is unset, and PATH is set to "/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11".
 .PP
 If a particular environment variable is required to be passed through
 untouched to the build process, this may be specified by using a

Modified: trunk/scripts/debuild.pl
===================================================================
--- trunk/scripts/debuild.pl    2008-04-15 16:58:19 UTC (rev 1345)
+++ trunk/scripts/debuild.pl    2008-04-15 17:06:21 UTC (rev 1346)
@@ -611,7 +611,8 @@
 unless ($preserve_env) {
     foreach my $var (keys %ENV) {
        delete $ENV{$var} unless
-           $save_vars{$var} or $var =~ /^(LC|DEB(SIGN)?)_[A-Z_]+$/;
+           $save_vars{$var} or $var =~ /^(LC|DEB(SIGN)?)_[A-Z_]+$/
+           or $var =~ /^(C(PP|XX)?|LD|F)FLAGS(_APPEND)?$/;
     }
 }
 
@@ -1008,8 +1009,49 @@
     } else {
        # Not using dpkg-cross, so we emulate dpkg-buildpackage ourselves
        # We emulate the version found in dpkg-buildpackage-snapshot in
-       # the source package with the addition of -j support
+       # the source package with the addition of -j and *FLAGS(_APPEND)
+       # support
 
+       my $build_opts = parsebuildopts();
+
+       # From dpkg-buildpackage 1.14.15
+       if ($parallel) {
+           $parallel = $build_opts->{parallel}
+               if (defined $build_opts->{parallel});
+           $ENV{MAKEFLAGS} ||= '';
+
+           if ($parallel eq '-1') {
+               $ENV{MAKEFLAGS} .= " -j";
+           } else {
+               $ENV{MAKEFLAGS} .= " -j$parallel";
+           }
+
+           $build_opts->{parallel} = $parallel;
+           setbuildopts($build_opts);
+       }
+
+       # From dpkg-buildpackage 1.14.18
+       # (with messages tweaked as we don't support localization)
+       my $default_flags = defined $build_opts->{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}) {
+               print "$progname: using $flag from environment: $ENV{$flag}\n";
+           } else {
+               $ENV{$flag} = $flags{$flag};
+               print "$progname: set $flag to defailt value: $ENV{$flag}\n";
+           }
+           if ($ENV{"${flag}_APPEND"}) {
+               $ENV{$flag} .= " ".$ENV{"${flag}_APPEND"};
+           }
+       }
+
        # First dpkg-buildpackage action: run dpkg-checkbuilddeps
        if ($checkbuilddep) {
            if ($binarytarget eq 'binary-arch') {
@@ -1058,24 +1100,6 @@
 
        run_hook('build', ! $sourceonly);
 
-       # From dpkg-buildpackage 1.14.15
-       if ($parallel) {
-           my $build_opts = parsebuildopts();
-
-           $parallel = $build_opts->{parallel}
-               if (defined $build_opts->{parallel});
-           $ENV{MAKEFLAGS} ||= '';
-
-           if ($parallel eq '-1') {
-               $ENV{MAKEFLAGS} .= " -j";
-           } else {
-               $ENV{MAKEFLAGS} .= " -j$parallel";
-           }
-
-           $build_opts->{parallel} = $parallel;
-           setbuildopts($build_opts);
-       }
-
        # Next dpkg-buildpackage action: build and binary targets
        if (! $sourceonly) {
            system_withecho('debian/rules', 'build');



-- 
To unsubscribe, send mail to [EMAIL PROTECTED]

Reply via email to