1

I am working on a module that I would like to have two backends, a Module(::PerlArray) and Module::PDL (which can will depend on Module). Both need access to a functions.c/.h file for building. This file has the rather complicated logic needed for the module. Rather than distribute it separately with each module, is there some way to keep it with the Module::PP on the system and then add it to the appropriate build flags in EU::MM or M::B (given the complexity here probably the latter)?

To put it more visually

--Module--
Module.pm
Module/PerlArray.pm
Module/PerlArray.xs (#include functions.h
              #include perlarray_backend.h)
Module/src/functions.c
Module/src/perlarray_backend.c
Module/inc/functions.h
Module/inc/perlarray_backend.h

--Module::PDL--
Module/PDL.pm
Module/PDL.xs (#include functions.h /*from Module*/
               #include pdl_backend.h)
Module/src/pdl_backend.c
Module/inc/pdl_backend.h

and the compilation makes functions.o and links. I'm sure I can figure out how to set the flags appropriately but how can I make Module keep the functions.c file while installing, and how can I then find it when installing Module::PDL? Is there some location I can place the functions.c/.h?

Joel Berger
  • 20,180
  • 5
  • 49
  • 104
  • 1
    The PP module should be reserved for Pure Perl (that's the convention), so it shouldn't be depending on the .[ch] files. – Jonathan Leffler Oct 12 '11 at 15:52
  • true, I will work on the naming. My pp (as I have called it) uses Perl native arrays vs using PDL, but you are right I shouldn't call it PP if it uses XS. – Joel Berger Oct 12 '11 at 17:07

2 Answers2

1

Have you looked at DBI? It does what you suggest: it installs some .h file(s) that the DBD drivers can #include in their XS code, as well as a library that the DBD drivers can call.

Tanktalus
  • 21,664
  • 5
  • 41
  • 68
0

Modules should be independently installable. That is, providing I have the pre-requisite Perl modules installed (but not necessarily still lying around in source form), then it should be possible to install all the modules in one distributed tar file without reference to the source for any other module.

You have options. One is to have a single source directory create several distributed tar balls, and they can each have a copy of the shared function.[ch] in the distributed source.

The other main option is to bundle both modules into a single distributed tar ball.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • While I generally agree with what you have said, the reason I want to do it this way is that PDL is a huge and annoying chain to install, and all it provides my module is a cleaner data storage unit. I don't imagine that all the (prospective) users of my `Module` will want nor need the headache of PDL. There is a smaller community that will benefit, and for them why build a giant array of `SV*` just so that they can then convert to a PDL object at the end. Therefore since `Module::PDL` will depend on `Module` and will not be independently installable anyway, I think this situation can work. – Joel Berger Oct 12 '11 at 17:12