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