]> ruderich.org/simon Gitweb - blhc/blhc.git/blobdiff - bin/blhc
Handle dependency generation flags (-M/-MM/-MD/-MMD).
[blhc/blhc.git] / bin / blhc
index 5adfca6c13ea2d28d7e3c43c3a61d43c8530e443..91a5f4943c29076d61bde0904dffc7aa8d38a74a 100755 (executable)
--- a/bin/blhc
+++ b/bin/blhc
@@ -731,6 +731,7 @@ FILE: foreach my $file (@ARGV) {
         # Skip unnecessary tests when only preprocessing.
         my $flag_preprocess = 0;
 
+        my $dependency = 0;
         my $preprocess = 0;
         my $compile    = 0;
         my $link       = 0;
@@ -740,11 +741,25 @@ FILE: foreach my $file (@ARGV) {
             $preprocess      = 1;
             $flag_preprocess = 1 if $1 eq '-E';
             $compile         = 1 if $1 eq '-S' or $1 eq '-c';
+        # Dependency generation for Makefiles. The other flags (-MF -MG -MP
+        # -MT -MQ) are always used with -M/-MM.
+        } elsif ($line =~ /\s(?:-M|-MM)\b/) {
+            $dependency = 1;
         # Otherwise assume we are linking.
         } else {
             $link = 1;
         }
 
+        # -MD/-MMD also cause dependency generation, but they don't imply -E!
+        if ($line =~ /\s(?:-MD|-MMD)\b/) {
+            $dependency      = 0;
+            $flag_preprocess = 0;
+        }
+
+        # Dependency generation for Makefiles, no preprocessing or other flags
+        # needed.
+        next if $dependency;
+
         # Get all file extensions on this line.
         my @extensions = $line =~ /$file_extension_regex/go;
         # Ignore all unknown extensions to speedup the search below.