1ExtUtils::Depends(3) User Contributed Perl Documentation ExtUtils::Depends(3)
2
3
4
6 ExtUtils::Depends - Easily build XS extensions that depend on XS
7 extensions
8
10 use ExtUtils::Depends;
11 $package = new ExtUtils::Depends ('pkg::name', 'base::package')
12 # set the flags and libraries to compile and link the module
13 $package->set_inc("-I/opt/blahblah");
14 $package->set_libs("-lmylib");
15 # add a .c and an .xs file to compile
16 $package->add_c('code.c');
17 $package->add_xs('module-code.xs');
18 # add the typemaps to use
19 $package->add_typemaps("typemap");
20 # install some extra data files and headers
21 $package->install (qw/foo.h data.txt/);
22 # save the info
23 $package->save_config('Files.pm');
24
25 WriteMakefile(
26 'NAME' => 'Mymodule',
27 $package->get_makefile_vars()
28 );
29
31 This module tries to make it easy to build Perl extensions that use
32 functions and typemaps provided by other perl extensions. This means
33 that a perl extension is treated like a shared library that provides
34 also a C and an XS interface besides the perl one.
35
36 This works as long as the base extension is loaded with the RTLD_GLOBAL
37 flag (usually done with a
38
39 sub dl_load_flags {0x01}
40
41 in the main .pm file) if you need to use functions defined in the
42 module.
43
44 The basic scheme of operation is to collect information about a module
45 in the instance, and then store that data in the Perl library where it
46 may be retrieved later. The object can also reformat this information
47 into the data structures required by ExtUtils::MakeMaker's
48 WriteMakefile function.
49
50 When creating a new Depends object, you give it a name, which is the
51 name of the module you are building. You can also specify the names
52 of modules on which this module depends. These dependencies will be
53 loaded automatically, and their typemaps, header files, etc merged with
54 your new object's stuff. When you store the data for your object, the
55 list of dependencies are stored with it, so that another module
56 depending on your needn't know on exactly which modules yours depends.
57
58 For example:
59
60 Gtk2 depends on Glib
61
62 Gnome2::Canvas depends on Gtk2
63
64 ExtUtils::Depends->new ('Gnome2::Canvas', 'Gtk2');
65 this command automatically brings in all the stuff needed
66 for Glib, since Gtk2 depends on it.
67
69 $object = ExtUtils::Depends->new($name, @deps)
70 Create a new depends object named $name. Any modules listed in
71 @deps (which may be empty) are added as dependencies and their
72 dependency information is loaded. An exception is raised if any
73 dependency information cannot be loaded.
74
75 $depends->add_deps (@deps)
76 Add modules listed in @deps as dependencies.
77
78 (hashes) = $depends->get_deps
79 Fetch information on the dependencies of $depends as a hash of
80 hashes, which are dependency information indexed by module name.
81 See "load".
82
83 $depends->set_inc (@newinc)
84 Add strings to the includes or cflags variables.
85
86 $depends->set_libs (@newlibs)
87 Add strings to the libs (linker flags) variable.
88
89 $depends->add_pm (%pm_files)
90 Add files to the hash to be passed through
91 ExtUtils::WriteMakefile's PM key.
92
93 $depends->add_xs (@xs_files)
94 Add xs files to be compiled.
95
96 $depends->add_c (@c_files)
97 Add C files to be compiled.
98
99 $depends->add_typemaps (@typemaps)
100 Add typemap files to be used and installed.
101
102 $depends->add_headers (list)
103 No-op, for backward compatibility.
104
105 $depends->install (@files)
106 Install @files to the data directory for $depends.
107
108 This actually works by adding them to the hash of pm files that
109 gets passed through WriteMakefile's PM key.
110
111 $depends->save_config ($filename)
112 Save the important information from $depends to $filename, and set
113 it up to be installed as name::Install::Files.
114
115 Note: the actual value of $filename seems to be irrelevant, but its
116 usage is kept for backward compatibility.
117
118 hash = $depends->get_makefile_vars
119 Return the information in $depends in a format digestible by
120 WriteMakefile.
121
122 This sets at least the following keys:
123
124 INC
125 LIBS
126 TYPEMAPS
127 PM
128
129 And these if there is data to fill them:
130
131 clean
132 OBJECT
133 XS
134
135 hashref = ExtUtils::Depends::load (name)
136 Load and return dependency information for name. Croaks if no such
137 information can be found. The information is returned as an
138 anonymous hash containing these keys:
139
140 instpath
141 The absolute path to the data install directory for this
142 module.
143
144 typemaps
145 List of absolute pathnames for this module's typemap files.
146
147 inc CFLAGS string for this module.
148
149 libs
150 LIBS string for this module.
151
152 deps
153 List of modules on which this one depends. This key will not
154 exist when loading files created by old versions of
155 ExtUtils::Depends.
156
157 $depends->load_deps
158 Load $depends dependencies, by calling "load" on each dependency
159 module. This is usually done for you, and should only be needed if
160 you want to call "get_deps" after calling "add_deps" manually.
161
163 Version 0.2 discards some of the more esoteric features provided by the
164 older versions. As they were completely undocumented, and this module
165 has yet to reach 1.0, this may not exactly be a bug.
166
167 This module is tightly coupled to the ExtUtils::MakeMaker architecture.
168
170 ExtUtils::MakeMaker.
171
173 Paolo Molaro <lupus at debian dot org> wrote the original version for
174 Gtk-Perl. muppet <scott at asofyet dot org> rewrote the innards for
175 version 0.2, borrowing liberally from Paolo's code.
176
178 The Gtk2 project, http://gtk2-perl.sf.net/
179
181 This library is free software; you may redistribute it and/or modify it
182 under the same terms as Perl itself.
183
184
185
186perl v5.12.0 2009-07-04 ExtUtils::Depends(3)