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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#!/usr/bin/perl -w
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0; #$running_under_some_shell
use strict;
use File::Find;
my $packages="";
open(FILE, "<./packages");
while(<FILE>){$packages.=$_;}
close(FILE);
my ($dirname,$dir,$file,@files,$filename,$tagname,$name,$caps,$pre,$post,$sources,@dupecheck);
$file = shift || die;
push(@files, $file);
foreach(@files){
my $cfg=$_;
($dirname=$cfg)=~s,(.*)/(.*),$1,;
($filename=$cfg)=~s,(.*/)(.*),$2,;
($tagname=$dirname)=~s,.*/,,;
($caps=$tagname)=~tr/[a-z]/[A-Z]/;
#print "cfg is $cfg\n";
#print "dir is $dirname\n";
#print "filename is $filename\n";
sub wanted;
if(-e "$dirname/config.in.in"){
my $contents;
open(FILE, "<$dirname/config.in.in");
while(<FILE>){ $contents.=$_; }
close(FILE);
if($contents=~/\@sources\@/){
($post = $contents) =~ s/^.*\@sources\@//s;
($pre = $contents) =~ s/\@sources\@.*$//s;
} else {
$pre = $contents;
}
} else {
$pre = "menu \"$tagname\"\n";
$post = "endmenu\n";
}
open(CFG, ">$cfg") || die "Unable to open $cfg for writing\n";
select(CFG);
print $pre;
@dupecheck=();
File::Find::find({wanted => \&wanted}, $dirname);
print $post;
select(STDOUT);
close(CFG);
}
exit;
open(FILE,">$dir/config.in");
select(FILE);
print "menu \"$name\"\n";
print "\n";
my @subdirs=();
my @dirs;
foreach(grep(/^$dir/, @dirs)){
chomp;
/^$dir\/$name.pro$/ && next;
my $localdir=$_;
if($dir=~m,^$localdir$,){
next;
}
#($locadir=$_)~s,/[^/]+$,,g;
if($localdir=~/^\.$/){next;}
if(grep(/^$localdir$/, @subdirs)){next;}
my $nslashes = $localdir =~ tr!/!!;
my $dirnslashes = $dir =~ tr!/!!;
$dirnslashes++;
if($dirnslashes != $nslashes ){next;}
print STDERR "$localdir/config.in\n";
print " source $localdir/config.in\n";
push(@subdirs, $localdir);
print "endmenu\n";
select(STDOUT);
close(FILE);
}
use vars qw/*name *dir *prune/;
*name = *File::Find::name;
*dir = *File::Find::dir;
*prune = *File::Find::prune;
sub wanted {
if( /config.in$/s ) {
if(grep(/^$File::Find::dir\/config.in$/, @dupecheck)){
return;
}
my $nslashes = $File::Find::dir =~ tr!/!!;
my $dirnslashes = $dirname =~ tr!/!!;
$dirnslashes++;
# print STDERR "dirnslashes is $dirnslashes\n";
# print STDERR "nslashes is $nslashes\n";
if($dirnslashes != $nslashes){return;}
print " source " . $File::Find::dir . "/config.in\n";
push(@dupecheck, $File::Find::dir . "/config.in");
}
}
|