summaryrefslogtreecommitdiff
path: root/make/calcdep.pl
diff options
context:
space:
mode:
Diffstat (limited to 'make/calcdep.pl')
-rwxr-xr-xmake/calcdep.pl23
1 files changed, 23 insertions, 0 deletions
diff --git a/make/calcdep.pl b/make/calcdep.pl
new file mode 100755
index 000000000..2b6742be3
--- /dev/null
+++ b/make/calcdep.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+use strict;
+BEGIN { push @INC, '..'; }
+use make::configure;
+
+my $file = shift;
+
+$file =~ /(.*)\.cpp$/ or die "Cannot process $file";
+my $base = $1;
+
+my $out = "$base.d";
+
+open IN, '<', $file or die "Could not read $file: $!";
+open OUT, '>', $out or die "Could not write $out: $!";
+
+my $cc_deps = qx($ENV{CC} $ENV{FLAGS} -MM $file);
+$cc_deps =~ s/.*?:\s*//;
+
+my $ext = $file =~ m#(modules|commands)/# ? '.so' : '.o';
+print OUT "$base$ext: $cc_deps";
+print OUT "\t@../make/unit-cc.pl \$(VERBOSE) $file $base$ext\n";
+print OUT "$base.d: $cc_deps";
+print OUT "\t../make/calcdep.pl $file\n";