PageRenderTime 67ms CodeModel.GetById 59ms app.highlight 1ms RepoModel.GetById 5ms app.codeStats 1ms

/build-extras/2008.1-odin/DBD-DB2.Makefile.PL

https://code.google.com/p/camelbox/
Perl | 178 lines | 134 code | 29 blank | 15 comment | 21 complexity | d575956a40d36f0ef2f5c08e0a23e922 MD5 | raw file
  1
  2#   engn/perldb2/Makefile.PL, engn_perldb2, db2_v82fp9, 1.11 04/09/14 10:47:41
  3#
  4#   Copyright (c) 1995-2004 International Business Machines Corp.
  5#
  6#!/usr/local/bin/perl -sw
  7
  8use ExtUtils::MakeMaker qw(&WriteMakefile $Verbose );
  9use Getopt::Std;
 10use Config;
 11require 'flush.pl';
 12
 13use DBI;        # The DBI must be installed before we can build a DBD
 14
 15my %opts = (
 16    'NAME'         => 'DBD::DB2',
 17    'VERSION_FROM' => 'DB2.pm',
 18    ($] ge '5.005')
 19       ? ( 'AUTHOR' => 'DB2 Perl (db2perl@ca.ibm.com)',
 20           'ABSTRACT' => 'Perl driver for IBM DB2 Universal Database', )
 21       : (),
 22    ( $Config{archname} =~ /-object\b/i )
 23       ? ( 'CAPI' => 'TRUE', )
 24       : (),
 25    'OBJECT'       => '$(O_FILES)',
 26);
 27
 28# --- Introduction
 29
 30print "\nConfiguring DBD::DB2...\n";
 31print "Remember to actually read the README and CAVEATS files!\n\n";
 32
 33# --- Operating system
 34
 35my $os = $^O;
 36
 37# --- Where is DB2 installed...
 38
 39my $envvar = 'DB2_HOME';
 40my $DB2 = $ENV{$envvar};
 41if( not $DB2 )
 42{
 43  $envvar = 'DB2PATH';
 44  $DB2 = $ENV{$envvar};
 45}
 46if( not $DB2 )
 47{
 48  my ($pathsep, $path, @pathlist);
 49
 50  $pathsep = $Config{'path_sep'};
 51  $pathsep = ':' unless $pathsep;
 52
 53  $path = $ENV{'PATH'};
 54  $path =~ s:\\:/:g if $pathsep eq ';';
 55
 56  @pathlist = split /$pathsep/, $path;
 57  foreach $path (@pathlist)
 58  {
 59    if( lc( substr( $path, -4 ) ) eq '/bin' &&
 60        -f "$path/../include/sqlcli.h" )
 61    {
 62      $DB2 = substr( $path, 0, -4 );
 63      last;
 64    }
 65  }
 66}
 67$DB2 =~ s:\\:/:g if $os eq 'MSWin32' || $os eq 'MSWin64' || $os eq 'os2';
 68$DB2 =~ s/"//g;
 69die "DB2_HOME environment variable must be set to installed location of DB2.\n"
 70    unless $DB2;
 71die "$envvar environment variable ($DB2) not valid.\n" unless -d $DB2;
 72
 73print qq(Using DB2 in "$DB2"\n);
 74
 75# --- Setup include paths and libraries
 76$opts{INC} .= qq(-I"$DB2/include" -I"$Config{sitearch}/auto/DBI" );
 77$opts{INC} .= qq(-I"$Config{vendorarch}/auto/DBI") if $Config{vendorarch};
 78$opts{dynamic_lib} = { OTHERLDFLAGS => '$(COMPOBJS) '};
 79
 80# libraries required to build DBD::DB2 driver
 81if( $os eq 'MSWin32' || $os eq 'MSWin64' || $os eq 'os2' )
 82{
 83  my $DB2LIB = $ENV{'DB2LIB'};
 84  if( not $DB2LIB )
 85  {
 86    if (-e "$DB2/lib64")
 87    {
 88      $DB2LIB = "$DB2/lib64";
 89    }
 90    else
 91    {
 92      if (-e "$DB2/lib32")
 93      {
 94         $DB2LIB = "$DB2/lib32";
 95      }
 96      else
 97      {
 98        $DB2LIB = "$DB2/lib";
 99      }
100    }
101  }
102  $sysliblist = qq(-L"$DB2LIB" db2cli.lib db2api.lib);
103  my @libpaths = split /;/, $ENV{'LIB'};
104  my $libpath;
105  while( @libpaths )
106  {
107    ( $libpath = shift(@libpaths) ) =~ s/"//g;  # Remove quotes
108    $libpath =~ s:\\:/:g;
109
110    if( $libpath && $sysliblist !~ /-L"$libpath"/i )
111    {
112      $sysliblist .= qq( -L"$libpath");
113    }
114  }
115}
116else
117{
118  my $DB2LIB = $ENV{'DB2LIB'};
119  if( not $DB2LIB )
120  {
121    if (-e "$DB2/lib64")
122    {
123      $DB2LIB = "$DB2/lib64";
124    }
125    else
126    {
127      if (-e "$DB2/lib32")
128      {
129         $DB2LIB = "$DB2/lib32";
130      }
131      else
132      {
133        $DB2LIB = "$DB2/lib";
134      }
135    }
136  }
137      
138  $sysliblist = "-L$DB2LIB -ldb2";
139
140}
141
142# --- Handle special cases ---
143if ($os eq 'hpux')
144{
145  $sysliblist .= ' -lcl';
146  $opts{DEFINE} .= ' +e';
147}
148
149#Defining a macro to fix the compile issue in DBD::DB2  
150#which was due to change in definition of DBIc_CACHED_KIDS in DBIv1.55  
151 
152#if( $DBI::VERSION > 1.54 )
153if( "$DBI::VERSION" ge "1.55" )
154{
155   $opts{DEFINE} .= ' -DDB2_CACHE_FIX ';
156}
157
158$opts{LIBS} = [ $sysliblist ];
159
160# log key platform information to help me help you quickly
161print "System: perl$] DBI$DBI::VERSION @Config{qw(myuname archname dlsrc)}\n";
162print "Compiler: @Config{qw(cc optimize ccflags)}\n";
163print "Includes: $opts{INC}\n";
164print "Libraries: @{$opts{LIBS}}\n";
165print "\n";
166
167WriteMakefile(%opts);
168
169exit 0;
170
171
172sub MY::post_initialize{
173'
174default_target: all
175';
176}
177
178__END__