File: makedeps.pl

package info (click to toggle)
prayer 1.3.5-dfsg1-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 6,576 kB
  • sloc: ansic: 43,161; makefile: 817; sh: 445; perl: 166
file content (47 lines) | stat: -rw-r--r-- 1,077 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl
#
# $Cambridge: hermes/src/prayer/templates/src/makedeps.pl,v 1.1 2010/07/07 08:27:02 dpc22 Exp $
#
# Generate proper list of dependancies between templates

my %index = ();
my %uses = ();

sub scan {
  my ($file) = @_;

  if (!exists $uses{$file}) {
    grep {
	$_ ne '' and open(FILE, '<', "$_/${file}.t")
    } '.', split(/ :/, $ENV{'VPATH'} || '')
    or die "failed to open ${file}: $!\n";
    while (<FILE>) {
      $uses{$file}{$1} = 1 if /^%\s+CALL ([\w-_]+)/;
    }
    close(FILE);

    foreach (keys %{$uses{$file}}) {
      $uses{$file}{$_} = 1 foreach keys %{scan($_)};
    }
    $uses{$file}{$file} = 1;
    $index{$file} = 1;
  }
  return $uses{$file}
}

my $suffix = '';
if ($ARGV[0] eq '--frontend') {
  shift;
  $suffix = '_frontend';
}
my $name = shift;

$, = ' '; $\ = "\n";
foreach my $i (@ARGV) {
  $i =~ s/([\w-_]+)\.t/$1/;
  print "$i.html:", map {"$_.t"} sort keys %{scan($i)};
}

my @all = sort keys %index;
print "_template_index$suffix.c:", map {"$_.t"} @all;
print "$name$suffix.so:", "_template_index$suffix.o", map {"$_.o"} @all;