diff options
Diffstat (limited to 'src/depend.pl')
-rw-r--r-- | src/depend.pl | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/depend.pl b/src/depend.pl new file mode 100644 index 0000000..b41b8f6 --- /dev/null +++ b/src/depend.pl @@ -0,0 +1,46 @@ +#!/usr/bin/perl -w +# $Header$ + +# Create dependencies for Fortran 90 "use" and "include" statements + +$src = $ARGV[0]; +$srcfile = $ARGV[1]; +$dest = $ARGV[2]; +$srcdir = $ARGV[3]; +$moddir = $ARGV[4]; +$srcsuffix = $ARGV[5]; +$modsuffix = $ARGV[6]; +@otherdirs = @ARGV[7..$#ARGV]; + +print "# $src\n"; +print "$dest:"; + +open (FILE, $src); +while (<FILE>) { + if (/^\s*include\s*['"]([^'"]+)['"]/i) { + print " $srcdir$1"; + } elsif (/^\s*use\s+(\w+)/i) { + $found = 0; + if (! $found) { + if (-e "$srcdir$1$srcsuffix") { + $found = 1; + print " $moddir$1$modsuffix"; + } + } + if (! $found) { + foreach $dir (@otherdirs) { + if (-e "$dir$1$modsuffix") { + $found = 1; + print " $dir$1$modsuffix"; + last; + } + } + } + if (! $found) { + die "\nWhile tracing depencencies:\nFortran module $1 (referenced in file $srcfile) not found.\nAborting.\n\n"; + } + } +} +close (FILE); + +print "\n"; |