-
Notifications
You must be signed in to change notification settings - Fork 34
/
Makefile.PL
executable file
·2045 lines (1677 loc) · 68.9 KB
/
Makefile.PL
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
## Makefile.PL for DBD::Oracle - see README file for more information.
# Copyright (c) 1994-2006 Tim Bunce. Ireland.
# Copyright (c) 2006-2008 John Scoles (The Pythian Group). Canada.
use 5.6.0;
use strict;
use warnings;
use ExtUtils::MakeMaker 5.16, qw(&WriteMakefile $Verbose);
use Getopt::Long;
use Config;
use Cwd;
use File::Find;
use Pod::Usage;
# DBI must be installed before we can build a DBD.
# For those not using Dynamic loading this means building a
# new static perl in the DBI directory by saying 'make perl'
# and then using _that_ perl to make this one.
use DBI 1.51;
use DBI::DBD; # DBD creation tools
# Some MakeMaker's forged some FileHandle methods
require FileHandle unless defined &FileHandle::new;
BEGIN {
return unless $^O eq 'VMS';
eval q{
use vmsish;
use VMS::Filespec;
1;
} or die $@;
}
my $dbi_arch_dir = dbd_dbi_arch_dir();
my $so = $Config{so}; # typically 'so', 'dylib' on Darwin/OSX
my $osvers = $Config{osvers}; $osvers =~ s/^\s*(\d+\.\d+).*/$1/; # drop sub-sub-version: 2.5.1 -> 2.5
my $exe_ext = ($^O eq 'VMS') ? '.pl' : '';
my $BELL = "\a";
# put this here as it might change
$| = 1;
my %opts = (
NAME => 'DBD::Oracle',
VERSION_FROM => 'Oracle.pm',
PREREQ_PM => { "Test::Simple" => 0.90, # actually Test::More pkg in T::S dist
"DBI" => 1.51},
OBJECT => '$(O_FILES)',
DEFINE => '',
DIR => [],
clean => { FILES => 'xstmp.c Oracle.xsi dll.base dll.exp sqlnet.log libOracle.def mk.pm DBD_ORA_OBJ.*' },
dist => {
DIST_DEFAULT => 'clean distcheck disttest tardist',
PREOP => '$(MAKE) -f Makefile.old distdir',
COMPRESS => 'gzip -v9', SUFFIX => 'gz',
},
META_MERGE => {
configure_requires => { "DBI" => '1.51' },
build_requires => {"DBI" => '1.51',
"ExtUtils::MakeMaker" => 0,
"Test::Simple" => '0.90'},
resources => {
bugtracker => {
mailto => 'bug-dbd-oracle at rt.cpan.org',
web =>
'http://rt.cpan.org/Public/Dist/Display.html?Name=DBD-Oracle',
},
homepage => 'http://search.cpan.org/dist/DBD-Oracle',
repository => {
type => 'git',
url => 'git://github.com/yanick/DBD-Oracle.git',
web => 'http://github.com/yanick/DBD-Oracle/tree',
},
},
},
);
my $eumm = $ExtUtils::MakeMaker::VERSION;
$eumm =~ tr/_//d;
if ($eumm >= 5.43) {
$opts{AUTHOR} = 'Tim Bunce ([email protected])';
$opts{ABSTRACT_FROM} = 'Oracle.pm';
$opts{PREREQ_PM} = { DBI => 1.51 };
$opts{CAPI} = 'TRUE' if $Config{archname} =~ /-object\b/i;
}
$opts{LICENSE} = 'perl' if $eumm >= 6.3002;
$opts{CCFLAGS} = "-P $Config{ccflags}" if $Config{cc} eq 'bcc32'; # force C++
$opts{LINKTYPE} = 'static' if $Config{dlsrc} =~ /dl_none/;
my(@MK, %MK, $MK_TEXT, %MK_expanding); # parsed macros from Oracle's makefiles
my %mk_target_deps;
my %mk_target_rules;
=head1 OPTIONS
=over
=item -b
Try to use Oracle's own 'build' rule. Defaults to true.
=item -r
With I<-b>, use this names build rule (eg -r=build64).
=item -m
Path to 'oracle.mk'
=item -h
Path to oracle header files.
=item -p
Alter preference for oracle.mk.
=item -n
Oracle .mk macro name to use for library list to link with.
=item -c
Don't encourage use of shared library.
=item -l
Try direct-link to libclntsh.
=item -g
Enable debugging (-g for compiler and linker).
=item -s
Find a symbol in oracle libs, Don't build a Makefile.
=item -S
Find a symbol in oracle & system libs, Don't build a Makefile.
=item -v
Be more verbose.
=item -d
Much more verbose for debugging.
=item -f
Include text of oracle's .mk file within generated Makefile.
=item -F
Force - ignore errors.
=item -W
Just write a basic default Makefile (won't build).
=item -w
Enable many gcc compiler warnings.
=item -V
Force assumption of specified Oracle version
If == 8 then we don't use the new OCI_INIT code
and we force our emulation of OCILobWriteAppend.
=back
=cut
# Options (rarely needed)
# to turn off an option prefix with 'no', ie 'perl Makefile.PL -nob'
#$::opt_ic10 = 1; # Build for Oracle 10g instantclient
$::opt_b = 1; # try to use Oracle's own 'build' rule
$::opt_r = ''; # With -b above, use this names build rule (eg -r=build64)
$::opt_m = ''; # path to oracle.mk file to read
$::opt_h = ''; # path to oracle header files
$::opt_p = ''; # alter preference for oracle.mk
$::opt_n = ''; # Oracle .mk macro name to use for library list to link with
$::opt_c = 0; # don't encourage use of shared library
$::opt_l = 0; # try direct-link to libclntsh
$::opt_g = ''; # enable debugging (-g for compiler and linker)
$::opt_s = ''; # Find a symbol in oracle libs, Don't build a Makefile
$::opt_S = ''; # Find a symbol in oracle & system libs, Don't build a Makefile
$::opt_v = 0; # be more verbose
$::opt_d = 0; # much more verbose for debugging
$::opt_f = 0; # include text of oracle's .mk file within generated Makefile
$::opt_F = 0; # force - ignore errors
$::opt_W = 0; # just write a basic default Makefile (won't build)
$::opt_w = 0; # enable many gcc compiler warnings
$::opt_V = 0; # force assumption of specified Oracle version
# If == 8 then we don't use the new OCI_INIT code
# and we force our emulation of OCILobWriteAppend
Getopt::Long::config( qw( no_ignore_case ) );
GetOptions(qw(b! r=s v! d! g! p! l! c! f! F! W! w! m=s h=s n=s s=s S=s V=s ))
or die pod2usage( -verbose => 99, -sections => [ 'OPTIONS' ] );
$::opt_g &&= '-g'; # convert to actual string
$::opt_v = 1 if $::opt_d;
$Verbose = 1 if $::opt_v;
my $is_developer = (-d ".svn" && -f "MANIFEST.SKIP");
if ($::opt_W) {
open MK_PM, ">/dev/null" or die "Unable to create 'mk.pm': $!";
exit WriteMakefile( dbd_edit_mm_attribs(\%opts) )
}
# --- Introduction
print qq{
Configuring DBD::Oracle for perl $] on $^O ($Config{archname})
Remember to actually *READ* the README file! Especially if you have any problems.
} unless $::opt_s;
# --- Where is Oracle installed...
my $ORACLE_ENV = ($^O eq 'VMS') ? 'ORA_ROOT' : 'ORACLE_HOME';
my $OH = $ENV{$ORACLE_ENV} || '';
$OH = win32_oracle_home($OH) if ($^O eq 'MSWin32') or ($^O =~ /cygwin/i);
$OH = unixify $OH if $^O eq 'VMS';
$OH =~ s:/$::;
if (!$OH) {
$OH = find_oracle_home() || die qq{
The $ORACLE_ENV environment variable is not set and I couldn\'t guess it.
It must be set to hold the path to an Oracle installation directory
on this machine (or a machine with a compatible architecture).
See the appropriate README file for your OS for more information.
ABORTED!
\n};
$ENV{$ORACLE_ENV} = $OH;
print "\n";
print "WARNING: Setting $ORACLE_ENV env var to $OH for you.\a\n";
print "WARNING: If these tests fail you may have to set ORACLE_HOME yourself!\n";
sleep 5;
}
-l $OH and $OH = Cwd::abs_path ($OH); # Oracle really dislikes symbolic links
die qq{ The $ORACLE_ENV environment variable value ($OH) is not valid.
It must be set to hold the path to an Oracle installation directory
on this machine (or a machine with a compatible architecture).
For an Instant Client install, the directory should include an sdk subdirectory.
See the appropriate README file for your OS for more information.
ABORTED!
} unless (-d $OH and $^O eq 'VMS')
or -d "$OH/sdk/." # Instant Client with SDK
or -d "$OH/lib/." # normal Oracle installation
or glob("$OH/libclntsh.$so*") # pre-sdk instant client or rpm
or -e "$OH/oci.dll"; # Windows Instant Client
print "Installing on a $^O, Ver#$osvers\n";
print "Using Oracle in $OH\n";
# $client_version => Major.Minor, $client_version_full => Major.Minor.X.Y.Z
my ($client_version, $client_version_full) = get_client_version($::opt_V);
die "DBD::Oracle no longer supports Oracle client versions before 9.2 \n Try a version before 1.25 for 9 and 1.18 for 8!"
if $client_version < 9;
check_macos_symbol_table();
symbol_search() if $::opt_s or $::opt_S;
# --- How shall we link with Oracle? Let me count the ways...
my $mkfile; # primary .mk file to use
my @mkfiles; # $mkfile plus any files it 'includes'
my $linkwith = "";
my $linkwith_msg = "";
my $need_ldlp_env;
if ($^O eq 'VMS') {
my $OCIINCLUDE = join " ", vmsify("$OH/rdbms/"),
vmsify("$OH/rdbms/public"),
vmsify("$OH/rdbms/demo/"),
vmsify("$OH/rdbms/demo/oci_demo/"),
vmsify("$OH/netconfig/demo/"); # eg nzt.h in 8.1.7 on VMS
$opts{INC} = "$OCIINCLUDE $dbi_arch_dir";
$opts{OBJECT} = 'oracle.obj dbdimp.obj oci7.obj oci8.obj' if $] < 5.005;
unless ($ENV{PERL_ENV_TABLES}) {
print qq{
The logical PERL_ENV_TABLES is not set.
This may mean that some of the UTF functionallity tests may fail,
and that some logicals may be set in the Oracle Table.
To ensure that testing the package only sets logicals in your process
table, please set this logical:
\$ DEFINE PERL_ENV_TABLES LNM\$PROCESS
\a\n};
sleep 3;
}
}
elsif (($^O eq 'MSWin32') or ($^O =~ /cygwin/i)) {
my $OCIDIR = "";
find( sub {
print "Found $_ directory\n" if /^OCI\d*$/i;
$OCIDIR = $_ if /^OCI\d*$/i && $OCIDIR lt $_;
$File::Find::prune = 1 if -d $_ && $_ !~ /^\./;
}, $OH );
$OCIDIR = 'sdk' if !$OCIDIR && -d "$OH/sdk"; # Instant Client SDK
die "OCI directory not found, please install OCI in $OH" if ! $OCIDIR;
print "Using OCI directory '$OCIDIR'\n";
if ($Config{cc} =~ /gcc/i) {
system("dlltool --input-def oci.def --output-lib liboci.a")
if ! -f "liboci.a";
die "Could not find or create liboci.a. See README.wingcc.txt\n"
if ! -f "liboci.a";
my $pwd = cwd();
$opts{LIBS} = [ "-L$pwd -loci" ];
} else {
my %OCILIB;
my $oci_compiler_dir;
my @oci_compiler_dirs =
map { -d "$OH/$OCIDIR/lib/$_" ? "$OH/$OCIDIR/lib/$_": () }
$Config{cc} eq 'bcc32' ? qw(BORLAND BC) : qw(MSVC);
find( sub {
$File::Find::prune = 1 if -d $_ && $_ !~ /^\./;
return unless /^(OCI|ORA).*\.LIB$/i;
($oci_compiler_dir = $File::Find::dir) =~ s:^.*/::;
print "Found $OCIDIR/lib/$oci_compiler_dir/$_ library\n";
$OCILIB{uc($_)} = $_;
}, @oci_compiler_dirs );
# sort the version numbered libs into assending order
my @OCILIB = sort grep { /(OCI|ORA)\d\d+\./i } keys %OCILIB;
# prefer the non-versioned library if present
push @OCILIB, "OCI.LIB" if $OCILIB{'OCI.LIB'};
my $OCILIB = pop @OCILIB || '';
$OCILIB =~ s/\.LIB$//i;
die qq{
Unable to find required Oracle OCI files for the build. Please check
that you have your OCI installed in your oracle home ($OH)
directory and that it has the following files (and probably more):
$OH\\$OCIDIR\\include\\oratypes.h
$OH\\$OCIDIR\\lib\\$oci_compiler_dir\\$OCILIB.lib
Please install OCI or send comments back to dbi-users\@perl.org
if you have an OCI directory other than $OCIDIR.
Alternatively, if you\'re using ActiveState perl on Windows try
ppm install ftp://ftp.esoftmatic.com/outgoing/DBI/5.8.3/DBI.ppd
ppm install ftp://ftp.esoftmatic.com/outgoing/DBI/5.8.3/DBD-Oracle.ppd
} unless (-e "$OH/$OCIDIR/include/oratypes.h"
&& -e "$OH/$OCIDIR/lib/$oci_compiler_dir/$OCILIB.lib")
or $::opt_F;
print "Using $OCIDIR/lib/$oci_compiler_dir/$OCILIB.lib\n";
$opts{LIBS} = [ "-L$OH/$OCIDIR/LIB/$oci_compiler_dir $OCILIB" ];
};
my $OCIINCLUDE = "-I$OH/$OCIDIR/include -I$OH/rdbms/demo";
$opts{INC} = "$OCIINCLUDE -I$dbi_arch_dir";
}
# --- UNIX Variants ---
elsif ($::opt_l and # use -l to enable this direct-link approach
@_=grep { m:/lib(cl(ie)?ntsh|oracle).\w+$:o } <$OH/lib/lib*>
) {
# --- the simple modern way ---
foreach(@_) { s:\Q$OH/lib/::g }
print "Found direct-link candidates: @_\n";
my $lib = ("@_" =~ m:lib(cl(ie)?ntsh)\.:) ? $1 : "oracle";
my $syslibs = read_sysliblist();
print "Oracle sysliblist: $syslibs\n";
my $libdir = ora_libdir();
$opts{dynamic_lib} = { OTHERLDFLAGS => "$::opt_g" };
my @h_dirs = find_headers();
if ($client_version_full =~ /^8.0.6/ && $^O eq 'hpux') {
$linkwith_msg = "-lextp -l$lib.";
$opts{LIBS} = [ "-L$OH/$libdir -lextp -l$lib $syslibs" ];
push @h_dirs, "$OH/network/public";
}
else {
$linkwith_msg = "-l$lib.";
$opts{LIBS} = [ "-L$OH/$libdir -l$lib $syslibs" ];
}
my $inc = join " ", map { "-I$_" } @h_dirs;
$opts{INC} = "$inc -I$dbi_arch_dir";
check_ldlibpthname();
}
# --- special case for Oracle 10g instant client (note lack of ../lib/...)
elsif (my @libclntsh = glob("$OH/libclntsh.$so*")) {
print "Looks like an Instant Client installation, okay\n";
# the libclntsh.$so (without version suffix) may be missing
# we need it to link to so try to create it
eval {
print "You don't have a libclntsh.$so file, only @libclntsh\n";
my $libclntsh_v = (grep { /\d$/ } sort @libclntsh)[0]; # tacky but sufficient
print "So I'm going to create a $OH/libclntsh.$so symlink to $libclntsh_v\n";
symlink($libclntsh_v, "$OH/libclntsh.$so")
or warn "Can't create symlink $OH/libclntsh.$so to $libclntsh_v: $!\n";
} unless -e "$OH/libclntsh.$so";
check_ldlibpthname($OH);
my $syslibs = read_sysliblist();
print "Oracle sysliblist: $syslibs\n";
$opts{dynamic_lib} = { OTHERLDFLAGS => "$::opt_g" };
my $lib = "clntsh";
$linkwith_msg = "-l$lib.";
$opts{LIBS} = [ "-L$OH -l$lib $syslibs" ];
my $inc = join " ", map { "-I$_" } find_headers();
$opts{INC} = "$inc -I$dbi_arch_dir";
}
elsif ($mkfile = find_mkfile() and $mkfile =~ /\bdemo_xe.mk$/) { # Oracle XE
print "Looks like Oracle XE ($mkfile)\n";
fetch_oci_macros($mkfile);
$MK{CCINCLUDES} = '-I$(ICINCHOME)'; # undo odd refinition in demo_xe.mk
# From linux Oracle XE (10.2.0):
# ICINCHOME=$(ORACLE_HOME)/rdbms/public/
# ICLIBHOME=$(ORACLE_HOME)/lib/
# ICLIBPATH=-L$(ICLIBHOME)
# THREADLIBS=-lpthread [initially -lthread then redefined]
# CCLIB=$(ICLIBPATH) -lclntsh $(THREADLIBS)
# CCINCLUDES = -I$(ICINCHOME) [see above]
# CCFLAGS=$(CCINCLUDES) -DLINUX -D_GNU_SOURCE -D_REENTRANT -g [initially without -DLINUX -D_GNU_SOURCE]
my $cclib = expand_mkvars($MK{CCLIB}, 0, 1);
my $ccflags = expand_mkvars($MK{CCFLAGS}, 0, 1);
$linkwith_msg = "$cclib";
$opts{LIBS} = [ $cclib ];
$opts{INC} = "-I$dbi_arch_dir $ccflags";
$opts{dynamic_lib} = { OTHERLDFLAGS => "$::opt_g" };
check_ldlibpthname();
}
else { # --- trawl the guts of Oracle's make files looking the how it wants to link
#Lincoln: pick the right library path
check_ldlibpthname();
my $libdir = ora_libdir();
my @ora_libs = <$OH/$libdir/lib*>;
if (@ora_libs < 6) { # just a helpful hint
warn "\nYou don't seem to have many Oracle libraries installed. If the"
."\nbuild fails you probably need to install more Oracle software.\n\n";
sleep 6;
}
# can we give the shared library a helping hand?
my @shared = grep { m:/lib(cl(ie)?ntsh|oracle).\w+$:o } @ora_libs;
# show original value of ORA_CLIENT_LIB if defined ...
print "\$ORA_CLIENT_LIB=$ENV{ORA_CLIENT_LIB}\n"
if defined $ENV{ORA_CLIENT_LIB};
# ... before we then set it how it probably should be set
# XXX but we still need to write it into the generated Makefile.
$ENV{ORA_CLIENT_LIB} = 'shared'
if !defined $ENV{ORA_CLIENT_LIB}
&& ($opts{LINKTYPE}||'') ne 'static' && @shared && !$::opt_c;
my $linkvia = fetch_oci_macros($mkfile) if -f $mkfile;
my $libhome = expand_mkvars($MK{LIBHOME}, 0, 1) || "$OH/lib";
$linkwith = expand_mkvars($linkvia, 0, 1);
#now use logic based of oracle version
$linkwith =~ s!/lib\b!/$libdir!g;
$libhome =~ s!/lib\b!/$libdir!g;
#print "linkwith=$linkwith\n";
my @build_rules = grep { $mk_target_rules{$_} } qw(build build64 build32);
my $build_target = "build";
if (@build_rules && $::opt_b) {
print "\n";
$build_target = "build32" if $mk_target_rules{build32};
$build_target = "build64" if $mk_target_rules{build64} && perl_is_64bit();
$build_target = $::opt_r if $::opt_r;
print "Attempting to discover Oracle OCI $build_target rules\n";
# create dummy C file to keep 'make $mkfile' happy
my $DBD_ORA_OBJ = 'DBD_ORA_OBJ';
open DBD_ORA_C, ">$DBD_ORA_OBJ.c"
or die "Can't create temporary $DBD_ORA_OBJ.c file in current directory: $!\n";
print DBD_ORA_C "int main() { return 1; }\n";
close DBD_ORA_C;
sleep 2; #
system("make $DBD_ORA_OBJ.o CC='$Config{cc}'"); # make a valid .o file.
my $make = "$Config{make} -f $mkfile $build_target"
." ECHODO=echo ECHO=echo GENCLNTSH='echo genclntsh' CC=true"
." OPTIMIZE= CCFLAGS="
." EXE=DBD_ORA_EXE OBJS=$DBD_ORA_OBJ.o";
print "by executing: [$make]\n";
my @cmds = `$make 2>&1`;
chomp @cmds;
print "returned:\n[".join("]\n[",@cmds)."]\n" if $::opt_v;
warn "WARNING: Oracle build rule discovery failed ($?)\n" if $?;
warn "Add path to $Config{make} command into your PATH environment variable.\n"
if $? && "@cmds" =~ /make.*not found/; # hint
my @filtered_cmds;
while (my $line = shift @cmds) {
# join lines split with \'s
while ($line =~ s/\\$/ /) { $line .= shift @cmds; }
# remove any echo's as the following line should be the result of the echo
next if $line =~ /^\s*\S*echo\s+/;
next if $line =~ /^\s*\S*make\s+/; # remove recursive calls to make
next if $line =~ /^\s*\S*make(\[\d\])?:/; # remove message rom "make:" or "make[x]:"
next if $line =~ /^\s*$/; # remove any blank lines
push @filtered_cmds, $line;
}
print "reduced to:\n[".join("]\n[",@filtered_cmds)."]\n"
if $::opt_v && "@filtered_cmds" ne "@cmds";
@cmds = @filtered_cmds;
my @prolog; push @prolog, shift @cmds while @cmds && $cmds[0] !~ /DBD_ORA_EXE/;
print "Oracle oci build prolog:\n \t[", join("]\n\t[", @prolog), "]\n" if @prolog;
print "Oracle oci build command:\n\t[", join("]\n\t[", @cmds ), "]\n";
if (@cmds == 1 && (my $build = shift @cmds) =~ /DBD_ORA_EXE/) {
$build =~ s/\s*true\s+//; # remove dummy compiler
$build =~ s/$DBD_ORA_OBJ.o//; # remove dummy object file
$build =~ s/\S+\s+DBD_ORA_EXE//; # remove dummy exe file and preceding flag
$build =~ s/-o build\S*//; # remove -o target that confuses gcc at least on Sun
$linkwith = $build;
# delete problematic crt?.o on solaris
$linkwith = del_crtobj($linkwith, 1) if $^O eq 'solaris';
}
else {
print "WARNING: Unable to interpret Oracle build commands from $mkfile.\a\n";
print "(Will continue by using fallback approach.)\n";
print "Please report this to dbi-users\@perl.org. See README for what to include.\n";
sleep 2;
$::opt_b = 0;
}
unlink "$DBD_ORA_OBJ.c", "$DBD_ORA_OBJ.o"
unless $^O eq 'darwin'; # why?
print "\n";
}
else {
print "WARNING: Oracle $mkfile doesn't define a 'build' rule.\n" if $::opt_b;
$::opt_b = 0;
print "\n";
print "WARNING: I will now try to guess how to build and link DBD::Oracle for you.$BELL\n";
print " This kind of guess work is very error prone and Oracle-version sensitive.\n";
print " It is possible that it won't be supported in future versions of DBD::Oracle.\n";
print " *PLEASE* notify dbi-users about exactly _why_ you had to build it this way.\n";
print "\n";
sleep 6;
}
$linkwith =~ s/-Y P,/-YP,/g if $Config{gccversion};
$linkwith =~ s:-R /:-R/:g if $^O eq 'solaris';
# modifications (mostly) by Lincoln Baxter
if ( ($^O eq 'hpux') && ($osvers > 10) && (
$Config{'cc'} eq 'cc' or $Config{'gccversion'}) )
{
# these get dragged in from demo_rdbms.mk where Oracle uses them
# the linker bitches about them not being valid options
# in this context
# (on my system, using gcc, the flags can't be removed entirely;
# instead, they have to be converted to the ld-compatible equivs.
# -- Sweth (<[email protected]>)
if ( $Config{'cc'} eq 'cc' ) {
$linkwith =~ s/-Wl,\+[sn]//g;
} elsif ( $Config{'gccversion'} ) {
$linkwith =~ s/-Wl,(\+[sn])/$1/g;
};
# Oracle 8.0.5 drags in these which also cause link errors:
# this produces a good link with the 32bit version of oracle
# (64bit version of 8.0.5 fails to link
# someone else will have to hack that one out)
$linkwith =~ s/\+D[AS]2\.0[W]* / /g;
#Lincoln: pick the right library path
my $libdir = ora_libdir();
$linkwith =~ s!/lib\b!/$libdir!g;
# A number of folks have had to add this library to resolve
# undefined symbol errors reported at runtime by ld.sl (the
# library loader) libqsmashr defines LhrStringInsert()...
# other libraries may have to be added (Lincoln Baxter <[email protected]>)
# we check for the library's existence first... (8.0.5 does not have it)
if ( -r "$OH/$libdir/libqsmashr.sl" ) {
$linkwith =~ s/$/ -lqsmashr/ if ( $linkwith !~ m/-lqsmshr/ );
}
if ( ($Config{'libswanted'} !~ m/\bcl\b/) or $Config{'libswanted'} !~ m/\bpthread\b/ ) {
print "WARNING: Oracle is built with multi-threading libraries\n"
. " You will most likely need to rebuild perl from sources\n"
. " with the following libraries: -lcl -lpthread\n" ;
}
if ( $osvers >= 11 and
$linkwith =~ m/-lcl\b/ && $linkwith =~ m/-l:libcl.a/
) { # from [email protected]
print "WARNING: Stripping -lcl from the link flags, because it\n",
" seems to conflict with -l:libcl.a\n" ;
$linkwith =~ s/\s*-lcl\b//g;
}
# Lincoln: Jay Strauss's Oracle 8.1.6 fix... I did this manually
# when I still had 8.1.6 to deal with (its in the README):
#
# Jay: 8.1.6 gets Unresolved symbols on LhtStrInsert
# $linkwith =~ s/$/ -lclntsh/ if ( $linkwith !~ = m/-lclntsh/ );
# Tim - Not to be disobedient but at this point of the code
# $client_version_full = 0, so I can't do Oracle version 8.1.6 logic
# So it seems easier to modify if I do it like below rather than above
# obviously its your choice
#
# Lincoln: I don't see how the code above could work if $inspdver{RDMS} == 0
# so I will add this Jays prefered way but inside a test like that
# above... if he tests this and it works great... if someone else is
# has a problem it is easy to comment out the test. I like Jay's test
# for existence first... And I added an addition test of $OH to see
# if it looks like 8.1.6 (just incase Jay was right).
#
# Jay: Add Librarys where one gets Unresolved symbols
#
if ( ( $osvers >= 11 and $client_version_full =~ /^8\.1\.6/ )
or ( $osvers >= 11 and $OH =~ m,/8\.1\.6, ) ) {
my @extraLib = qw[libqsmashr.sl libclntsh.sl];
foreach my $extraLib (@extraLib) {
if (-r "$OH/lib/$extraLib") {
$extraLib =~ s/^lib([^\.]+).*$/\-l$1/;
$linkwith =~ s/$/ $extraLib/ if ( $linkwith !~ m/$extraLib/ );
}
}
}
if ($osvers >= 11 and $linkwith =~ m/-l:libcl.a/) {
print "WARNING: stripping -l:libcl.a from liblist (conflict with ld looking for shared libs)\n";
$linkwith =~ s/\s*-l:libcl.a\b//g;
}
#lincoln: this is bringing back everything we thought we removed... (like libcl.a)
# I wonder if this should targetted less specifically than only HPUX 11
# For now this should be relatively safe...
if ( $osvers >= 11 and
$linkwith =~ s/(`cat[^`]+sysliblist`)//g
) {
print "WARNING: Stripped $1 \n",
" from link command, because it contains libraries not \n",
" compiled with +z or +Z (PIC) causing link to fail.\n",
" Furthermore, we should have already grabbed these libraries\n";;
}
my $ccf = join " ", map { $_ || '' } @Config{qw(ccflags ccldflags cccdlflags)};
if ($Config{cc} =~ /gcc/i) {
print "WARNING: perl was not built with -fpic or -fPIC in compiler flags.\n",
" You may need to rebuild perl from sources.\n",
" See instructions in README.hpux.txt\n"
unless $ccf =~ m/-fpic\b/i;
}
else {
print "WARNING: perl was not built with +z or +Z in compiler flags.\n",
" You may need to rebuild perl from sources.\n",
" See instructions in README.hpux.txt\n"
unless $ccf =~ m/\+[zZ]/;
}
}
if ($::opt_b) { # The simple approach
$opts{dynamic_lib} = { OTHERLDFLAGS => "$::opt_g $linkwith" };
$linkwith_msg = "OTHERLDFLAGS = $linkwith [from '$build_target' rule]";
}
else { # the not-so-simple approach!
# get a cut down $linkwith to pass to MakeMaker liblist
my $linkwith_s = expand_mkvars($linkwith, 1, 1);
# convert "/full/path/libFOO.a" into "-L/full/path -lFOO"
# to cater for lack of smarts in MakeMaker / Liblist
# which ignores /foo/bar.a entries!
my $lib_ext_re = "(a|$Config{dlext}|$Config{so})";
$linkwith_s =~ s!(\S+)/lib(\w+)\.($lib_ext_re)\b!-L$1 -l$2!g;
# Platform specific fix-ups:
# delete problematic crt?.o on solaris
$linkwith_s = del_crtobj($linkwith_s) if $^O eq 'solaris';
$linkwith_s =~ s/-l:lib(\w+)\.sl\b/-l$1/g; # for hp-ux
# this kind of stuff should be in a ./hints/* file:
$linkwith_s .= " -lc" if $Config{osname} eq 'dynixptx'
or $Config{archname} =~ /-pc-sco3\.2v5/;
if ($^O eq 'solaris' and $linkwith_s =~ /-lthread/
and $osvers >= 2.3 and $osvers <= 2.6
) {
print "WARNING: Solaris 2.5 bug #1224467 may cause '_rmutex_unlock' error.\n";
print "Deleting -lthread from link list as a possible workround ($osvers).\n";
$linkwith_s =~ s/\s*-lthread\b/ /g;
}
# extract object files, keep for use later
my @linkwith_o;
push @linkwith_o, $1 while $linkwith_s =~ s/(\S+\.[oa])\b//;
# also extract AIX .exp files since they confuse MakeMaker
push @linkwith_o, $1 while $linkwith_s =~ s/(-bI:\S+\.exp)\b//;
$linkwith_msg = "@linkwith_o $linkwith_s [from $linkvia]";
$opts{LIBS} = [ "-L$libhome $linkwith_s" ];
$opts{dynamic_lib} = { OTHERLDFLAGS => "$::opt_g @linkwith_o \$(COMPOBJS)" };
}
my $OCIINCLUDE = expand_mkvars($MK{INCLUDE} || '', 0, 0);
my @h_dirs = find_headers();
my $inc = join " ", map { "-I$_" } @h_dirs;
$opts{INC} = "$inc $OCIINCLUDE -I$dbi_arch_dir";
}
# --- Handle special cases ---
if ($::opt_g && $^O eq "MSWin32" && $Config::Config{cc} eq "cl") {
$opts{LDDLFLAGS} = $Config::Config{lddlflags} . ' -debug'
}
$opts{DEFINE} .= ' -Wall -Wno-comment' if $Config{gccversion};
$opts{DEFINE} .= ' -Xa' if $Config{cc} eq 'clcc'; # CenterLine CC
$opts{DEFINE} .= ' -DUTF8_SUPPORT' if ($] >= 5.006);
# Use OCIEnvNlsCreate if available for best unicode behaviour
#$opts{DEFINE} .= ' -DNEW_OCI_INIT' if $client_version >= 9.2;
$opts{DEFINE} .= ($^O ne 'VMS')
? " -DORA_OCI_VERSION=\\\"$client_version_full\\\""
: " -DORA_OCI_VERSION=\"$client_version_full\"";
# force additional special behavior for oci 8. For now, this means
# emulating OciLobWriteAppend
# use this if, for some reason the default handling for this function
# doesn't work or you are building a binary release for distribution
# to machines with older client libraries.
print "\nclient_version=$client_version\n\n";
$opts{DEFINE} .= " -DORA_OCI_102" if ($::opt_V && $client_version == 10.2)
or ( $client_version >= 10.2);
$opts{DEFINE} .= " -DORA_OCI_112" if ($::opt_V && $client_version == 11.2)
or ( $client_version >= 11.2);
print "\nDEFINE=$opts{DEFINE}\n\n";
# OCIStmntFetch2() is a feature of OCI 9.0.0
$opts{DEFINE} .= " -DUSE_ORA_OCI_STMNT_FETCH " if ( $client_version < 9.0 );
# Set some private WriteMakefile options if this is 'me' :-)
if ($is_developer){ # a reasonable guess
$BELL = "<BELL>" if ($ENV{LOGNAME}||'') eq 'timbo';
$::opt_g = '-g';
if ($Config{gccversion}) {
$opts{DEFINE} .= ' -Wall -Wcast-align -Wpointer-arith';
$opts{DEFINE} .= ' -Wbad-function-cast -Wcast-qual';
#$opts{DEFINE} .= ' -Wconversion'; # very noisy so remove to see what people say
$opts{DEFINE} .= ' -Wimplicit -Wimplicit-int -Wimplicit-function-declaration -Werror-implicit-function-declaration -Wimport -Winline -Wlong-long -Wmissing-braces -Wmissing-format-attribute -Wmissing-noreturn -Wmultichar -Wpacked -Wparentheses -Wpointer-arith -Wreturn-type -Wsequence-point -Wsign-compare -Wswitch -Wtrigraphs -Wundef -Wuninitialized -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wbad-function-cast -Wmissing-declarations -Wnested-externs'
if $::opt_w;
}
$opts{dynamic_lib}->{OTHERLDFLAGS} .= " $::opt_g";
}
# HP-UX 9 cannot link a non-PIC object file into a shared library.
# Since the # .a libs that Oracle supplies contain non-PIC object
# files, we sadly have to build static on HP-UX 9 :(
if ($^O eq 'hpux') {
if ($osvers < 10) {
print "WARNING: Forced to build static not dynamic on $^O $osvers.$BELL\n";
$opts{LINKTYPE} = 'static';
}
else {
print "WARNING: If you have trouble, see README.hpux.txt...\n"
." you may have to build your own perl, or go hunting for libraries\n";
}
print "WARNING: If you have trouble, try perl Makefile.PL -l\n" unless $::opt_l;
sleep 5;
$opts{DEFINE} .= ' $(HP64DEFINES)' if ($Config{archname} =~ /-thread\b/i and perl_is_64bit());
# linker doesn't understand +DD64 flag Weiguo Sun <[email protected]>
$opts{dynamic_lib}->{OTHERLDFLAGS} =~ s/\+DD64\b// if $opts{dynamic_lib}->{OTHERLDFLAGS};
# see also const_cccmd for -Aa to -Ae flag change
}
# --- check for Test::Harness bug
print "\nChecking for functioning wait.ph\n";
eval { package WAIT; local $^W = 0; require 'wait.ph' };
if (!$@ && !defined(&WAIT::WCOREDUMP)) {
print "You have a wait.ph file generated by perl h2ph utility.\n";
print "(I found it at $INC{'wait.ph'})\n";
print "It does not define a WCOREDUMP function. That's probably an error.\n";
print "If a DBD::Oracle test fails then you will probably see a message\n";
print "from Test::Harness about WCOREDUMP being undefined. You can either ignore\n";
print "it or try to fix your wait.ph file. The message DOES NOT reflect the\n";
print "cause of the test failure, it's just a problem interpreting the failure.\n";
}
print "\n";
# --- display summary information
# log key platform information to help others help you quickly if needed
print "\n";
print "System: perl$] @Config{qw(myuname)}\n";
print "Compiler: @Config{qw(cc optimize ccflags)}\n";
print "Linker: ". (find_bin('ld')||"not found") ."\n" unless $^O eq 'VMS';
print "Sysliblist: ".read_sysliblist()."\n";
print "Oracle makefiles would have used these definitions but we override them:\n"
if $MK{CFLAGS} || $MK{LDFLAGS} || $MK{LDSTRING};
print " CC: $MK{CC}\n" if $MK{CC};
print " CFLAGS: $MK{CFLAGS}\n" if $MK{CFLAGS};
print " [".mkvar('CFLAGS',0,1,0). "]\n" if $MK{CFLAGS};
print " CLIBS: $MK{CLIBS}\n" if $MK{CLIBS};
print " [".mkvar('CLIBS',0,1,0). "]\n" if $MK{CLIBS};
if ($mk_target_rules{build} && !$::opt_b) {
my $rules = join "\n", '', @{ $mk_target_rules{build} };
$rules = expand_mkvars($rules, 0, 0, 1, 1) if $rules =~ /^\s*\$\(\w+\)\s*$/;
print " build: $rules\n";
print " [".expand_mkvars($rules,0,1,0). "]\n";
}
print " LDFLAGS: $MK{LDFLAGS}\n" if $MK{LDFLAGS};
print " [".mkvar('LDFLAGS',0,1,0). "]\n" if $MK{LDFLAGS};
print " LDSTRING: $MK{LDSTRING}\n" if $MK{LDSTRING};
print " [".mkvar('LDSTRING',0,1,0)."]\n" if $MK{LDSTRING};
print "Linking with $linkwith_msg\n" if $linkwith_msg;
print "\n";
# --- display extra notes and warnings
if ($^O eq 'aix' and $osvers >= 4 and $Config{cc} ne 'xlc_r') {
print "\n";
print "WARNING: You will may need to rebuild perl using the xlc_r compiler.\a\n";
print " The important thing is that perl and DBD::Oracle be built with the same compiler.\n";
print " You may also need to: ORACCENV='cc=xlc_r'; export ORACCENV\n";
print " Also see README.aix for gcc instructions and read about the -p option.\n";
sleep 5;
}
if ($Config{archname} !~ /-thread\b/i) {
print "\n";
print "WARNING: If you have problems you may need to rebuild perl with threading enabled.$BELL\n";
sleep 5;
}
if ($Config{usemymalloc} eq 'y') {
print "\n";
print "WARNING: If you have problems you may need to rebuild perl with -Uusemymalloc.$BELL\n";
sleep 5;
}
print "WARNING: Your GNU C compiler is very old. Please upgrade.\n"
if ($Config{gccversion} and $Config{gccversion} =~ m/^(1|2\.[1-5])/);
if ($opts{LINKTYPE} && $opts{LINKTYPE} eq 'static') {
print "** Note: DBD::Oracle will be built *into* a NEW perl binary. You MUST use that new perl.\n";
print " See README and Makefile.PL for more information.$BELL\n";
}
# --- write the name file etc ---
# create this before WriteMakefile so MakeMaker knows it's here
open(MK_PM, ">mk.pm") or die "Unable to create mk.pm: $!";
WriteMakefile( dbd_edit_mm_attribs(\%opts) );
check_security() unless $^O eq 'VMS' or $^O eq 'MSWin32' or $^O =~ /cygwin/i;
print "\n";
print "*** If you have problems...\n";
print " read all the log printed above, and the README and README.help.txt files.\n";
print " (Of course, you have read README by now anyway, haven't you?)\n\n";
vms_logical_names_sanity_check();
exit 0;
# === utility functions ================================
sub vms_logical_names_sanity_check {
return unless $^O eq 'VMS';
unless ( $ENV{PERL_ENV_TABLES} ) { # perl_env_tables not set report
print <<'END_TXT';
The logical PERL_ENV_TABLES is not set.
This means that any logical names set when testing the package
will be set in the first logical name table that occurs in the
LNM$FILE_DEV list.
Please read the Readme.VMS file for further information.
END_TXT
return;
}
return if grep { $ENV{$_} eq 'LNM$JOB' }
grep { /^PERL_ENV_TABLES;\d+$/ }
keys %ENV;
# perl_env_tables set but the element we want is missing
print <<'END_TXT';
The logical PERL_ENV_TABLES is set, but without LNM$JOB.
Testing the package can fail because of inability to correctly
translate SYS$SCRATCH for temporary storage, as SYS$SCRATCH is
set at the JOB level.
To ensure that testing the package correctly translates SYS$SCRATCH,
please ensure that LNM$JOB is part of PERL_ENV_TABLES like this:
$ DEFINE PERL_ENV_TABLES LNM$PROCESS, LNM$JOB , CRTL_ENV
END_TXT
}
sub find_oracle_home {
print "Trying to find an ORACLE_HOME\n";
my @path = split /\Q$Config{path_sep}/, $ENV{PATH};
print "using PATH @path\n" if $::opt_v;
# instant client has libclntsh in same dir as sqlplus
my @oh = grep { (glob("$_/libclntsh.$so*"))[0] } @path;
if (!@oh) { # failing that, try LD_LIBRARY_PATH or equiv
my (undef, undef, @ldlibpth) = ldlibpth_info(1);
print "using ldlib @ldlibpth\n" if $::opt_v;
@oh = grep { (glob("$_/libclntsh.$so*"))[0] } @ldlibpth;
# for instant client @oh may be actual ORACLE_HOME
# but for non-IC ORACLE_HOME may be dir above a /lib*
s:/lib\w*/?$:: for @oh; # remove possible trailing lib dir
}
if (!@oh) { # else try the traditional kind of install
# this should work for non-instant-client installs ($OH/bin & $OH/lib*)
@oh = grep { (glob("$_/../lib*/libclntsh.$so*"))[0] } @path;
s:/[^/]/?$:: for @oh;
}
print "Found @oh\n" if @oh;
return $oh[0];
}
sub win32_oracle_home {
my $oh = shift;
my ($req_ok, $hkey, $Val, $Keys);
my $default_home;
if ( ! $oh ) {
if ( $Config{osname} eq "MSWin32") {
# Win32::TieRegistry is prefered, but it requires Win32API::Registry
# which is not available in mingw or cygwin
eval {
require Win32::TieRegistry;
$Win32::TieRegistry::Registry->Delimiter("/");
$req_ok = 1;
$hkey = $Win32::TieRegistry::Registry->{"LMachine/SOFTWARE/Oracle/"};
};
eval { # older name of Win32::TieRegistry