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 = $_ ; } }