DBD-Oracle
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
}
else {
$linkvia = '$(PROLDLIBS)';
}
}
elsif (!$linkvia && int($mkver) == 1) {
if ($MK{LLIBOCIC}) {
$linkvia = '$(LLIBOCIC) $(TTLIBS)';
} else {
print "WARNING: Guessing what to link with.\n";
$linkvia = '-locic $(TTLIBS)'; # XXX GUESS HACK
}
}
elsif (!$linkvia && $MK{CCLIB}) { # Oracle XE
$linkvia = '$(CCLIB)';
}
unless ($linkvia){
die "ERROR parsing $file: Unable to determine what to link with.\n"
."Please send me copies of these files (one per mail message):\n@mkfiles\n";
}
$MK_TEXT = join("\n", @MK);
return $linkvia;
}
sub read_inc_file {
my $file = shift;
my $fh;
unless ($fh = new FileHandle "<$file") {
# Workaround more oracle bungling (Oracle 7.3.2/Solaris x86)
my $alt; ($alt = $file) =~ s/\.dk\.mk$/\.mk/;
$fh = new FileHandle "<$alt";
die "Unable to read $file: $!" unless $fh;
}
print "Reading $file\n";
my @lines;
push(@mkfiles, $file);
while(<$fh>) {
# soak up while looking for include directives
push(@lines, $_), next
unless /^\s*include\s+(.*?)\s*$/m;
my $inc_file = $1;
# deal with "include $(ORACLE_HOME)/..."
# (can't use expand_mkvars() here)
$inc_file =~ s/\$\((ORACLE_HOME|ORACLE_ROOT)\)/$ENV{$ORACLE_ENV}/og;
push(@lines, read_inc_file($inc_file));
}
print "Read a total of ".@lines." lines from $file (including inclusions)\n" if $::opt_v;
return @lines;
}
my %expand_shellescape;
sub expand_shellescape {
my($orig, $level) = @_;
my $cmd = $orig;
my $debug = $::opt_d || $::opt_v;
print "Evaluating `$orig`\n"
if $debug && !$expand_shellescape{$orig};
# ensure we have no $(...) vars left - strip out undefined ones:
$cmd =~ s/\$[({](\w+)[})]/mkvar("$1", 1, 0, $level+1)/ge;
print " expanded `$cmd`\n" if $debug and $cmd ne $orig;
my $result = `$cmd`;
$result =~ s/\s+$/ /; # newlines etc to single space
print " returned '$result'\n"
if $debug && !$expand_shellescape{$orig};
$expand_shellescape{$orig} = $result;
$result;
}
sub expand_mkvars {
my ($string, $strip, $backtick, $level, $maxlevel) = @_;
return if(!defined $string);
$level ||= 1;
local($_) = $string;
print "$level Expanding $_\n" if $::opt_d;
# handle whizzo AIX make feature used by Oracle
s/\$[({] (\w+) \? ([^(]*?) : ([^(]*?) [})]/
my ($vname, $vT, $vF) = ($1,$2,$3);
$MK{$vname} = (mkvar($vname, 1, $backtick, $level+1)) ? $vT : $vF
/xge; # can recurse
s/\$[({] (\w+) [})]/
mkvar("$1", $strip, $backtick, $level+1, $maxlevel)
/xge; # can recurse
s/`(.*?[^\\])`/expand_shellescape("$1", $level+1)/esg if $backtick; # can recurse
s/\s*\\\n\s*/ /g; # merge continuations
s/\s+/ /g; # shrink whitespace
print "$level Expanded $string\n to $_\n\n" if $::opt_d and $_ ne $string;
$_;
}
sub mkvar {
my($var, $strip, $backtick, $level, $maxlevel) = @_;
my $default = $strip ? '' : "\$($var)";
print "$level Variable: $var\n" if $::opt_d;
return '$(LIBHOME)' if $var eq 'LIBHOME' && !$strip; # gets noisy
return $ENV{$ORACLE_ENV} if $var eq 'ORACLE_HOME';
my $val = $MK{$var};
if (!defined $val and exists $ENV{$var}) {
$val = $ENV{$var};
print "Using value of $var from environment: $val\n"
unless $var eq 'LD_LIBRARY_PATH';
}
return $default unless defined $val;
if ($MK_expanding{$var}) {
print "Definition of \$($var) includes \$($var).\n";
return "\$($var)";
}
local($MK_expanding{$var}) = 1;
return $val if $maxlevel && $level >= $maxlevel;
return expand_mkvars($val, $strip, $backtick, $level+1, $maxlevel); # can recurse
}
sub read_file {
my $file = shift;
unless (open(ROL, "<$file")) {
warn "WARNING: Unable to open $file: $!\n";
return "";
}
my $text = join "", <ROL>;
$text =~ s/\n+/ /g;
close ROL;
return $text;
}
sub find_bin{
my $bin = shift;
my $path_sep = $Config{path_sep};
foreach (split(/\Q$path_sep/, $ENV{PATH})){
return "$_/$bin" if -x "$_/$bin";
{
# let's try harder
# see rt#84530 for why we don't go straight for it
use filetest 'access';
return "$_/$bin" if -x "$_/$bin";
}
}
return undef;
}
( run in 2.149 seconds using v1.01-cache-2.11-cpan-5735350b133 )