File: Makefile.PL

package info (click to toggle)
libdbd-firebird-perl 0.91-2%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 680 kB
  • sloc: perl: 4,085; ansic: 2,262; makefile: 14
file content (312 lines) | stat: -rw-r--r-- 8,859 bytes parent folder | download | duplicates (2)
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
#!perl
#-----------------------------------------------------------------------------
#
#   Copyright (c) 2011 Stefan Suciu <stefbv70@gmail.com>
#   Copyright (c) 2011 Damyan Ivanov <dmn@debian.org>
#   Copyright (c) 2011 Marius Popa <mapopa@gmail.com>
#   Copyright (c) 2011 Alexandr Ciornii <alexchorny@gmail.com>
#   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. Subdirectory of FIREBIRD_HOME
# 3. 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
        $FB::INC = $FB::INC || File::Spec->catdir( $FB::HOME, 'include' );
        $FB::LIB = $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') {
            locate_firebird_ms();
        }
        else {
            locate_firebird();
        }
    }
}

my $client_lib = $EMBEDDED ? 'fbembed' : 'fbclient';

if ($interactive) {

    # Interactive mode setup
    welcome_msg();

    prompt_for_settings();
}
else {
    print "\n";
    print 'FIREBIRD_HOME   : ', $FB::HOME, "\n";
    print 'FIREBIRD_INCLUDE: ', $FB::INC,  "\n";
    print 'FIREBIRD_LIB    : ', $FB::LIB,  "\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 $comp_opts = $Config{q{ccflags}}//'';
$comp_opts .= " $ENV{CFLAGS}" if $ENV{CFLAGS};

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      => "-Wall -fno-strict-aliasing $comp_opts",
    ( $EMBEDDED ? ( DEFINE => '-DEMBEDDED' ) : () ),
    INC          => qq(-I"$FB::INC" -I"$FB::dbi_arch_dir"),
    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_trace_* dbd-fb-testdb.fdb)
    },
    realclean => { FILES => qq($test_conf $test_mark t/*.sql embed t/embed-*.t) },
    AUTHOR => 'Edwin Pratomo (edpratomo@users.sourceforge.net)',
    ABSTRACT =>
'DBD::Firebird is a DBI driver for Firebird, written using Firebird C API.',
    PREREQ_PM          => { DBI          => 1.41 },
    CONFIGURE_REQUIRES => { DBI          => 1.41 },
    BUILD_REQUIRES     => {
        'Test::More' => 0.4,
        'Test::Exception' => 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} ) {     # not tested
            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 '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 'hpux' && do {
        $MakeParams{LIBS} = '-lgds -ldld';
        last SWITCH;
    };
    $os eq 'sunos' && do {
        $MakeParams{LIBS} = '-lgdslib -ldl';
        last SWITCH;
    };
    $os eq 'irix' && do {
        $MakeParams{LIBS} = '-lgds -lsun';
        last SWITCH;
    };
    $os eq 'aix' && do {
        $MakeParams{LIBS} = '-lgdsshr';
        last SWITCH;
    };
    $os eq 'dgux' && do {
        $MakeParams{LIBS} = '-lgds -lgdsf -ldl -ldgc';
        last SWITCH;
    };
    $os eq 'osf1' && do {
        $MakeParams{LIBS} = '-lgds';
        last SWITCH;
    };
    $os eq 'sysv' && do {
        $MakeParams{LIBS} = '-lgds -lnsl -lsocket -ldl';
        last SWITCH;
    };
    $os eq 'darwin' && do {
        $MakeParams{LDDLFLAGS} = $Config{lddlflags} . " -framework Firebird ";
        last SWITCH;
    };

    carp "DBD::Firebird is not supported on platform $os.\n";
    exit 1;
}

unless ($EMBEDDED) {
    if ($FB::libfbembed_available) {
        print "Found libfbembed, will build DBD::FirebirdEmbed too.\n";
        create_embedded_files();
    }
    else {
        print "libfbembed not found, 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 ( !$ENV{DBI_PASS} and !$ENV{ISC_PASSWORD} );


exit 0;

#- end of Makefile.PL