File: makeMake.pl

package info (click to toggle)
emboss 6.6.0%2Bdfsg-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 571,584 kB
  • sloc: ansic: 460,579; java: 29,383; perl: 13,573; sh: 12,753; makefile: 3,294; csh: 706; asm: 351; xml: 239; pascal: 237; modula3: 8
file content (157 lines) | stat: -rwxr-xr-x 3,313 bytes parent folder | download | duplicates (7)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/usr/bin/perl -w

# creates and commits the Makefile.am for the text and html doc directories
# the default is to do the text directory.
# any parameter causes it to do the html directory

my @list = ();
my $line = "";
my $flag = 0;
my $flag2 = 0;
my $dir;  
my $html;
my $cvsdoc;

sub ingroups($$) {
    my ($a,$b) = @_;

    $a =~ s/_group[.]html//;
    $b =~ s/_group[.]html//;

    $a =~ s/groups[.]html//;
    $b =~ s/groups[.]html//;

    $ret = ($a cmp $b);

    return $ret;
}

open (VERS, "embossversion -full -auto|") || die "Cannot run embossversion";
while (<VERS>) {
    if(/BaseDirectory: +(\S+)/) {$distribtop = $1}
}
close VERS;
# where the CVS tree program doc pages are
$cvsdoc = "$distribtop/doc/programs/";

if ($#ARGV >= 0) {
    $html = 1;
    print "Doing HTML directory\n";
} else {
    $html = 0;
    print "Doing TEXT directory\n";
}


if ($html) {
    $dir = "html";
} else {
    $dir = "text";
}

chdir "$cvsdoc/$dir";

open (OLD, "Makefile.am") || die "Cannot open Makefile.am\n";
$data = 0;
while (<OLD>) {
    if(/_DATA\s*= /) {$data=1}
    if(/dir\s*= /) {$data=0}
    if($data) {
	@names = split(/\s+/, $_);
	foreach $n (@names) {
	    if($n =~ /_DATA$/) {next}
	    if($n eq "=") {next}
	    if($n eq "\\") {next}
	    $oldnames{$n}++;
	}
    }
}
close OLD;

open(M, ">make.temp") || die "Cannot open make.temp\n";

print M "## Process this file with automake to produce Makefile.in
";

# process gifs, then groups, then to lindna, then to end

if($html) {
    print M "
eimagesdir    = \$(pkgdatadir)/doc/programs/html
egroupsdir    = \$(pkgdatadir)/doc/programs/html
eprograms1dir = \$(pkgdatadir)/doc/programs/html
eprograms2dir = \$(pkgdatadir)/doc/programs/html

";
    print M "eimages\_DATA =";
    foreach $file (glob("*.jpg"), glob("*.gif")) {
	if($newnames{$file}) {next}
	$newnames{$file}++;
	if(!defined($oldnames{$file})) {
	    print "$file\n";
	}
	print M " \\\n$file";
    }
    print M "\n\n";

    print M "egroups\_DATA =";
    foreach $file (sort ingroups ("groups.html", glob("*_group.html"))) {
	if($newnames{$file}) {next}
	$newnames{$file}++;
	if(!defined($oldnames{$file})) {
	    print "$file\n";
	}
	print M " \\\n$file";
    }
    print M "\n\n";

    $firstchar="a";
    $set = 1;
    print M "eprograms$set\_DATA =";
    foreach $file (glob("*.html")) {
	if($newnames{$file}) {next}
	$newnames{$file}++;
	if(!defined($oldnames{$file})) {
	    print "$file\n";
	}
	$file =~ /^(.)/;
	if($1 ne $firstchar) {$firstchar = $1;$newfirst=1}
	if($newfirst && $firstchar ge "l" && $set == 1) {
	    ++$set;
	    print M "\n\neprograms$set\_DATA =";
	}
	print M " \\\n$file";
    }
    print M "\n\n";
}
else {
    print M "
eprograms1dir = \$(pkgdatadir)/doc/programs/text
eprograms2dir = \$(pkgdatadir)/doc/programs/text

";
    $firstchar="a";
    $set = 1;
    print M "eprograms$set\_DATA =";
    foreach $file (glob("*.txt")) {
	if($newnames{$file}) {next}
	$newnames{$file}++;
	if(!defined($oldnames{$file})) {
	    print "$file\n";
	}
	$file =~ /^(.)/;
	if($1 ne $firstchar) {$firstchar = $1;$newfirst=1}
	if($newfirst && $firstchar ge "l" && $set == 1) {
	    ++$set;
	    print M "\n\neprograms$set\_DATA =";
	}
	print M " \\\n$file";
    }
    print M "\n";
}

close (M);

# copy make.text to be Makefile.am
system("diff make.temp Makefile.am");