Fun with ExtUtils::MakeMaker and Windows import libraries



I've been working on getting the Gtk2-Perl stack to compile under
MSWin32 without as much pain as there is now.  Windows has something
called 'import libraries' [1], which currently I have to create by
hand when I compile Cairo and Glib in order to get Gtk2 to compile.  I
create these import libraries by hacking up the Makefile and adding
something similar to this:

dlltool --input-def Cairo.def --dllname Cairo.dll --output-lib libCairoPerl.a
$(CP) libCairoPerl.a C:/camelbox/lib

I have been able to abstract the above and add it to the Makefile.PL
file.  My questions right now are:

1) I created a dynamic_lib method in the Makefile.PL for
Cairo/Glib/Gtk2, and added Makefile code similar to the above.  It
didn't work, as MakeHelper overrides my dynamic_lib method later on in
order to quiet things somewhere.  I disabled dynamic_lib in MakeHelper
and my overridden dynamic_lib method gets fired.  Is there a better
place for my extra code than the dynamic_lib method?  Oh,  I just
found the extra copy of MakeHelper.pm in the Glib source, I'm now
doing my sad panda face :(

2) What should I call my import libraries?  I've been using
libGlibPerl, libCairoPerl and libGtk2Perl.  They would only needed  if
( $^O ~= /MSWin32/), they shouldn't be needed on cygwin or anywhere
else for that matter.

3) I was going to add a test in Makefile.PL to decide if the above
import libraries get added to the Makefile via
ExtUtils::Depends->set_libs, it would end up looking something like
this (taken from a patch I have made to the Gtk2 Makefile.PL):

use Config;
if ( $^O =~ /Win32/ ) {
        $gtk2->set_libs (q(-L) . $Config{bin} . q( ) . $pkgcfg_gtk{libs}
                . q(-lGlibPerl -lCairoPerl));
} else {
        $gtk2->set_libs ($pkgcfg_gtk{libs});
}

Can someone think of a better way to do this?  Is this not worth
pursuing at all because?  Too much hassle?

My demo patches for the Makefile.PL included with Cairo/Glib/Gtk2 are
available at [2], [3] and [4].  They all work but only as long as
dynamic_lib has been disabled in $PERL5LIB/Glib/MakeHelper.pm (or
MakeHelper.pm in Glib source).

Thanks,

Brian

[1] http://docs.python.org/ext/dynamic-linking.html; yeah, I know,
python website
[2] http://code.google.com/p/camelbox/source/browse/trunk/build-extras/2008.1-odin/Cairo-Makefile.PL.diff
[3] http://code.google.com/p/camelbox/source/browse/trunk/build-extras/2008.1-odin/Glib-Makefile.PL.diff
[4] http://code.google.com/p/camelbox/source/browse/trunk/build-extras/2008.1-odin/Gtk2-Makefile.PL.diff



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]