joachim99@2
|
1 #!/usr/bin/perl -w
|
joachim99@2
|
2
|
joachim99@2
|
3 # this script patches a config.status file, to use our own perl script
|
joachim99@2
|
4 # in the main loop
|
joachim99@2
|
5 # we do it this way to circumvent hacking (and thereby including)
|
joachim99@2
|
6 # autoconf function (which are GPL) into our LGPL acinclude.m4.in
|
joachim99@2
|
7 # written by Michael Matz <matz@kde.org>
|
joachim99@2
|
8 # adapted by Dirk Mueller <mueller@kde.org>
|
joachim99@2
|
9
|
joachim99@2
|
10 # we have to change two places
|
joachim99@2
|
11 # 1. the splitting of the substitutions into chunks of 90 (or even 48 in
|
joachim99@2
|
12 # later autoconf's
|
joachim99@2
|
13 # 2. the big main loop which patches all Makefile.in's
|
joachim99@2
|
14 use File::Basename;
|
joachim99@2
|
15
|
joachim99@2
|
16 my $ac_aux_dir = dirname($0);
|
joachim99@2
|
17 my ($flag);
|
joachim99@2
|
18 local $ac_version = 0;
|
joachim99@2
|
19 my $vpath_seen = 0;
|
joachim99@2
|
20 $flag = 0;
|
joachim99@2
|
21
|
joachim99@2
|
22 while (<>) {
|
joachim99@2
|
23 # usage of $flag: 0 -- we have seen nothing yet
|
joachim99@2
|
24 # 1 -- we are in (1)
|
joachim99@2
|
25 # 2 -- we have ended (1)
|
joachim99@2
|
26 # 3 -- we are in (2)
|
joachim99@2
|
27 # 4 -- we ended (2)
|
joachim99@2
|
28
|
joachim99@2
|
29 if ($flag == 4) {
|
joachim99@2
|
30 print;
|
joachim99@2
|
31 } elsif ($flag == 0) {
|
joachim99@2
|
32 # 1. begins with (including): "ac_max_sed_\S+\s*=\s*[0-9]+..."
|
joachim99@2
|
33 # ends with (excluding) "CONFIG_FILE=..."
|
joachim99@2
|
34 # in later autoconf (2.14.1) there is no CONFIG_FILES= line,
|
joachim99@2
|
35 # but instead the (2) directly follow (1)
|
joachim99@2
|
36 if (/^\s*ac_max_sed_([a-z]+).*=\s*([0-9]+)/ ) {
|
joachim99@2
|
37 $flag = 1;
|
joachim99@2
|
38 if ($1 eq 'lines') {
|
joachim99@2
|
39 # lets hope its different with 2141,
|
joachim99@2
|
40 # wasn't able to verify that
|
joachim99@2
|
41 if ($2 eq '48') {
|
joachim99@2
|
42 $ac_version = 250;
|
joachim99@2
|
43 }
|
joachim99@2
|
44 else {
|
joachim99@2
|
45 $ac_version = 2141;
|
joachim99@2
|
46 }
|
joachim99@2
|
47 } elsif ($1 eq 'cmds') {
|
joachim99@2
|
48 $ac_version = 213;
|
joachim99@2
|
49 }
|
joachim99@2
|
50 # hmm, we don't know the autoconf version, but we try anyway
|
joachim99@2
|
51 } else {
|
joachim99@2
|
52 print;
|
joachim99@2
|
53 }
|
joachim99@2
|
54 } elsif ($flag == 1) {
|
joachim99@2
|
55 if (/^\s*CONFIG_FILES=/ && ($ac_version != 250)) {
|
joachim99@2
|
56 print;
|
joachim99@2
|
57 $flag = 2;
|
joachim99@2
|
58 } elsif (/^\s*for\s+ac_file\s+in\s+.*CONFIG_FILES/ ) {
|
joachim99@2
|
59 $flag = 3;
|
joachim99@2
|
60 }
|
joachim99@2
|
61 } elsif ($flag == 2) {
|
joachim99@2
|
62 # 2. begins with: "for ac_file in.*CONFIG_FILES" (the next 'for' after (1))
|
joachim99@2
|
63 # end with: "rm -f conftest.s\*"
|
joachim99@2
|
64 # on autoconf 250, it ends with '# CONFIG_HEADER section'
|
joachim99@2
|
65 if (/^\s*for\s+ac_file\s+in\s+.*CONFIG_FILES/ ) {
|
joachim99@2
|
66 $flag = 3;
|
joachim99@2
|
67 } else {
|
joachim99@2
|
68 print;
|
joachim99@2
|
69 }
|
joachim99@2
|
70 } elsif ($flag == 3) {
|
joachim99@2
|
71 if (/^\s*rm\s+-f\s+conftest/ ) {
|
joachim99@2
|
72 $flag = 4;
|
joachim99@2
|
73 &insert_main_loop();
|
joachim99@2
|
74 } elsif (/^\s*rm\s+-f\s+.*ac_cs_root/ ) {
|
joachim99@2
|
75 $flag = 4;
|
joachim99@2
|
76 &insert_main_loop();
|
joachim99@2
|
77 #die "hhhhhhh";
|
joachim99@2
|
78 if ($ac_version != 2141) {
|
joachim99@2
|
79 print STDERR "hmm, don't know autoconf version\n";
|
joachim99@2
|
80 }
|
joachim99@2
|
81 } elsif (/^\#\s*CONFIG_HEADER section.*/) {
|
joachim99@2
|
82 $flag = 4;
|
joachim99@2
|
83 &insert_main_loop();
|
joachim99@2
|
84 if($ac_version != 250) {
|
joachim99@2
|
85 print STDERR "hmm, something went wrong :-(\n";
|
joachim99@2
|
86 }
|
joachim99@2
|
87 } elsif (/VPATH/ ) {
|
joachim99@2
|
88 $vpath_seen = 1;
|
joachim99@2
|
89 }
|
joachim99@2
|
90 }
|
joachim99@2
|
91 }
|
joachim99@2
|
92
|
joachim99@2
|
93 die "wrong input (flag != 4)" unless $flag == 4;
|
joachim99@2
|
94 print STDERR "hmm, don't know autoconf version\n" unless $ac_version;
|
joachim99@2
|
95
|
joachim99@2
|
96 sub insert_main_loop {
|
joachim99@2
|
97
|
joachim99@2
|
98 if ($ac_version == 250) {
|
joachim99@2
|
99 &insert_main_loop_250();
|
joachim99@2
|
100 }
|
joachim99@2
|
101 else {
|
joachim99@2
|
102 &insert_main_loop_213();
|
joachim99@2
|
103 }
|
joachim99@2
|
104 }
|
joachim99@2
|
105
|
joachim99@2
|
106 sub insert_main_loop_250 {
|
joachim99@2
|
107
|
joachim99@2
|
108 print <<EOF;
|
joachim99@2
|
109 #echo Doing the fast build of Makefiles -- autoconf $ac_version
|
joachim99@2
|
110 EOF
|
joachim99@2
|
111 if ($vpath_seen) {
|
joachim99@2
|
112 print <<EOF;
|
joachim99@2
|
113 # VPATH subst was seen in original config.status main loop
|
joachim99@2
|
114 echo '/^[ ]*VPATH[ ]*=[^:]*\$/d' >>\$tmp/subs.sed
|
joachim99@2
|
115 EOF
|
joachim99@2
|
116 }
|
joachim99@2
|
117 print <<EOF;
|
joachim99@2
|
118 rm -f \$tmp/subs.files
|
joachim99@2
|
119 for ac_file in .. \$CONFIG_FILES ; do
|
joachim99@2
|
120 if test "x\$ac_file" != x..; then
|
joachim99@2
|
121 echo \$ac_file >> \$tmp/subs.files
|
joachim99@2
|
122 fi
|
joachim99@2
|
123 done
|
joachim99@2
|
124 if test -f \$tmp/subs.files ; then
|
joachim99@2
|
125 perl $ac_aux_dir/config.pl "\$tmp/subs.sed" "\$tmp/subs.files" "\$srcdir" "\$INSTALL"
|
joachim99@2
|
126 fi
|
joachim99@2
|
127 rm -f \$tmp/subs.files
|
joachim99@2
|
128
|
joachim99@2
|
129 fi
|
joachim99@2
|
130 EOF
|
joachim99@2
|
131 return;
|
joachim99@2
|
132 }
|
joachim99@2
|
133
|
joachim99@2
|
134 sub insert_main_loop_213 {
|
joachim99@2
|
135 print <<EOF;
|
joachim99@2
|
136 #echo Doing the fast build of Makefiles -- autoconf $ac_version
|
joachim99@2
|
137 if test "x\$ac_cs_root" = "x" ; then
|
joachim99@2
|
138 ac_cs_root=conftest
|
joachim99@2
|
139 fi
|
joachim99@2
|
140 EOF
|
joachim99@2
|
141 if ($vpath_seen) {
|
joachim99@2
|
142 print <<EOF;
|
joachim99@2
|
143 # VPATH subst was seen in original config.status main loop
|
joachim99@2
|
144 echo '/^[ ]*VPATH[ ]*=[^:]*\$/d' >> \$ac_cs_root.subs
|
joachim99@2
|
145 EOF
|
joachim99@2
|
146 }
|
joachim99@2
|
147 print <<EOF;
|
joachim99@2
|
148 rm -f \$ac_cs_root.sacfiles
|
joachim99@2
|
149 for ac_file in .. \$CONFIG_FILES ; do
|
joachim99@2
|
150 if test "x\$ac_file" != x..; then
|
joachim99@2
|
151 echo \$ac_file >> \$ac_cs_root.sacfiles
|
joachim99@2
|
152 fi
|
joachim99@2
|
153 done
|
joachim99@2
|
154 if test -f \$ac_cs_root.sacfiles ; then
|
joachim99@2
|
155 perl $ac_aux_dir/config.pl "\$ac_cs_root.subs" "\$ac_cs_root.sacfiles" "\$ac_given_srcdir" "\$ac_given_INSTALL"
|
joachim99@2
|
156 fi
|
joachim99@2
|
157 rm -f \$ac_cs_root.s*
|
joachim99@2
|
158
|
joachim99@2
|
159 EOF
|
joachim99@2
|
160 return;
|
joachim99@2
|
161 }
|