Shared admin folder
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

conf.change.pl 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. #!/usr/bin/env perl
  2. # this script patches a config.status file, to use our own perl script
  3. # in the main loop
  4. # we do it this way to circumvent hacking (and thereby including)
  5. # autoconf function (which are GPL) into our LGPL acinclude.m4.in
  6. # written by Michael Matz <matz@kde.org>
  7. # adapted by Dirk Mueller <mueller@kde.org>
  8. #
  9. # This file is free software; you can redistribute it and/or
  10. # modify it under the terms of the GNU Library General Public
  11. # License as published by the Free Software Foundation; either
  12. # version 2 of the License, or (at your option) any later version.
  13. # This library is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. # Library General Public License for more details.
  17. # You should have received a copy of the GNU Library General Public License
  18. # along with this library; see the file COPYING.LIB. If not, write to
  19. # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  20. # Boston, MA 02110-1301, USA.
  21. # we have to change two places
  22. # 1. the splitting of the substitutions into chunks of 90 (or even 48 in
  23. # later autoconf's
  24. # 2. the big main loop which patches all Makefile.in's
  25. use strict;
  26. use File::Basename;
  27. my $ac_aux_dir = dirname($0);
  28. my ($flag);
  29. my $ac_version = 0;
  30. my $vpath_seen = 0;
  31. $flag = 0;
  32. while (<>) {
  33. # usage of $flag: 0 -- we have seen nothing yet
  34. # 1 -- we are in (1)
  35. # 2 -- we have ended (1)
  36. # 3 -- we are in (2)
  37. # 4 -- we ended (2)
  38. if ($flag == 4) {
  39. print;
  40. } elsif ($flag == 0) {
  41. # 1. begins with (including): "ac_max_sed_\S+\s*=\s*[0-9]+..."
  42. # ends with (excluding) "CONFIG_FILE=..."
  43. # in later autoconf (2.14.1) there is no CONFIG_FILES= line,
  44. # but instead the (2) directly follow (1)
  45. if (/^\s*ac_max_sed_([a-z]+).*=\s*([0-9]+)/ ) {
  46. $flag = 1;
  47. if ($1 eq 'lines') {
  48. # lets hope its different with 2141,
  49. # wasn't able to verify that
  50. if ($2 eq '48') {
  51. $ac_version = 250;
  52. }
  53. else {
  54. $ac_version = 2141;
  55. }
  56. } elsif ($1 eq 'cmds') {
  57. $ac_version = 213;
  58. }
  59. # hmm, we don't know the autoconf version, but we try anyway
  60. } else {
  61. print;
  62. }
  63. } elsif ($flag == 1) {
  64. if (/^\s*CONFIG_FILES=/ && ($ac_version != 250)) {
  65. print;
  66. $flag = 2;
  67. } elsif (/^\s*for\s+ac_file\s+in\s+.*CONFIG_FILES/ ) {
  68. $flag = 3;
  69. }
  70. } elsif ($flag == 2) {
  71. # 2. begins with: "for ac_file in.*CONFIG_FILES" (the next 'for' after (1))
  72. # end with: "rm -f conftest.s\*"
  73. # on autoconf 250, it ends with '# CONFIG_HEADER section'
  74. #
  75. # gg: if a post-processing commands section is found first,
  76. # stop there and insert a new loop to honor the case/esac.
  77. # (pattern: /^\s+#\sRun the commands associated with the file./)
  78. if (/^\s*for\s+ac_file\s+in\s+.*CONFIG_FILES/ ) {
  79. $flag = 3;
  80. } else {
  81. print;
  82. }
  83. } elsif ($flag == 3) {
  84. if (/^\s*rm\s+-f\s+conftest/ ) {
  85. $flag = 4;
  86. &insert_main_loop();
  87. } elsif (/^\s*rm\s+-f\s+.*ac_cs_root/ ) {
  88. $flag = 4;
  89. &insert_main_loop();
  90. #die "hhhhhhh";
  91. if ($ac_version != 2141) {
  92. print STDERR "hmm, don't know autoconf version\n";
  93. }
  94. } elsif (/^\#\s*CONFIG_(HEADER|COMMANDS) section.*|^\s+#\s(Run) the commands associated/) {
  95. $flag = 4;
  96. my $commands = defined $2;
  97. &insert_main_loop();
  98. $commands && insert_command_loop();
  99. if($ac_version != 250) {
  100. print STDERR "hmm, something went wrong :-(\n";
  101. }
  102. } elsif (/VPATH/ ) {
  103. $vpath_seen = 1;
  104. }
  105. }
  106. }
  107. die "wrong input (flag != 4)" unless $flag == 4;
  108. print STDERR "hmm, don't know autoconf version\n" unless $ac_version;
  109. sub insert_main_loop {
  110. if ($ac_version == 250) {
  111. &insert_main_loop_250();
  112. }
  113. else {
  114. &insert_main_loop_213();
  115. }
  116. }
  117. sub insert_main_loop_250 {
  118. print <<EOF;
  119. #echo Doing the fast build of Makefiles -- autoconf $ac_version
  120. EOF
  121. if ($vpath_seen) {
  122. print <<EOF;
  123. # VPATH subst was seen in original config.status main loop
  124. echo '/^[ ]*VPATH[ ]*=[^:]*\$/d' >>\$tmp/subs.sed
  125. EOF
  126. }
  127. print <<EOF;
  128. rm -f \$tmp/subs.files
  129. for ac_file in .. \$CONFIG_FILES ; do
  130. if test "x\$ac_file" != x..; then
  131. echo \$ac_file >> \$tmp/subs.files
  132. fi
  133. done
  134. if test -f \$tmp/subs.files ; then
  135. perl $ac_aux_dir/config.pl "\$tmp/subs.sed" "\$tmp/subs.files" "\$srcdir" "\$INSTALL"
  136. fi
  137. rm -f \$tmp/subs.files
  138. fi
  139. EOF
  140. return;
  141. }
  142. sub insert_main_loop_213 {
  143. print <<EOF;
  144. #echo Doing the fast build of Makefiles -- autoconf $ac_version
  145. if test "x\$ac_cs_root" = "x" ; then
  146. ac_cs_root=conftest
  147. fi
  148. EOF
  149. if ($vpath_seen) {
  150. print <<EOF;
  151. # VPATH subst was seen in original config.status main loop
  152. echo '/^[ ]*VPATH[ ]*=[^:]*\$/d' >> \$ac_cs_root.subs
  153. EOF
  154. }
  155. print <<EOF;
  156. rm -f \$ac_cs_root.sacfiles
  157. for ac_file in .. \$CONFIG_FILES ; do
  158. if test "x\$ac_file" != x..; then
  159. echo \$ac_file >> \$ac_cs_root.sacfiles
  160. fi
  161. done
  162. if test -f \$ac_cs_root.sacfiles ; then
  163. perl $ac_aux_dir/config.pl "\$ac_cs_root.subs" "\$ac_cs_root.sacfiles" "\$ac_given_srcdir" "\$ac_given_INSTALL"
  164. fi
  165. rm -f \$ac_cs_root.s*
  166. EOF
  167. return;
  168. }
  169. sub insert_command_loop {
  170. print <<EOF;
  171. for ac_file in .. \$CONFIG_FILES ; do
  172. EOF
  173. }