-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile.PL
338 lines (297 loc) · 9.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
#!perl
#-----------------------------------------------------------------------------
#
# Copyright (c) 2011 Stefan Suciu <[email protected]>
# Copyright (c) 2011 Damyan Ivanov <[email protected]>
# Copyright (c) 2011 Marius Popa <[email protected]>
# Copyright (c) 2011 Alexandr Ciornii <[email protected]>
# Copyright (c) 1999-2008 Edwin Pratomo
# Portions Copyright (c) 2001-2005 Daniel Ritz
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
#
#-----------------------------------------------------------------------------
# Changes:
#
# 2011-09-02: Integrated patch from real-dam
# Do not link with libdl.so on GNU/Linux
#
# 2011-04-04: Integrated patch from Alexandr Ciornii regarding
# WriteMakefile sub.
# Moved prompting to subs, other layout changes.
#
# 2011-04-03, Added CLI prompting with optional -interactive command
# line parameter.
# Added support for VC++ copy-paste from the original (NOT tested!)
#
# 2011-03-30, Refactored.
# Modified to use environment vars or helper subs to locate Firebird
# (only MinGW support), removed the CLI prompts.
# inspired by the App::Info module: Info.pm - 2008-07-18 16:17:45Z by david
# and DBD::Pg - Makefile.PL 2010-11-21 04:19:18Z by turnstep
#
# 2011-01-31, stefansbv:
# using the three-argument form of open for reading tests-setup.tmp.conf
#
# 2011-01-26, stefansbv:
# fixed the isql tool path and the command line
# (using quotes around parameters and canonpath)
# when isql error create the test database and inform the user
# improved support for MinGW (now using the Config module)
# added support for ActivePerl! :)
#
# Notes: MS specific required Firebird installation setting: Copy
# Firebird client library to <system> directory? - Yes, unless the
# Firebird HOME is in your path.
#
package MY;
our $postamble;
sub postamble {
return $postamble;
}
1;
package main;
use strict;
use warnings;
use Carp;
use 5.008;
use Getopt::Long;
use File::Spec;
use File::Basename;
use ExtUtils::MakeMaker 5.16, qw(prompt &WriteMakefile $Verbose);
use Config;
# Globals vars
our $EMBEDDED = 0;
BEGIN {
# Theory of operation:
# we copy this Makefile.PL to embed/ and set $EMBEDDED to 1 there
# this way we have to maintain one code base with special cases for
# the embedded module build
# See create_embedded_Makefile_PL below
unless ($EMBEDDED) {
unshift @INC, 'inc';
require FirebirdMaker;
FirebirdMaker->import;
}
}
my $interactive;
my $help;
my $os = $^O;
GetOptions(
interactive => \$interactive,
help => \$help,
) unless $EMBEDDED;
if ($help) {
help_message();
exit;
}
my $module_name = $EMBEDDED ? 'DBD::FirebirdEmbedded' : 'DBD::Firebird';
print "Configuring $module_name (on $os)\n";
$FB::libfbembed_available = 0;
# We set FIREBIRD_HOME from the first found of:
# 1. Environment variable
# 2. Helper subs (search Firebird in the known locations)
unless ($EMBEDDED) {
# 1. Environment variables
$FB::HOME = $ENV{FIREBIRD_HOME};
$FB::INC = $ENV{FIREBIRD_INCLUDE};
$FB::LIB = $ENV{FIREBIRD_LIB};
if ($FB::HOME) {
# 2. Subdirectory of FIREBIRD_HOME
if ($os eq 'darwin') {
$FB::INC ||= (grep -d, (
# could be set to Resources/ or not
File::Spec->catdir( $FB::HOME, '..', 'Headers' ),
File::Spec->catdir( $FB::HOME, 'Headers' ),
File::Spec->catdir( $FB::HOME, 'include' ),
))[0];
$FB::LIB ||= (grep -d, (
File::Spec->catdir( $FB::HOME, '..', 'Libraries' ),
File::Spec->catdir( $FB::HOME, 'Libraries' ),
File::Spec->catdir( $FB::HOME, 'lib' ),
))[0];
}
else {
$FB::INC ||= File::Spec->catdir( $FB::HOME, 'include' );
$FB::LIB ||= File::Spec->catdir( $FB::HOME, 'lib' );
}
}
else {
# No FIREBIRD_HOME
# We could check FIREBIRD_INCLUDE and FIREBIRD_LIB and set
# FIREBIRD_HOME as parent dir, but maybe is to weird :)
# Anyway their value take precedence in locate_firebird sub.
# Try to locate Firebird in the ususal places
if ($os eq 'MSWin32' || $os eq 'cygwin') {
locate_firebird_ms();
}
elsif ($os eq 'darwin') {
$FB::HOME = '/Library/Frameworks/Firebird.framework/Resources';
$FB::INC = '/Library/Frameworks/Firebird.framework/Headers';
$FB::LIB = '/Library/Frameworks/Firebird.framework/Libraries';
}
else {
locate_firebird();
}
}
detect_firebird_api_version();
}
my $client_lib = ( $EMBEDDED and $FB::API_VER < 30 ) ? 'fbembed' : 'fbclient';
if ($interactive) {
# Interactive mode setup
welcome_msg();
prompt_for_settings();
}
else {
print "\n";
print 'FIREBIRD_HOME : ', $FB::HOME || '(none)', "\n";
print 'FIREBIRD_INCLUDE: ', $FB::INC || '(none)', "\n";
print 'FIREBIRD_LIB : ', $FB::LIB || '(none)', "\n";
print 'Client library : ', $client_lib,"\n";
print "\n";
save_test_parameters() unless $EMBEDDED;
}
do {
eval {
require DBI::DBD;
};
if ($@) {
print "Could not load DBI::DBD - is the DBI module installed?\n";
exit 0;
}
$MY::postamble ||= DBI::DBD::dbd_postamble();
## Prevent duplicate debug info as dbd_postamble also calls this
local *STDOUT;
$FB::dbi_arch_dir ||= DBI::DBD::dbd_dbi_arch_dir();
} unless $EMBEDDED;
my $cflags = $Config{q{ccflags}}||'';
$cflags .= " $ENV{CFLAGS}" if $ENV{CFLAGS};
if ($Config{cc} =~ /gcc/) {
$cflags = "-Wall -fno-strict-aliasing $cflags";
}
my @inc;
for ( $FB::INC, $FB::dbi_arch_dir ) { push @inc, qq(-I"$_") if $_ }
my %MakeParams = (
NAME => $module_name,
VERSION_FROM => $EMBEDDED
? 'FirebirdEmbedded.pm'
: 'Firebird.pm', # finds $VERSION
C => ['dbdimp.c'],
H => [ 'dbdimp.h', $EMBEDDED ? 'FirebirdEmbedded.h' : 'Firebird.h' ],
CCFLAGS => $cflags,
( $EMBEDDED ? ( DEFINE => '-DEMBEDDED' ) : () ),
INC => join( ' ', @inc ),
OBJECT => join( ' ',
$EMBEDDED ? "FirebirdEmbedded.o" : "Firebird.o", "dbdimp.o" ),
LIBS => [''],
OPTIMIZE => $Config{optimize},
XSPROTOARG => '-noprototypes',
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz' },
clean => {
FILES =>
qq(*.xsi *.old t/*.old *~ t/*~ trace.txt t/trace.txt lib/DBD/Firebird/*~ lib/DBD/Firebird/*.old lib/Bundle/DBD/*~ lib/Bundle/DBD/*.old dll.* fb_init fb_sem fb_trace_* dbd-fb-testdb.fdb)
},
realclean => { FILES => qq($test_conf $test_mark t/*.sql embed t/embed-*.t) },
AUTHOR => 'Edwin Pratomo ([email protected])',
ABSTRACT =>
'DBD::Firebird is a DBI driver for Firebird, written using Firebird C API.',
PREREQ_PM => { DBI => 1.41 },
CONFIGURE_REQUIRES => {
DBI => 1.41,
'File::Which' => 0,
},
BUILD_REQUIRES => {
},
TEST_REQUIRES => {
'File::Path' => 0,
'File::Temp' => 0,
'Math::BigFloat' => 1.55,
'Test::CheckDeps' => 0.007,
'Test::Deep' => 0,
'Test::Exception' => 0.31,
'Test::More' => 0.4,
'Time::HiRes' => 0,
},
LICENSE => 'perl',
MIN_PERL_VERSION => '5.008001',
META_MERGE => {
resources =>
{ repository => 'https://github.com/mariuz/perl-dbd-firebird', },
},
);
# The OS specific build environment setup
SWITCH: {
$os eq 'MSWin32' && do {
# Choices for the compiler
if ( $Config{cc} =~ m{gcc} ) {
setup_for_ms_gcc();
}
elsif ( $Config{cc} eq q{cl} ) {
setup_for_ms_cl();
}
else {
print "No suitable compiler found\n";
print "(Try: ppm install MinGW, to install MinGW!)\n";
exit 1;
}
last SWITCH;
};
$os eq 'cygwin' && do {
setup_for_cygwin();
last SWITCH;
};
$os eq 'solaris' && do {
$MakeParams{LIBS} = '-lgdsmt -lm -lc';
last SWITCH;
};
$os eq 'linux' && do {
$MakeParams{LIBS} = "-L$FB::LIB -l$client_lib ";
last SWITCH;
};
$os eq 'freebsd' && do {
$MakeParams{LIBS} = "-L$FB::LIB -l$client_lib ";
last SWITCH;
};
$os eq 'gnukfreebsd' && do {
$MakeParams{LIBS} = "-L$FB::LIB -l$client_lib ";
last SWITCH;
};
$os eq 'darwin' && do {
my $framework_dir = dirname $FB::HOME; #"/Library/Frameworks/Firebird.framework";
my $framework_name = File::Spec->catfile( $framework_dir, "Firebird");
# For some reason, the framework file can be a broken symlink, see issue #??
# We can use -e to check if the symlink is broken:
if ( -e $framework_name ) {
$MakeParams{LDDLFLAGS} = $Config{lddlflags} . " -framework Firebird ";
}
else {
$MakeParams{LDDLFLAGS} = $Config{lddlflags};
$MakeParams{LIBS} = "-L$FB::LIB -l$client_lib ";
}
last SWITCH;
};
carp "DBD::Firebird is not supported on platform $os.\n";
exit 1;
}
unless ($EMBEDDED) {
if ($FB::libfbembed_available or $FB::API_VER >= 30) {
print "Found libfbembed, will build DBD::FirebirdEmbed too.\n";
create_embedded_files();
}
else {
print
"libfbembed not found and API version is $FB::API_VER, building of DBD::FirebirdEmbed skipped.\n";
# make sure there is no embedded build involved
my $mfpl = File::Spec->catfile( 'embed', 'Makefile.PL' );
unlink $mfpl if -e $mfpl;
}
}
# And last but not least write the Makefile
WriteMakefile1(%MakeParams);
closing_msg()
if !$EMBEDDED
and !$interactive
and ( !defined $ENV{DBI_PASS} and !defined $ENV{ISC_PASSWORD} );
exit 0;
#- end of Makefile.PL