apxs.in revision 229f6f59eeca254a5e681ccd26946b9636839d80
2818N/A## ==================================================================== 2818N/A## Copyright (c) 1998-1999 The Apache Group. All rights reserved. 2818N/A## Redistribution and use in source and binary forms, with or without 2818N/A## modification, are permitted provided that the following conditions 2818N/A## 1. Redistributions of source code must retain the above copyright 2818N/A## notice, this list of conditions and the following disclaimer. 2818N/A## 2. Redistributions in binary form must reproduce the above copyright 2818N/A## notice, this list of conditions and the following disclaimer in 2818N/A## the documentation and/or other materials provided with the 2818N/A## 3. All advertising materials mentioning features or use of this 2818N/A## software must display the following acknowledgment: 2818N/A## "This product includes software developed by the Apache Group 2818N/A## 4. The names "Apache Server" and "Apache Group" must not be used to 3633N/A## endorse or promote products derived from this software without 2818N/A## prior written permission. For written permission, please contact 2818N/A## 5. Products derived from this software may not be called "Apache" 2818N/A## nor may "Apache" appear in their names without prior written 3396N/A## permission of the Apache Group. 2818N/A## 6. Redistributions of any form whatsoever must retain the following 2818N/A## "This product includes software developed by the Apache Group 2818N/A## THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY 2818N/A## EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 3396N/A## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2899N/A## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR 2818N/A## ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2818N/A## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2818N/A## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 2818N/A## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2818N/A## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 2818N/A## STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2818N/A## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 2818N/A## OF THE POSSIBILITY OF SUCH DAMAGE. 2818N/A## ==================================================================== 2818N/A## This software consists of voluntary contributions made by many 2818N/A## individuals on behalf of the Apache Group and was originally based 2818N/A## on public domain software written at the National Center for 2818N/A## Supercomputing Applications, University of Illinois, Urbana-Champaign. 2818N/A## For more information on the Apache Group and the Apache HTTP server 2818N/A## apxs -- APache eXtenSion tool 2818N/A## Written by Ralf S. Engelschall <rse@apache.org> 2818N/A# the "+" metacharater at the format string to allow a list to be build by 2818N/A# subsequent occurance of the same option. 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 " [-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"; if ($opt_S =~ m/^([^=]+)=(.*)$/) { print STDERR "apxs:Error: no config variable $var\n"; eval "\$CFG_${var}=\"${val}\""; print STDERR "apxs:Error: malformatted -S option\n"; ## Initial shared object support check print STDERR "apxs:Error: Sorry, no shared object support for Apache\n"; print STDERR "apxs:Error: available under your platform. Make sure\n"; print STDERR "apxs:Error: the Apache module mod_so is compiled into\n"; # helper function for executing a list of # system command with return code checks printf(STDERR "apxs:Break: Command failed with rc=%d\n", $rc << 8); ## SAMPLE MODULE SOURCE GENERATION my $data = join('', <DATA>); TARGET CC CFLAGS CFLAGS_SHLIB LD_SHLIB LDFLAGS_SHLIB LIBS_SHLIB PREFIX SBINDIR INCLUDEDIR LIBEXECDIR SYSCONFDIR ## SHARED OBJECT COMPILATION # split files into sources and objects # create compilation commands # allow one-step compilation and installation ## SHARED OBJECT INSTALLATION # determine installation commands print STDERR "apxs:Error: file $f is not a shared object\n"; $t =~ s|^.+/([^/]+)$|$1|; # determine module symbolname and filename print "apxs:Error: Sorry, cannot determine bootstrap symbol name\n"; print "apxs:Error: Please specify one with option `-n'\n"; $filename = "mod_${name}.c"; my $dir = $CFG_LIBEXECDIR; $dir =~ s|^$CFG_PREFIX/?||; push(@lmd, sprintf("LoadModule %-18s %s", "${name}_module", "$dir$t")); push(@amd, sprintf("AddModule %s", $filename)); print "apxs:Error: Config file $CFG_SYSCONFDIR/$CFG_TARGET.conf not found\n"; my $content = join('', <FP>); if ($content !~ m|\n#?\s*LoadModule\s+|) { print STDERR "apxs:Error: Activation failed for custom $CFG_SYSCONFDIR/$CFG_TARGET.conf file.\n"; $content =~ s|^(.*\n#?\s*LoadModule\s+[^\n]+\n)|$1$c$lmd\n|sg; $lmd =~ m|LoadModule\s+(.+?)_module.*|; $content =~ s|^(.*\n#?\s*AddModule\s+[^\n]+\n)|$1$c$amd\n|sg; $content =~ s|^(.*\n)#?\s*$amd[^\n]*\n|$1$c$amd\n|sg; ## Makefile -- Build procedure for sample %NAME% Apache module ## Autogenerated via ``apxs -n %NAME% -g''. # additional defines, includes and libraries #DEF=-Dmy_define=my_value # compile the shared object file # install the shared object file into Apache # install and activate shared object by reloading Apache to # force a reload of the shared object file ** $ apxs -c -i mod_%NAME%.c ap_rputs("The sample page from mod_%NAME%.c\n", r); NULL, /* [#1] URI to filename translation */ NULL, /* [#4] validate user id from request */ NULL, /* [#5] check if the user is ok _here_ */ NULL, /* [#3] check access by host address */ NULL, /* [#6] determine MIME type */ NULL, /* [#7] pre-run fixups */ NULL, /* [#9] log a transaction */ NULL, /* [#2] header parser */ NULL /* [#0] post read-request */