]> ruderich.org/simon Gitweb - blhc/blhc.git/blobdiff - bin/blhc
Release 0.07
[blhc/blhc.git] / bin / blhc
index e918ee85c3e713a96145b5cf439dc4be47f11e21..accb99fbff8226aa42fb55ed423a9e32b40d3710 100755 (executable)
--- a/bin/blhc
+++ b/bin/blhc
@@ -24,7 +24,7 @@ use warnings;
 use Getopt::Long ();
 use Text::ParseWords ();
 
-our $VERSION = '0.06';
+our $VERSION = '0.07';
 
 
 # CONSTANTS/VARIABLES
@@ -89,10 +89,10 @@ my @source_no_preprocess_compile_cpp = (
     qw( mii ),
 );
 my @source_no_preprocess_compile_ada = (
+    # Ada source
+    qw( ada ),
     # Ada body
     qw( adb ),
-    # If you add another file, fix use of @source_no_preprocess_compile_ada
-    # below (search for $compile_ada).
 );
 my @source_no_preprocess_compile = (
     # C
@@ -106,11 +106,15 @@ my @source_no_preprocess_compile = (
     # Ada
     @source_no_preprocess_compile_ada,
 );
+my @source_no_preprocess_no_compile_ada = (
+    # Ada specification
+    qw( ads ),
+);
 my @source_no_preprocess_no_compile = (
     # Assembly
     qw( s ),
-    # Ada specification
-    qw( ads ),
+    # Ada
+    @source_no_preprocess_no_compile_ada,
 );
 my @source_no_preprocess = (
     @source_no_preprocess_compile,
@@ -161,6 +165,10 @@ my %extensions_compile_cpp = map { $_ => 1 } (
     @source_preprocess_compile_cpp,
     @source_no_preprocess_compile_cpp,
 );
+my %extensions_ada = map { $_ => 1 } (
+    @source_no_preprocess_compile_ada,
+    @source_no_preprocess_no_compile_ada,
+);
 my %extensions_object = map { $_ => 1 } (
     @object,
 );
@@ -972,6 +980,8 @@ foreach my $file (@ARGV) {
             # look like a compiler executable thus causing the line to be
             # treated as a normal compiler line.
             next if $line =~ m{^\s*rm\s+};
+            # Some build systems emit "gcc > file".
+            next if $line =~ m{$cc_regex_normal\s*>\s*\S+};
 
             # Check if additional hardening options were used. Used to ensure
             # they are used for the complete build.
@@ -1012,8 +1022,8 @@ foreach my $file (@ARGV) {
 
     # Option or auto detected.
     if ($arch) {
-        # The following was partially copied from dpkg-dev 1.18.7
-        # (/usr/share/perl5/Dpkg/Vendor/Debian.pm, add_hardening_flags()),
+        # The following was partially copied from dpkg-dev 1.18.10
+        # (/usr/share/perl5/Dpkg/Vendor/Debian.pm, _add_hardening_flags()),
         # copyright RaphaĆ«l Hertzog <hertzog@debian.org>, Kees Cook
         # <kees@debian.org>, Canonical, Ltd. licensed under GPL version 2 or
         # later. Keep it in sync.
@@ -1022,7 +1032,8 @@ foreach my $file (@ARGV) {
         my ($abi, $os, $cpu) = Dpkg::Arch::debarch_to_debtriplet($arch);
 
         # Disable unsupported hardening options.
-        if ($os !~ /^(?:linux|knetbsd|hurd)$/ or $cpu =~ /^(?:hppa|avr32)$/) {
+        if ($os !~ /^(?:linux|kfreebsd|knetbsd|hurd)$/
+                or $cpu =~ /^(?:hppa|avr32)$/) {
             $harden_pie = 0;
         }
         if ($cpu =~ /^(?:ia64|alpha|hppa|nios2)$/ or $arch eq 'arm') {
@@ -1227,10 +1238,9 @@ LINE:
             $compile_cpp = 1;
         # Ada needs special CFLAGS, use them if only ada files are compiled.
         } elsif ($ada
-                    and $compile
-                    and array_equal(\@extensions,
-                                    \@source_no_preprocess_compile_ada)) {
+                and extension_found(\%extensions_ada, @extensions)) {
             $compile_ada = 1;
+            $preprocess = 0; # Ada uses no CPPFLAGS
             @cflags_backup = @cflags;
             @cflags        = @cflags_ada;
         }