1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
use File::Spec ;
use File::Find ;
use Cwd ;
$win32 = ($^O eq 'MSWin32') ;
if (!$win32)
{
$path = $ENV{XALANPATH} || GetString ("Enter path of XALAN base directory or single dot for not using XALAN", $XALANPATH || '.') ;
if (!$path || $path eq '.')
{
print "Xalan will not be linked into Embperl\n" ;
return undef ;
}
if (!-f "$path/src/XalanTransformer/XalanTransformer.hpp")
{
if (!-f "$path/c/src/XalanTransformer/XalanTransformer.hpp")
{
if (!-f "$path/xml-xalan/c/src/XalanTransformer/XalanTransformer.hpp")
{
print "Xalan sources not found\n" ;
return undef ;
}
else
{
$path = "$path/xml-xalan/c/" ;
}
}
else
{
$path = "$path/c/" ;
}
}
$path = File::Spec -> canonpath ($path) ;
my $currdir = Cwd::fastcwd ;
eval { find (\&xalanlib, $win32?"$path/Build":"$path/lib") ; } ;
$@ = '' ;
chdir ($currdir);
if (!$xalanlib)
{
print "Xalan library not found under $path\n" ;
return undef ;
}
my $xpath = Cwd::fast_abs_path ("$path/../..") ;
eval { find (\&xerceslib, $xpath) ; } ;
$@ = '' ;
chdir ($currdir);
if (!$xerceslib)
{
print "Xerces library not found under $xpath/../..\n" ;
return undef ;
}
$xalanlibpath = File::Spec -> canonpath ($xalanlibpath) ;
$xerceslibpath = File::Spec -> canonpath ($xerceslibpath) ;
print "Found Xalan library $xalanlib at $xalanlibpath\n" ;
print "Found Xerces library $xerceslib at $xerceslibpath\n" ;
my $platform ;
my $cpp ;
my $cppflags ;
my $makefile = "$path/src/Makefile" ;
my $extralibs = '' ;
if (-f $makefile)
{
$platform = search_config ('PLATFORM', $makefile) ;
$cpp = search_config ('CXX', $makefile) ;
$cppflags = search_config ('CXXFLAGS', $makefile) ;
$extralibs = '-lCrun -lCstd' if ($platform eq 'SOLARIS' && $cpp eq 'CC') ;
print "Found XALAN was build for '$platform', C++ Compiler is $cpp, with flags $cppflags\n" ;
}
else
{
print "Makefile for XALAN not found. Assuming prebuild version using defaults\n" ;
print "!!! NOTE: If you get compiler errors when build epxalan.cpp, try to build\n" ;
print "!!! XALAN from the sources. See INSTALL.pod\n\n" ;
}
my $pathsrc = File::Spec -> canonpath ("$path/src") ;
my $xercesinc = File::Spec -> canonpath ("$xerceslibpath/../include") ;
my ($l1, $l2) = "$xalanlib $xerceslib" =~ /^lib(.*?)\.so(?:\.\d+)? lib(.*?)\.so(?:\.\d+)?$/ ;
($l1, $l2) = "$xalanlib $xerceslib" =~ /^(xalan.*?\.lib) (xerces.*?\.lib)$/i if ($win32) ;
print "Somethings is wrong with library names ($l1, $l2)\n" if (!$l1 || !$l2) ;
return { cflags => "-I\"$pathsrc\" -I\"$xercesinc\" -D_REENTRANT " ,
cpp => $cpp,
cppflags => $cppflags,
libs => "-L\"$xalanlibpath\" -L\"$xerceslibpath\" -l$l1 -l$l2 $extralibs",
defines => '-DXALAN' . ($platform?" -D$platform":'') ,
objects => 'driver/epxalan$(OBJ_EXT)',
save => { '$XALANPATH' => $path }} ;
}
print "Xalan is currently not supported on Win32\n" ;
return undef ;
sub xalanlib
{
if ($File::Find::dir =~ m#/\.#)
{
$File::Find::prune = 1 ;
return ;
}
if ((!$win32 && (/^libxalan.*\.so/)) ||
($win32 && (/^xalantransformer.*\.lib/i)) )
{
$xalanlibpath = $File::Find::dir ;
die $xalanlib = $_ ;
}
}
sub xerceslib
{
if ($File::Find::dir =~ m#/\.#)
{
$File::Find::prune = 1 ;
return ;
}
if ((!$win32 && (/^libxerces.*\.so/)) ||
($win32 && (/^xerces.*\.lib/i)) )
{
$xerceslibpath = $File::Find::dir ;
die $xerceslib = $_ ;
}
}
|