~ubuntu-branches/ubuntu/hoary/gwenview/hoary

« back to all changes in this revision

Viewing changes to admin/config.pl

  • Committer: Bazaar Package Importer
  • Author(s): Christopher Martin
  • Date: 2004-06-13 18:55:04 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040613185504-net8ekxoswwvyxs9
Tags: 1.1.3-1
New upstream release. Translations now included.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl
 
1
#!/usr/bin/env perl
2
2
# a script for use by autoconf to make the Makefiles
3
3
# from the Makefile.in's
4
4
#
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!
12
12
#
13
 
# written by Michael Matz <matz@ifh.de>
14
 
#
15
 
# the first part was done by looking at the config.status files generated
16
 
# by configure.
17
 
18
 
my $ac_cs_root=$ARGV[0];
19
 
my $ac_given_srcdir=$ARGV[1];
20
 
my $ac_given_INSTALL=$ARGV[2];
21
 
 
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";
25
 
 
 
13
# written by Michael Matz <matz@kde.org>
 
14
# adapted by Dirk Mueller <mueller@kde.org>
 
15
 
 
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.
 
20
 
 
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.
 
25
 
 
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.
 
30
 
 
31
use strict;
 
32
 
 
33
use File::Path;
 
34
 
 
35
my $ac_subs=$ARGV[0];
 
36
my $ac_sacfiles = $ARGV[1];
 
37
my $ac_given_srcdir=$ARGV[2];
 
38
my $ac_given_INSTALL=$ARGV[3];
 
39
 
 
40
my @comp_match;
 
41
my @comp_subs;
 
42
 
 
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";
 
47
 
 
48
my $configure_input;
26
49
my ($srcdir, $top_srcdir);
27
50
my $INSTALL;
28
51
my $bad_perl = ($] < 5.005);
 
52
my $created_file_count = 0;
29
53
 
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: $!";
31
55
my @subs = <CF>;
32
56
close(CF);
33
57
chomp @subs;
37
61
if ($bad_perl) {
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% )
44
69
           ) {
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)
 
73
            my $srch = $1;
 
74
            my $repl = $2;
 
75
            $repl =~ s/\\(.)/$1/g;
 
76
            push @comp_subs, make_closure($srch, $repl);
 
77
 
48
78
        } elsif ( ($pat =~ /%([^%]*)%d/ )
49
79
           || ($pat =~ m%/([^/]*)/d% )
50
80
           ) {
51
81
            push @comp_subs, make_closure($1, "");
52
82
        } else {
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
55
85
        }
56
86
    }
57
87
} else {
58
88
    foreach my $pat (@subs) {
59
 
        if (  ($pat =~ /s%([^%]*)%([^%]*)%g/ )
60
 
           || ($pat =~ m%/([^/]*)/([^/]*)/g% )
61
 
           || ($pat =~ /s%([^%]*)%([^%]*)%;t/ )
62
 
           || ($pat =~ m%/([^/]*)/([^/]*)/;t% )
63
 
           ) {
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
67
 
            push @comp_subs, $2;
68
 
        } elsif ( ($pat =~ /%([^%]*)%d/ )
69
 
           || ($pat =~ m%/([^/]*)/d% )
70
 
           ) {
71
 
            push @comp_match, eval "qr/\Q$1\E/";
72
 
            push @comp_subs, "";
73
 
        } else {
74
 
            die "Uhh. Malformed pattern in $ac_cs_root.subs ($pat)"
75
 
                unless ( $pat =~ /^\s*$/ );   # ignore white lines
76
 
        }
 
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)
 
95
         my $srch = $1;
 
96
         my $repl = $2;
 
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% )
 
102
              ) {
 
103
        push @comp_match, eval "qr/\Q$1\E/";
 
104
        push @comp_subs, "";
 
105
      } else {
 
106
          die "Uhh. Malformed pattern in $ac_subs ($pat)"
 
107
          unless ( $pat =~ /^\s*$/ );   # ignore white lines
 
108
      }
77
109
    }
78
110
}
79
111
undef @subs;
81
113
# read the list of files to be patched, form:
82
114
# ./Makefile arts/Makefile arts/examples/Makefile arts/flow/Makefile
83
115
 
84
 
open(CF, "< $ac_cs_root.sacfiles") || die "can't open $ac_cs_root.sacfiles: $!";
 
116
open(CF, "< $ac_sacfiles") || die "can't open $ac_sacfiles: $!";
85
117
my @ac_files = <CF>;
86
118
close(CF);
87
119
chomp @ac_files;
88
120
 
 
121
 
89
122
my $ac_file;
90
123
foreach $ac_file (@ac_files) {
91
124
    next if $ac_file =~ /\.\./;
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
148
 
    }
 
178
    $configure_input="$ac_file.  Generated from $fname by config.pl.";
149
179
 
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;
153
183
 
154
 
    patch_file($ac_file, $ac_file_inputs, $ac_comsub);
 
184
    patch_file($ac_file, $ac_file_inputs);
 
185
    ++$created_file_count;
155
186
}
156
187
 
 
188
print "config.pl: fast created $created_file_count file(s).\n";
 
189
 
157
190
sub patch_file {
158
 
    my ($outf, $infiles, $firstline) = @_;
 
191
    my ($outf, $infiles) = @_;
159
192
    my $filedata;
160
193
    my @infiles=split(' ', $infiles);
161
194
    my $i=0;
162
195
 
163
 
    if ($firstline) {
164
 
        $filedata = $firstline;
165
 
    }
166
196
    foreach my $name (@infiles) {
167
197
        if (open(CF, "< $name")) {
168
198
            while (<CF>) {
198
228
 
199
229
sub make_closure {
200
230
    my ($pat, $sub) = @_;
201
 
    $pat =~ s/\@/\\@/g;   # @bla@ -> \@bla\@
202
 
    $pat =~ s/\$/\\\$/g;  # $bla -> \$bla
203
 
    $sub =~ s/\@/\\@/g;
204
 
    $sub =~ s/\$/\\\$/g;
205
 
    my $ret = eval "return sub { my \$ref=shift; \$\$ref =~ s%$pat%$sub%g; }";
 
231
    my $ret = eval "return sub { my \$ref=shift; \$\$ref =~ s%\Q$pat\E%\Q$sub\E%g; }";
206
232
    if ($@) {
207
233
        print "can't create CODE: $@\n";
208
234
    }