forked from perl5-dbi/DBD-MariaDB
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.PL
999 lines (892 loc) · 34.7 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
# -*- cperl -*-
use strict;
use warnings;
use utf8;
use 5.008_001;
use Config;
use Getopt::Long;
use ExtUtils::MakeMaker;
use Data::Dumper;
use Devel::CheckLib 1.12;
use File::Spec;
require DBI;
require DBI::DBD;
my $TESTDB = "test";
# On WIN32 windows.h and winsock.h need to be included before mysql.h
# Otherwise SOCKET type which is needed for mysql.h is not defined
my @mysql_headers;
push @mysql_headers, 'windows.h', 'winsock.h' if $^O eq 'MSWin32';
push @mysql_headers, 'mysql.h';
our $opt = { "help" => \&Usage, };
my ($test_host, $test_port, $test_socket, $test_authplugin);
{
local ($::test_host, $::test_port, $::test_user, $::test_socket, $::test_authplugin, $::test_password, $::test_db, $::test_mysql_config, $::test_cflags, $::test_libs);
eval { require "./t/MariaDB.mtest" } and do {
$opt->{'testuser'} = $::test_user;
$opt->{'testpassword'} = $::test_password;
$opt->{'testdb'} = $::test_db;
$opt->{'mysql_config'} = $::test_mysql_config;
$opt->{'cflags'} = $::test_cflags;
$opt->{'libs'} = $::test_libs;
$test_host = $::test_host;
$test_port = $::test_port;
$test_socket = $::test_socket;
$test_authplugin = $::test_authplugin;
}
}
Getopt::Long::GetOptions(
$opt,
"help",
"testdb:s",
"testhost:s",
"testport:s",
"testuser:s",
"testpassword:s",
"testsocket:s",
"testauthplugin:s",
"cflags:s",
"libs:s",
"mysql_config:s",
"mariadb_config:s",
) || die Usage();
$opt->{mysql_config} = delete $opt->{mariadb_config} if exists $opt->{mariadb_config};
my $source = {};
#Check for mysql_config first
$source->{'mysql_config'} = "guessed";
if ($opt->{'mysql_config'}) {
$source->{'mysql_config'} = "User's choice";
}
if (!$opt->{'mysql_config'} && $ENV{DBD_MARIADB_CONFIG}) {
$opt->{'mysql_config'} = $ENV{DBD_MARIADB_CONFIG};
$source->{'mysql_config'} = 'environment';
}
if ($opt->{'mysql_config'})
{
if ($opt->{'mysql_config'} ne 'skip') {
$opt->{'mysql_config'} = Win32::GetShortPathName($opt->{'mysql_config'}) || $opt->{'mysql_config'}
if $^O eq 'MSWin32';
if (!CanExecute($opt->{'mysql_config'}))
{
die <<"MSG";
Specified mysql configuration script '$opt->{'mysql_config'}' doesn't exist.
Please check path/permissions.
MSG
}
}
}
else
{
if (CanExecute("mariadb_config"))
{
$opt->{'mysql_config'} = "mariadb_config";
}
elsif (CanExecute("mysql_config"))
{
$opt->{'mysql_config'} = "mysql_config";
}
else
{
print <<MSG;
Cannot find the file 'mariadb_config' nor 'mysql_config'! Your execution PATH doesn't seem
not contain the path to mariadb_config or mysql_config. Resorting to guessed values!
MSG
}
}
for my $key (qw(testdb testhost testuser testpassword testsocket testauthplugin testport cflags libs))
{
Configure($opt, $source, $key);
}
if (!$opt->{testport} && (!$opt->{testhost} || $opt->{testhost} eq 'localhost') && !defined $opt->{testsocket} && $test_socket) {
$opt->{testsocket} = $test_socket;
$source->{testsocket} = "User's choice";
}
if (!$opt->{testsocket}) {
if (!defined $opt->{testhost} && $test_host && (!$opt->{testport} || $test_host ne 'localhost')) {
$opt->{testhost} = $test_host;
$source->{testhost} = "User's choice";
}
if (!defined $opt->{testport} && $test_port && (!$opt->{testhost} || $opt->{testhost} ne 'localhost')) {
$opt->{testport} = $test_port;
$source->{testport} = "User's choice";
}
} else {
if (!defined $opt->{testhost} && $test_host && $test_host eq 'localhost') {
$opt->{testhost} = 'localhost';
$source->{testhost} = "User's choice";
}
}
#if we have a testport but no host, assume 127.0.0.1
if ( $opt->{testport} && !$opt->{testhost} ) {
$opt->{testhost} = '127.0.0.1';
$source->{testhost} = 'guessed';
}
foreach (qw(testhost testport testsocket testauthplugin)) {
next if defined $opt->{$_};
$opt->{$_} = '';
$source->{$_} = 'default';
}
# testsocket makes sense only when testhost is localhost
if ($opt->{testsocket} && $opt->{testhost} && $opt->{testhost} ne 'localhost') {
die << "MSG";
Option --testport or --testhost different from localhost cannot be specified together with option --testsocket.
MSG
}
# testport cannot be specified when host is localhost
if ($opt->{testport} && $opt->{testhost} && $opt->{testhost} eq 'localhost') {
die << "MSG";
Option --testport cannot be specified when --testhost is localhost.
MSG
}
# testhost cannot be embedded
if ($opt->{testhost} && $opt->{testhost} eq 'embedded') {
die << "MSG";
Option --testhost cannot be embedded.
MSG
}
# Separate libs and libdirs from ldflags
# When linking libdirs must be specified before libs due to runtime linking problems
my ($main_lib, @libs, @libdirs, @ldflags);
for (split ' ', $opt->{libs}) {
if (not defined $main_lib and /^-l(?:.*mariadb.*|.*mysql.*)$/) {
$main_lib = $_;
} elsif (/^-l/) {
push @libs, $_;
} elsif (/^-L/) {
push @libdirs, $_;
} else {
push @ldflags, $_;
}
}
if (not defined $main_lib) {
$main_lib = shift @libs;
}
if (not defined $main_lib) {
die <<"MSG";
No MariaDB or MySQL client library was specified. Use
perl Makefile.PL --libs="-L<dir> -l<library>"
to set directory and client library. For details see the DBD::MariaDB::INSTALL,
section "Linker flags" or type
perl Makefile.PL --help
MSG
}
print <<"MSG";
I will use the following settings for compiling and testing:
MSG
delete $opt->{'help'};
my $keylen = 0;
for my $key (keys %$opt)
{
$keylen = length($key) if length($key) > $keylen;
}
my $slen = 0;
for my $val (values %$source)
{
$slen = length($val) if length($val) > $slen;
}
for my $key (sort { $a cmp $b} keys %$opt)
{
printf(" %-" . $keylen . "s (%-" . $slen . "s) = %s\n",
$key, $source->{$key}, $opt->{$key})
}
print <<"MSG";
To change these settings, see 'perl Makefile.PL --help' and
'perldoc DBD::MariaDB::INSTALL'.
MSG
print "Checking if libs and header files are available for compiling...\n";
assert_lib(
LIBS => (join ' ', @libdirs, $main_lib, @libs),
ccflags => (join ' ', $opt->{cflags}, ($Config{usedl} ? $Config{cccdlflags} : ())),
ldflags => (join ' ', @libdirs, @ldflags, ($Config{usedl} ? $Config{lddlflags} : ())),
header => \@mysql_headers,
not_execute => 1,
);
print "Checking if correct version of MariaDB or MySQL client is present...\n";
check_lib(
LIBS => (join ' ', @libdirs, $main_lib),
ccflags => $opt->{cflags},
ldflags => (join ' ', @libdirs, @libs, @ldflags),
header => \@mysql_headers,
function => "\n#ifndef MYSQL_VERSION_ID\n#include <mysql_version.h>\n#endif\nreturn (MYSQL_VERSION_ID >= 40108) ? 0 : 1;\n",
) or die <<"MSG";
ERROR: Wrong version or unable to check version of MariaDB/MySQL include files.
To build DBD::MariaDB it is needed MariaDB or MySQL client >= 4.1.8.
MSG
print "Looks good.\n\n";
my $have_embedded = check_lib(
LIBS => (join ' ', @libdirs, $main_lib),
ccflags => $opt->{cflags},
ldflags => (join ' ', @libdirs, @libs, @ldflags),
header => \@mysql_headers,
function => 'return mysql_embedded() ? 0 : 1;',
);
print "Embedded server: " . ($have_embedded ? "supported" : "not supported by client library") . "\n\n";
my $have_get_charset_number = check_lib(
LIBS => (join ' ', @libdirs, $main_lib),
ccflags => $opt->{cflags},
ldflags => (join ' ', @libdirs, @libs, @ldflags),
header => \@mysql_headers,
function => 'unsigned int get_charset_number(const char *cs_name, unsigned int cs_flags); mysql_server_init(-1, 0, 0); get_charset_number("utf8", 32); return 0;',
);
my $have_get_option = check_lib(
LIBS => (join ' ', @libdirs, $main_lib),
ccflags => $opt->{cflags},
ldflags => (join ' ', @libdirs, @libs, @ldflags),
header => \@mysql_headers,
function => 'MYSQL mysql; char buf[1024]; mysql_server_init(-1, 0, 0); mysql_init(&mysql); mysql_get_option(&mysql, 0, &buf); return 0;',
);
my $have_deinitialize_ssl = check_lib(
LIBS => (join ' ', @libdirs, $main_lib),
ccflags => $opt->{cflags},
ldflags => (join ' ', @libdirs, @libs, @ldflags),
header => \@mysql_headers,
function => 'mariadb_deinitialize_ssl = 0; return 0;',
);
# Check if mysql_server_end() deinitialize OpenSSL library functions
# See: https://github.com/perl5-dbi/DBD-MariaDB/issues/119
my $have_problem_with_openssl = !check_lib(
LIBS => (join ' ', @libdirs, $main_lib),
ccflags => $opt->{cflags},
ldflags => (join ' ', @libdirs, @libs, @ldflags, $Config{perllibs}),
header => \@mysql_headers,
function => << 'EOF'
#ifndef _WIN32
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <dlfcn.h>
#ifndef RTLD_DEFAULT
#define RTLD_DEFAULT ((void *)0)
#endif
#endif
int (*OPENSSL_init_ssl_func)(unsigned long long, const void *);
void (*SSL_load_error_strings_func)(void);
int (*SSL_library_init_func)(void);
void *(*SSL_CTX_new_func)(const void *method);
void (*SSL_CTX_free_func)(void *ctx);
const void *(*TLS_method_func)(void);
const void *method1;
const void *method2;
void *ctx1;
void *ctx2;
#ifdef _WIN32
BOOL (WINAPI *EnumProcessModules_func)(HANDLE, HMODULE *, DWORD, LPDWORD);
HMODULE psapi_lib;
DWORD size, i;
HMODULE *modules;
modules = NULL;
psapi_lib = LoadLibraryA("Psapi.dll");
if (psapi_lib) {
EnumProcessModules_func = (BOOL (WINAPI *)(HANDLE, HMODULE *, DWORD, LPDWORD))GetProcAddress(psapi_lib, "EnumProcessModules");
if (EnumProcessModules_func) {
if (EnumProcessModules_func((HANDLE)-1, NULL, 0, &size)) {
modules = (HMODULE *)GlobalAlloc(GPTR, size);
if (modules && !EnumProcessModules_func((HANDLE)-1, modules, size, &size))
modules = NULL;
}
}
}
#define SYMBOL(var, type, sym) do { \
var = (type)GetProcAddress(GetModuleHandle(NULL), sym); \
if (!var) { \
if (!modules) \
return 1; \
for (i = 0; i < size/sizeof(*modules); ++i) { \
var = (type)GetProcAddress(modules[i], sym); \
if (var) \
break; \
} \
} \
} while (0)
#else
#define SYMBOL(var, type, sym) do { var = (type)dlsym(RTLD_DEFAULT, sym); } while (0)
#endif
SYMBOL(OPENSSL_init_ssl_func, int (*)(unsigned long long, const void *), "OPENSSL_init_ssl");
SYMBOL(SSL_library_init_func, int (*)(void), "SSL_library_init");
if (!OPENSSL_init_ssl_func && !SSL_library_init_func)
return 0;
SYMBOL(SSL_load_error_strings_func, void (*)(void), "SSL_load_error_strings");
if (!OPENSSL_init_ssl_func && !SSL_load_error_strings_func)
return 0;
SYMBOL(SSL_CTX_new_func, void *(*)(const void *), "SSL_CTX_new");
if (!SSL_CTX_new_func)
return 0;
SYMBOL(SSL_CTX_free_func, void (*)(void *), "SSL_CTX_free");
if (!SSL_CTX_free_func)
return 0;
SYMBOL(TLS_method_func, const void *(*)(void), "TLS_method");
if (!TLS_method_func)
SYMBOL(TLS_method_func, const void *(*)(void), "TLSv1_2_method");
if (!TLS_method_func)
SYMBOL(TLS_method_func, const void *(*)(void), "TLSv1_1_method");
if (!TLS_method_func)
SYMBOL(TLS_method_func, const void *(*)(void), "TLSv1_method");
if (!TLS_method_func)
return 0;
if (OPENSSL_init_ssl_func) {
OPENSSL_init_ssl_func(0, (void *)0);
} else {
SSL_library_init_func();
SSL_load_error_strings_func();
}
method1 = TLS_method_func();
if (!method1)
return 1;
ctx1 = SSL_CTX_new_func(method1);
if (!ctx1)
return 1;
mysql_server_init(-1, 0, 0);
mysql_server_end();
method2 = TLS_method_func();
if (!method2)
return 1;
ctx2 = SSL_CTX_new_func(method2);
if (!ctx2)
return 1;
SSL_CTX_free_func(ctx1);
SSL_CTX_free_func(ctx2);
return 0;
EOF
);
print "Client library deinitialize OpenSSL library functions: " . ($have_problem_with_openssl ? "yes" : "no") . "\n\n";
my $fileName = File::Spec->catfile("t", "MariaDB.mtest");
(open(FILE, ">$fileName") &&
(print FILE ("{ local " . Data::Dumper->Dump([$opt], ["opt"]) .
" local " . Data::Dumper->Dump([$source], ["source"]) .
"\$::test_host = \$opt->{'testhost'};\n" .
"\$::test_port = \$opt->{'testport'};\n" .
"\$::test_user = \$opt->{'testuser'};\n" .
"\$::test_socket = \$opt->{'testsocket'};\n" .
"\$::test_authplugin = \$opt->{'testauthplugin'};\n" .
"\$::test_password = \$opt->{'testpassword'};\n" .
"\$::test_db = \$opt->{'testdb'};\n" .
"\$::test_dsn = \"DBI:MariaDB:\$::test_db\";\n" .
"\$::test_dsn .= \":\$::test_host\" if \$::test_host;\n" .
"\$::test_dsn .= \":\$::test_port\" if \$::test_port;\n".
"\$::test_dsn .= \";mariadb_socket=\$::test_socket\" if \$::test_socket;\n" .
"\$::test_dsn .= \";mariadb_auth_plugin=\$::test_authplugin\" if \$::test_authplugin;\n" .
"\$::test_dsn .= \";mariadb_connect_timeout=120;mariadb_read_timeout=120;mariadb_write_timeout=120\";\n" .
"\$::test_mysql_config = \$opt->{'mysql_config'} if \$source->{'mysql_config'} eq 'User\\'s choice';\n" .
"\$::test_cflags = \$opt->{'cflags'} if \$source->{'cflags'} eq 'User\\'s choice';\n" .
"\$::test_libs = \$opt->{'libs'} if \$source->{'libs'} eq 'User\\'s choice';\n" .
"} 1;\n")) &&
close(FILE)) || die "Failed to create $fileName: $!";
my $cflags = "-I\$(DBI_INSTARCH_DIR) $opt->{'cflags'}";
$cflags .= " -DHAVE_DBI_1_634" if eval { DBI->VERSION(1.634) };
$cflags .= " -DHAVE_DBI_1_642" if eval { DBI->VERSION(1.642) };
$cflags .= " -DHAVE_EMBEDDED" if $have_embedded;
$cflags .= " -DHAVE_GET_CHARSET_NUMBER" if $have_get_charset_number;
$cflags .= " -DHAVE_GET_OPTION" if $have_get_option;
$cflags .= " -DHAVE_DEINITIALIZE_SSL" if $have_deinitialize_ssl;
$cflags .= " -DHAVE_PROBLEM_WITH_OPENSSL" if $have_problem_with_openssl;
my %o =
(
'NAME' => 'DBD::MariaDB',
'INC' => $cflags,
'dist' => {
'SUFFIX' => ".gz",
'DIST_DEFAULT' => 'all tardist',
'TARFLAGS' => '--format=ustar -c -v -f',
'COMPRESS' => "gzip -9f",
},
'clean' => { 'FILES' => '*.xsi' },
'realclean' => { 'FILES' => 't/MariaDB.mtest' },
'C' => [ "dbdimp.c", "MariaDB.c" ],
'XS' => { 'MariaDB.xs' => 'MariaDB.c' },
'PM' => {
'lib/DBD/MariaDB.pm' => '$(INST_LIB)/DBD/MariaDB.pm',
'lib/DBD/MariaDB.pod' => '$(INST_LIB)/DBD/MariaDB.pod',
'lib/DBD/MariaDB/INSTALL.pod' => '$(INST_LIB)/DBD/MariaDB/INSTALL.pod',
'README.pod' => '$(INST_LIB)/DBD/MariaDB/README.pod',
},
'MAN3PODS' => {
'lib/DBD/MariaDB.pod' => '$(INST_MAN3DIR)/DBD::MariaDB.$(MAN3EXT)',
'lib/DBD/MariaDB/INSTALL.pod' => '$(INST_MAN3DIR)/DBD::MariaDB::INSTALL.$(MAN3EXT)',
'README.pod' => '$(INST_MAN3DIR)/DBD::MariaDB::README.$(MAN3EXT)',
},
'OBJECT' => '$(O_FILES)',
'LIBS' => (join ' ', @libdirs, $main_lib, @libs),
@ldflags ? (dynamic_lib => { OTHERLDFLAGS => (join ' ', @ldflags) }) : (),
'VERSION_FROM' => 'lib/DBD/MariaDB.pm',
ABSTRACT => 'MariaDB and MySQL driver for the Perl5 Database Interface (DBI)',
AUTHOR => 'Pali <[email protected]>',
LICENSE => 'perl',
MIN_PERL_VERSION => '5.008001',
META_MERGE => {
'meta-spec' => {
version => 2,
},
dynamic_config => 0,
resources => {
repository => {
url => 'https://github.com/perl5-dbi/DBD-MariaDB.git',
web => 'https://github.com/perl5-dbi/DBD-MariaDB',
type => 'git',
},
bugtracker => {
web => 'https://github.com/perl5-dbi/DBD-MariaDB/issues',
},
x_MailingList => 'mailto:[email protected]',
license => [ 'http://dev.perl.org/licenses/' ],
homepage => 'https://github.com/perl5-dbi/DBD-MariaDB',
x_IRC => 'irc://irc.perl.org/#dbi',
},
x_contributors => [
# a list of our awesome contributors generated from git
# using the command:
# git shortlog -se | cut -f2- | sed "s/^/ '/;s/$/',/"
'Alexandr Ciornii <[email protected]>',
'Alexey Molchanov <[email protected]>',
'Amiri Barksdale at Home <[email protected]>',
'Andrew Miller <[email protected]>',
'Aran Deltac <[email protected]>',
'Bernt M. Johnsen <[email protected]>',
'Branislav Zahradník <[email protected]>',
'Chase Whitener <[email protected]>',
'Chip Salzenberg <[email protected]>',
'Chris Hammond <[email protected]>',
'Chris Weyl <[email protected]>',
'Christian Walde <[email protected]>',
'Dagfinn Ilmari Mannsåker <[email protected]>',
'Daisuke Murase <[email protected]>',
'Damyan Ivanov <[email protected]>',
'Dan Book <[email protected]>',
'Daniël van Eeden <[email protected]>',
'Dave Lambley <davel@isosceles.(none)>',
'David Farrell <[email protected]>',
'David Steinbrunner <[email protected]>',
'Dominik Sauer <[email protected]>',
'E. Choroba <[email protected]>',
'Giovanni Bechis <[email protected]>',
'Graham Ollis <[email protected]>',
'H.Merijn Brand - Tux <[email protected]>',
'Hanno <[email protected]>',
'James McCoy <[email protected]>',
'Jan Holčapek <[email protected]>',
'Jim Winstead <[email protected]>',
'Juergen Weigert <[email protected]>',
'Kenny Gryp <[email protected]>',
'Lu Shengliang <[email protected]>',
'Martin Cermak <[email protected]>',
'Masahiro Chiba <[email protected]>',
'Matthew Horsfall (alh) <[email protected]>',
'Michiel Beijen <[email protected]>',
'Mike Pomraning <[email protected]>',
'Mohammad S Anwar <[email protected]>',
'Pali <[email protected]>',
'Patrick Galbraith <[email protected]>',
'Perlover <[email protected]>',
'Peter Botha <[email protected]>',
'Petr Písař <[email protected]>',
'Reini Urban <[email protected]>',
'Rob Hoelz <[email protected]>',
'Rob Van Dam <[email protected]>',
'Rudy Lippan <[email protected]>',
'Scimon <[email protected]>',
'Sergey Zhuravlev <[email protected]>',
'Sergiy Borodych <[email protected]>',
'Sharif Nassar <[email protected]>',
'Steffen Mueller <[email protected]>',
'Steven Hartland <[email protected]>',
'Taro Kobayashi <[email protected]>',
'Tatsuhiko Miyagawa <[email protected]>',
'Tim Mullin <[email protected]>',
'Ville Skyttä <[email protected]>',
'Vladimir Marek <[email protected]>',
'Walt Mankowski <[email protected]>',
'katyavoid <[email protected]>',
'kmx <[email protected]>',
'tokuhirom <[email protected]>',
'zefram <[email protected]>',
'zentooo <[email protected]>',
],
prereqs => {
test => {
recommends => {
'Net::SSLeay' => '1.43',
'Proc::ProcessTable' => 0,
'TAP::Harness' => '3.31',
'CPAN::Meta::YAML' => 0,
},
suggests => {
'Storable' => 0,
'Test::Pod' => '1.41',
'Test::DistManifest' => 0,
},
},
},
},
CONFIGURE_REQUIRES => {
'strict' => 0,
'utf8' => 0,
'warnings' => 0,
'Config' => 0,
'Data::Dumper' => 0,
'DBI' => '1.608',
'Devel::CheckLib' => '1.12',
'ExtUtils::MakeMaker' => 0,
'File::Spec' => 0,
'Getopt::Long' => 0,
},
PREREQ_PM => {
'strict' => 0,
'warnings' => 0,
'DBI' => 1.608,
'DynaLoader' => 0,
},
TEST_REQUIRES => {
'bigint' => 0,
'constant' => 0,
'lib' => 0,
'strict' => 0,
'utf8' => 0,
'vars' => 0,
'warnings' => 0,
'B' => 0,
'DBI' => 0,
'DBI::Const::GetInfoType' => 0,
'Data::Dumper' => 0,
'Encode' => 0,
'File::Temp' => 0,
'FindBin' => 0,
'Test::Deep' => 0,
'Test::More' => '0.90',
'Time::HiRes' => 0,
},
);
WriteMakefile1(%o);
exit 0;
############################################################################
#
# Name: Usage
#
# Purpose: Print Usage message and exit with error status.
#
############################################################################
sub Usage {
print STDERR <<"USAGE";
Usage: perl $0 [options]
Possible options are:
--cflags=<flags> Use <flags> for running the C compiler; defaults
to the value of "mariadb_config --cflags" or a guessed
value
--libs=<libs> Use <libs> for running the linker; defaults
to the value of "mariadb_config --libs" or a guessed
value
--testdb=<db> Use the database <db> for running the test suite;
defaults to $TESTDB
--testuser=<user> Use the username <user> for running the test suite;
defaults to no username
--testpassword=<pwd> Use the password <pwd> for running the test suite;
defaults to no password
--testhost=<host> Use <host> as a database server for running the
test suite; defaults to localhost.
--testport=<port> Use <port> as the port number of the database;
by default the port number is chosen from the
mariadb/mysqlclient library; ignored when --testhost
is set to "localhost"
--testsocket=<socket> Use <socket> as a unix socket for connecting to
the database server; by default unix socket is chosen
by mariadb/mysqlclient library; takes effect only
when --testhost is set to "localhost"
--testauthplugin=<ap> Use <ap> auth plugin when doing user authentication
handshake with server; for older server versions it is
needed to pass "mysql_native_password"
--mariadb_config Synonym for --mysql_config, override it
--mysql_config=<path> Specify <path> for mariadb_config or mysql_config script
--help Print this message and exit
All options may be configured on the command line. If they are
not present on the command line, then mariadb_config is called (if
it can be found):
mariadb_config --cflags
mariadb_config --libs
and so on. See DBD::MariaDB::INSTALL for details.
USAGE
exit 1;
}
sub CanExecute {
my ($command) = @_;
return MM->maybe_command($command) if File::Spec->file_name_is_absolute($command);
foreach my $dir (File::Spec->path) {
return 1 if MM->maybe_command(File::Spec->catfile($dir, $command));
}
return 0;
}
my %ParsedCache;
sub ParseMySQLConfig {
my ($opt, $param) = @_;
return $ParsedCache{$param} if exists $ParsedCache{$param};
return undef unless $opt->{'mysql_config'} and $opt->{'mysql_config'} ne 'skip';
my $output = `$opt->{'mysql_config'} --$param 2>&1`;
if ($? == 0 and defined $output and $output !~ /Options:|Usage:|unrecognized option/) {
$output =~ s/\s+$//s;
$output =~ s/^\s+//s;
$ParsedCache{$param} = $output;
} else {
$ParsedCache{$param} = undef;
}
return $ParsedCache{$param};
}
############################################################################
#
# Name: Configure
#
# Purpose: Automatic configuration
#
# Inputs: $param - Name of the parameter being configured
#
# Returns: Generated value, never undef
#
############################################################################
sub Configure {
my($opt, $source, $param) = @_;
if (defined($opt->{$param})) {
$source->{$param} = "User's choice";
return;
}
# First try to get options values from mysql_config
if ($param eq 'cflags') {
my $str = ParseMySQLConfig($opt, 'cflags');
if (defined $str) {
$opt->{$param} = $str;
$source->{$param} = "mysql_config";
return;
}
} elsif ($param eq 'libs') {
foreach (qw(libmysqld-libs libs_r libs)) {
my $str = ParseMySQLConfig($opt, $_);
next unless defined $str;
# Unfortunately ExtUtils::MakeMaker doesn't deal very well with -L'...'
$str =~ s/\-L\'(.*?)\'/-L$1/sg;
$str =~ s/\-L\"(.*?)\"/-L$1/sg;
# libmysqld-libs and libs_r do not have to be always installed
# check that we use correct library, sometimes library reported
# by mysql_config is not present but linker find different
# version in system wide location; so check that version in
# header file matches version in library
my ($main_lib, @libdirs, @ldflags);
for (split ' ', $str) {
if (not defined $main_lib and /^-l(?:.*mariadb.*|.*mysql.*)$/) {
$main_lib = $_;
} elsif (/^-L/) {
push @libdirs, $_;
} else {
push @ldflags, $_;
}
}
my $check_passed;
if (defined $main_lib) {
my $function = "\n#ifndef MYSQL_VERSION_ID\n#include <mysql_version.h>\n#endif\n";
if ($_ eq 'libmysqld-libs') {
# libmariadbd.so from MariaDB 10.3.1 - 10.3.7 is broken, unusable
# and always crash in mysql_real_connect() function, so avoid its usage
# https://jira.mariadb.org/browse/MDEV-16478
$function .= "\n#if defined(MARIADB_BASE_VERSION) || defined(MARIADB_PACKAGE_VERSION)\nif (mysql_get_client_version() >= 100301 && mysql_get_client_version() < 100308) return 1;\n#endif\n";
# libmysqld.a from MySQL 8.x is broken too
$function .= "\n#if !defined(MARIADB_BASE_VERSION) && !defined(MARIADB_PACKAGE_VERSION)\nif (mysql_get_client_version() >= 80000) return 1;\n#endif\n";
}
# MariaDB Connector/C 3.1.10+ has broken mysql_get_client_version() function, so use mariadb_get_infov(MARIADB_CLIENT_VERSION_ID) instead
$function .= "size_t version;\n";
$function .= "#if defined(MARIADB_PACKAGE_VERSION) && defined(MARIADB_PACKAGE_VERSION_ID) && MARIADB_PACKAGE_VERSION_ID >= 30000\n";
$function .= "if (mariadb_get_infov((void *)0, MARIADB_CLIENT_VERSION_ID, &version) != 0)\n";
$function .= "#endif\n";
$function .= "version = mysql_get_client_version();\n";
$function .= 'return (version == MYSQL_VERSION_ID) ? 0 : 1;';
# libmysqld is built using g++ rather than gcc and sometimes
# we have to use libstdc++ to resolve linking problems
foreach my $add_ldflags (undef, '-lstdc++') {
my $ldflags = join ' ', @ldflags, (defined $add_ldflags ? $add_ldflags : ());
if ($Config{usedl}) {
# check that we can create a shared library (not executable)
check_lib(
LIBS => (join ' ', @libdirs, $main_lib),
ldflags => (join ' ', @libdirs, $ldflags, $Config{lddlflags}),
ccflags => (join ' ', $opt->{cflags}, $Config{cccdlflags}),
header => \@mysql_headers,
function => $function,
not_execute => 1,
) or next;
}
# and now create executable and do real version check
check_lib(
LIBS => (join ' ', @libdirs, $main_lib),
ldflags => (join ' ', @libdirs, $ldflags),
ccflags => $opt->{cflags},
header => \@mysql_headers,
function => $function,
) or next;
$str .= ' ' . $add_ldflags if defined $add_ldflags;
$check_passed = 1;
last;
}
}
# libs param is checked as last, so ensure that mysql_config
# error is reported back to the caller
next unless $_ eq 'libs' or $check_passed;
$opt->{$param} = $str;
$source->{$param} = "mysql_config";
return;
}
}
# Ok, mysql_config doesn't work. We need to do our best
# First check environment variables
my $normparam = uc($param);
$normparam =~ tr/-/_/;
if (defined($ENV{'DBD_MARIADB_'.$normparam})) {
$opt->{$param} = $ENV{'DBD_MARIADB_'.$normparam};
$source->{$param} = 'environment';
}
# Then try to guess
unless ($opt->{$param}) {
if ($param eq 'testuser') {
my $user = $ENV{USER} || '';
print "
PLEASE NOTE:
For 'make test' to run properly, you must ensure that the
database user '$user' can connect to your MariaDB or MySQL server
and has the proper privileges that these tests require such
as 'drop table', 'create table', 'drop procedure', 'create procedure'
as well as others.
mysql> grant all privileges on test.* to '$user'\@'localhost' identified by 's3kr1t';
For MySQL 8 it is needed to use different syntax:
mysql> create user '$user'\@'localhost' identified by 's3kr1t';
mysql> grant all privileges on test.* to '$user'\@'localhost';
You can also optionally set the user to run 'make test' with:
perl Makefile.PL --testuser=username
";
$opt->{$param} = $user;
$source->{$param} = 'guessed';
}
elsif ($param eq "testdb") {
$source->{$param} = "default";
$opt->{$param} = $TESTDB;
}
elsif ($param eq "testpassword") {
$source->{$param} = "default";
$opt->{$param} = "";
}
elsif ($param eq "cflags") {
$source->{$param} = "guessed";
my ($dir, $file) = SearchFor('include', 'mysql.h');
if ($dir) {
$opt->{$param} = "-I$dir";
return;
}
die <<"MSG";
Failed to determine directory of mysql.h. Use
perl Makefile.PL --cflags=-I<dir>
to set this directory. For details see DBD::MariaDB::INSTALL,
section "C Compiler flags" or type
perl Makefile.PL --help
MSG
}
elsif ($param eq "libs") {
$source->{$param} = "guessed";
my @files = qw(mariadb.lib libmariadb.lib mariadbclient.lib mysqlclient.lib
libmysqld.so libmysqld.a libmariadb.so libmariadb.a
libmysqlclient.so libmysqlclient.a);
my ($dir, $file) = SearchFor('lib', @files);
if ($dir) {
my $lib = $file;
$lib =~ s/\.[^.]+$//;
$lib =~ s/^lib//;
$opt->{$param} = "-L$dir -l$lib";
return;
}
die <<"MSG";
Failed to determine directory of MariaDB or MySQL client library. Use
perl Makefile.PL --libs="-L<dir> -l<library>"
to set directory and client library. For details see the DBD::MariaDB::INSTALL,
section "Linker flags" or type
perl Makefile.PL --help
MSG
}
elsif ($param eq "testhost" || $param eq "testport" || $param eq "testsocket" || $param eq "testauthplugin") {
# known parameter, but do nothing
}
else {
die "Unknown configuration parameter: $param";
}
}
}
sub SearchFor {
my($subdir, @files) = @_;
my @dirs = ($^O eq 'MSWin32') ? qw(C:) : qw(/usr/local /usr /opt);
for my $f (@files) {
for my $dir (@dirs) {
my $try1 = File::Spec->catdir($dir, $subdir);
my $try2 = File::Spec->catdir($try1, "mariadb");
my $try3 = File::Spec->catdir($try1, "mysql");
for my $path ($try1, $try2, $try3) {
my $file = File::Spec->catfile($path, $f);
if (-f $file) {
my (undef, undef, $file) = File::Spec->splitpath($file);
return ($path, $file);
}
}
}
}
}
package MY;
sub postamble { return DBI::DBD::dbd_postamble(@_); }
package main;
sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
my %params=@_;
my $eumm_version=$ExtUtils::MakeMaker::VERSION;
$eumm_version=eval $eumm_version;
die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
die "License not specified" if not exists $params{LICENSE};
if ($params{META_MERGE} and $params{META_MERGE}->{'meta-spec'}->{version} >= 2 and $eumm_version < 6.68) {
#EUMM 6.68 has problems with meta-spec 2
delete $params{META_MERGE}->{'meta-spec'};
if ($params{META_MERGE}->{resources}) {
foreach (values %{$params{META_MERGE}->{resources}}) {
$_ = $_->{url} || $_->{web} if ref $_ eq 'HASH';
}
}
if ($params{META_MERGE}->{prereqs}) {
$params{CONFIGURE_REQUIRES} = { %{$params{CONFIGURE_REQUIRES} || {'ExtUtils::MakeMaker' => 0}}, %{$params{META_MERGE}->{prereqs}->{configure}->{requires} || {}} };
$params{BUILD_REQUIRES} = { %{$params{BUILD_REQUIRES} || {'ExtUtils::MakeMaker' => 0}}, %{$params{META_MERGE}->{prereqs}->{build}->{requires} || {}} };
$params{TEST_REQUIRES} = { %{$params{TEST_REQUIRES} || {}}, %{$params{META_MERGE}->{prereqs}->{test}->{requires} || {}} };
$params{PREREQ_PM} = { %{$params{PREREQ_PM} || {}}, %{$params{META_MERGE}->{prereqs}->{runtime}->{requires} || {}} };
my @recommends = (
%{$params{META_MERGE}->{prereqs}->{configure}->{recommends} || {}},
%{$params{META_MERGE}->{prereqs}->{configure}->{suggests} || {}},
%{$params{META_MERGE}->{prereqs}->{build}->{recommends} || {}},
%{$params{META_MERGE}->{prereqs}->{build}->{suggests} || {}},
%{$params{META_MERGE}->{prereqs}->{test}->{recommends} || {}},
%{$params{META_MERGE}->{prereqs}->{test}->{suggests} || {}},
%{$params{META_MERGE}->{prereqs}->{runtime}->{recommends} || {}},
%{$params{META_MERGE}->{prereqs}->{runtime}->{suggests} || {}},
);
$params{META_MERGE}->{recommends} = { %{$params{META_MERGE}->{recommends} || {}}, @recommends } if @recommends;
delete $params{META_MERGE}->{prereqs};
}
}
if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
#EUMM 6.5502 has problems with BUILD_REQUIRES
$params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
delete $params{BUILD_REQUIRES};
}
if ($params{TEST_REQUIRES} and $eumm_version < 6.64) {
#EUMM 6.64 has problems with TEST_REQUIRES
$params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{TEST_REQUIRES}} };
delete $params{TEST_REQUIRES};
}
if ($params{CONFIGURE_REQUIRES} and $eumm_version < 6.52) {
#EUMM prior to 6.52 has problems with CONFIGURE_REQUIRES
$params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{CONFIGURE_REQUIRES}} };
delete $params{CONFIGURE_REQUIRES};
}
if ($params{MIN_PERL_VERSION} and $eumm_version < 6.48) {
#EUMM prior to 6.48 has problems with MIN_PERL_VERSION
$params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , perl => $params{MIN_PERL_VERSION} };
delete $params{MIN_PERL_VERSION};
}
delete $params{META_MERGE} if $eumm_version < 6.46;
delete $params{META_ADD} if $eumm_version < 6.46;
delete $params{LICENSE} if $eumm_version < 6.31;
delete $params{AUTHOR} if $] < 5.005;
delete $params{ABSTRACT_FROM} if $] < 5.005;
delete $params{BINARY_LOCATION} if $] < 5.005;
ExtUtils::MakeMaker::WriteMakefile(%params);
}