You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Pier Fumagalli <pi...@betaversion.org> on 2002/04/27 18:47:29 UTC

[PATCH] apxs.in

This is (again) Thom's patch to make APXS work when we don't use standard
layouts, and we move things around after building...

It works great on Darwin, if someone could possibly check that out and
review, that would be absolutely fantastic...

    Pier

--
I think that it's extremely foolish to name a server after the current U.S.
President.                                                 B.W. Fitzpatrick



Re: [PATCH] apxs.in

Posted by Thom May <th...@planetarytramp.net>.
* Jeff Trawick (trawick@attglobal.net) wrote :
> Thom May <th...@planetarytramp.net> writes:
> 
> > * Jeff Trawick (trawick@attglobal.net) wrote :
> > > Why doesn't the code to move things around after building fix it up
> > > and not require the user to specify "-d my-server-root"?  That's what
> > > Apache's install-bindist.sh does.  I guess I'm confused about when the
> > > user would use the new -d option.
> > The major case is:
> > after we install, we then move the whole tree to a different location.
> > for the sake of argument, install into /usr/local/apache2
> > mv  /usr/local/apache2 /usr/local/ap2-test
> > at that point, we need -d.
> > (it's analogous to the -d option to httpd)
> 
> I would suggest that it is better to do the mv in a script that knows
> how to
> 
> 1) update the prefix encoded in apxs
> 2) update the path to the libraries in envvars
> 
> Is that impossible for some reason?  The install script for a binary
> build is able to do that.
> 

No, it's certainly not impossible, just an added imposition. having the
facility to just use apxs, in the same way that httpd just works, was to me
more valuable. 

> Your patch has some very necessary fixes but I can't seem to make
> peace with the -d, as it seems to be a burden and it doesn't seem to
> completely solve what happens when you mv the tree since it doesn't
> address the need for httpd to find libapr et al via the new path.
> 

OK, I've changed LD_LIBRARY_PATH to be @SHLIBPATH_VAR@ in apxs.in
I've also changed it so that envvars is sourced at the same time.
Cheers,
-Thom

-- 
Thom May -> thom@planetarytramp.net

Which is also probably true of most, if not all, of the people who are 
involved in Linux. We are not developing a system to take over the OS 
market, we are just having a good time. --Michael Kaufman


Index: support/apxs.in
===================================================================
RCS file: /home/cvspublic/httpd-2.0/support/apxs.in,v
retrieving revision 1.37
diff -u -u -r1.37 apxs.in
--- support/apxs.in	29 Apr 2002 18:09:02 -0000	1.37
+++ support/apxs.in	1 May 2002 13:48:14 -0000
@@ -58,36 +58,6 @@
 package apxs;
 
 ##
-##  Configuration
-##
-
-my $prefix         = "@prefix@";
-my $CFG_PREFIX     = $prefix;
-
-# read the configuration variables once
-my %config_vars = ();
-get_config_vars("$prefix/build/config_vars.mk",\%config_vars);
-
-my $exec_prefix    = get_vars("exec_prefix");
-my $CFG_TARGET     = get_vars("progname");
-my $CFG_SYSCONFDIR = get_vars("sysconfdir");
-my $CFG_CFLAGS     = join ' ', map { get_vars($_) }
-  qw(SHLTCFLAGS CFLAGS NOTEST_CPPFLAGS EXTRA_CPPFLAGS EXTRA_CFLAGS);
-my $includedir     = get_vars("includedir");
-my $CFG_INCLUDEDIR = eval qq("$includedir");
-my $CFG_CC         = get_vars("CC");
-my $libexecdir     = get_vars("libexecdir");
-my $CFG_LIBEXECDIR = eval qq("$libexecdir");
-my $sbindir        = get_vars("sbindir");
-my $CFG_SBINDIR    = eval qq("$sbindir");
-my $ltflags        = $ENV{'LTFLAGS'};
-$ltflags or $ltflags = "--silent";
-
-my %internal_vars = map {$_ => 1}
-    qw(TARGET CC CFLAGS CFLAGS_SHLIB LD_SHLIB LDFLAGS_SHLIB LIBS_SHLIB
-       PREFIX SBINDIR INCLUDEDIR LIBEXECDIR SYSCONFDIR);
-
-##
 ##  parse argument line
 ##
 
@@ -108,6 +78,7 @@
 my $opt_A = 0;
 my $opt_q = 0;
 my $opt_h = 0;
+my $opt_d = '';
 
 #   this subroutine is derived from Perl's getopts.pl with the enhancement of
 #   the "+" metacharacter at the format string to allow a list to be built by
@@ -174,19 +145,19 @@
 }
 
 sub usage {
-    print STDERR "Usage: apxs -g [-S <var>=<val>] -n <modname>\n";
-    print STDERR "       apxs -q [-S <var>=<val>] <query> ...\n";
-    print STDERR "       apxs -c [-S <var>=<val>] [-o <dsofile>] [-D <name>[=<value>]]\n";
+    print STDERR "Usage: apxs -g [-d <server-root>] [-S <var>=<val>] -n <modname>\n";
+    print STDERR "       apxs -q [-d <server-root>] [-S <var>=<val>] <query> ...\n";
+    print STDERR "       apxs -c [-d <server-root>] [-S <var>=<val>] [-o <dsofile>] [-D <name>[=<value>]]\n";
     print STDERR "               [-I <incdir>] [-L <libdir>] [-l <libname>] [-Wc,<flags>]\n";
     print STDERR "               [-Wl,<flags>] <files> ...\n";
-    print STDERR "       apxs -i [-S <var>=<val>] [-a] [-A] [-n <modname>] <dsofile> ...\n";
-    print STDERR "       apxs -e [-S <var>=<val>] [-a] [-A] [-n <modname>] <dsofile> ...\n";
+    print STDERR "       apxs -i [-d <server-root>] [-S <var>=<val>] [-a] [-A] [-n <modname>] <dsofile> ...\n";
+    print STDERR "       apxs -e [-d <server-root>]  [-S <var>=<val>] [-a] [-A] [-n <modname>] <dsofile> ...\n";
     exit(1);
 }
 
 #   option handling
 my $rc;
-($rc, @ARGV) = &Getopts("qn:gco:I+D+L+l+W+S+eiaA", @ARGV);
+($rc, @ARGV) = &Getopts("d:qn:gco:I+D+L+l+W+S+eiaA", @ARGV);
 &usage if ($rc == 0);
 &usage if ($#ARGV == -1 and not $opt_g);
 &usage if (not $opt_q and not ($opt_g and $opt_n) and not $opt_i and not $opt_c and not $opt_e);
@@ -217,10 +188,81 @@
     }
 }
 
+
+##
+##  Configuration
+##
+
+# read the configuration variables once
+my %config_vars = ();
+my $mode;
+my $working_dir;
+my $server_root;
+my $installbuilddir;
+
+my $temp_path = $0;
+    
+while (-l $temp_path) {
+    $temp_path = readlink $temp_path;
+}
+        
+if ($temp_path =~ /^(.*)\/apxs/){
+    $working_dir = $1;
+}
+
+if  ($opt_d ne ''){
+    $mode = "rel";
+    $server_root = $opt_d . "/";
+    $installbuilddir = $server_root . "@rel_installbuilddir@";
+}
+elsif ($working_dir eq '@exp_bindir@') {
+#if ($working_dir eq '@exp_bindir@') {
+    #we are in absolute mode
+    $installbuilddir = '@exp_installbuilddir@/';
+    $mode = "exp";
+    $server_root = '@prefix@' . "/";
+}
+elsif ($working_dir =~ /(.*)@rel_bindir@/) {
+    #we are working in relative mode. 
+    #we need to calculate what the server root is,
+    #and then use that as a base to work from
+    $server_root = $1;
+    $mode = "rel";
+    $installbuilddir = $server_root . "@rel_installbuilddir@";
+}
+else {
+    die "Can't calculate what the server root is. Please use -d\n";
+}
+
+get_config_vars("$installbuilddir/config_vars.mk",\%config_vars)||die "Can't open config_vars.mk, $!";
+	
+my $prefix         = $server_root;
+my $CFG_PREFIX     = $prefix;
+my $exec_prefix    = $server_root . get_vars("rel_exec_prefix");
+my $progname       = get_vars("progname");
+my $CFG_TARGET     = $progname;
+my $CFG_SYSCONFDIR = $server_root . get_vars("rel_sysconfdir");
+my $CFG_CFLAGS     = join ' ', map { get_vars($_) }
+  qw(SHLTCFLAGS CFLAGS NOTEST_CPPFLAGS EXTRA_CPPFLAGS EXTRA_CFLAGS);
+my $includedir     = $server_root . get_vars("rel_includedir");
+my $CFG_INCLUDEDIR = eval qq("$includedir");
+my $CFG_CC         = get_vars("CC");
+my $libexecdir     = $server_root . get_vars("rel_libexecdir");
+my $CFG_LIBEXECDIR = eval qq("$libexecdir");
+my $sbindir        = $server_root . get_vars("rel_sbindir");
+my $CFG_SBINDIR    = eval qq("$sbindir");
+my $libdir         = $server_root . get_vars("rel_libdir");
+my $ltflags        = $ENV{'LTFLAGS'};
+$ltflags or $ltflags = "--silent";
+
+my %internal_vars = map {$_ => 1}
+    qw(TARGET CC CFLAGS CFLAGS_SHLIB LD_SHLIB LDFLAGS_SHLIB LIBS_SHLIB
+       PREFIX SBINDIR INCLUDEDIR LIBEXECDIR SYSCONFDIR);
+
 ##
 ##  Initial shared object support check
 ##
-my $httpd = get_vars("sbindir") . "/" . get_vars("progname");
+my $httpd = $sbindir . "/" . $progname;
 $httpd = eval qq("$httpd");
 $httpd = eval qq("$httpd");
 my $envvars = get_vars("bindir") . "/envvars";
@@ -233,11 +275,18 @@
 }
 
 unless (-x "$httpd") {
-	error("$httpd not found or not executable");
-	exit 1;
+    error("$httpd not found or not executable");
+    exit 1;
+}
+
+if ($mode eq 'rel') {
+    $httpd = ". $envvars && @SHLIBPATH_VAR@=$libdir\:\$@SHLIBPATH_VAR@ && $httpd";
+}
+else {
+    $httpd = ". $envvars && $httpd";
 }
 
-unless (grep /mod_so/, `. $envvars && $httpd -l`) {
+unless (grep /mod_so/, `$httpd -l`) {
     error("Sorry, no shared object support for Apache");
     error("available under your platform. Make sure");
     error("the Apache module mod_so is compiled into");
@@ -324,6 +373,7 @@
     $data =~ s|%NAME%|$name|sg;
     $data =~ s|%TARGET%|$CFG_TARGET|sg;
     $data =~ s|%PREFIX%|$prefix|sg;
+    $data =~ s|%INSTBUILDDIR%|$installbuilddir|sg;
 
     my ($mkf, $mods, $src) = ($data =~ m|^(.+)-=#=-\n(.+)-=#=-\n(.+)|s);
 
@@ -418,7 +468,7 @@
         $la =~ s|\.c$|.la|;
         my $o = $s;
         $o =~ s|\.c$|.o|;
-        push(@cmds, "$prefix/build/libtool $ltflags --mode=compile $CFG_CC $cflags -I$CFG_INCLUDEDIR $opt -c -o $lo $s && touch $slo");
+        push(@cmds, "$installbuilddir/libtool $ltflags --mode=compile $CFG_CC $cflags -I$CFG_INCLUDEDIR $opt -c -o $lo $s && touch $slo");
         unshift(@objs, $lo);
     }
 
@@ -443,7 +493,7 @@
         $opt .= " -l$opt_l";
     }
 
-    push(@cmds, "$prefix/build/libtool $ltflags --mode=link $CFG_CC -o $dso_file -rpath $CFG_LIBEXECDIR -module -avoid-version $opt $lo");
+    push(@cmds, "$installbuilddir/libtool $ltflags --mode=link $CFG_CC -o $dso_file -rpath $CFG_LIBEXECDIR -module -avoid-version $opt $lo");
 
     #   execute the commands
     &execute_cmds(@cmds);
@@ -474,8 +524,8 @@
         $t =~ s|^.+/([^/]+)$|$1|;
         $t =~ s|\.la$|\.so|;
         if ($opt_i) {
-	    push(@cmds, "$prefix/build/instdso.sh SH_LIBTOOL='" .
-                 "$prefix/build/libtool' $f $CFG_LIBEXECDIR");
+	    push(@cmds, "$installbuilddir/instdso.sh SH_LIBTOOL='" .
+                 "$installbuilddir/libtool' $f $CFG_LIBEXECDIR");
 	    push(@cmds, "chmod 755 $CFG_LIBEXECDIR/$t");
         }
 
@@ -592,7 +642,7 @@
 builddir=$(shell pwd)
 top_srcdir=%PREFIX%
 top_builddir=%PREFIX%
-include %PREFIX%/build/special.mk
+include %INSTBUILDDIR%/special.mk
 
 #   the used tools
 APXS=apxs

Re: [PATCH] apxs.in

Posted by Jeff Trawick <tr...@attglobal.net>.
Thom May <th...@planetarytramp.net> writes:

> * Jeff Trawick (trawick@attglobal.net) wrote :
> > Why doesn't the code to move things around after building fix it up
> > and not require the user to specify "-d my-server-root"?  That's what
> > Apache's install-bindist.sh does.  I guess I'm confused about when the
> > user would use the new -d option.
> The major case is:
> after we install, we then move the whole tree to a different location.
> for the sake of argument, install into /usr/local/apache2
> mv  /usr/local/apache2 /usr/local/ap2-test
> at that point, we need -d.
> (it's analogous to the -d option to httpd)

I would suggest that it is better to do the mv in a script that knows
how to

1) update the prefix encoded in apxs
2) update the path to the libraries in envvars

Is that impossible for some reason?  The install script for a binary
build is able to do that.

Your patch has some very necessary fixes but I can't seem to make
peace with the -d, as it seems to be a burden and it doesn't seem to
completely solve what happens when you mv the tree since it doesn't
address the need for httpd to find libapr et al via the new path.

-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

Re: [PATCH] apxs.in

Posted by Thom May <th...@planetarytramp.net>.
* Jeff Trawick (trawick@attglobal.net) wrote :
> Thom May <th...@planetarytramp.net> writes:
> 
> > * Jeff Trawick (trawick@attglobal.net) wrote :
> > > Pier Fumagalli <pi...@betaversion.org> writes:
> > > 
> > > > This is (again) Thom's patch to make APXS work when we don't use standard
> > > > layouts, and we move things around after building...
> 
> Why doesn't the code to move things around after building fix it up
> and not require the user to specify "-d my-server-root"?  That's what
> Apache's install-bindist.sh does.  I guess I'm confused about when the
> user would use the new -d option.
The major case is:
after we install, we then move the whole tree to a different location.
for the sake of argument, install into /usr/local/apache2
mv  /usr/local/apache2 /usr/local/ap2-test
at that point, we need -d.
(it's analogous to the -d option to httpd)
-Thom

Re: [PATCH] apxs.in

Posted by Jeff Trawick <tr...@attglobal.net>.
Thom May <th...@planetarytramp.net> writes:

> * Jeff Trawick (trawick@attglobal.net) wrote :
> > Pier Fumagalli <pi...@betaversion.org> writes:
> > 
> > > This is (again) Thom's patch to make APXS work when we don't use standard
> > > layouts, and we move things around after building...

Why doesn't the code to move things around after building fix it up
and not require the user to specify "-d my-server-root"?  That's what
Apache's install-bindist.sh does.  I guess I'm confused about when the
user would use the new -d option.

> Index: apxs.in
> ===================================================================
> RCS file: /home/cvspublic/httpd-2.0/support/apxs.in,v
> retrieving revision 1.36
> diff -u -u -r1.36 apxs.in
> --- apxs.in	13 Mar 2002 20:48:05 -0000	1.36
> +++ apxs.in	29 Apr 2002 17:38:43 -0000

> @@ -217,10 +188,81 @@
>      }
>  }
>  
> +
> +##
> +##  Configuration
> +##
> +
> +# read the configuration variables once
> +my %config_vars = ();
> +my $mode;
> +my $working_dir;
> +my $server_root;
> +my $installbuilddir;
> +
> +my $temp_path = $0;
> +    
> +while (-l $temp_path) {
> +    $temp_path = readlink $temp_path;
> +}
> +        
> +if ($temp_path =~ /^(.*)\/apxs/){
> +    $working_dir = $1;
> +}
> +
> +if  ($opt_d ne ''){
> +    $mode = "rel";
> +    $server_root = $opt_d . "/";
> +    $installbuilddir = $server_root . "@rel_installbuilddir@";
> +}
> +elsif ($working_dir eq '@exp_bindir@') {
> +#if ($working_dir eq '@exp_bindir@') {

oops

> @@ -234,6 +276,10 @@
>  	exit 1;
>  }
>  
> +if ($mode eq 'rel') {
> +    $httpd = "LD_LIBRARY_PATH=$libdir $httpd";
> +}

like I mentioned before, this doesn't work everywhere... envvars has
the right stuff, and I just committed a change to source envvars before
running httpd; I hope envvars has been tweaked in whatever environment
corresponds to $mode == 'rel'

--/--

I'm out of time for today unfortunately.
-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

Re: [PATCH] apxs.in

Posted by Thom May <th...@planetarytramp.net>.
* Jeff Trawick (trawick@attglobal.net) wrote :
> Pier Fumagalli <pi...@betaversion.org> writes:
> 
> > This is (again) Thom's patch to make APXS work when we don't use standard
> > layouts, and we move things around after building...
> 
> a few comments/questions:
> 
> 1) application/octet-stream attachments are a pain
> 
> 2) why no spaces around '.' and '='?
> 
> 3) I think this line
> 
>    print STDERR "       apxs -d -c [-S <var>=<val>] [-o <dsofile>] [-D <name>[=<value>]]\n";
> 
>    was supposed to be
> 
>    print STDERR "       apxs -d <server-root> -c [-S <var>=<val>] [-o <dsofile>] [-D <name>[=<value>]]\n";
> 
> 4) -d <server-root> is optional everywhere, not required, as far as I
>     can tell; syntax should show [-d <server-root>] 
> 
> 5) I think it is better to have the -d syntax shown *after* the major
>    option (e.g., '-d', '-q', '-c') in the usage message
> 

Hopefully this new patch takes care of your concerns.
-- 
Thom May -> thom@planetarytramp.net

* liiwi starts planning breakfast
<aj> "And then, squadron A will attempt to extract the cereal from quadrant 34,
     while teams F and Q ensure the lactic fluid remains chilled and readily 
     available..."


Re: [PATCH] apxs.in

Posted by Pier Fumagalli <pi...@betaversion.org>.
"Jeff Trawick" <tr...@attglobal.net> wrote:

> Pier Fumagalli <pi...@betaversion.org> writes:
> 
>> This is (again) Thom's patch to make APXS work when we don't use standard
>> layouts, and we move things around after building...
> 
> a few comments/questions:
> 
> 1) application/octet-stream attachments are a pain

I'll try to figure out how to deal with those kind of attachments under
OS/X. 

    Pier

--
I think that it's extremely foolish to name a server after the current U.S.
President.                                                 B.W. Fitzpatrick



Re: [PATCH] apxs.in

Posted by Jeff Trawick <tr...@attglobal.net>.
Pier Fumagalli <pi...@betaversion.org> writes:

> This is (again) Thom's patch to make APXS work when we don't use standard
> layouts, and we move things around after building...

a few comments/questions:

1) application/octet-stream attachments are a pain

2) why no spaces around '.' and '='?

3) I think this line

   print STDERR "       apxs -d -c [-S <var>=<val>] [-o <dsofile>] [-D <name>[=<value>]]\n";

   was supposed to be

   print STDERR "       apxs -d <server-root> -c [-S <var>=<val>] [-o <dsofile>] [-D <name>[=<value>]]\n";

4) -d <server-root> is optional everywhere, not required, as far as I
    can tell; syntax should show [-d <server-root>] 

5) I think it is better to have the -d syntax shown *after* the major
   option (e.g., '-d', '-q', '-c') in the usage message

-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...