1 use ExtUtils::MakeMaker;
5 # Suppress warnings about parameters we allow the user to specify.
6 $ExtUtils::MakeMaker::Recognized_Att_Keys{CPPFLAGS} = 1;
7 $ExtUtils::MakeMaker::Recognized_Att_Keys{CXX} = 1;
8 $ExtUtils::MakeMaker::Recognized_Att_Keys{CXXFLAGS} = 1;
9 $ExtUtils::MakeMaker::Recognized_Att_Keys{XAPIAN_CONFIG} = 1;
14 if ($srcdir =~ s!/([^/]*)$!!) {
15 # Set $0 to be just the leafname. If we don't, WriteMakefile() reruns this
16 # script for reasons unknown, leading to a seemingly infinite loop
17 # consuming increasing amounts of memory. With setting $0, it still reruns
18 # this script, but only once.
20 chomp($builddir = `pwd`);
29 if (/^XAPIAN_CONFIG=(.*)/) {
31 } elsif (/^CXX=(.*)/) {
33 } elsif (/^(C(?:XX|PP)FLAGS)=(.*)/) {
38 if (!defined $xapian_config && exists $ENV{XAPIAN_CONFIG}) {
39 $xapian_config = $ENV{XAPIAN_CONFIG};
40 push @ARGV, "XAPIAN_CONFIG=$xapian_config";
42 $xapian_config ||= 'xapian-config';
44 if (!defined $CC && exists $ENV{CXX}) {
46 push @ARGV, "CXX=$CC";
51 if ($^O eq 'cygwin' and $CC eq 'g++') {
52 # Cygwin packages of Perl < 5.9.5 used "ld2" for $Config{ld} and
53 # $Config{lddlflags} didn't contain -shared so we need to specify
54 # this explicitly. Perl >= 5.9.5 package do away with "ld2", but
55 # it should be harmless to specify "-shared" there.
59 my $xver = `$xapian_config --version`;
62 $xapian_config not found.
64 You need Xapian installed before you can build SymbolTest. If you have
65 installed Xapian from a package, you will also need to install the correspoding
66 -dev or -devel package. If Xapian is installed but xapian-config isn't on your
67 PATH you can tell Makefile.PL this by running it like so:
69 perl Makefile.PL XAPIAN_CONFIG=/path/to/xapian-config
71 # Perversely, the CPAN automatic testing script expects exit status 0 to
72 # indicate "can't build because of missing dependencies" (which it
73 # distinguishes from "all OK" by seeing if Makefile is generated). So we
74 # exit with status 0 in this case to avoid being spammed with useless
75 # "bug" reports from testers without Xapian installed.
79 $xver =~ s/.*\s//; # "xapian 1.2.0" -> "1.2.0"
81 my $inc = `$xapian_config --cxxflags`;
84 my @writemakefile_args = ();
86 my $libs = `$xapian_config --libs 2> /dev/null`;
88 my ($xapian_config_dir) = $xapian_config =~ /^(.*?)[^\/]*$/;
89 if ($? || ($xapian_config_dir ne '' && -f "${xapian_config_dir}Makefile")) {
90 # Assume we're being asked to build against an uninstalled xapian-core.
91 my $libtool = "${xapian_config_dir}libtool";
92 unless (-x $libtool) {
93 die "You've asked me to link against what appears to be an uninstalled xapian-core tree, but I can't find libtool in that tree\n";
96 # We can't pass a .la file in LIBS since MakeMaker "knows better" and
97 # ignores it. Passing it in LDLOADLIBS works, but generates a warning.
98 # We can avoid the warning by setting LDLOADLIBS using 'macro'.
100 $libs = `$xapian_config --ltlibs`;
102 $libs = {'LDLOADLIBS' => $libs};
103 $LD = "$libtool --tag=CXX --mode=link $CC -avoid-version -module";
104 $LD .= " -rpath \$(PERL_ARCHLIB)/auto/\$(FULLEXT)";
105 $LD .= " -shrext .".$Config{'dlext'};
106 $CC = "$libtool --tag=CXX --mode=compile $CC";
107 push @writemakefile_args, (
110 'FULLPERL' => '$(PERL) "-I$(INST_ARCHAUTODIR)/.libs"',
114 # Filter out some gcc options which g++ doesn't support.
115 my $CCFLAGS = $Config{'ccflags'};
116 # Perl is built with -Wdeclaration-after-statement on RHEL5 - this isn't
117 # meaningful for C++ - it only emits a warning but it's easy to fix.
118 $CCFLAGS =~ s/(?:^|\s+)-Wdeclaration-after-statement(?:\s+|$)/ /;
119 # The generated code causes "variable may be used uninitialized" warnings
120 # if Perl was built with -Wall.
121 $CCFLAGS =~ s/(^|\s+)-Wall(\s+|$)/$1-Wall -Wno-uninitialized$2/;
123 $CCFLAGS .= ' ' . $var{CPPFLAGS} if exists $var{CPPFLAGS};
124 $CCFLAGS .= ' ' . $var{CXXFLAGS} if exists $var{CXXFLAGS};
126 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
127 # the contents of the Makefile that is written.
128 push @writemakefile_args, (
129 'NAME' => 'SymbolTest',
130 'VERSION_FROM' => 'SymbolTest.pm', # finds $VERSION
131 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1
132 $libsvar => $libs, # e.g., '-lm'
133 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
135 'CCFLAGS' => $CCFLAGS,
137 'INC' => $inc, # e.g., '-I/usr/include/other'
138 'OBJECT' => '$(BASEEXT)$(OBJ_EXT)',
141 WriteMakefile(@writemakefile_args);