DBD-ODBC

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

    # line below does nothing since 6.33 of MakeMaker.
    BUILD_REQUIRES => {
        "Test::Simple" => 0.90, # actually Test::More pkg in T::S dist,
        "Test::Output" => 1.031 },
    PREREQ_PM    => { "DBI" => 1.609 },
    clean        => { FILES => 'ODBC.xsi dbdodbc.h' },
    dist         => {
	DIST_DEFAULT => 'clean distcheck tardist',
	PREOP        => '$(MAKE) -f Makefile.old distdir',
	COMPRESS     => 'gzip -v9', SUFFIX => 'gz'
    },
    OBJECT       => '$(O_FILES)',
    DEFINE => q{},
 );
# just save the open suse guys patching the following:
if ($ENV{RPM_OPT_FLAGS}) {
    $opts{OPTIMIZE} = $ENV{RPM_OPT_FLAGS};
}

my $eumm = $ExtUtils::MakeMaker::VERSION;
$eumm =~ tr/_//d;

$opts{LICENSE} = 'perl' if $eumm >= 6.3002;
$opts{NO_META} = 1 if $eumm >= 6.10;

if ($eumm >= 5.43) {
    $opts{AUTHOR} = 'Tim Bunce, Jeff Urlwin, Martin J. Evans mailto:dbi-users@perl.org';
    $opts{ABSTRACT} = 'ODBC driver for the DBI module.';
    $opts{CAPI} = 'TRUE' if $Config{archname} =~ /-object\b/i;
    # Never set PREREQ_FATAL to true - it is flawed
    # - see http://wiki.cpantesters.org/wiki/CPANAuthorNotes
    #$opts{PREREQ_FATAL} = 1;
    # See
    # http://www.mail-archive.com/cpan-testers-discuss%40perl.org/msg00076.html
    # In ExtUtils::MakeMaker 6.32 and earlier CONFIGURE was run after PREREQ_PM
    # so we could safely require DBI::DBD here and PREREQ_PM would fail first
    # if DBI was not installed. Since 6.33 CONFIGURE is run before PREREQ_PM
    # so now the require below fails and if we do not exit 0 without generating
    # a Makefile cpan-testers will fail us if DBI is not found.
    $opts{CONFIGURE} = sub {
        eval {require DBI::DBD;};
        if ($@) {
            warn $@;
            exit 0;
        } else {
        my $dbi_arch_dir = DBI::DBD::dbd_dbi_arch_dir();
        if (exists($opts{INC})) {
            return {INC => "$opts{INC} -I$dbi_arch_dir"};
        } else {
            return {INC => "-I$dbi_arch_dir"};
        }
    }
    };
}
if ($eumm >= 5.48) {
    $opts{PREREQ_PRINT} = 1;
}

my $opt_g = 0;                  # build debug
my $opt_o = q{};                # odbc home overrides ODBCHOME
my $opt_u = undef;              # build unicode version
my $opt_e = undef;              # easysoft
my $opt_x = undef;              # prefer unixODBC over iODBC
my $opt_w = undef;              # enable -Wall (gcc only)

$opt_u = 1 if $ENV{DBD_ODBC_UNICODE};

my @options = ("g!" => \$opt_g,
               "o=s" => \$opt_o,
               "u!" => \$opt_u,
               "e!" => \$opt_e,
               "x!" => \$opt_x,
               "w!" => \$opt_w);
my %options = @options;
Getopt::Long::GetOptions(@options) or die "Invalid arguments\n";

print "Command line options:\n",
    (map {"  $_ = " . (defined(${$options{$_}}) ? ${$options{$_}} : 'undef') . "\n"} keys %options), "\n";
if (($ENV{LANG} || q{}) =~ m/utf-?8/i) {
    print <<"EOT";

Your LANG environment variable is set to "$ENV{LANG}"\a
This is known to cause problems in some perl installations - even stopping
this Makefile.PL from running without errors. If you have problems please
try re-running with LANG unset or with the utf part of LANG removed.

EOT
    sleep 4;
}

if ($Config{useithreads}) {
    print <<'EOT';
You are using a Perl configured with threading enabled.
Please read the warnings in DBI about this.

EOT
    if ($OSNAME ne 'MSWin32') {
        print <<'EOT';
You should also be aware that on non-Windows platforms ODBC drivers come
in two forms, thread-safe and non-thread-safe drivers and you may need
to make sure you are using the right one.

EOT
    }
    # see rt 46944 for why the following was suggested to be commented
    # out which I rejected as PERL_MM_USE_DEFAULT can be used
    prompt("Press return to continue...");
}
print "Overriding ODBC Directory with command line option: $opt_o\n"
    if $opt_o ;
if ($opt_g) {
   print "Setting debug options!\n";
   if ($OSNAME eq 'MSWin32') {
      $opts{OPTIMIZE} = '/Zi';
   } else {
      $opts{OPTIMIZE} = '-g -O0';
   }
}
if ($opt_w) {
    $opts{CCFLAGS} = '-Wint-to-pointer-cast -fno-strict-aliasing -Wall -Werror=format-security';
}

Makefile.PL  view on Meta::CPAN

    if (!$myodbc && ($opt_x || $ENV{PERL_DBD_ODBC_PREFER_UNIXODBC})) {
        ($myodbc, $odbclibdir) = find_unixodbc($odbchome);
    } else {
        ($myodbc, $odbclibdir) = find_iodbc($odbchome) if !$myodbc;

        ($myodbc, $odbclibdir) = find_unixodbc($odbchome) if !$myodbc;
    }

    $myodbc = 'Microsoft ODBC'
        if (!$myodbc &&
                (-e "$odbchome/system/odbc32.dll" or
                     -e "$odbchome/system32/odbc32.dll" or
                         -e "$odbchome/odbc32.dll"));

    $myodbc = 'empress'
        if !$myodbc && glob "$odbchome/lib/libempodbc.*";

    $myodbc = 'intersolve'
        if !$myodbc && -f "$odbchome/include/qeodbc.h";

    $myodbc = 'sapdb'
        if !$myodbc && -f "$odbchome/lib/libsqlod.$arext";

    $myodbc = 'adabas'
        if (!$myodbc &&
                $ENV{DBROOT} &&
                    ($odbchome eq $ENV{DBROOT}) &&
                        -f "$odbchome/lib/odbclib.$arext");

    $myodbc = 'udbc'
        if !$myodbc && -f "$odbchome/lib/libudbc.$arext";

    $myodbc = 'solid'
        if !$myodbc && -f "$odbchome/lib/libsolcli.$dlext";

    # JL 2002-12-16: This test is accurate on Unix (Solaris 7) with IBM
    # Informix ClientSDK 2.80.UC1, which includes IBM Informix CLI
    # v3.81.000, an ODBC 3.x driver.
	# NB: The correct value for $ODBCHOME is $INFORMIXDIR.
    $myodbc = 'informix'
        if !$myodbc && -f "$odbchome/lib/cli/libifcli.$dlext";

    if (!$myodbc) {
	local($LIST_SEPARATOR) = ", ";
	my($list) = "@known_drivers";
	$list =~ s/^(.{30,70})\s/$1\n\t/gmo;
        die qq{I cannot find an ODBC driver manager that I recognize.\n...And I know about these drivers:\n$list\n};
    }

    warn "\nThis looks like a $myodbc type of driver manager.\n";

    # some specific checks for incompatibilities
    if (defined($opt_u) && $opt_u) {
        if (-e File::Spec->catfile($odbcincdir, 'sql.h')) {
            my $fh;
            open($fh, q/</, "$odbchome/include/sql.h") or
                die "Failed to open $odbchome/include/sql.h - $!";
            my @lines = <$fh>;
            my @found = grep {/iODBC driver manager/i} @lines;
            if (scalar(@found)) {
                die "\n\nDBD::ODBC does not support unicode with iODBC and this looks like iODBC. The iODBC driver manager expects wide characters to be 4 bytes long and DBD::ODBC wants wide characters to be UTF16.\nEither\no) Rerun without the -u sw...
            }
            close $fh or warn "Failed to close sql.h - $!";
        }
    }

    if ($myodbc eq 'Microsoft ODBC') {
        print "\nBuilding for Microsoft under Cygwin\n";
        $opts{LIBS} = "-L/usr/lib/w32api -lodbc32";
        print {$sqlhfh} "#include <windows.h>\n";
        print {$sqlhfh} "#include <sql.h>\n";
        print {$sqlhfh} "#include <sqltypes.h>\n";
        print {$sqlhfh} "#include <sqlext.h>\n";
        print {$sqlhfh} "#undef WIN32\n";
        $opts{dynamic_lib} = {OTHERLDFLAGS => "-lodbc32"};
    } elsif ($myodbc eq 'ingrescli') {
        $opts{INC} .= " -I$odbcincdir";
        $opts{LIBS} = "-L$odbclibdir -liiodbc.1";
        print {$sqlhfh}
            qq{typedef void* PTR;\n#include <sql.h>\n#include <sqlext.h>\n};
    } elsif ($myodbc eq 'iodbc') {
        my @libs = glob "$odbclibdir/*iodbc*.*";
        my @ilibs = grep { /\.($dlext|$soext|$arext)/ } @libs;
        if (scalar(@ilibs) == 0) {
            die "That's odd, I can't see any iodbc libs in $odbclibdir. " .
                "This is all I found:\n" . join(q{,}, @libs) . "\n" .
                "Perhaps you need to install the iODBC development " .
                "package, often called libiodbc-dev.";
        }
        # Note: we use DEFINE not INC for iODBC so we don't get its config.h
        my $ilibpath = $ilibs[0]; # if both .so and .a, pick based on LINKTYPE?
        my $ilibname = basename($ilibpath);
        $opts{DEFINE} .= " -I$odbcincdir";
        if ($ilibname =~ /^iodbc/) { # no "lib" prefix
            $opts{LIBS} = q{};
            $opts{dynamic_lib} = { OTHERLDFLAGS => "$ilibpath" };
        }
        else {
            if ($ilibname =~ /^lib(iodbc[^.]*?)\.\w+$/) {
                # remove lib prefix and .so suffix so "-l" style link can be used
                $ilibname = $1;
                $opts{LIBS} = "-L$odbclibdir -l$ilibname";
            } else {
                # cannot use "-l" style link so specify pull path
                $opts{LIBS} = q{};
                $opts{dynamic_lib} = { OTHERLDFLAGS => "$ilibpath" };
            }
            warn "Warning: LD_LIBRARY_PATH doesn't include $odbchome/lib\n"
                if (!defined($ENV{LD_LIBRARY_PATH})) ||
                    ($ENV{LD_LIBRARY_PATH} =~ /\Q$odbclibdir/);
        }
        if (-x "$odbchome/bin/iodbc-config") {
            my $cf = `$odbchome/bin/iodbc-config --cflags 2>&1`;
            if ($cf =~ /\-I/) {
                chomp $cf;
                $cf =~ s/\n//g;
                print qq/Adding iodbc_config --cflags "$cf" to CC line\n/;
                $opts{DEFINE} .= " $cf";
            }
        }
        print {$sqlhfh} qq{#include <sqlext.h>\n};



( run in 1.848 second using v1.01-cache-2.11-cpan-39bf76dae61 )