use File::Copy; use Cwd; use Config; BEGIN { eval { require File::Spec::Functions ; File::Spec::Functions->import( qw(catfile rel2abs) ) } ; *catfile = sub { return join( '/', @_ ) } if $@; } require VMS::Filespec if $^O eq 'VMS'; sub dump_block { my %block; ( $block{1}, $block{2} ) = @_; for ( my $i=0; $i) { print STDERR $_; } close($in); } } our $BZLIB_BIN ; our $BZLIB_LIB ; our $BZLIB_INCLUDE ; our $BUILD_BZLIB ; sub ParseCONFIG { my $CONFIG = shift || 'config.in' ; my ($k, $v) ; my @badkey = () ; my %Info = () ; my @Options = qw( BZLIB_INCLUDE BZLIB_LIB BUILD_BZLIB BZLIB_BIN ) ; my %ValidOption = map {$_, 1} @Options ; my %Parsed = %ValidOption ; my $debugf = 0; print STDERR "Parsing $CONFIG...\n" if $debugf; if (!open(F, "<$CONFIG")) { warn "warning: failed to open $CONFIG: $!\n"; } else { while () { chomp; s/#.*$//; next if !/\S/; ($k, $v) = split(/\s*=\s*/, $_, 2) ; $k = uc $k ; if ($ValidOption{$k}) { delete $Parsed{$k} ; $Info{$k} = $v ; } else { push(@badkey, $k) ; } } close F ; } print STDERR "Unknown keys in $CONFIG ignored [@badkey]\n" if $debugf && scalar(@badkey) ; $BZLIB_INCLUDE = $ENV{'BZLIB_INCLUDE'} || $Info{'BZLIB_INCLUDE'} ; $BZLIB_LIB = $ENV{'BZLIB_LIB'} || $Info{'BZLIB_LIB'} ; $BZLIB_BIN = $ENV{'BZLIB_BIN'} || $Info{'BZLIB_BIN'} ; if ($^O eq 'VMS') { $BZLIB_INCLUDE = VMS::Filespec::vmspath($BZLIB_INCLUDE); $BZLIB_LIB = VMS::Filespec::vmspath($BZLIB_LIB); $BZLIB_BIN = VMS::Filespec::vmspath($BZLIB_BIN); } my $x = defined($ENV{BUILD_BZLIB}) ? $ENV{BUILD_BZLIB} : $Info{BUILD_BZLIB}; $x = 'Test' if !defined($x); if ( $x =~ /^yes|on|true|1$/i ) { $BUILD_BZLIB = 1; print STDERR "Building internal libbz2 enabled\n" if $debugf ; } elsif ( $x =~ /^test$/i ) { undef $BUILD_BZLIB; ## prefix libpth locincpth my $command = $Config{cc} . ' '. $Config{ccflags} . ( $BZLIB_INCLUDE ? " -I$BZLIB_INCLUDE" : '' ) . ' '. $Config{ldflags} . ' -o show_bzversion show_bzversion.c' . ( $BZLIB_LIB ? " -L$BZLIB_LIB" : '' ) . ' -lbz2' . ($^O eq 'MSWin32' ? ' 2>nul' : ' 2>/dev/null'); #print STDERR "command $command\n"; if ( !system( $command ) ) { if ( -x 'show_bzversion' && -s 'show_bzversion' ) { my $version = `./show_bzversion`; if ( $version ) { chomp $version; $BUILD_BZLIB = 0; print STDERR "found bzip2 $version ".($BZLIB_LIB ? "in $BZLIB_LIB" : 'installed')."\n" if $debugf; } else { $BUILD_BZLIB = 1; print STDERR "compile command '$command' failed\n" if $debugf; print STDERR "system bzip2 not useable, building internal libbz2\n" if $debugf; } } else { $BUILD_BZLIB = 1; print STDERR "compile command '$command' failed\n" if $debugf; print STDERR "system bzip2 not useable, building internal libbz2\n" if $debugf; } } else { $BUILD_BZLIB = 1; print STDERR "compile command '$command' failed\n" if $debugf; print STDERR "system bzip2 not found, building internal libbz2\n" if $debugf; } } print STDERR <