I want to include an extra .c file when building a .xs module. My Makefile.PM currently uses ExtUtils::MakeMaker, but if I have to switch to Module::Build to accomplish the purpose, that's OK. I would like to contribute the module to CPAN in the future.

The reason for the separate .c file is that I copied several source functions out of a standard library package written in C, made some small modifications to them, renamed them, and want to include them in the .so file with my module. The mods were to comment out lock and unlock operations so that the locking can be done at a higher/outer level in my .xs module.

It doesn't seem like a good idea to '#include' the resulting .c file in my .xs file, because the code from the other library wants to be compiled with the same .h file as is in my .xs, but with the '#include' preceded by a '#define private' statement as in the file from which I copied them.

man/perldoc ExtUtils::MakeMaker mentions a 'C' => [array of c files] option. If the list includes the .c file produced from my .xs file, the build proceeds as if the option is omitted from the MakeMaking, otherwise nothing at all is compiled. Including the name of the other .c file in this array doesn't cause it to be compiled.

What's the best way to set up building this module?
cmac
www.animalhead.com

In reply to extra .c file in .xs module building by cmac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.