-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgen-wwwdepend.pl
57 lines (53 loc) · 1.29 KB
/
gen-wwwdepend.pl
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
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env perl
#
# Public domain.
#
# Scan <build.www.mk> sources for m4 include() statements and output
# the required make dependencies.
#
sub Scan ($)
{
my $file = shift;
my @rv = ();
if (!open(SRC, $file)) {
return ();
}
foreach my $line (<SRC>) {
if ($line !~ /include\s*\(([\w\-\.\s\/]+)\)/) { next; }
my $incl = $1;
$incl =~ s/__FILE/$file/g;
$incl =~ s/__LANG/en/g;
$incl =~ s/__BASE_DIR/$ENV{'BASEDIR'}/g;
$incl =~ s/__TEMPLATE/$ENV{'TEMPLATE'}/g;
$incl =~ s/__CSS_TEMPLATE/$ENV{'CSS_TEMPLATE'}/g;
if ($incl eq $ENV{'BASEDIR'}.'/base.htm') {
next;
}
push @rv, $incl;
if (-e $incl) {
push @rv, Scan($incl);
}
}
close(SRC);
return (@rv);
}
if (@ARGV < 1) {
print STDERR "Usage: gen-wwwdepend.pl [files]\n";
exit(1);
}
foreach my $file (@ARGV) {
my $src;
if ($file =~ /^([\w\-\.\s]+)\.(html|html\.var)$/) {
my $src = $1.'.htm';
my $tmplFile = $ENV{'BASEDIR'}.'/'.$ENV{'TEMPLATE'}.'.m4';
print $file.': '. join(' ',
$src, Scan($src), $tmplFile, Scan($tmplFile)), "\n";
} elsif ($file =~ /^([\w\-\.\s]+)\.(css)$/) {
my $src = $1.'.css-in';
my $tmplFile = $ENV{'BASEDIR'}.'/'.$ENV{'CSS_TEMPLATE'}.'.m4';
print $file.': '. join(' ',
$src, Scan($src), $tmplFile, @tmplDeps), "\n";
} else {
print STDERR "$file: Unknown extension\n";
}
}