1 package ExtUtils::MakeMaker::FAQ;
10 ExtUtils::MakeMaker::FAQ - Frequently Asked Questions About MakeMaker
14 FAQs, tricks and tips for C<ExtUtils::MakeMaker>.
16 =head2 Philosophy and History
20 =item Why not just use <insert other build config tool here>?
22 Why did MakeMaker reinvent the build configuration wheel? Why not
23 just use autoconf or automake or ppm or Ant or ...
25 There are many reasons, but the major one is cross-platform
28 Perl is one of the most ported pieces of software ever. It works on
29 operating systems I've never even heard of (see perlport for details).
30 It needs a build tool that can work on all those platforms and with
31 any wacky C compilers they might have.
33 No such build tool existed at the time and I only know of one now
37 =item What's Module::Build and how does it relate to MakeMaker?
39 Module::Build is a project by Ken Williams to supplant MakeMaker.
40 Its primary advantages are:
44 =item * pure perl. no make, no shell commands
46 =item * easier to customize
48 =item * cleaner internals
54 Module::Build is the official heir apparent to MakeMaker and we
55 encourage people to work on M::B rather than spending time improving
64 =item How do I make two or more XS files coexist in the same directory?
66 Sometimes you need to have two and more XS files in the same package.
67 One way to go is to put them into separate directories, but sometimes
68 this is not the most suitable solution. The following technique allows
69 you to put two (and more) XS files in the same directory.
71 Let's assume that we have a package C<Cool::Foo>, which includes
72 C<Cool::Foo> and C<Cool::Bar> modules each having a separate XS
73 file. First we use the following I<Makefile.PL>:
75 use ExtUtils::MakeMaker;
79 VERSION_FROM => 'Foo.pm',
80 OBJECT => q/$(O_FILES)/,
84 Notice the C<OBJECT> attribute. MakeMaker generates the following
85 variables in I<Makefile>:
87 # Handy lists of source code files:
95 Therefore we can use the C<O_FILES> variable to tell MakeMaker to use
96 these objects into the shared library.
98 That's pretty much it. Now write I<Foo.pm> and I<Foo.xs>, I<Bar.pm>
99 and I<Bar.xs>, where I<Foo.pm> bootstraps the shared library and
100 I<Bar.pm> simply loading I<Foo.pm>.
102 The only issue left is to how to bootstrap I<Bar.xs>. This is done
105 MODULE = Cool::Foo PACKAGE = Cool::Foo
108 # boot the second XS file
109 boot_Cool__Bar(aTHX_ cv);
111 If you have more than two files, this is the place where you should
112 boot extra XS files from.
114 The following four files sum up all the details discussed so far.
122 our @ISA = qw(DynaLoader);
123 our $VERSION = '0.01';
124 bootstrap Cool::Foo $VERSION;
132 use Cool::Foo; # bootstraps Bar.xs
142 MODULE = Cool::Foo PACKAGE = Cool::Foo
145 # boot the second XS file
146 boot_Cool__Bar(aTHX_ cv);
148 MODULE = Cool::Foo PACKAGE = Cool::Foo PREFIX = cool_foo_
151 cool_foo_perl_rules()
154 fprintf(stderr, "Cool::Foo says: Perl Rules\n");
162 MODULE = Cool::Bar PACKAGE = Cool::Bar PREFIX = cool_bar_
165 cool_bar_perl_rules()
168 fprintf(stderr, "Cool::Bar says: Perl Rules\n");
170 And of course a very basic test:
175 BEGIN { plan tests => 1 };
178 Cool::Foo::perl_rules();
179 Cool::Bar::perl_rules();
182 This tip has been brought to you by Nick Ing-Simmons and Stas Bekman.
188 If you have a question you'd like to see added to the FAQ (whether or
189 not you have the answer) please send it to makemaker@perl.org.
193 The denizens of makemaker@perl.org.
197 L<ExtUtils::MakeMaker>