[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xerces-p-dev
Subject:    Re: [Stuart Denning] RE: XML::Xerces Installation on Solaris9
From:       jason () openinformatics ! com (Jason E !  Stewart)
Date:       2004-12-10 15:30:30
Message-ID: 87pt1ikwqh.fsf () openinformatics ! com
[Download RAW message or body]

> From: "Stuart Denning" <StuartD@ctsnet.co.uk>
> Subject: RE: XML::Xerces Installation on Solaris9
> To: "Jason E. Stewart" <jason@openinformatics.com>
> Date: Thu, 9 Dec 2004 12:11:27 -0000
>
> Thanks for your prompt reply previously.

You're welcome!

> I have reverted to using the source as suggested, and have built icu and
> xerces-c using the SUN Studio 8 compiler.

Ok. You indicated that you wanted to use gcc - I can guarantee that
xerces will compile and work fine with gcc, the rest I don't know.

> The resulting files I put into /usr/local/include (xercesc sub dir) and
> /usr/local/lib
>
> I set :
> 	$XERCES_INCLUDE=/usr/local/include
> and
> 	$XERCES_LIB=/usr/local/lib
> and
> 	$XERCESROOT is not set
> and
> 	
> $XERCES_CONFIG=/live/stuart/xerces-c-src_2_5_0/src/xercesc/config.status
>
> I run :
> 	Perl Makefile.PL
> Which tells me this :
> 	Using XERCES_LIB = /usr/local/lib
> 	Using XERCES_INCLUDE = /usr/local/include
> 	Using Xerces-C version info from
> /usr/local/include/xercesc/util/XercesVersion.h
> 	pp
> 	Checking to see if libxerces is in your library path...Success!!
> 	Using Xerces-C version: 2.5.0
> 	Processing hints file hints/solaris_2.pl
> 	Writing Makefile for Handler
> 	Writing Makefile for XML::Xerces

Oh how embarrassing...

You have just discovered that my code in Makefile.PL that reads the
required info from the config.status file only works if XERCESCROOT is
set...

Sorry. I'm including a patched Makefile.PL. Try it and you should get
better results.

> 	cc -c -I. -IHandler -I/usr/local/include -D_LARGEFILE_SOURCE -
> D_FILE_OFFSET_BITS
> 	=64 -xO3 -xdepend   -DVERSION=\"0.10\" -DXS_VERSION=\"0.10\"
> -KPIC -	I/usr/perl5/
> 	5.6.1/lib/sun4-solaris-64int/CORE  PerlCallbackHandler.cpp
> 	cc: No input file specified, no output generated
> 	make[1]: *** [PerlCallbackHandler.o] Error 1
> 	make[1]: Leaving directory
> `/live/stuart/XML-Xerces-2.5.0-0/Handler'
> 	make: *** [blib/arch/auto/Handler/Handler.a] Error 2
> which is the same as before

Correct 'cc' can't work - it is the C compiler and these are C++
files, but that is the default that is used if the config.status file
is not properly read.

Cheers,
jas.


["Makefile.PL" (application/x-perl)]

use ExtUtils::MakeMaker;
use Env qw(XERCES_LIB 
	   XERCES_CONFIG
	   XERCES_INCLUDE
	   XERCESCROOT
	   XERCES_DEVEL
	   SWIG);
use strict;
use vars qw($INCLUDES $CXX $CFLAGS @LDFLAGS @OPTIMIZE);
use File::Basename;

eval {
  require 5.6.0;
};
if ($@) {
  die <<ERROR;


    !!!WHOA!!!

You are using an *ancient* version of Perl. Because of the need to
support Unicode, XML::Xerces requires you upgrade to at least
v5.6.0. If you plan on using Unicode in your XML, you should really
upgrade to 5.7.2.

ERROR
}


if (defined $XERCES_LIB || defined $XERCES_INCLUDE) {
  # this is the default, so do nothing
} elsif (defined $XERCESCROOT) {
  # they are instructing us to use the build directories
  $XERCES_INCLUDE = "$XERCESCROOT/include";
  $XERCES_LIB = "$XERCESCROOT/lib";
} 

my $LIBS = '-lpthread';
$INCLUDES = '-I. -IHandler';
if (defined $XERCES_LIB) {
  print STDERR "Using XERCES_LIB = $XERCES_LIB\n";
  $LIBS .= " -L$XERCES_LIB ";
}

if (defined $XERCES_INCLUDE) {
  print STDERR "Using XERCES_INCLUDE = $XERCES_INCLUDE\n";
  $INCLUDES .= " -I$XERCES_INCLUDE";
}

if (!defined $XERCES_LIB && !defined $XERCES_INCLUDE) {
  print STDERR <<EOW;

   WARNING

You have not defined any of the following environment variables:
   XERCESCROOT
   XERCES_LIB
   XERCES_INCLUDE

These instruct me how to locate the Xerces header files, and the
Xerces dynamic library. If they are installed in a standard system
directory, I will located them without those variables.

However, if they have been installed in a non-standard location
(e.g. '/usr/include/xerces'), then I will need help. See the README
for more info.

Proceeding ...
EOW
}

my $config_file = 'config.status';
my $CXXFLAGS;
my $LDFLAGS;
if (defined $XERCES_CONFIG) {
  unless (-f $XERCES_CONFIG) {
  print STDERR <<EOW;

   WARNING

You have defined the XERCES_CONFIG variable, but it does not seem to
point to the $config_file file that was used to build your
Xerces-C. Without that file, I may not be able to properly build the
C++ glue files that come with Xerces.pm.

Proceeding ...
EOW
  }
} elsif (defined $XERCESCROOT) {
  $XERCES_CONFIG = "$XERCESCROOT/src/xercesc/$config_file";
  unless (-f $XERCES_CONFIG) {
    print STDERR <<EOW;

   WARNING

You have defined the XERCESCROOT variable, but I am unable to locate
the $config_file file that was used to build your Xerces-C. It is
supposed to be located at: $XERCES_CONFIG

Without that file, I may not be able to properly build the C++ glue
files that come with Xerces.pm.

Proceeding ...
EOW
  }
} else {
  print STDERR <<EOW;

   WARNING

You have not defined any of the following environment variables:
   XERCESCROOT
   XERCES_CONFIG

Without these I cannot find the $config_file file that was used to
build your Xerces-C. Without that file, I may not be able to properly
build the C++ glue files that come with Xerces.pm.

Proceeding ...
EOW
}

if ($XERCES_CONFIG) {
  print STDERR "using config file: $XERCES_CONFIG\n";
  open(CONF,$XERCES_CONFIG)
    or die "Couldn't open $XERCES_CONFIG for reading";
  while (<CONF>) {
    if (/\@CXXFLAGS\@/) {
      my ($flags) = /%([^%]*)%g$/;
      my @flags = split /\s+/, $flags;
      my @new_flags;
      foreach my $flag (@flags) {
	if ($flag =~ /^(-(g|O).?)$/) {
	  @OPTIMIZE = (OPTIMIZE => $1);
	  next;
	} elsif ($flag =~ /^-DPROJ_/) {
	  next;
	}
	push(@new_flags,$flag);
      }
      ($CXXFLAGS) = join(' ',@new_flags);
    } elsif (/\@LDFLAGS\@/) {
      ($LDFLAGS) = /%([^%]*)%g$/;
      @LDFLAGS = ('LDFLAGS'     => $LDFLAGS)
	if $LDFLAGS !~ /^\s*$/;
    } elsif (/\@CXX\@/) {
      ($CXX) = /%([^%]*)%g$/
    }
  }
  print STDERR <<EOM;

Found CXX      = $CXX
Found CXXFLAGS = $CXXFLAGS
Found LDFLAGS  = $LDFLAGS
EOM
}

$CFLAGS .= " $CXXFLAGS ";

# We need to know which version of libxerces we are to use.
# As of Xerces-C 1.5.1, minor version numbers are used
my $XERCES_MAJOR_VERSION = '2.5';
my $XERCES_MINOR_VERSION = '0';
my $XERCES_LIB_VERSION = "$XERCES_MAJOR_VERSION.$XERCES_MINOR_VERSION";
my $XERCES_PERL_VERSION = $XERCES_LIB_VERSION . '-0';
my $XERCES_VERSION = "$XERCES_LIB_VERSION";

# find the version of Xerces-C we are using
my $file_name = 'XercesVersion.hpp';
my $file = "$XERCES_INCLUDE/xercesc/util/$file_name";
open(VERSION,$file)
  or die "Couldn't find $file_name in your include directory $XERCES_INCLUDE";
print STDERR "Using Xerces-C version info from $file\n";
my ($major,$minor,$rev);
while (<VERSION>) {
  next unless /^\#define\s+XERCES_VERSION_/;
  if (/MAJOR\s+(\d)/) {
    $major = $1;
  } elsif (/MINOR\s+(\d)/) {
    $minor = $1;
  } elsif (/REVISION\s(\d)/) {
    $rev = $1;
  }
}
die "Couldn't find Xerces-C MAJOR version"
  unless defined $major;
die "Couldn't find Xerces-C MINOR version"
  unless defined $minor;
die "Couldn't find Xerces-C REVISION version"
  unless defined $rev;

my $XERCES_C_VERSION = "$major.$minor.$rev";

die <<EOE if $XERCES_VERSION ne $XERCES_C_VERSION;
      *** Version Mismatch ***

You are attempt to build XML::Xerces-$XERCES_PERL_VERSION using \
Xerces-C-$XERCES_C_VERSION, this will most likely fail, so I am aborting. 

You must use Xerces-C-$XERCES_LIB_VERSION

EOE

# this substitution will yield '1_4' from '1.4' to be used by 'LIBS'
# $XERCES_LIB_VERSION =~ s/\./_/g;
my $LIBXERCES = "-lxerces-c";
if ($^O eq 'cygwin') {
  $LIBXERCES .= "$major$minor.dll";
} elsif ($^O eq 'MSWin32') {
  $LIBXERCES = "-lxerces-c_2";
}
$LIBS .= " $LIBXERCES";

# now we ensure that libxerces is in the library path
# if not we die()
print STDERR "Checking to see if libxerces is in your library path...";
my $lib = 1;
#($lib) = MM->new->ExtUtils::Liblist::ext($LIBS);

die <<EOE unless $lib;


    !!!WHOA!!!

I couldn\'t find $LIBXERCES anywhere in your library path. Begging to
differ with perl, this is most assuredly *NOT* harmless. This is a
critical error that will prevent you from running Xerces.pm.

Check your settings of \$XERCES_INCLUDE and \$XERCES_LIB, and rerun
'perl Makefile.PL'

EOE

print STDERR "Success!!\n";

# give some nice feedback for the user
print STDERR "Using Xerces-C version: $XERCES_VERSION\n";

my $HANDLER_LIB = '$(INST_ARCHLIB)/auto/Handler/Handler$(LIB_EXT)';

sub MY_postamble {
qq[

$HANDLER_LIB:
	\$(MAKE) -C Handler static
];

}
*MY::postamble = \&MY_postamble;

my @MACRO;
$CFLAGS .= '-D_REENTRANT';

# we only consider using SWIG if we are a Xerces Developer
if ($XERCES_DEVEL) {
  # replace this with the path to your Unix compatible find application
  my $FIND = 'find';

  # set up the custom headers
  my @header_files;
  my @handler_headers;
  chomp(@handler_headers = `$FIND Handler -name "*.swig.hpp"`);

  sub Xerces_postamble {
    chomp(my @import_files = `$FIND Handler -name "*.i"`);
    push(@header_files,@handler_headers,@import_files);
    local $" = ' ';
    my $OS_DEF;
    my $CC_DEF;
    if ($^O eq 'linux') {
      $OS_DEF = '-DXML_LINUX';
    } elsif($^O eq 'darwin') {
      $OS_DEF = '-DXML_MACOSX';
    } else {
      die 'unsupported operating system';
    }
    if ($CXX =~ /g\+\+/) {
      $CC_DEF = '-DXML_GCC';
    } else {
      die 'unsupported compiler';
    }
    my $SWIG_ARGS = qq[-Wall $OS_DEF $CC_DEF -DXERCES_VERSION="$XERCES_PERL_VERSION" \
\$(INC) -perl5 -c++ -shadow];

    my $MAKE = '	\$(MAKE) -C Handler static';
    if ($^O eq 'MSWin32') {
      # nmake doesn't not honor '-C'
      $MAKE =  '	cd Handler && \$(MAKE) static';
    }

    my $retval = <<TERMINUS;
Xerces.cpp: Xerces.i typemaps.i @header_files postSource.pl 
	\$(SWIG) $SWIG_ARGS -o Xerces.cpp Xerces.i
	perl postSource.pl Xerces.cpp
	perl postModule.pl Xerces.pm


Xerces.pm: Xerces.cpp postModule.pl Xerces-extra.pm
	if [[ postModule.pl -nt Xerces.pm || Xerces-extra.pm -nt Xerces.pm ]] ; then \\
\$(SWIG) $SWIG_ARGS -o foo.C Xerces.i ; \\
rm foo.C ; \\
perl postModule.pl Xerces.pm ; \\
cp -f Xerces.pm blib/lib/XML ; \\
	fi

$HANDLER_LIB:
$MAKE
TERMINUS
    return $retval;
  }

  print STDERR "Welcome Xerces Developer!\n";
  # if we're to use SWIG, we need to know which version is available
  my $swig = $SWIG || 'swig';
  @MACRO = ('macro'       => {
    'SWIG'         => "$swig",
  });

  # we'll assume that we want -g as a default
  #  @OPTIMIZE = (OPTIMIZE => '-g');

  # we want all warnings
  $CFLAGS .= ' -Wall';
#  print STDERR "Using SWIG version: SWIG_$ {sv_maj}_$ {sv_min}\n";
  *MY::postamble = \&Xerces_postamble;
}

# set up the list of object files to include in Xerces\$(OBJ_EXT)
my $OBJS = 'Xerces$(OBJ_EXT)';

# write the makefile
# see the hints/ directory for architecture specific stuff!
WriteMakefile(
  'NAME'        => 'XML::Xerces',
  'AUTHOR'      => 'The Xerces-P developers: xerces-p-dev@xml.apache.org',
  'ABSTRACT'    => 'Perl Interface for Xerces XML API',
  'CC'          => $CXX,
  'CCFLAGS'     => $CFLAGS,
  'PM'          => {
    'Xerces.pm' => '$(INST_LIB)/XML/Xerces.pm',
  },
  'INC'         => $INCLUDES,
  'MYEXTLIB'    => $HANDLER_LIB,
  'LIBS'        => [$LIBS],
  'OBJECT'      => $OBJS,
  'VERSION'     => "$XERCES_PERL_VERSION",
  @OPTIMIZE,
  @MACRO,
  @LDFLAGS,
);



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic