for my $file ($dh->read) {
next unless $file =~ /\.xs$/;
push @xs_names, module_name_from_xs("$dir/$file");
push @xs_files, $file;
unless ($mani_src{"$dir/$file"}) {
cp "$dir/$file", $d;
print "Adding module `$xs_names[-1]' to httpd\n";
}
}
#print "XS_NAMES=@xs_names\n";
#print "XS_FILES=@xs_files\n";
#XXX think about this some more
iedit $mf, "s/^#STATIC_SRC.*/STATIC_SRC = @xs_files/";
iedit $mf, "s/^#STATIC_EXTS.*/STATIC_EXTS = @xs_names/";
NAME
Apache::MyConfig - build options access
SYNOPSIS
use Apache::MyConfig;
die unless \$Apache::MyConfig::Setup{PERL_FILE_API};
DESCRIPTION
Apache::MyConfig module provides access to the various hooks and features set when mod_perl is built. This circumvents the need to set up a live server just to find out if a certain callback hook is available.
Itterate through \%Apache::MyConfig::Setup to get obtain build information then see Appendix B of the Eagle book for more detail on each key.
EOT close FH;
}
# obtain the Apache and mod_perl lib and include directories for Win32 sub win32_inc_and_lib {
my $modperl_src = win32_fix_path(cwd) . '/src';
$win32_path{MODPERL_INC} = $modperl_src . '/modules/perl';
$win32_path{MODPERL_LIB} = ($win32_args{DEBUG} == 1) ?
$modperl_src . '/modules/win32/Debug' :
$modperl_src . '/modules/win32/Release';
unless ( -d $win32_args{APACHE_SRC}) {
opendir(DIR, '../') or die "Cannot read parent directory: $!\n";
my @dirs = map {"../$_"}
grep {/apache/ and -d "../$_"} readdir DIR;
closedir DIR or die "Cannot close parent directory: $!\n";
die "Cannot find the apache sources\n"
unless ($win32_args{APACHE_SRC} = find_dir(\@dirs, 'apache source'));
}
$win32_args{APACHE_SRC} = win32_fix_path($win32_args{APACHE_SRC});
if (-d "$win32_args{APACHE_SRC}/libexec") {
$win32_path{APACHE_LIB} = $win32_args{APACHE_SRC} . '/libexec';
$win32_path{APACHE_INC} = $win32_args{APACHE_SRC} . '/include';
$win32_args{APACHE_VERS} = httpd_version($win32_path{APACHE_INC}, 1);
}
else {
$win32_args{APACHE_SRC} .= '/src' unless $win32_args{APACHE_SRC} =~ /src$/;
$win32_path{APACHE_INC} = $win32_args{APACHE_SRC} . '/include';
$win32_args{APACHE_VERS} = httpd_version($win32_path{APACHE_INC}, 1);
$win32_path{APACHE_LIB} = ($win32_args{DEBUG} == 1) ?
$win32_args{APACHE_SRC} .
($win32_args{APACHE_VERS} < 1315 ? '/CoreD' : '/Debug') :
$win32_args{APACHE_SRC} .
($win32_args{APACHE_VERS} < 1315 ? '/CoreR' : '/Release');
}
die "Cannot find ApacheCore.lib under $win32_path{APACHE_LIB}\n"
unless -f "$win32_path{APACHE_LIB}/ApacheCore.lib";
die "Cannot find httpd.h under $win32_path{APACHE_INC}\n"
unless -f "$win32_path{APACHE_INC}/httpd.h";
if ($win32_args{INSTALL_DLL} ) {
$win32_args{INSTALL_DLL} =
win32_fix_path($win32_args{INSTALL_DLL});
unless ( -d $win32_args{INSTALL_DLL}) {
my @dirs = grep {-d}
('\Program Files\Apache Group\Apache\modules',
'\Apache\modules', '\Program Files\Apache\modules');
$win32_args{INSTALL_DLL} = find_dir(\@dirs, 'Apache/modules');
if ($win32_args{INSTALL_DLL} and -d $win32_args{INSTALL_DLL}) {
$win32_args{INSTALL_DLL} =
win32_fix_path($win32_args{INSTALL_DLL});
}
else {
print <<'END';
**** The Apache/modules directory was not found. ******* **** Please install mod_perl.so manually. *******
END } } } if ($win32_args{INSTALL_LIB} ) { $win32_args{INSTALL_LIB} = win32_fix_path($win32_args{INSTALL_LIB}); unless ( -d $win32_args{INSTALL_LIB}) { my @dirs = grep {-d} ('\Program Files\Apache Group\Apache\libexec', '\Apache\libexec', '\Program Files\Apache\libexec'); $win32_args{INSTALL_LIB} = find_dir(\@dirs, 'Apache/libexec'); if ($win32_args{INSTALL_LIB} and -d $win32_args{INSTALL_LIB}) { $win32_args{INSTALL_LIB} = win32_fix_path($win32_args{INSTALL_LIB}); } else { print <<'END';
**** The Apache/libexec directory was not found. ******* **** Please install mod_perl.lib manually. *******
END } } } }
# fix mod_perl.dsp with the perl and apache inc and lib directories sub win32_fix_dsp {
my $amp = 'src/modules/win32';
my $dsp = 'mod_perl.dsp';
unless ( -f "$amp/$dsp.orig") {
rename("$amp/$dsp", "$amp/$dsp.orig")
or die "Couldn't rename $amp/$dsp: $!\n";
}
my $perl_inc = win32_fix_path_dsp("$Config{archlibexp}/CORE");
open(OLDDSP, "$amp/$dsp.orig")
or die "Couldn't read $amp/$dsp.orig: $!\n";
open(NEWDSP, ">$amp/$dsp")
or die "Couldn't create $amp/$dsp: $!\n";
while (<OLDDSP>) {
if (/^SOURCE=.*ApacheCore\.lib/) {
printf NEWDSP "SOURCE=%s\n",
win32_fix_path_dsp("$win32_path{APACHE_LIB}/ApacheCore.lib");
}
elsif (/^SOURCE=.*perl(56)?\.lib/) {
print NEWDSP qq{SOURCE=$perl_inc\\$Config{libperl}\n};
}
elsif (/ADD CPP/) {
my $apache_inc = win32_fix_path_dsp($win32_path{APACHE_INC});
s!(/D "WIN32")!/I "$apache_inc" /I "$apache_inc/../os/win32" /I "$perl_inc" $1!;
s!(/D "WIN32")!$1 /D "EAPI" ! if $win32_args{EAPI};
print NEWDSP $_;
}
else {
print NEWDSP $_;
}
}
close OLDDSP;
close NEWDSP;
return;
}
# find a directory of type $type, given some possible $dirs sub find_dir { my ($dirs, $type) = @_; my $j = 0; my $src; while (1) { $src = @$dirs > 0 ? $dirs->[$j] : ''; $src = prompt("\nWhere is your $type directory? (q to quit)", $src); return undef if $src eq 'q'; return $src if -d $src; print qq{'$src': no such directory\n}; $j = ($j == @$dirs-1) ? 0 : $j + 1; } }
# fix a path for Win32 Makefile sub win32_fix_path { my $path = shift; $path = File::Spec->rel2abs($path) if not File::Spec->file_name_is_absolute($path); $path = Win32::GetShortPathName($path) if $path =~ / /; $path =~ tr!\\!/!; $path =~ s!/$!!; return $path; }
# fix a path for mod_perl.dsp sub win32_fix_path_dsp { local $_ = shift; tr!/!\\!; return $_; }
#in version 1.2505 of Embed.pm we could just import these instead of using ``, #but it might require lots of people to upgrade
sub ccopts { unless ($Embed::ccopts) { $Embed::ccopts = "$Config{ccflags} -I$Config{archlibexp}/CORE"; if($USE_THREADS) { $Embed::ccopts .= " -DPERL_THREADS"; } } $Embed::ccopts; }
sub ldopts { $Embed::ldopts ||= `$^X -MExtUtils::Embed -e ldopts`; if($^O eq "aix") { $Embed::ldopts =~ s,(-bE:)(perl\.exp),$1$Config{archlibexp}/$2,; } $Embed::ldopts; }
sub perl_version { my $v = "$]"; $v =~ s/\.//g; $v .= "0" while length($v) < 6; $v; }
#for linking third-party xs modules static built w/ MakeMaker's: 'make static' #must have when the xs module is compiled with profiling `-pg -a' flags sub add_static_ar { $PERL_STATIC_AR ||= ""; my $cur = $APACHE_SRC =~ /^../ ? "$PWD/" : ""; for (qw(blib/arch/auto arch/auto)) { last if -d ($ar_dir = "$APACHE_SRC/modules/perl/$_"); $ar_dir = ""; } return unless -d $ar_dir;
finddepth(sub {
return unless /^[A-Z]\w+\.a$/;
(my $rel = $File::Find::dir) =~ s:$APACHE_SRC/?::;
(my $mod = $rel) =~ s:.*auto/::;
$mod =~ s,/,::,;
print "linking static $mod => $rel/$_\n";
$PERL_STATIC_AR .= $cur . "$File::Find::dir/$_ ";
$PERL_STATIC_EXTS .= "$mod ";
}, $ar_dir);
}
sub APACI::init { return undef if $Is_Win32; my $lib_cfg; if($USE_APXS) { $lib_cfg = "apaci/mod_perl.config"; chmod 0644, $lib_cfg; } elsif($USE_APACI) { $lib_cfg = "$APACHE_SRC/modules/perl/mod_perl.config"; } else { return undef; } unless (File::Compare::compare($lib_cfg,"apaci/mod_perl.config") == 0) { #warn "mod_perl.config already edited\n"; #return undef; }
my $apaci_cfg = FileHandle->new(">$lib_cfg") or
die "can't open $lib_cfg $!";
my @static_src = ();
for (@xs_mod_snames) {
push @static_src, "$_.c";
}
add_static_ar();
my $static_targets = "";
$static_targets = <<EOF unless $DYNAMIC;
PERL_STATIC_EXTS = @xs_modules $PERL_STATIC_EXTS
PERL_STATIC_SRCS = @static_src
EOF
$static_targets .= "PERL_STATIC_AR = $PERL_STATIC_AR\n" if $PERL_STATIC_AR;
print $apaci_cfg <<EOF;
##
## mod_perl.config -- mod_perl shared configuration file
##
# mod_perl version MOD_PERL_VERSION = $VERSION
# Perl interpreter to use PERL = $^X LIBPERL = $LIBPERL
$static_targets
EOF
print $apaci_cfg <<EOF if defined $MOD_PERL_PREFIX;
# mod_perl installation prefix MOD_PERL_PREFIX = $MOD_PERL_PREFIX
EOF
for (qw(PERL_SECTIONS PERL_SSI PERL_TRACE)) {
my $yes_no = $$_ ? "yes" : "no";
print $apaci_cfg "$_ = $yes_no\n";
}
$yes_no = 'no';
$yes_no = 'yes' if $USE_THREADS;
print $apaci_cfg "PERL_THREADS = $yes_no\n";
return $apaci_cfg;
}
sub phat_warn { my($msg, $abort) = @_; my $level = $abort ? "ERROR" : "WARNING"; warn <<EOF; ************* $level *************
$msg
************* $level ************* EOF if ($abort) { exit 1; } else { sleep 5; } }
sub system_sanity_check { return if $Is_Win32;
my $ccflags = $Config{'ccflags'};
for (split /\s+/, $ccflags) {
next unless s/^-I//;
my $header = "$_/ap_mmn.h";
if (-e $header) {
phat_warn(<<EOF);
Apache headers found in unexpected location: ``$_'', suggestions:
*) Remove via ``rpm -e apache''
*) Remove by hand
*) Complain to your os vendor about their poor layout choice
*) Complain to your sysadmin about their poor layout choice
EOF
}
}
my $ld = basename $Config{ld};
if ($^O eq 'hpux' and ($USE_DSO or $USE_APXS) and $ld eq 'ld') {
unless ($ccflags =~ /\+z/i) {
my $switch = $] >= 5.006 ? 'A' : 'D';
phat_warn(<<EOF);
mod_perl is unlikely to link with your libperl, suggestions:
*) Rebuild Perl with Configure -${switch}ccflags=+Z ...
*) Build mod_perl static rather than DSO
EOF
}
}
gdbm_check();
malloc_check();
uselargefiles_check();
dynaloader_check();
shrplib_check();
if ($USE_APXS and $Config{libs} =~ /($thrlib)/) {
my $lib = $1;
phat_warn(<<EOF);
Your Perl is linked with $lib, make sure that your httpd is built with LIBS=$lib
EOF
}
}
sub gdbm_check { if ($Config{libs} =~ /gdbm/) { require DynaLoader; require AutoLoader; #eek my $found = 0; my @path = split /\s+/, $Config{libpth};
for (@path) {
last if $found = DynaLoader::dl_findfile($_, "-lgdbm");
}
unless ($found) {
my @maybe = ();
for (@path) {
push @maybe, grep { ! -l $_ } <$_/libgdbm.*>;
}
my $suggest = @maybe ?
"You could just symlink it to $maybe[0]" :
"You might need to install Perl from source";
phat_warn(<<EOF);
Your Perl is configured to link against libgdbm,
but libgdbm.so was not found.
$suggest
EOF
}
}
}
sub uselargefiles_check { return unless $] >= 5.006 and $Config{uselargefiles} and $PERL_USELARGEFILES and $USE_APXS; local $Apache::src::APXS = $WITH_APXS; my $cflags = Apache::src->new->apxs('-q' => 'CFLAGS') || ''; return if $cflags =~ /LARGEFILE/;
$PERL_USELARGEFILES=0; #just do it since
return; #nobody seems to listen to the warning below
phat_warn(<<EOF);
Your Perl is uselargefiles enabled, but Apache is not, suggestions:
*) Rebuild mod_perl with Makefile.PL PERL_USELARGEFILES=0
*) Rebuild Apache with CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
*) Rebuild Perl with Configure -Uuselargefiles
*) Let mod_perl build Apache (USE_DSO=1 instead of USE_APXS=1)
EOF
}
sub malloc_check { return unless $USE_DSO or $USE_APXS; return unless $Config{'usemymalloc'} eq 'y';
my $abort = $^O eq 'solaris';
my $bincompat = $Config{bincompat5005} and
$Config{bincompat5005} eq 'define';
if ($] < 5.006) {
phat_warn(<<EOF, $abort);
Your current configuration will most likely trigger core dumps, suggestions:
*) Do not configure mod_perl as a DSO
*) Upgrade your Perl version to 5.6.0 or higher (w/ -Ubincompat5005)
*) Configure Perl with -Uusemymalloc (not recommended for performance)
EOF
}
elsif ($bincompat) {
phat_warn(<<EOF, $abort);
Your current configuration will most likely trigger core dumps, suggestions:
*) Do not configure mod_perl as a DSO
*) Rebuild Perl without malloc pollution (Configure -Ubincompat5005)
EOF
}
}
sub dynaloader_check { return unless $^O eq 'aix' and $] <= 5.00503 and ($USE_DSO or $USE_APXS); phat_warn(<<EOF); Please make sure that you apply the following patch to the perl distribution before you install mod_perl, without this patch you will not be able load any xs modules. EOF
warn <<EOF;
--- perl5.005_03/ext/DynaLoader/dl_aix.xs.orig Fri Mar 3 17:00:58 2000
+++ perl5.005_03/ext/DynaLoader/dl_aix.xs Sun Apr 2 13:37:05 2000
@@ -74,8 +74,8 @@
} Module, *ModulePtr;
/*
- * We keep a list of all loaded modules to be able to call the fini
- * handlers at atexit() time.
+ * We keep a list of all loaded modules to be able to reference count
+ * duplicate dlopen's.
*/
static ModulePtr modList;
@@ -88,7 +88,6 @@
static void caterr(char *);
static int readExports(ModulePtr);
-static void terminate(void);
static void *findMain(void);
static char *strerror_failed = "(strerror failed)";
@@ -165,7 +164,6 @@
if (!mainModule) {
if ((mainModule = findMain()) == NULL)
return NULL;
- atexit(terminate);
}
/*
* Scan the list of modules if have the module already loaded.
@@ -222,7 +220,16 @@
mp->refCnt = 1;
mp->next = modList;
modList = mp;
- if (loadbind(0, mainModule, mp->entry) == -1) {
+ /*
+ * Assume anonymous exports come from the module this dlopen
+ * is linked into, that holds true as long as dlopen and all
+ * of the perl core are in the same shared object. Also bind
+ * against the main part, in the case a perl is not the main
+ * part, e.g mod_perl as DSO in Apache so perl modules can
+ * also reference Apache symbols.
+ */
+ if (loadbind(0, (void *)dlopen, mp->entry) == -1 ||
+ loadbind(0, mainModule, mp->entry) == -1) {
dlclose(mp);
errvalid++;
strcpy(errbuf, "loadbind: ");
@@ -336,12 +343,6 @@
safefree(mp->name);
safefree(mp);
return result;
-}
-
-static void terminate(void)
-{
- while (modList)
- dlclose(modList);
}
/* Added by Wayne Scott
EOF }
sub shrplib_check { return unless $Config{'useshrplib'} and $Config{'useshrplib'} eq 'define';
my $libperl = $Config{'libperl'} || 'libperl.so';
for my $dir (qw(/lib /usr/lib /usr/local/lib)) {
next unless -e "$dir/$libperl";
my $coredir = "$Config{'archlibexp'}/CORE";
my $corelib = "$coredir/$libperl";
phat_warn(<<EOF);
$dir/$libperl might override
$corelib
This may cause build or runtime errors with mod_perl. Consider removing $dir/$libperl, it should not be there.
If your vendor has installed $libperl there, complain to them and install Perl from source if needed.
$libperl should only exist in Perl version/arch directories, for example: $coredir EOF } }
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 1755:
=pod directives shouldn't be over one line long! Ignoring all 5 lines of content