joachim99@2: #!/usr/bin/perl -w joachim99@2: joachim99@2: # this script patches a config.status file, to use our own perl script joachim99@2: # in the main loop joachim99@2: # we do it this way to circumvent hacking (and thereby including) joachim99@2: # autoconf function (which are GPL) into our LGPL acinclude.m4.in joachim99@2: # written by Michael Matz joachim99@2: # adapted by Dirk Mueller joachim99@2: joachim99@2: # we have to change two places joachim99@2: # 1. the splitting of the substitutions into chunks of 90 (or even 48 in joachim99@2: # later autoconf's joachim99@2: # 2. the big main loop which patches all Makefile.in's joachim99@2: use File::Basename; joachim99@2: joachim99@2: my $ac_aux_dir = dirname($0); joachim99@2: my ($flag); joachim99@2: local $ac_version = 0; joachim99@2: my $vpath_seen = 0; joachim99@2: $flag = 0; joachim99@2: joachim99@2: while (<>) { joachim99@2: # usage of $flag: 0 -- we have seen nothing yet joachim99@2: # 1 -- we are in (1) joachim99@2: # 2 -- we have ended (1) joachim99@2: # 3 -- we are in (2) joachim99@2: # 4 -- we ended (2) joachim99@2: joachim99@2: if ($flag == 4) { joachim99@2: print; joachim99@2: } elsif ($flag == 0) { joachim99@2: # 1. begins with (including): "ac_max_sed_\S+\s*=\s*[0-9]+..." joachim99@2: # ends with (excluding) "CONFIG_FILE=..." joachim99@2: # in later autoconf (2.14.1) there is no CONFIG_FILES= line, joachim99@2: # but instead the (2) directly follow (1) joachim99@2: if (/^\s*ac_max_sed_([a-z]+).*=\s*([0-9]+)/ ) { joachim99@2: $flag = 1; joachim99@2: if ($1 eq 'lines') { joachim99@2: # lets hope its different with 2141, joachim99@2: # wasn't able to verify that joachim99@2: if ($2 eq '48') { joachim99@2: $ac_version = 250; joachim99@2: } joachim99@2: else { joachim99@2: $ac_version = 2141; joachim99@2: } joachim99@2: } elsif ($1 eq 'cmds') { joachim99@2: $ac_version = 213; joachim99@2: } joachim99@2: # hmm, we don't know the autoconf version, but we try anyway joachim99@2: } else { joachim99@2: print; joachim99@2: } joachim99@2: } elsif ($flag == 1) { joachim99@2: if (/^\s*CONFIG_FILES=/ && ($ac_version != 250)) { joachim99@2: print; joachim99@2: $flag = 2; joachim99@2: } elsif (/^\s*for\s+ac_file\s+in\s+.*CONFIG_FILES/ ) { joachim99@2: $flag = 3; joachim99@2: } joachim99@2: } elsif ($flag == 2) { joachim99@2: # 2. begins with: "for ac_file in.*CONFIG_FILES" (the next 'for' after (1)) joachim99@2: # end with: "rm -f conftest.s\*" joachim99@2: # on autoconf 250, it ends with '# CONFIG_HEADER section' joachim99@2: if (/^\s*for\s+ac_file\s+in\s+.*CONFIG_FILES/ ) { joachim99@2: $flag = 3; joachim99@2: } else { joachim99@2: print; joachim99@2: } joachim99@2: } elsif ($flag == 3) { joachim99@2: if (/^\s*rm\s+-f\s+conftest/ ) { joachim99@2: $flag = 4; joachim99@2: &insert_main_loop(); joachim99@2: } elsif (/^\s*rm\s+-f\s+.*ac_cs_root/ ) { joachim99@2: $flag = 4; joachim99@2: &insert_main_loop(); joachim99@2: #die "hhhhhhh"; joachim99@2: if ($ac_version != 2141) { joachim99@2: print STDERR "hmm, don't know autoconf version\n"; joachim99@2: } joachim99@2: } elsif (/^\#\s*CONFIG_HEADER section.*/) { joachim99@2: $flag = 4; joachim99@2: &insert_main_loop(); joachim99@2: if($ac_version != 250) { joachim99@2: print STDERR "hmm, something went wrong :-(\n"; joachim99@2: } joachim99@2: } elsif (/VPATH/ ) { joachim99@2: $vpath_seen = 1; joachim99@2: } joachim99@2: } joachim99@2: } joachim99@2: joachim99@2: die "wrong input (flag != 4)" unless $flag == 4; joachim99@2: print STDERR "hmm, don't know autoconf version\n" unless $ac_version; joachim99@2: joachim99@2: sub insert_main_loop { joachim99@2: joachim99@2: if ($ac_version == 250) { joachim99@2: &insert_main_loop_250(); joachim99@2: } joachim99@2: else { joachim99@2: &insert_main_loop_213(); joachim99@2: } joachim99@2: } joachim99@2: joachim99@2: sub insert_main_loop_250 { joachim99@2: joachim99@2: print <>\$tmp/subs.sed joachim99@2: EOF joachim99@2: } joachim99@2: print <> \$tmp/subs.files joachim99@2: fi joachim99@2: done joachim99@2: if test -f \$tmp/subs.files ; then joachim99@2: perl $ac_aux_dir/config.pl "\$tmp/subs.sed" "\$tmp/subs.files" "\$srcdir" "\$INSTALL" joachim99@2: fi joachim99@2: rm -f \$tmp/subs.files joachim99@2: joachim99@2: fi joachim99@2: EOF joachim99@2: return; joachim99@2: } joachim99@2: joachim99@2: sub insert_main_loop_213 { joachim99@2: print <> \$ac_cs_root.subs joachim99@2: EOF joachim99@2: } joachim99@2: print <> \$ac_cs_root.sacfiles joachim99@2: fi joachim99@2: done joachim99@2: if test -f \$ac_cs_root.sacfiles ; then joachim99@2: perl $ac_aux_dir/config.pl "\$ac_cs_root.subs" "\$ac_cs_root.sacfiles" "\$ac_given_srcdir" "\$ac_given_INSTALL" joachim99@2: fi joachim99@2: rm -f \$ac_cs_root.s* joachim99@2: joachim99@2: EOF joachim99@2: return; joachim99@2: }