Next: ExtUtils::PkgConfig | Previous: Cairo | [Gtk2-Perl - Table of Contents] | [Gtk2-Perl - Index] |
ExtUtils::Depends - Easily build XS extensions that depend on XS extensions
use ExtUtils::Depends; $package = new ExtUtils::Depends ('pkg::name', 'base::package') # set the flags and libraries to compile and link the module $package->set_inc("-I/opt/blahblah"); $package->set_libs("-lmylib"); # add a .c and an .xs file to compile $package->add_c('code.c'); $package->add_xs('module-code.xs'); # add the typemaps to use $package->add_typemaps("typemap"); # install some extra data files and headers $package->install (qw/foo.h data.txt/); # save the info $package->save_config('Files.pm'); WriteMakefile( 'NAME' => 'Mymodule', $package->get_makefile_vars() );
This module tries to make it easy to build Perl extensions that use functions and typemaps provided by other perl extensions. This means that a perl extension is treated like a shared library that provides also a C and an XS interface besides the perl one.
This works as long as the base extension is loaded with the RTLD_GLOBAL flag (usually done with a
sub dl_load_flags {0x01}
in the main .pm file) if you need to use functions defined in the module.
The basic scheme of operation is to collect information about a module in the instance, and then store that data in the Perl library where it may be retrieved later. The object can also reformat this information into the data structures required by ExtUtils::MakeMaker's WriteMakefile function.
When creating a new Depends object, you give it a name, which is the name of the module you are building. You can also specify the names of modules on which this module depends. These dependencies will be loaded automatically, and their typemaps, header files, etc merged with your new object's stuff. When you store the data for your object, the list of dependencies are stored with it, so that another module depending on your needn't know on exactly which modules yours depends.
For example:
Gtk2 depends on Glib Gnome2::Canvas depends on Gtk2 ExtUtils::Depends->new ('Gnome2::Canvas', 'Gtk2'); this command automatically brings in all the stuff needed for Glib, since Gtk2 depends on it.
load
.
This actually works by adding them to the hash of pm files that gets passed through WriteMakefile's PM key.
Note: the actual value of $filename seems to be irrelevant, but its usage is kept for backward compatibility.
This sets at least the following keys:
INC LIBS TYPEMAPS PM
And these if there is data to fill them:
clean OBJECT XS
load
on each dependency module.
This is usually done for you, and should only be needed if you want to call
get_deps
after calling add_deps
manually.
Version 0.2 discards some of the more esoteric features provided by the older versions. As they were completely undocumented, and this module has yet to reach 1.0, this may not exactly be a bug.
This module is tightly coupled to the ExtUtils::MakeMaker architecture.
ExtUtils::MakeMaker.
Paolo Molaro <lupus at debian dot org> wrote the original version for Gtk-Perl. muppet <scott at asofyet dot org> rewrote the innards for version 0.2, borrowing liberally from Paolo's code.
The Gtk2 project, http://gtk2-perl.sf.net/
This library is free software; you may redistribute it and/or modify it under the same terms as Perl itself.