apxs.in revision 2d0b0e8c8f940cbdf31c97826529370e6bf9c070
#!@perlbin@
# ====================================================================
# The Apache Software License, Version 1.1
#
# Copyright (c) 2000-2001 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. The end-user documentation included with the redistribution,
# if any, must include the following acknowledgment:
# "This product includes software developed by the
# Apache Software Foundation (http://www.apache.org/)."
# Alternately, this acknowledgment may appear in the software itself,
# if and wherever such third-party acknowledgments normally appear.
#
# 4. The names "Apache" 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 name, without prior written
# permission of the Apache Software Foundation.
#
# THIS SOFTWARE IS PROVIDED ``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. For more
# information on the Apache Software Foundation, please see
#
require 5.003;
use strict;
##
## Configuration
##
my $prefix = "@prefix@";
my $CFG_PREFIX = "$prefix";
##
## 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
##
#allow apxs to be run from the source tree, before installation
}
exit(1);
}
exit(1);
}
sub get_vars {
my $result = '';
my $arg;
my $ok = 0;
foreach $arg (@_) {
open IN, "$prefix/build/config_vars.mk" or die "open $prefix/build/config_vars.mk: $!";
while (<IN>) {
my $var;
my $val;
if (/(.*) = (.*)$/) {
$var = $1;
$val = $2;
}
next unless $var;
if ($arg eq $var or $arg eq lc($var)) {
$result .= "$val;;";
$ok = 1;
last;
}
}
if (not $ok) {
exit(1);
}
}
$result =~ s|;;$||;
$result =~ s|:| |;
}
##
## Operation
##
# helper function for executing a list of
# system command with return code checks
sub execute_cmds {
my (@cmds) = @_;
foreach $cmd (@cmds) {
if ($rc != 0) {
exit(1);
}
}
}
if ($opt_g) {
##
## SAMPLE MODULE SOURCE GENERATION
##
if (-d $name) {
exit(1);
}
exit(0);
}
##
## QUERY INFORMATION
##
}
##
## 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 $mod;
my $slo = $s;
my $lo = $s;
my $la = $s;
my $o = $s;
$o =~ s|\.c$|.o|;
push(@cmds, "libtool --silent --mode=compile $CFG_CC $cflags -I$CFG_INCLUDEDIR $opt -c -o $lo $s && touch $slo");
}
# create link command
my $o;
my $lo;
}
} else {
}
}
}
}
push(@cmds, "libtool --silent --mode=link $CFG_CC -o $dso_file -rpath $CFG_LIBEXECDIR -module -avoid-version $opt $lo");
# execute the commands
# allow one-step compilation and installation
}
}
##
## SHARED OBJECT INSTALLATION
##
# determine installation commands
# and corresponding LoadModule/AddModule directives
my $f;
if ($f !~ m#(\.so$|\.la$)#) {
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/|;
$t =~ s|\.la$|.so|;
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;
open(FP, "httpd.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
# 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)
{
return DECLINED;
}
if (!r->header_only)
return OK;
}
static void %NAME%_register_hooks(apr_pool_t *p)
{
}
%NAME%_register_hooks /* register hooks */
};