#!@perlbin@ -w
#
-# Copyright 2000-2004 Apache Software Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
my $CFG_SYSCONFDIR = get_vars("sysconfdir");
my $CFG_CFLAGS = join ' ', map { get_vars($_) }
qw(SHLTCFLAGS CFLAGS NOTEST_CPPFLAGS EXTRA_CPPFLAGS EXTRA_CFLAGS);
+my $CFG_LDFLAGS = join ' ', map { get_vars($_) }
+ qw(LDFLAGS NOTEST_LDFLAGS SH_LDFLAGS);
my $includedir = get_vars("includedir");
my $CFG_INCLUDEDIR = eval qq("$includedir");
my $CFG_CC = get_vars("CC");
my $opt_q = 0;
my $opt_h = 0;
my $opt_p = 0;
+my $opt_v = 0;
# this subroutine is derived from Perl's getopts.pl with the enhancement of
# the "+" metacharacter at the format string to allow a list to be built by
my ($argumentative, @ARGV) = @_;
my $errs = 0;
local $_;
- local $[ = 0;
my @args = split / */, $argumentative;
while (@ARGV && ($_ = $ARGV[0]) =~ /^-(.)(.*)/) {
last;
}
my $pos = index($argumentative,$first);
- if ($pos >= $[) {
+ if ($pos >= 0) {
if ($pos < $#args && $args[$pos+1] eq ':') {
shift @ARGV;
if ($rest eq '') {
sub usage {
print STDERR "Usage: apxs -g [-S <var>=<val>] -n <modname>\n";
- print STDERR " apxs -q [-S <var>=<val>] <query> ...\n";
+ print STDERR " apxs -q [-v] [-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>] [-p] <files> ...\n";
# option handling
my $rc;
-($rc, @ARGV) = &Getopts("qn:gco:I+D+L+l+W+S+eiaAp", @ARGV);
+($rc, @ARGV) = &Getopts("qn:gco:I+D+L+l+W+S+eiaApv", @ARGV);
&usage if ($rc == 0);
-&usage if ($#ARGV == -1 and not $opt_g);
+&usage if ($#ARGV == -1 and not $opt_g and not $opt_q);
&usage if (not $opt_q and not ($opt_g and $opt_n) and not $opt_i and not $opt_c and not $opt_e);
# argument handling
##
## Initial shared object support check
##
-my $httpd = get_vars("sbindir") . "/" . get_vars("progname");
-$httpd = eval qq("$httpd");
-$httpd = eval qq("$httpd");
-my $envvars = get_vars("sbindir") . "/envvars";
-$envvars = eval qq("$envvars");
-$envvars = eval qq("$envvars");
-
-#allow apxs to be run from the source tree, before installation
-if ($0 =~ m:support/apxs$:) {
- ($httpd = $0) =~ s:support/apxs$::;
-}
-
-unless (-x "$httpd") {
- error("$httpd not found or not executable");
- exit 1;
-}
-
-unless (grep /mod_so/, `. $envvars && $httpd -l`) {
+unless ("@MOD_SO_ENABLED@" eq "yes") {
error("Sorry, no shared object support for Apache");
error("available under your platform. Make sure");
error("the Apache module mod_so is compiled into");
- error("your server binary `$httpd'.");
+ error("the server binary.");
exit 1;
}
}
}
$result =~ s|;;$||;
- $result =~ s|:| |;
return $result;
}
##
## QUERY INFORMATION
##
- my $result = get_vars(@args);
- print "$result\n";
+ my $result;
+ if ($#args >= 0) {
+ $result = get_vars(@args);
+ print "$result\n";
+ } else {
+ # -q without var name prints all variables and their values
+
+ # Additional -v pretty-prints output
+ if ($opt_v) {
+ # Variable names in alphabetic order
+ my @vars = sort {uc($a) cmp uc($b)} keys %config_vars;
+
+ # Make the left column as wide as the longest variable name
+ my $width = 0;
+ foreach (@vars) {
+ my $l = length $_;
+ $width = $l unless ($l <= $width);
+ }
+
+ foreach (@vars) {
+ printf "%-${width}s = %s\n", $_, $config_vars{$_};
+ }
+ } else {
+ # Unprettified name=value list
+ foreach (keys %config_vars) {
+ print "$_=$config_vars{$_}\n";
+ }
+ }
+ }
}
-my $apr_bindir = get_vars("APR_BINDIR");
+my $apr_config = get_vars("APR_CONFIG");
-if (! -x "$apr_bindir/apr-config") {
- error("$apr_bindir/apr-config not found!");
+if (! -x "$apr_config") {
+ error("$apr_config not found!");
exit(1);
}
-my $apu_bindir = get_vars("APU_BINDIR");
+my $apr_major_version = (split /\./, `$apr_config --version`)[0];
-if (! -x "$apu_bindir/apu-config") {
- error("$apu_bindir/apu-config not found!");
- exit(1);
+my $apu_config = "";
+if ($apr_major_version < 2) {
+ $apu_config = get_vars("APU_CONFIG");
+
+ if (! -x "$apu_config") {
+ error("$apu_config not found!");
+ exit(1);
+ }
}
-my $libtool = `$apr_bindir/apr-config --installbuilddir`;
+my $libtool = `$apr_config --apr-libtool`;
chomp($libtool);
-$libtool = "$libtool/libtool";
-my $apr_includedir = `$apr_bindir/apr-config --includes`;
+my $apr_includedir = `$apr_config --includes`;
chomp($apr_includedir);
-my $apu_includedir = `$apu_bindir/apu-config --includes`;
-chomp($apu_includedir);
+my $apu_includedir = "";
+if ($apr_major_version < 2) {
+ $apu_includedir = `$apu_config --includes`;
+ chomp($apu_includedir);
+}
if ($opt_c) {
##
$dso_file =~ s|\.[^.]+$|.la|;
}
else {
- $dso_file = "mod_unknown.so";
+ $dso_file = "mod_unknown.la";
}
}
else {
$dso_file = $opt_o;
+ $dso_file =~ s|\.[^.]+$|.la|;
}
# create compilation commands
$lo .= " $o";
}
my ($opt_Wl, $opt_L, $opt_l);
+ $opt = '';
foreach $opt_Wl (@opt_W) {
- if ($CFG_CC !~ m/gcc$/) {
- $opt .= " $1" if ($opt_Wl =~ m|^\s*l,(.*)$|);
- } else {
- $opt .= " -W$opt_Wl";
- }
+ $opt .= "$1 " if ($opt_Wl =~ m|^\s*l,(.*)$|);
}
foreach $opt_L (@opt_L) {
$opt .= " -L$opt_L";
$opt .= " -l$opt_l";
}
+ my $ldflags = "$CFG_LDFLAGS";
if ($opt_p == 1) {
- my $apr_libs=`$apr_bindir/apr-config --cflags --ldflags --link-libtool --libs`;
+ my $apr_libs=`$apr_config --cflags --ldflags --link-libtool --libs`;
chomp($apr_libs);
- my $apu_libs=`$apu_bindir/apu-config --ldflags --link-libtool --libs`;
- chomp($apu_libs);
+ my $apu_libs="";
+ if ($apr_major_version < 2) {
+ $apu_libs=`$apu_config --ldflags --link-libtool --libs`;
+ chomp($apu_libs);
+ }
$opt .= " ".$apu_libs." ".$apr_libs;
}
else {
- my $apr_ldflags=`$apr_bindir/apr-config --ldflags`;
+ my $apr_ldflags=`$apr_config --ldflags`;
chomp($apr_ldflags);
$opt .= " -rpath $CFG_LIBEXECDIR -module -avoid-version $apr_ldflags";
}
- push(@cmds, "$libtool $ltflags --mode=link $CFG_CC -o $dso_file $opt $lo");
+ push(@cmds, "$libtool $ltflags --mode=link $CFG_CC $ldflags -o $dso_file $opt $lo");
# execute the commands
&execute_cmds(@cmds);
my @cmds = ();
my $f;
foreach $f (@args) {
- if ($f !~ m#(\.so$|\.la$)#) {
+ # ack all potential gcc, hp/ux, win32+os2+aix and os/x extensions
+ if ($f !~ m#(\.so$|\.la$|\.sl$|\.dll$|\.dylib$|)#) {
error("file $f is not a shared object");
exit(1);
}
my $t = $f;
$t =~ s|^.+/([^/]+)$|$1|;
- $t =~ s|\.la$|\.so|;
+ # use .so unambigiously for installed shared library modules
+ $t =~ s|\.[^./\\]+$|\.so|;
if ($opt_i) {
push(@cmds, "$installbuilddir/instdso.sh SH_LIBTOOL='" .
"$libtool' $f $CFG_LIBEXECDIR");
open(FP, "<$base.c");
my $content = join('', <FP>);
close(FP);
- if ($content =~ m|.*module\s+(?:AP_MODULE_DECLARE_DATA\s+)?([a-zA-Z0-9_]+)_module\s*=\s*.*|s) {
+ if ($content =~ m|.*AP_DECLARE_MODULE\s*\(\s*([a-zA-Z0-9_]+)\s*\)\s*=.*|s || $content =~ m|.*module\s+(?:AP_MODULE_DECLARE_DATA\s+)?([a-zA-Z0-9_]+)_module\s*=\s*.*|s) {
$name = "$1";
$filename = "$base.c";
$filename =~ s|^[^/]+/||;
$c = '#' if ($opt_A);
foreach $lmd (@lmd) {
my $what = $opt_A ? "preparing" : "activating";
- if ($content !~ m|\n#?\s*$lmd|) {
+ my $lmd_re = $lmd;
+ $lmd_re =~ s/\s+/\\s+/g;
+
+ if ($content !~ m|\n#?\s*$lmd_re|) {
# check for open <containers>, so that the new LoadModule
# directive always appears *outside* of an <container>.
}
} else {
# replace already existing LoadModule line
- $content =~ s|^(.*\n)#?\s*$lmd[^\n]*\n|$1$c$lmd\n|s;
+ $content =~ s|^(.*\n)#?\s*$lmd_re[^\n]*\n|$1$c$lmd\n|s;
}
$lmd =~ m|LoadModule\s+(.+?)_module.*|;
notice("[$what module `$1' in $CFG_SYSCONFDIR/$CFG_TARGET.conf]");
include %INSTALLBUILDDIR%/special.mk
# the used tools
-APXS=apxs
APACHECTL=apachectl
# additional defines, includes and libraries
all: local-shared-build
# install the shared object file into Apache
-install: install-modules
+install: install-modules-yes
# cleanup
clean: