You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-dev@httpd.apache.org by Bojan Smojver <bo...@rexursive.com> on 2003/10/03 05:07:33 UTC

[PATCH]: Enable static build of APREQ 2

Here we go, the first crack at it. This patch should enable
installing/uninstalling of all relevant files from libapreq2 into modules/apreq
in Apache 2 source tree.

To use this feature, one would configure libapreq2 like this:

./configure --with-apache2=/path/to/apache2/source/directory [--disable-shared]
make
make install

The, from Apache 2 source tree, one would run:

./buildconf
./config.nice
make
make install

After that, mod_apreq should automagically appear in the list of modules that
are statically linked into Apache 2. You *HAVE TO* configure, make and make
install vanilla Apache2 for this to work, of course.

You can, of course, disable mod_apreq, by running:

./configure --disable-apreq

from Apache 2 source directory.

-- 
Bojan

Re: [PATCH]: Enable static build of APREQ 2

Posted by Bojan Smojver <bo...@rexursive.com>.
Sounds pretty cool to me :-)

On Mon, 2003-10-06 at 14:38, Joe Schaefer wrote:
> Bojan Smojver <bo...@rexursive.com> writes:
> 
> > On Mon, 2003-10-06 at 11:47, Joe Schaefer wrote:
> 
> [...]
> 
> > > Another possibility is to do something clever with httpd's 
> > > --with-module=... option, but I'm not smart enough to get a full
> > > compile out of it.
> > 
> > Not sure about this. Never used it.
> 
> Ok, I just got httpd to compile with this:
> 
>   % CPPFLAGS=-I/path/to/httpd-apreq-2/src \
>     HTTPD_LDFLAGS=/path/to/httpd-apreq-2/src/libapreq.la \
>     ./configure --with-module=filters:../httpd-apreq-2/env/mod_apreq.c
>   % make
> 
> What this winds up doing is copying ../httpd-apreq-2/env/mod_apreq.c 
> into modules/filters and compiling it as if it were a normal module.  
> When it comes time to compile httpd, libapreq.la must already have 
> been built, but our current Makefiles make that a bit tricky to pull 
> off without a functional apxs.  However, since libapreq is purely ap[ru]-
> dependent, we shouldn't need apxs to build it- just ap[ru]-config.
-- 
Bojan


Re: [PATCH]: Enable static build of APREQ 2

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
The first use I considered for apreq was mod_autoindex.  That module
accepts several query args to determine how to format and filter a file
listing.

It might be interesting if someone had an hour or few to demonstrate
a patch for autoindex that would accept both GET queryargs or POST
variables to the module.  That would probably sway many httpd'ers to
consider this module and all it can accomplish.

See http://httpd.apache.org/docs-2.0/mod/mod_autoindex.html#query
for an example of what I'm describing.

Bill

At 11:57 AM 10/7/2003, Joe Schaefer wrote:
>Bojan Smojver <bo...@rexursive.com> writes:
>
>> Never asked before... What's the position of Apache folks on
>> including mod_apreq in Apache 2 as a standard module?
>
>When we asked on dev@ about a year ago, William Rowe was the only
>httpd committer that said it was a good idea.  He's probably the best
>person to address this question to (not sure if he follows apreq-dev
>anymore though).
>
>-- 
>Joe Schaefer



Re: [PATCH]: Enable static build of APREQ 2

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Bojan Smojver <bo...@rexursive.com> writes:

> Never asked before... What's the position of Apache folks on
> including mod_apreq in Apache 2 as a standard module?

When we asked on dev@ about a year ago, William Rowe was the only
httpd committer that said it was a good idea.  He's probably the best
person to address this question to (not sure if he follows apreq-dev
anymore though).

-- 
Joe Schaefer


Re: [PATCH]: Enable static build of APREQ 2

Posted by Bojan Smojver <bo...@rexursive.com>.
Never asked before... What's the position of Apache folks on including
mod_apreq in Apache 2 as a standard module?

-- 
Bojan


Re: [PATCH]: Enable static build of APREQ 2

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Joe Schaefer <jo...@sunstarsys.com> writes:

[...]

> Ok, I just got httpd to compile with this:
> 
>   % CPPFLAGS=-I/path/to/httpd-apreq-2/src \
>     HTTPD_LDFLAGS=/path/to/httpd-apreq-2/src/libapreq.la \
>     ./configure --with-module=filters:../httpd-apreq-2/env/mod_apreq.c
>   % make

Here's a PATCH against current cvs that carries this out.
It's based on Bojan's patch, but it has several practical
advantages:

  1) does not require a preinstallation of httpd,
  2) does not require mod_so (except to run the env/c-modules tests),
  3) does not require a rerun of httpd's buildconf.

One remaining problem it has is to get the env/ tests to work
from an httpd source directory.  I took a naive stab at it by
passing "-httpd=..." to Apache::Test, but that's not doing the trick.
If we manage to get this to work, users would be able to build
everything (apr,httpd,apreq,modperl too?) and test it all out before 
installing *anything*.

Here's the patch-  I'd like to commit something along these lines
in short order.

TIA.

Index: INSTALL
===================================================================
RCS file: /home/cvs/httpd-apreq-2/INSTALL,v
retrieving revision 1.6
diff -u -r1.6 INSTALL
--- INSTALL	23 Jul 2003 05:07:11 -0000	1.6
+++ INSTALL	7 Oct 2003 19:48:21 -0000
@@ -50,3 +50,26 @@
   C:\httpd-apreq-2> nmake mod_apreq
   C:\httpd-apreq-2> nmake perl_glue
   C:\httpd-apreq-2> nmake perl_test
+
+
+
+TO COMPILE mod_apreq.c AS A STATIC MODULE:
+
+First configure httpd to add mod_apreq.c to its filter modules:
+
+  % cd /path/to/httpd-2.0
+  % CPPFLAGS=-I/path/to/httpd-apreq-2/src \
+    HTTPD_LDFLAGS=/path/to/httpd-apreq-2/src/libapreq.la \
+    ./configure --with-module=filters:/path/to/httpd-apreq-2/env/mod_apreq.c \
+    ...(add usual httpd+apr options here)...
+
+then compile and install everything using httpd-apreq-2's build system:
+
+            % cd /path/to/httpd-apreq-2
+            % ./configure --with-apache2-src=/path/to/httpd-2.0
+            % make
+  (optional)% make test
+            % make httpd_install
+            % make install
+
+
Index: Makefile.am
===================================================================
RCS file: /home/cvs/httpd-apreq-2/Makefile.am,v
retrieving revision 1.12
diff -u -r1.12 Makefile.am
--- Makefile.am	2 Oct 2003 01:50:45 -0000	1.12
+++ Makefile.am	7 Oct 2003 19:48:21 -0000
@@ -1,10 +1,10 @@
 AUTOMAKE_OPTIONS = foreign
 SUBDIRS = src env t
 EXTRA_DIST = INSTALL
-APUDIR=`@APU_CONFIG@ --srcdir`
-APRDIR=`@APR_CONFIG@ --srcdir`
-APUDOX = (cd $(APUDIR); cat - docs/doxygen.conf | doxygen -)
-APRDOX = (cd $(APRDIR); cat - docs/doxygen.conf | doxygen -)
+APU_SRCDIR=`@APU_CONFIG@ --srcdir`
+APR_SRCDIR=`@APR_CONFIG@ --srcdir`
+APU_DOX = (cd $(APU_SRCDIR); cat - docs/doxygen.conf | doxygen -)
+APR_DOX = (cd $(APR_SRCDIR); cat - docs/doxygen.conf | doxygen -)
 COOKIE_POD=glue/perl/blib/lib/Apache/Cookie.pod
 REQUEST_POD=glue/perl/blib/lib/Apache/Request.pod
 
@@ -20,8 +20,8 @@
 
 apr_tags: 
 	-mkdir docs
-	echo GENERATE_TAGFILE=`pwd`/docs/apu.tag | $(APUDOX)
-	echo GENERATE_TAGFILE=`pwd`/docs/apr.tag | $(APRDOX)
+	echo GENERATE_TAGFILE=`pwd`/docs/apu.tag | $(APU_DOX)
+	echo GENERATE_TAGFILE=`pwd`/docs/apr.tag | $(APR_DOX)
 
 test: lib_test env_test
 
@@ -41,3 +41,10 @@
 	cd glue/perl; @PERL@ ../../build/xsbuilder.pl run
 	cd glue/perl; @PERL@ Makefile.PL -apxs @APACHE2_APXS@
 	cd glue/perl; make
+
+if BUILD_HTTPD
+
+httpd_install:
+	cd @APACHE2_SRC@; make install
+
+endif
Index: acinclude.m4
===================================================================
RCS file: /home/cvs/httpd-apreq-2/acinclude.m4,v
retrieving revision 1.8
diff -u -r1.8 acinclude.m4
--- acinclude.m4	2 Oct 2003 02:21:55 -0000	1.8
+++ acinclude.m4	7 Oct 2003 19:48:22 -0000
@@ -1,31 +1,71 @@
 AC_DEFUN(AC_APREQ, [
 	AC_ARG_WITH(apache2-apxs,
-		[  --with-apache2-apxs  path to apache2's apxs],
+		AC_HELP_STRING([--with-apache2-apxs],[path to apache2's apxs]),
 		[APACHE2_APXS=$withval],
-		[APACHE2_APXS="/usr/local/apache2/bin/apxs"])
+		[APACHE2_APXS="apxs"])
+	AC_ARG_WITH(apache2-src,
+        	AC_HELP_STRING([--with-apache2-src],[path to httpd-2 source]),
+		[APACHE2_SRC=$withval],
+		[APACHE2_SRC=""])
 	AC_ARG_WITH(perl,
-		[  --with-perl  path to perl executable],
+		AC_HELP_STRING([--with-perl],[path to perl executable]),
 		[PERL=$withval],
 		[PERL="perl"])
-        APU_CONFIG=`$APACHE2_APXS -q APU_BINDIR`/apu-config
-        APR_CONFIG=`$APACHE2_APXS -q APR_BINDIR`/apr-config
-	APACHE2_INCLUDES=`$APACHE2_APXS -q INCLUDEDIR`
-        APACHE2_MODULES=`$APACHE2_APXS -q LIBEXECDIR`
-        APACHE2_LIBS=`$APACHE2_APXS -q LIBDIR`
+
+        AM_CONDITIONAL(BUILD_HTTPD, test -n "$APACHE2_SRC")
+
+        if test -n "$APACHE2_SRC"; then
+                APACHE2_SRC=`cd $APACHE2_SRC;pwd`
+                APACHE2_INCLUDES=$APACHE2_SRC/include
+                APACHE2_HTTPD=$APACHE2_SRC/httpd
+                AC_ARG_WITH(apr-config,
+                    AC_HELP_STRING([--with-apr-config],[path to apr-config (requires --with-apache2-src)]),
+                    [APR_CONFIG=$withval],
+                    [APR_CONFIG="$APACHE2_SRC/srclib/apr/apr-config"])
+                AC_ARG_WITH(apu-config,
+                    AC_HELP_STRING([--with-apu-config],[path to apu-config (requires --with-apache2-src)]),
+                    [APU_CONFIG=$withval],
+                    [APU_CONFIG="$APACHE2_SRC/srclib/apr-util/apu-config"])
+
+        else
+                APACHE2_INCLUDES=`$APACHE2_APXS -q INCLUDEDIR`
+                APACHE2_HTTPD=`$APACHE2_APXS -q BINDIR`/httpd
+                APR_CONFIG=`$APACHE2_APXS -q APR_BINDIR`/apr-config
+                APU_CONFIG=`$APACHE2_APXS -q APU_BINDIR`/apu-config
+ 
+        fi
+
+        AC_CHECK_FILE([$APACHE2_INCLUDES/httpd.h],,
+                AC_MSG_ERROR([invalid Apache2 include directory]))
+        AC_CHECK_FILE([$APR_CONFIG],,
+                AC_MSG_ERROR([invalid apr-config location- perhaps you need to configure apr first?]))
+        AC_CHECK_FILE([$APU_CONFIG],,
+                AC_MSG_ERROR([invalid apu-config location- perhaps you need to configure apr-util first?]))
+
+        AM_CONDITIONAL(BUILD_APR, test "x$APR_CONFIG" = x`$APR_CONFIG --srcdir`/apr-config)
+        AM_CONDITIONAL(BUILD_APU, test "x$APU_CONFIG" = x`$APU_CONFIG --srcdir`/apu-config)
+
+        dnl Reset the default installation prefix to be the same as apu's
+        ac_default_prefix=`$APU_CONFIG --prefix`
+        
         APR_INCLUDES=`$APR_CONFIG --includedir`
         APU_INCLUDES=`$APU_CONFIG --includedir`
-        APR_LIBS=`$APR_CONFIG --link-ld --link-libtool`
-        APU_LIBS=`$APU_CONFIG --link-ld --link-libtool`
-        AC_SUBST(APU_CONFIG)
-        AC_SUBST(APR_CONFIG)
+        APR_LIBS=`$APR_CONFIG --link-libtool --libs`
+        APU_LIBS=`$APU_CONFIG --link-libtool --libs`
+        APR_LA=`$APR_CONFIG --link-libtool`
+        APU_LA=`$APU_CONFIG --link-libtool`
         AC_SUBST(APACHE2_APXS)
+        AC_SUBST(APACHE2_SRC)
 	AC_SUBST(APACHE2_INCLUDES)
-        AC_SUBST(APACHE2_MODULES)
-        AC_SUBST(APACHE2_LIBS)
+        AC_SUBST(APACHE2_HTTPD)
+        AC_SUBST(APU_CONFIG)
+        AC_SUBST(APR_CONFIG)
         AC_SUBST(APR_INCLUDES)
         AC_SUBST(APU_INCLUDES)
         AC_SUBST(APR_LIBS)
         AC_SUBST(APU_LIBS)
+        AC_SUBST(APR_LA)
+        AC_SUBST(APU_LA)
         AC_SUBST(PERL)
 ])
 
@@ -50,4 +90,3 @@
     done
   fi
 ])
-
Index: env/Makefile.am
===================================================================
RCS file: /home/cvs/httpd-apreq-2/env/Makefile.am,v
retrieving revision 1.11
diff -u -r1.11 Makefile.am
--- env/Makefile.am	2 Oct 2003 02:21:55 -0000	1.11
+++ env/Makefile.am	7 Oct 2003 19:48:22 -0000
@@ -1,25 +1,42 @@
 INCLUDES = -I../src -I@APACHE2_INCLUDES@ -I@APR_INCLUDES@ -I@APU_INCLUDES@
-LIBS = @APR_LIBS@ @APU_LIBS@
+LIBS = ../src/libapreq.la @APR_LIBS@ @APU_LIBS@
 TEST_CONFIG_SCRIPT = package Apache::TestMM; filter_args(); generate_script("t/TEST")
 
 lib_LIBRARIES = libapreq_cgi.a
-noinst_LTLIBRARIES = mod_apreq.la
+libapreq_cgi_a_SOURCES = libapreq_cgi.c
 
-mod_apreq_la_SOURCES = mod_apreq.c
-mod_apreq_la_LDFLAGS = -export-dynamic -module -avoid-version -rpath @APACHE2_MODULES@
-mod_apreq_la_LIBADD = ../src/libapreq.la
+if BUILD_APACHE
 
-libapreq_cgi_a_SOURCES = libapreq_cgi.c
-libapreq_cgi_a_LIBADD = ../src/libapreq.la
+# mod_apreq.c needs to be built from httpd-2.X, e.g.
+#
+# % cd ../httpd-2.X;
+# % ./configure --with-module=filters:../httpd-apreq-2/env/mod_apreq.c ...
+#
+# See the INSTALL file for details.
 
-libdir = @APACHE2_LIBS@
-includedir = @APACHE2_INCLUDES@
+@APACHE2_HTTPD@:
+	cd @APACHE2_SRC@ && make
+
+all-local: @APACHE2_HTTPD@
+
+t/TEST : Makefile.am
+	@PERL@ -MApache::TestMM -e '$(TEST_CONFIG_SCRIPT)' -- -httpd @APACHE2_HTTPD@
+
+else
+
+APACHE2_MODULES=`@APACHE2_APXS@ -q LIBEXECDIR`
+
+noinst_LTLIBRARIES = mod_apreq.la
+mod_apreq_la_SOURCES = mod_apreq.c
+mod_apreq_la_LDFLAGS = -export-dynamic -module -avoid-version -rpath $(APACHE2_MODULES)
 
 install-exec-local: mod_apreq.la
 	@APACHE2_APXS@ -i -a -n apreq mod_apreq.la
 
 t/TEST : Makefile.am
 	@PERL@ -MApache::TestMM -e '$(TEST_CONFIG_SCRIPT)' -- -apxs @APACHE2_APXS@
+
+endif
 
 run_tests : t/TEST
 	@PERL@ t/TEST
Index: src/Makefile.am
===================================================================
RCS file: /home/cvs/httpd-apreq-2/src/Makefile.am,v
retrieving revision 1.10
diff -u -r1.10 Makefile.am
--- src/Makefile.am	2 Oct 2003 02:21:55 -0000	1.10
+++ src/Makefile.am	7 Oct 2003 19:48:22 -0000
@@ -1,12 +1,23 @@
 INCLUDES = -I@APR_INCLUDES@ -I@APU_INCLUDES@
 LIBS = @APR_LIBS@ @APU_LIBS@
-
 lib_LTLIBRARIES = libapreq.la
 nobase_include_HEADERS = apreq.h apreq_cookie.h apreq_params.h \
                          apreq_env.h apreq_parsers.h
+libapreq_la_LDFLAGS = -version-info 2:0 
+
+BUILT_SOURCES= @APR_LA@ @APU_LA@
 libapreq_la_SOURCES = apreq.c apreq_cookie.c \
                       apreq_params.c apreq_parsers.c
-libapreq_la_LDFLAGS = -version-info 2:0 
+if BUILD_APR
+
+@APR_LA@:
+	cd `@APR_CONFIG@ --srcdir` && make
+
+endif
+
+if BUILD_APU
+
+@APU_LA@: @APR_LA@
+	cd `@APU_CONFIG@ --srcdir` && make
 
-libdir=@APACHE2_LIBS@
-includedir=@APACHE2_INCLUDES@
+endif
cvs server: Diffing t
Index: t/Makefile.am
===================================================================
RCS file: /home/cvs/httpd-apreq-2/t/Makefile.am,v
retrieving revision 1.11
diff -u -r1.11 Makefile.am
--- t/Makefile.am	2 Oct 2003 02:21:55 -0000	1.11
+++ t/Makefile.am	7 Oct 2003 19:48:22 -0000
@@ -1,13 +1,11 @@
 INCLUDES = -I../src -I@APR_INCLUDES@ -I@APU_INCLUDES@
-LIBS = -L../src @APR_LIBS@ @APU_LIBS@
+LIBS = ../src/libapreq.la @APR_LIBS@ @APU_LIBS@
 
 noinst_LIBRARIES = libapreq_tests.a
 libapreq_tests_a_SOURCES = CuTest.c env.c cookie.c params.c parsers.c
-libapreq_tests_a_LIBADD = ../src/libapreq.la
 
 check_PROGRAMS = testall
-testall_LDADD =  libapreq_tests.a
-testall_LINK = @APACHE2_APXS@ -c -p -L../src -lapreq -o testall
+testall_LDADD  = libapreq_tests.a
 
 test:	check
 	./testall -v
cvs server: Diffing win32


Re: [PATCH]: Enable static build of APREQ 2

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Bojan Smojver <bo...@rexursive.com> writes:

> On Mon, 2003-10-06 at 11:47, Joe Schaefer wrote:

[...]

> > Another possibility is to do something clever with httpd's 
> > --with-module=... option, but I'm not smart enough to get a full
> > compile out of it.
> 
> Not sure about this. Never used it.

Ok, I just got httpd to compile with this:

  % CPPFLAGS=-I/path/to/httpd-apreq-2/src \
    HTTPD_LDFLAGS=/path/to/httpd-apreq-2/src/libapreq.la \
    ./configure --with-module=filters:../httpd-apreq-2/env/mod_apreq.c
  % make

What this winds up doing is copying ../httpd-apreq-2/env/mod_apreq.c 
into modules/filters and compiling it as if it were a normal module.  
When it comes time to compile httpd, libapreq.la must already have 
been built, but our current Makefiles make that a bit tricky to pull 
off without a functional apxs.  However, since libapreq is purely ap[ru]-
dependent, we shouldn't need apxs to build it- just ap[ru]-config.

-- 
Joe Schaefer


Re: [PATCH]: Enable static build of APREQ 2

Posted by Bojan Smojver <bo...@rexursive.com>.
On Mon, 2003-10-06 at 11:47, Joe Schaefer wrote:

> Looks great so far!  I haven't tried running it yet, but I'm wondering
> about the apxs dependence in the patch.  Doesn't apxs depend on mod_so
> being installed?  Does the preinstalled httpd need to have a working apxs?  

Not sure and yes. This can, of course, be avoided by having more options
given to the configure script about where the relevant directories are.
I just thought that there aren't many people without APXS out there.

> If not, where should/does libapreq.so wind up after installation?

Well, since APXS has to be there, if it isn't found, nothing happens at
all (i.e. configure fails). If you don't specify --disable-shared,
libapreq.so will end up in the library directory of Apache 2 and it'll
be most likely used to link against when httpd is build, rather than
libapreq.a (gcc normally prefers shared libs). Don't see any harm in
that.

> Also, since we can get the apache srcdir from `apxs -q abs_srcdir`, if
> we're going to require a working apxs, maybe we should just do something
> with "--with-apache2-apxs=... --disable-shared" instead of adding
> another configure option (and distinguish between shared/static libapreq
> and shared/static mod_apreq).

That's a possibility as well. I actually did the --with-apache2 on
purpose - it enables static linking by explicitly setting the root of
the source tree of Apache. But that is not the only way to go about it.

> Another possibility is to do something clever with httpd's 
> --with-module=... option, but I'm not smart enough to get a full
> compile out of it.

Not sure about this. Never used it.

> Maybe a small step in this direction would 
> be to move httpd-apreq-2/src/* over to httpd-2.0/srclib/apreq
> and figure out how to get *that* to compile libapreq.

That's not difficult to do. All you need to do is fiddle with config.m4
file from the patch and specify which files are dependencies of
mod_apreq.so (looking at one of Apache supplied config.m4 files is an
excellent start). Then Apache build system does the rest. With Apache,
there is more than one way to skin the cat ;-)

> If I'm jumping the gun by asking such questions before trying the
> patch, just holler.

Nah, it's better that you include something you like than nothing at
all. For all it matters, you could just have a config.m4 file, Apache's
Makefile.in and then a few sentences in README on how it's done (i.e.
copy files X, Y, Z to Apache source tree, run ./buildconf etc.)

-- 
Bojan


Re: [PATCH]: Enable static build of APREQ 2

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Bojan Smojver <bo...@rexursive.com> writes:

[...]

> To use this feature, one would configure libapreq2 like this:
> 
> ./configure --with-apache2=/path/to/apache2/source/directory
> [--disable-shared] 
> make
> make install
> 
> The, from Apache 2 source tree, one would run:
> 
> ./buildconf
> ./config.nice
> make
> make install
> 
> After that, mod_apreq should automagically appear in the list of
> modules that are statically linked into Apache 2. You *HAVE TO*
> configure, make and make install vanilla Apache2 for this to work,
> of course. 

Looks great so far!  I haven't tried running it yet, but I'm wondering
about the apxs dependence in the patch.  Doesn't apxs depend on mod_so
being installed?  Does the preinstalled httpd need to have a working apxs?  
If not, where should/does libapreq.so wind up after installation?

Also, since we can get the apache srcdir from `apxs -q abs_srcdir`, if
we're going to require a working apxs, maybe we should just do something
with "--with-apache2-apxs=... --disable-shared" instead of adding
another configure option (and distinguish between shared/static libapreq
and shared/static mod_apreq).

Another possibility is to do something clever with httpd's 
--with-module=... option, but I'm not smart enough to get a full
compile out of it.  Maybe a small step in this direction would 
be to move httpd-apreq-2/src/* over to httpd-2.0/srclib/apreq
and figure out how to get *that* to compile libapreq.


If I'm jumping the gun by asking such questions before trying the
patch, just holler.

-- 
Joe Schaefer