apxs.in revision 3d96ee83babeec32482c9082c9426340cee8c44d
#!@perlbin@
# ====================================================================
# The Apache Software License, Version 1.1
#
# Copyright (c) 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. 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
#
##
## apxs -- APache eXtenSion tool
## Written by Ralf S. Engelschall <rse@apache.org>
##
require 5.003;
use strict;
##
## Configuration
##
my $CFG_TARGET = '@progname@';
my $CFG_CC = '@CC@';
my $CFG_DEFS = '@DEFS@';
my $CFG_CFLAGS = '@CFLAGS@ @EXTRA_CFLAGS@';
my $CFG_PREFIX = "@prefix@";
my $prefix = "$CFG_PREFIX";
my $CFG_EXEC_PREFIX = "@exec_prefix@";
my $exec_prefix = "$CFG_EXEC_PREFIX";
my $CFG_SBINDIR = "@bindir@";
my $CFG_INCLUDEDIR = "@includedir@";
my $CFG_LIBEXECDIR = "@libexecdir@";
my $CFG_SYSCONFDIR = "@sysconfdir@";
##
## 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
##
my $httpd = "$CFG_SBINDIR/$CFG_TARGET";
#allow apxs to be run from the source tree, before installation
$httpd .= $CFG_TARGET;
}
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 $slo = $s;
my $lo = $s;
my $la = $s;
push(@cmds, "libtool --silent --mode=compile $CFG_CC $cflags -I$CFG_INCLUDEDIR -I$CFG_INCLUDEDIR/apr $opt -c $s && touch $slo");
push(@cmds, "libtool --silent --mode=link $CFG_CC $cflags -o $la -rpath $CFG_LIBEXECDIR -module -avoid-version $lo");
}
# 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[] = {
};
};