apxs.in revision 64185f9824e42f21ca7b9ae6c004484215c031a7
## ====================================================================
## Copyright (c) 1998-2000 The Apache Software Foundation. All rights reserved.
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
##
## 1. Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
##
## 2. Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in
## distribution.
##
## 3. All advertising materials mentioning features or use of this
## software must display the following acknowledgment:
## "This product includes software developed by the Apache Software Foundation
## for use in the Apache HTTP server project (http://www.apache.org/)."
##
## 4. The names "Apache Server" and "Apache Software Foundation" must not be used to
## endorse or promote products derived from this software without
## prior written permission. For written permission, please contact
## apache@apache.org.
##
## 5. Products derived from this software may not be called "Apache"
## nor may "Apache" appear in their names without prior written
## permission of the Apache Software Foundation.
##
## 6. Redistributions of any form whatsoever must retain the following
## acknowledgment:
## "This product includes software developed by the Apache Software Foundation
## for use in the Apache HTTP server project (http://www.apache.org/)."
##
## THIS SOFTWARE IS PROVIDED BY THE Apache Software Foundation ``AS IS'' AND ANY
## EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE Apache Software Foundation OR
## ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
## STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
## OF THE POSSIBILITY OF SUCH DAMAGE.
## ====================================================================
##
## This software consists of voluntary contributions made by many
## individuals on behalf of the Apache Software Foundation and was originally based
## on public domain software written at the National Center for
## Supercomputing Applications, University of Illinois, Urbana-Champaign.
## For more information on the Apache Software Foundation and the Apache HTTP server
## project, please see <http://www.apache.org/>.
##
##
## apxs -- APache eXtenSion tool
## Written by Ralf S. Engelschall <rse@apache.org>
##
require 5.003;
use strict;
##
## Configuration
##
##
## Cleanup the above stuff
##
$CFG_CFLAGS =~ s|^\s+||;
$CFG_CFLAGS =~ s|\s+$||;
$CFG_CFLAGS =~ s|\s+`.+apaci`||;
##
## parse argument line
##
# defaults for parameters
my $opt_n = '';
my $opt_g = '';
my $opt_c = 0;
my $opt_o = '';
my @opt_D = ();
my @opt_I = ();
my @opt_L = ();
my @opt_l = ();
my @opt_W = ();
my @opt_S = ();
my $opt_e = 0;
my $opt_i = 0;
my $opt_a = 0;
my $opt_A = 0;
my $opt_q = 0;
# this subroutine is derived from Perl's getopts.pl with the enhancement of
# the "+" metacharater at the format string to allow a list to be build by
# subsequent occurance of the same option.
sub Getopts {
local ($_);
local ($[) = 0;
if ($_ =~ m|^--$|) {
last;
}
++$errs;
}
}
}
++$errs;
}
}
}
else {
}
else {
}
}
}
else {
++$errs;
}
else {
}
}
}
}
sub usage {
exit(1);
}
# option handling
my $rc;
# argument handling
my $name = 'unknown';
if (@opt_S) {
&usage;
}
eval "\$CFG_${var}=\"${val}\"";
} else {
&usage;
}
}
}
##
## Initial shared object support check
##
exit(1);
}
exit(1);
}
##
## Operation
##
# helper function for executing a list of
# system command with return code checks
sub execute_cmds {
my (@cmds) = @_;
my ($cmd, $rc);
foreach $cmd (@cmds) {
print STDERR "$cmd\n";
$rc = system("$cmd");
if ($rc != 0) {
printf(STDERR "apxs:Break: Command failed with rc=%d\n", $rc << 8);
exit(1);
}
}
}
if ($opt_g) {
##
## SAMPLE MODULE SOURCE GENERATION
##
if (-d $name) {
exit(1);
}
my $data = join('', <DATA>);
$data =~ s|%TARGET%|$CFG_TARGET|sg;
print FP $mkf;
close(FP);
print FP $src;
close(FP);
exit(0);
}
if ($opt_q) {
##
## QUERY INFORMATION
##
my $result = '';
my $arg;
foreach $arg (@args) {
my $ok = 0;
my $name;
foreach $name (qw(
TARGET CC CFLAGS CFLAGS_SHLIB LD_SHLIB LDFLAGS_SHLIB LIBS_SHLIB
PREFIX SBINDIR INCLUDEDIR LIBEXECDIR SYSCONFDIR
)) {
$ok = 1;
}
}
if (not $ok) {
exit(1);
}
}
$result =~ s|::$||;
$result =~ s|::| |;
print $result;
}
if ($opt_c) {
##
## SHARED OBJECT COMPILATION
##
# split files into sources and objects
my $f;
if ($f =~ m|\.c$|) {
}
else {
}
}
# determine output file
my $dso_file;
}
}
else {
}
}
else {
}
# create compilation commands
}
}
}
my $s;
my $o = $s;
$o =~ s|\.c$|.o|;
}
# create link command
my $o;
}
} else {
}
}
}
}
# execute the commands
# allow one-step compilation and installation
}
}
##
## SHARED OBJECT INSTALLATION
##
# determine installation commands
# and corresponding LoadModule/AddModule directives
my $f;
exit(1);
}
my $t = $f;
$t =~ s|^.+/([^/]+)$|$1|;
}
# determine module symbolname and filename
my $base = $f;
$base =~ s|\.[^.]+$||;
$filename =~ s|^[^/]+/||;
}
}
$filename =~ s|^[^/]+/||;
}
}
print "apxs:Error: Sorry, cannot determine bootstrap symbol name\n";
print "apxs:Error: Please specify one with option `-n'\n";
exit(1);
}
}
if ($filename eq '') {
$filename = "mod_${name}.c";
}
my $dir = $CFG_LIBEXECDIR;
$dir =~ s|^$CFG_PREFIX/?||;
$dir =~ s|(.)$|$1/|;
push(@lmd, sprintf("LoadModule %-18s %s", "${name}_module", "$dir$t"));
push(@amd, sprintf("AddModule %s", $filename));
}
# execute the commands
&execute_cmds(@cmds);
# activate module via LoadModule/AddModule directive
if ($opt_a or $opt_A) {
if (not -f "$CFG_SYSCONFDIR/$CFG_TARGET.conf") {
print "apxs:Error: Config file $CFG_SYSCONFDIR/$CFG_TARGET.conf not found\n";
exit(1);
}
open(FP, "<$CFG_SYSCONFDIR/$CFG_TARGET.conf") || die;
my $content = join('', <FP>);
close(FP);
if ($content !~ m|\n#?\s*LoadModule\s+|) {
print STDERR "apxs:Error: Activation failed for custom $CFG_SYSCONFDIR/$CFG_TARGET.conf file.\n";
exit(1);
}
my $lmd;
my $c = '';
$c = '#' if ($opt_A);
foreach $lmd (@lmd) {
} else {
}
$lmd =~ m|LoadModule\s+(.+?)_module.*|;
}
my $amd;
} else {
}
}
} else {
}
}
}
}
##EOF##
##
## Makefile -- Build procedure for sample %NAME% Apache module
## Autogenerated via ``apxs -n %NAME% -g''.
##
# the used tools
# additional defines, includes and libraries
#DEF=-Dmy_define=my_value
# the default target
# compile the shared object file
# install the shared object file into Apache
# cleanup
# simple test
test: reload
lynx -mime_header http://localhost/%NAME%
# install and activate shared object by reloading Apache to
# force a reload of the shared object file
# procedures
stop:
-=#=-
/*
**
** by running:
**
** $ apxs -c -i mod_%NAME%.c
**
**
** # %TARGET%.conf
** SetHandler %NAME%
** </Location>
**
** Then after restarting Apache via
**
**
**
** $ lynx -mime_header http://localhost/%NAME%
**
**
** Connection: close
**
*/
#include "httpd.h"
#include "http_config.h"
#include "http_protocol.h"
#include "ap_config.h"
static int %NAME%_handler(request_rec *r)
{
if (!r->header_only)
return OK;
}
static const handler_rec %NAME%_handlers[] = {
};
NULL, /* module initializer */
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, /* child_init */
NULL, /* child_exit */
NULL /* [#0] post read-request */
};