10
10
# this script does better. It changes all Makefile.ins in one process.
11
11
# in kdelibs the time for building Makefile went down from 2:59 min to 13 sec!
13
# written by Michael Matz <matz@ifh.de>
15
# the first part was done by looking at the config.status files generated
18
my $ac_cs_root=$ARGV[0];
19
my $ac_given_srcdir=$ARGV[1];
20
my $ac_given_INSTALL=$ARGV[2];
22
# print "ac_cs_root=$ac_cs_root\n";
23
# print "ac_given_srcdir=$ac_given_srcdir\n";
24
# print "ac_given_INSTALL=$ac_given_INSTALL\n";
13
# written by Michael Matz <matz@kde.org>
14
# adapted by Dirk Mueller <mueller@kde.org>
16
# This file is free software; you can redistribute it and/or
17
# modify it under the terms of the GNU Library General Public
18
# License as published by the Free Software Foundation; either
19
# version 2 of the License, or (at your option) any later version.
21
# This library is distributed in the hope that it will be useful,
22
# but WITHOUT ANY WARRANTY; without even the implied warranty of
23
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24
# Library General Public License for more details.
26
# You should have received a copy of the GNU Library General Public License
27
# along with this library; see the file COPYING.LIB. If not, write to
28
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
29
# Boston, MA 02111-1307, USA.
36
my $ac_sacfiles = $ARGV[1];
37
my $ac_given_srcdir=$ARGV[2];
38
my $ac_given_INSTALL=$ARGV[3];
43
#print "ac_subs=$ac_subs\n";
44
#print "ac_sacfiles=$ac_sacfiles\n";
45
#print "ac_given_srcdir=$ac_given_srcdir\n";
46
#print "ac_given_INSTALL=$ac_given_INSTALL\n";
26
49
my ($srcdir, $top_srcdir);
28
51
my $bad_perl = ($] < 5.005);
52
my $created_file_count = 0;
30
open(CF, "< $ac_cs_root.subs") || die "can't open $ac_cs_root.subs: $!";
54
open(CF, "< $ac_subs") || die "can't open $ac_subs: $!";
38
62
print "Using perl older than version 5.005\n";
39
63
foreach my $pat (@subs) {
40
if ( ($pat =~ /s%([^%]*)%([^%]*)%g/ )
41
|| ($pat =~ m%/([^/]*)/([^/]*)/g% )
42
|| ($pat =~ /s%([^%]*)%([^%]*)%;t/ )
43
|| ($pat =~ m%/([^/]*)/([^/]*)/;t% )
64
if ( ($pat =~ m/s%([^%]*)%([^%]*)%g/ )
65
|| ($pat =~ m/s%([^%]*)%([^%]*)%;t/ )
66
|| ($pat =~ m/s,([^,]*),(.*),;t/)
67
|| ($pat =~ m%s/([^/]*)/([^/]*)/g% )
68
|| ($pat =~ m%s/([^/]*)/([^/]*)/;t% )
45
70
# form : s%bla%blubb%g
46
# or s%bla%blubb%;t t (newer autoconf)
47
push @comp_subs, make_closure($1, $2);
71
# or s%bla%blubb%;t t (autoconf > 2.13 and < 2.52 ?)
72
# or s,bla,blubb,;t t (autoconf 2.52)
75
$repl =~ s/\\(.)/$1/g;
76
push @comp_subs, make_closure($srch, $repl);
48
78
} elsif ( ($pat =~ /%([^%]*)%d/ )
49
79
|| ($pat =~ m%/([^/]*)/d% )
51
81
push @comp_subs, make_closure($1, "");
53
die "Uhh. Malformed pattern in $ac_cs_root.subs ($pat)"
83
die "Uhh. Malformed pattern in $ac_subs ($pat)"
54
84
unless ( $pat =~ /^\s*$/ ); # ignore white lines
58
88
foreach my $pat (@subs) {
59
if ( ($pat =~ /s%([^%]*)%([^%]*)%g/ )
60
|| ($pat =~ m%/([^/]*)/([^/]*)/g% )
61
|| ($pat =~ /s%([^%]*)%([^%]*)%;t/ )
62
|| ($pat =~ m%/([^/]*)/([^/]*)/;t% )
64
# form : s%bla%blubb%g
65
# or s%bla%blubb%;t t (newer autoconf)
66
push @comp_match, eval "qr/\Q$1\E/"; # compile match pattern
68
} elsif ( ($pat =~ /%([^%]*)%d/ )
69
|| ($pat =~ m%/([^/]*)/d% )
71
push @comp_match, eval "qr/\Q$1\E/";
74
die "Uhh. Malformed pattern in $ac_cs_root.subs ($pat)"
75
unless ( $pat =~ /^\s*$/ ); # ignore white lines
89
if ( ($pat =~ /s%([^%]*)%([^%]*)%g/ ) ||
90
($pat =~ /s%([^%]*)%([^%]*)%;t/ ) ||
91
($pat =~ /s,([^,]*),(.*),;t/) ) {
92
# form : s%bla%blubb%g
93
# or s%bla%blubb%;t t (autoconf > 2.13 and < 2.52 ?)
94
# or s,bla,blubb,;t t (autoconf 2.52)
97
push @comp_match, eval "qr/\Q$srch\E/"; # compile match pattern
98
$repl =~ s/\\(.)/$1/g;
99
push @comp_subs, $repl;
100
} elsif ( ($pat =~ /%([^%]*)%d/ )
101
|| ($pat =~ m%/([^/]*)/d% )
103
push @comp_match, eval "qr/\Q$1\E/";
106
die "Uhh. Malformed pattern in $ac_subs ($pat)"
107
unless ( $pat =~ /^\s*$/ ); # ignore white lines
106
139
($ac_dir = $ac_file) =~ s%/[^/][^/]*$%%;
107
140
if ( ($ac_dir ne $ac_file) && ($ac_dir ne ".")) {
108
141
# The file is in a subdirectory.
109
if (! -d "$ac_dir") { mkdir "$ac_dir", 0777; }
142
if (! -d "$ac_dir") { mkpath "$ac_dir", 0, 0777; }
110
143
($ac_dir_suffix = $ac_dir) =~ s%^./%%;
111
144
$ac_dir_suffix="/".$ac_dir_suffix;
112
145
# A "../" for each directory in $ac_dir_suffix.
142
175
my $ac_comsub="";
143
176
my $fname=$ac_file_in;
144
177
$fname =~ s%.*/%%;
145
my $configure_input="Generated automatically from $fname by config.pl.";
146
if ($ac_file =~ /.*[Mm]akefile.*/) {
147
$ac_comsub="# ".$configure_input."\n"; # for the first line in $ac_file
178
$configure_input="$ac_file. Generated from $fname by config.pl.";
150
180
my $ac_file_inputs;
151
181
($ac_file_inputs = $ac_file_in) =~ s%^%$ac_given_srcdir/%;
152
182
$ac_file_inputs =~ s%:% $ac_given_srcdir/%g;
154
patch_file($ac_file, $ac_file_inputs, $ac_comsub);
184
patch_file($ac_file, $ac_file_inputs);
185
++$created_file_count;
188
print "config.pl: fast created $created_file_count file(s).\n";
158
my ($outf, $infiles, $firstline) = @_;
191
my ($outf, $infiles) = @_;
160
193
my @infiles=split(' ', $infiles);
164
$filedata = $firstline;
166
196
foreach my $name (@infiles) {
167
197
if (open(CF, "< $name")) {