diff options
author | James Bursa <james@netsurf-browser.org> | 2004-10-07 09:26:23 +0000 |
---|---|---|
committer | James Bursa <james@netsurf-browser.org> | 2004-10-07 09:26:23 +0000 |
commit | 47e75ceb17f8e75f3ba24c469e33d3c19f9bd145 (patch) | |
tree | d546145b7b2ab13a423dc4e0647e6214e0cf255a /scandeps | |
parent | c0f18cd43453fff2a174955f17cbe91808aa6118 (diff) | |
download | netsurf-47e75ceb17f8e75f3ba24c469e33d3c19f9bd145.tar.gz netsurf-47e75ceb17f8e75f3ba24c469e33d3c19f9bd145.tar.bz2 |
[project @ 2004-10-07 09:26:23 by bursa]
New dependency scanning script and updated makefile.
svn path=/import/netsurf/; revision=1306
Diffstat (limited to 'scandeps')
-rwxr-xr-x | scandeps | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/scandeps b/scandeps new file mode 100755 index 000000000..e60c5b8f1 --- /dev/null +++ b/scandeps @@ -0,0 +1,48 @@ +#!/usr/bin/perl -W
+
+%include = ();
+
+die "Usage: scandeps prefix object_dirs -- sources" if (@ARGV < 4);
+
+$prefix = shift @ARGV;
+$prefix = $prefix; # silence warning
+
+@objdirs = ();
+while (($z = shift @ARGV) ne "--") {
+ push @objdirs, $z;
+}
+
+# scan all files for relevant #include lines
+foreach my $file (@ARGV) {
+ open FILE, "<$file" or die "Failed to open $file: $!";
+ while (my $line = <FILE>) {
+ if ($line =~ m|#include "$prefix/?([^"]+)"|) {
+ $include{$file}{$1} = 1;
+ }
+ }
+ close FILE;
+}
+
+# output dependencies
+foreach my $file (@ARGV) {
+ next unless $file =~ m|([^/]+)[.]c$|;
+ %deps = ();
+ search_deps($file);
+ foreach my $z (@objdirs) {
+ print "$z/$1.o ";
+ }
+ print ": $file ";
+ foreach my $z (sort keys %deps) { print "$z " }
+ print "\n";
+}
+
+
+sub search_deps {
+ my $file = shift;
+ return unless exists $include{$file};
+ foreach my $z (keys %{$include{$file}}) {
+ next if exists $deps{$z};
+ $deps{$z} = 1;
+ search_deps($z);
+ }
+}
|