On Nov 8, 2005, at 9:47 PM, Marvin Humphrey wrote:
I have a new problem now: in addition to the XS code, there's a
bunch of straight up C code which I've been stuffing in at the top
of the .xs file. That C codebase is growing large enough that it
needs to be broken out into separate files. However, I don't
understand the MakeMaker docs on how to add in .c and .h files.
Various approaches:
dirty: write your extra C and H files. include them in MANIFEST.
#include them from your xs code's verbatim C section.
proper: follow the example of EXAMPLE 4 in perlxstut, and build a
little library for yourself, which you link in. c.f. L<perlxstut>
quick and just as good: add your extra files' names to MANIFEST so
that they get dirstributed, and add extra object files to the OBJECT
key to WriteMakefile, like so:
WriteMakefile (
...
OBJECT => q[$(BASE_EXT)$(OBJ_EXT) myextracfile$(OBJ_EXT)],
...
);
Note that you are overwriting the default for OBJECT, so we supply
that default manually -- that's what $(BASE_EXT)$(OBJ_EXT) is. You
specify only the object file version of your filename -- for
myextracfile.c you'd specify myextracfile$(OBJ_EXT), which gets
expanded to myextracfile.o or myextracfile.obj or whatever is correct
for the platform; the make rules can figure out that this needs to be
built from a c file with the same name. See L<ExtUtils::MakeMaker>
for more info -- search for OBJECT.
I'll need to learn make eventually, and I'm happy to study, I'd
just like to 1) solve my current problem sooner rather than later,
and 2) go about learning systematically. Any advice?
Make is actually quite easy, once you understand how it does
bookkeeping. The harder part is writing portable Make and getting it
to be happy with MakeMaker.
--
Examples really shouldn't include unexploded ordnance.
-- Joe Smith, referring to an example program i wrote.