26
26
use ExtUtils::Embed ();
29
use constant IS_MOD_PERL_BUILD => grep { -e "$_/lib/mod_perl2.pm" } qw(. ..);
29
use constant IS_MOD_PERL_BUILD => grep
30
{ -e "$_/Makefile.PL" && -e "$_/lib/mod_perl2.pm" } qw(. ..);
31
32
use constant AIX => $^O eq 'aix';
32
33
use constant DARWIN => $^O eq 'darwin';
154
155
return $path unless $self->{MP_AP_DESTDIR};
157
my($dest_vol, $dest_dir) = splitpath $self->{MP_AP_DESTDIR}, 1;
158
my ($dest_vol, $dest_dir) = splitpath $self->{MP_AP_DESTDIR}, 1;
158
159
my $real_dir = (splitpath $path)[1];
160
161
$path = catpath $dest_vol, catdir($dest_dir, $real_dir), '';
308
309
$self->{'httpd'} ||= $httpd;
309
310
push @Apache::TestMM::Argv, ('httpd' => $self->{'httpd'});
311
my $mplib = "$self->{MP_LIBNAME}$Config{lib_ext}";
312
my $mplibpath = catfile($self->{cwd}, qw(src modules perl), $mplib);
313
my $ldopts = $self->ldopts;
316
# Cygwin's httpd port links its modules into httpd2core.dll,
317
# instead of httpd.exe. In this case, we have a problem,
318
# because libtool doesn't want to include static libs (.a)
319
# into a dynamic lib (.dll). Workaround this by setting
320
# mod_perl.a as a linker argument (including all other flags
322
my $mplib = "$self->{MP_LIBNAME}$Config{lib_ext}";
325
'--export-all-symbols',
326
'--enable-auto-image-base',
327
"$self->{cwd}/src/modules/perl/$mplib",
330
$ldopts =~ s/(\S+)/-Wl,$1/g;
333
my $mplib = "$self->{MP_LIBNAME}$Config{lib_ext}";
334
$mplibpath = catfile($self->{cwd}, qw(src modules perl), $mplib);
314
337
local $ENV{BUILTIN_LIBS} = $mplibpath;
315
local $ENV{AP_LIBS} = $self->ldopts;
338
local $ENV{AP_LIBS} = $ldopts;
316
339
local $ENV{MODLIST} = 'perl';
318
#XXX: -Wall and/or -Werror at httpd configure time breaks things
341
# XXX: -Wall and/or -Werror at httpd configure time breaks things
319
342
local $ENV{CFLAGS} = join ' ', grep { ! /\-Wall|\-Werror/ }
320
343
split /\s+/, $ENV{CFLAGS} || '';
322
345
my $cd = qq(cd $self->{MP_AP_PREFIX});
324
#We need to clean the httpd tree before configuring it
347
# We need to clean the httpd tree before configuring it
325
348
if (-f File::Spec->catfile($self->{MP_AP_PREFIX}, 'Makefile')) {
326
349
my $cmd = qq(make clean);
327
350
debug "Running $cmd";
469
492
$ldopts .= $self->gtop_ldopts;
472
if (CYGWIN && $self->is_dynamic) {
473
$ldopts .= join ' ', '', $self->apru_link_flags;
476
495
$config->{ldflags} = $ldflags; #reset
478
497
# on Irix mod_perl.so needs to see the libperl.so symbols, which
508
527
$ccopts .= " $Wall -DAP_DEBUG";
509
528
$ccopts .= " -DAP_HAVE_DESIGNATED_INITIALIZER";
531
if ($self->has_gcc_version('3.3.2') &&
532
$ccopts !~ /declaration-after-statement/) {
533
debug "Adding -Wdeclaration-after-statement to ccopts";
534
$ccopts .= " -Wdeclaration-after-statement";
513
538
if ($self->{MP_COMPAT_1X}) {
568
sub has_gcc_version {
570
my $requested_version = shift;
572
my $has_version = $self->perl_config('gccversion');
574
return 0 unless $has_version;
576
#Only interested in leading version digits
577
$has_version =~ s/^([0-9.]+).*/$1/;
579
my @tuples = split /\./, $has_version, 3;
580
my @r_tuples = split /\./, $requested_version, 3;
582
return cmp_tuples(\@tuples, \@r_tuples) == 1;
586
my ($num_a, $num_b) = @_;
588
while (@$num_a && @$num_b) {
589
my $cmp = shift @$num_a <=> shift @$num_b;
593
return @$num_a <=> @$num_b;
543
596
sub perl_ccopts {
544
597
my $self = shift;
694
747
sub find_dlfile {
695
my($self, $name) = (shift, shift);
748
my ($self, $name) = (shift, shift);
697
750
require DynaLoader;
698
751
require AutoLoader; #eek
702
my(@path) = ($self->libpth, @_);
755
my (@path) = ($self->libpth, @_);
705
758
if ($found = DynaLoader::dl_findfile($_, "-l$name")) {
746
799
#--- user interaction ---
749
my($self, $q, $default) = @_;
802
my ($self, $q, $default) = @_;
750
803
return $default if $self->{MP_PROMPT_DEFAULT};
751
804
require ExtUtils::MakeMaker;
752
805
ExtUtils::MakeMaker::prompt($q, $default);
757
810
$self->prompt($q, 'y') =~ /^y/i;
762
815
$self->prompt($q, 'n') =~ /^n/i;
766
my($self, $msg, $abort) = @_;
819
my ($self, $msg, $abort) = @_;
767
820
my $level = $abort ? 'ERROR' : 'WARNING';
769
822
************* $level *************
837
890
sub default_file {
838
my($self, $name, $override) = @_;
891
my ($self, $name, $override) = @_;
839
892
my $key = join '_', 'file', $name;
840
893
$self->{$key} ||= ($override || $default_files{$name});
1050
1103
sub apr_generation {
1052
return $self->httpd_version_as_int =~ m/21\d+/ ? 1 : 0;
1105
return $self->httpd_version_as_int =~ m/2[1-9]\d+/ ? 1 : 0;
1055
1108
# returns an array of apr/apu linking flags (--link-ld --libs) if found
1056
1109
# an empty array otherwise
1057
1110
my @apru_link_flags = ();
1058
1111
sub apru_link_flags {
1061
1114
return @apru_link_flags if @apru_link_flags;
1122
1175
if ($self->{MP_AP_CONFIGURE} &&
1123
1176
$self->{MP_AP_CONFIGURE} =~ /--with-${what_long}=(\S+)/) {
1125
$dir =~ s/$config$// unless -d $dir;
1178
$dir = dirname $dir if -f $dir;
1126
1179
push @tries, grep -d $_, $dir, catdir $dir, 'bin';
1274
1327
sub httpd_version_as_int {
1275
my($self, $dir) = @_;
1328
my ($self, $dir) = @_;
1276
1329
my $v = $self->httpd_version($dir);
1280
1333
sub httpd_version_cache {
1281
my($self, $dir, $v) = @_;
1334
my ($self, $dir, $v) = @_;
1282
1335
return '' unless $dir;
1283
1336
$self->{httpd_version}->{$dir} = $v if $v;
1284
1337
$self->{httpd_version}->{$dir};
1287
1340
sub httpd_version {
1288
my($self, $dir) = @_;
1341
my ($self, $dir) = @_;
1290
1343
return unless $dir = $self->ap_includedir($dir);
1357
1410
while (<$fh>) {
1358
1411
next unless s/^\#define\s+APR_((HAVE|HAS|USE)_\w+)/$1/;
1360
my($name, $val) = split /\s+/, $_, 2;
1413
my ($name, $val) = split /\s+/, $_, 2;
1361
1414
next unless $wanted_apr_config{$name};
1362
1415
$val =~ s/\s+$//;
1363
1416
next unless $val =~ /^\d+$/;
1370
1423
#--- generate Makefile ---
1372
1425
sub canon_make_attr {
1373
my($self, $name) = (shift, shift);
1426
my ($self, $name) = (shift, shift);
1375
1428
my $attr = join '_', 'MODPERL', uc $name;
1376
1429
$self->{$attr} = "@_";
1537
1590
"\t" . '$(MODPERL_RANLIB) $@';
1593
sub dynamic_link_cygwin {
1596
$(MODPERL_LIBNAME).$(MODPERL_DLEXT): $(MODPERL_PIC_OBJS)
1598
$(MODPERL_CC) -shared -o $@ \
1599
-Wl,--out-implib=$(MODPERL_LIBNAME).dll.a \
1600
-Wl,--export-all-symbols -Wl,--enable-auto-import \
1601
-Wl,--enable-auto-image-base -Wl,--stack,8388608 \
1602
$(MODPERL_PIC_OBJS) \
1603
$(MODPERL_LDDLFLAGS) $(MODPERL_LDOPTS) \
1605
$(MODPERL_RANLIB) $@
1540
1609
sub dynamic_link {
1541
1610
my $self = shift;
1542
1611
my $link = \&{"dynamic_link_$^O"};
1544
1613
$link->($self);
1616
# Returns the link flags for the apache shared core library
1617
my $apache_corelib_cygwin;
1618
sub apache_corelib_cygwin {
1619
return $apache_corelib_cygwin if $apache_corelib_cygwin;
1622
my $mp_src = "$self->{cwd}/src/modules/perl";
1623
my $core = 'httpd2core';
1625
# There's a problem with user-installed perl on cygwin.
1626
# MakeMaker doesn't know about the .dll.a libs and warns
1627
# about missing -lhttpd2core. "Fix" it by copying
1628
# the lib and adding .a suffix.
1629
# For the static build create a soft link, because libhttpd2core.dll.a
1630
# doesn't exist at this time.
1631
if ($self->is_dynamic) {
1632
my $libpath = $self->apxs(-q => 'exp_libdir');
1633
File::Copy::copy("$libpath/lib$core.dll.a", "$mp_src/lib$core.a");
1635
my $libpath = catdir($self->{MP_AP_PREFIX}, '.libs');
1636
mkdir $libpath unless -d $libpath;
1637
qx{touch $libpath/lib$core.dll.a && \
1638
ln -fs $libpath/lib$core.dll.a $mp_src/lib$core.a};
1641
$apache_corelib_cygwin = "-L$mp_src -l$core";
1547
1644
sub apache_libs_MSWin32 {
1548
1645
my $self = shift;
1549
1646
my $prefix = $self->apxs(-q => 'PREFIX') || $self->dir;
1561
1663
sub modperl_libs_MSWin32 {
1562
1664
my $self = shift;
1563
# mod_perl.lib will be installed into MP_AP_PREFIX/lib
1564
# for use by 3rd party xs modules
1565
1665
"$self->{cwd}/src/modules/perl/$self->{MP_LIBNAME}.lib";
1568
1668
sub modperl_libs_cygwin {
1569
1669
my $self = shift;
1570
return $self->is_dynamic
1571
? "-L$self->{cwd}/src/modules/perl -l$self->{MP_LIBNAME}"
1572
: $self->modperl_static_libs_cygwin;
1670
return '' unless $self->is_dynamic;
1671
return "-L$self->{cwd}/src/modules/perl -l$self->{MP_LIBNAME}";
1575
1674
sub modperl_libs {
1579
1678
$libs->($self);
1582
my $modperl_static_libs_cygwin = '';
1583
sub modperl_static_libs_cygwin {
1586
return $modperl_static_libs_cygwin if $modperl_static_libs_cygwin;
1588
my $dyna_filepath = catdir $self->perl_config('archlibexp'),
1589
'auto/DynaLoader/DynaLoader.a';
1590
my $modperl_path = "$self->{cwd}/src/modules/perl";
1591
# Create symlink to mod_perl.a, but copy DynaLoader.a, because
1592
# when running make clean the real DynaLoader.a may get deleted.
1593
my $src = catfile $modperl_path, "$self->{MP_LIBNAME}.a";
1594
my $dst = catfile $modperl_path, "lib$self->{MP_LIBNAME}.a";
1595
# perl's link() on Cygwin seems to copy mod_perl.a to
1596
# libmod_perl.a, but at this stage mod_perl.a is still a dummy lib
1597
# and at the end we get nothing. whereas `ln -s` seems to create
1598
# something like the shortcut on windows and it works.
1599
qx{ln -s $src $dst} unless -e $dst;
1600
File::Copy::copy($dyna_filepath, "$modperl_path/libDynaLoader.a");
1602
$modperl_static_libs_cygwin = join ' ',
1604
"-l$self->{MP_LIBNAME}",
1606
$self->apru_link_flags,
1607
'-L' . catdir($self->perl_config('archlibexp'), 'CORE'),
1610
$modperl_static_libs_cygwin;
1681
sub modperl_libpath_MSWin32 {
1683
# mod_perl.lib will be installed into MP_AP_PREFIX/lib
1684
# for use by 3rd party xs modules
1685
"$self->{cwd}/src/modules/perl/$self->{MP_LIBNAME}.lib";
1688
sub modperl_libpath_cygwin {
1690
"$self->{cwd}/src/modules/perl/$self->{MP_LIBNAME}.dll.a";
1693
sub modperl_libpath {
1695
my $libpath = \&{"modperl_libpath_$^O"};
1696
return "" unless defined &$libpath;
1613
1700
# returns the directory and name of the aprext lib built under blib/
1640
1727
# This is ugly, but is the only way to prevent the "undefined
1641
1728
# symbols" error
1642
$libs .= join ' ', '', $self->apru_link_flags,
1729
$libs .= join ' ', '',
1643
1730
'-L' . catdir($self->perl_config('archlibexp'), 'CORE'), '-lperl';
1717
1804
#XXX short-term compat for Apache::TestConfigPerl
1718
1805
$libs{shared} = $libs{dso};
1720
while (my($type, $lib) = each %libs) {
1807
while (my ($type, $lib) = each %libs) {
1721
1808
print $fh $self->canon_make_attr("lib_$type", $libs{$type});
1734
if (my $libs = $self->modperl_libs) {
1821
if ($self->is_dynamic && (my $libs = $self->modperl_libpath)) {
1735
1822
print $fh $self->canon_make_attr('lib_location', $libs);
1737
1824
print $fh $self->canon_make_attr('ap_libdir',
1883
sub otherldflags_cygwin {
1885
my $flags = $self->otherldflags_default;
1887
unless ($self->{MP_STATIC_EXTS}) {
1888
$flags .= join ' ', '', $self->apru_link_flags;
1895
1971
my $self = shift;
1896
1972
my @typemaps = ();
2049
2125
# will have to make sure to prevent any operations that may rely on
2050
2126
# effects created by uselargefiles, e.g. Off_t=8 instead of Off_t=4)
2051
2127
sub strip_lfs {
2052
my($self, $cflags) = @_;
2128
my ($self, $cflags) = @_;
2053
2129
return $cflags unless $self->has_large_files_conflict();
2055
2131
my $lf = $Config{ccflags_uselargefiles}