#!/bin/bash set -ex # Make sure that DB2PATH is set and contains a Cygwin path with no spaces. : ${DB2PATH:=$DB2_HOME} : ${DB2PATH:?DB2_HOME or DB2PATH must be set} DB2PATH=$(cygpath -u $(cygpath -d "$DB2PATH")) if [ -z "$DB2LIB" ]; then case $(uname -s) in *64) DB2LIB=$DB2PATH/lib/Win32;; *) DB2LIB=$DB2PATH/lib;; esac export DB2LIB fi # Create links with proper names for GCC of DB2 libraries { cd "$DB2LIB" ln -fv db2api.lib libdb2api.a ln -fv db2cli.lib libdb2cli.a } # Perl on Cygwin, when linking to DLLs, passes ld the # --export-all-symbols option. For some reason, this fails when # linking against DB2, so we disable this feature temporarily. # # For Perl 5.8 we need to edit this in the /usr/bin/perlld script. # For Perl 5.10 we disable it in Makefile.PL in the below patch. if [ -e /usr/bin/perlld ]; then if [ -e /usr/bin/perlld.bak ]; then mv /usr/bin/perlld.bak /usr/bin/perlld fi sed -i.bak -e 's/EXPORT_ALL = 1/EXPORT_ALL = 0/' /usr/bin/perlld fi set +e # Download, unpack, patch, install DBD::DB2 perl -MCPAN -e 'CPAN::Shell->look("DBD::DB2")' <<'EOF' set -e patch Makefile.PL <<'END_PATCH' --- Makefile.PL.orig 2008-07-01 14:35:53.356596500 +1200 +++ Makefile.PL 2008-07-01 14:39:09.480356700 +1200 @@ -134,8 +134,14 @@ } } } - - $sysliblist = "-L$DB2LIB -ldb2"; + + if ($os eq 'cygwin') { + $sysliblist = "-L$DB2LIB -ldb2cli -ldb2api"; + $opts{LDDLFLAGS} = $Config{lddlflags}; + $opts{LDDLFLAGS} =~ s/-Wl,--export-all-symbols //; + } else { + $sysliblist = "-L$DB2LIB -ldb2"; + } END_PATCH cpan . EOF if [ -e /usr/bin/perlld ] && [ -e /usr/bin/perlld.bak ]; then mv /usr/bin/perlld.bak /usr/bin/perlld fi