Xavier,
Changing this line in Makefile.PL...
NAME => 'Foo::Bar::Baz',
to this...
NAME => 'Foo::Bar::Baz::XSModule',
... triggers compilation for me.
I'm curious why you're doing things this way. I have a similar
scheme going on for my 50+ module distro, mainly because I want to
have the XS code and the Perl code in the same file to make editing
and revision tracking easier. To elaborate on posts from earlier
this week, this is how it works:
Before Makefile.PL invokes WriteMakefile, it generates KinoSearch.xs,
from scratch, on the fly. It starts with a little bit of header code
in a here-doc:
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#define NEED_sv_2pv_nolen
#include "ppport.h"
#include "KinoGlobals.h"
#include "KinoDataTypes.h"
#include "KinoIO.h"
MODULE = KinoSearch PACKAGE = KinoSearch
PROTOTYPES: disable
SV*
_dummy_function()
CODE:
RETVAL = newSVpv("Hello World", 0);
OUTPUT:
RETVAL
(If _dummy_function isn't there, compilation fails -- I think xsubpp
doesn't know what to do with a blank MODULE/PACKAGE section.) Then
it walks the file hierarchy in lib/ opening up .pm modules and
looking for code like this:
1;
__END__
__XS__
MODULE = KinoSearch PACKAGE = KinoSearch::Store::InStream
[...]
__POD__
=head1 NAME
It adds everything between the __XS__ token and the next line-
starting-double-underscore-token to KinoSearch.xs. Only one C shared
library gets built -- the one loaded by KinoSearch.pm. Here's
KinoSearch.pm, minus the docs:
package KinoSearch;
use strict;
use warnings;
use 5.008003;
our $VERSION = '0.05_03';
use constant K_DEBUG => 0;
use base qw( Exporter );
use XSLoader;
# This loads a large number of disparate subs.
# See the docs for KinoSearch::Util::ToolSet.
XSLoader::load( 'KinoSearch', $KinoSearch::VERSION );
our @EXPORT_OK = qw( K_DEBUG );
1;
Though it's done via a ToolSet (see the new ToolSet module on CPAN),
effectively every module in the KinoSearch suite has "use
KinoSearch;" at the top, which causes the C library to load. That's
all KinoSearch.pm does, actually -- it has no public UI.
To come back to where we started... the line in my Makefile.PL which
corresponds to yours is:
NAME => 'KinoSearch',
That's also the name of the distro. I'm not sure about the simplest
way to make things work if you want to distribute Foo::Bar::Baz and
not Foo::Bar::Baz::XSModule; a second Makefile.PL in another
directory would probably do the trick, but there may be an easier way.
HTH,
Marvin Humphrey
Rectangular Research
http://www.rectangular.com/
Post by Xavier NoriaPost by Marvin HumphreyTry it with the .xs file in the root directory of the distro --
the same directory as Makefile.PL.
Post by Xavier NoriaWhat are MODULE and PACKAGE set to?
For the above config, set...
MODULE = Foo::Bar::Baz::XSModule PACKAGE = Foo::Bar::Baz
Foo::Bar::Baz::XSModule should contain the XSLoader::load
command. Foo::Bar::Baz should "use Foo::Bar::Baz::XSModule;", but
should *not* contain an XSLoader::load command, or you'll get
redefinition warnings.
% make
cp lib/Foo/Bar/Baz.pm blib/lib/Foo/Bar/Baz.pm
cp lib/Foo/Bar/Baz/XSModule.pm blib/lib/Foo/Bar/Baz/XSModule.pm
Running Mkbootstrap for Foo::Bar::Baz ()
chmod 644 Baz.bs
rm -f blib/arch/auto/Foo/Bar/Baz/Baz.bundle
env MACOSX_DEPLOYMENT_TARGET=10.3 cc -bundle -undefined
dynamic_lookup -L/usr/local/lib Baz.o -o blib/arch/auto/Foo/Bar/
Baz/Baz.bundle \
\
powerpc-apple-darwin8-gcc-4.0.1: Baz.o: No such file or directory
powerpc-apple-darwin8-gcc-4.0.1: no input files
make: *** [blib/arch/auto/Foo/Bar/Baz/Baz.bundle] Error 1
Playing around with MODULE and PACKAGE wasn't fruitful. I uploaded
http://www.hashref.com/tmp/Foo-Bar-Baz.tar.gz
-- fxn