Since this appears to have been eaten by apache's listserver, i'll resend...

-------- Original Message --------
Subject: Patch for building support programs
From: "Thom May" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>

Hi,
Building support programs currently is easy to break under most
conditions. If I change apachectl.in like so:
-HTTPD='@prefix@/bin/@progname@'
+HTTPD='@sbindir@/@progname@'
where sbindir is defined to configure as exec_prefix/sbin, the end result
after a configure run is that apachectl looks like:
HTTPD='${exec_prefix}/sbin/apache

which is fine for a Makefile, but not so useful for a perl script. As
part of the debian packages build, the configure script is patched so
that program generation is handled by a separate perl script,
build-progs.pl

I have attached the perl script as a patch for your review, and then
hopefully inclusion into the build process.
Cheers,
-Thom

--- apache2/build/buildprogs.pl.orig    Fri Aug 24 00:48:01 2001
+++ apache2/build/buildprogs.pl Fri Aug 24 00:47:22 2001
@@ -0,0 +1,114 @@
+#!/usr/bin/perl
+# Copyright (C) Thom May <[EMAIL PROTECTED]> 2001
+# Licensed under the BSD License, without the advertising clause. +#
Bugs - can't handle multiple replaces on one line, unless it's of the
form:
+# @ONE@/@TWO@
+# I have no idea what happens if it finds something it doesn't know
about...
+#
+
+my $buildir=`pwd`;
+chomp($buildir);
+die "Usage: $0 srcdir file1 [file2...]\n"
+       if ($#ARGV < 0);
+
+my $srcdir = shift(@ARGV);
+my $config_vars = "$srcdir/config_vars.mk";
+&read_config();
+
+while ($file = shift(@ARGV))
+{
+       if ($file =~ /^([^\.]*)\.in/){
+               $infile = $&;
+               $outfile = $1;
+       }
+       else
+       {
+               $outfile = $file;
+               $infile = "$file.in";
+       }
+       # now we read the file, substitute the necessary bits, and close the
file again.
+       # fortunately the "nice" way actually works!
+       $perlbin = `which perl`;
+       chomp($perlbin);
+       open(INFILE, "<$infile") || die "Couldn't open $infile - $!\n";
+       open(OUTFILE, ">$outfile") || die "Couldn't open $outfile for
writing - $!\n";
+       while(<INFILE>)
+       {
+               if(/\@([\w]*)\@(\/\@([\w]*)\@)?/g)
+               {
+                       if($3)
+                       {
+                               $replace1 = $$1;
+                               $replace2 = $$3;
+                               $replace1 = &replace($replace1);
+                               $replace2 = &replace($replace2);
+                               s/\@([\w]*)\@(\/\@([\w]*)\@)?/$replace1\/
$replace2/;
+                               print OUTFILE;
+                       }
+                       else
+                       {
+                               $replace1 = $$1;
+                               $replace1 = &replace($replace1);
+                               s/\@([\w]*)\@/$replace1/;
+                                print OUTFILE;
+                       }
+
+               } else
+               {
+                       print OUTFILE;
+               }
+       }
+       close(OUTFILE);
+       close(INFILE);
+}
+# read in config_vars.mk, grab the relevant bits, dump them to
variables. +sub read_config
+{
+       die "Couldn't find config variables!\n" if (! -f $config_vars);
+       open(CFG_VARS,"<$config_vars")||die "Couldn't open $config_vars, $!
\n";
+       my @configs = <CFG_VARS>;
+       close(CFG_VARS);
+       foreach(@configs) #read out the relevant bits of config_vars.mk
+       {
+               if(!/^#/ && !/^$/ && /=/)
+               {
+                       chomp();
+                       my ($lv,$rv) = split(/=/,$_,2);
+                       $lv = trim($lv);
+                       $rv = trim($rv);
+                       $_=$lv;
+                       $$lv=$rv;
+               }
+       # unfortunately we aren't going to know the prefix until some
arbitrary point
+       # thus we are going to have to rewrite the variables at write time.
+       #
this is pretty nasty :/
+       }
+       $exec_prefix=replace($exec_prefix);
+}
+
+sub replace
+{
+       $temp = $_[0];
+       if($temp =~ /^(\$\(exec_prefix\))\/(.*)/)
+       {
+               $temp = "$exec_prefix/$2";
+       }
+       else
+       {
+               if ($temp =~ /^(\$\(prefix\))\/(.*)/)
+                       {
+                               $temp = "$prefix/$2";
+                       }
+       }
+       $temp =~ s/\/\/(.*)/\/$1/gi;
+
+       $temp;
+}
+
+sub trim
+{
+       $_=$_[0];
+       s/^\040+//g;
+       s/\040+$//g;
+       $_;
+}



Reply via email to