http://qs1969.pair.com?node_id=919504

dk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I'm writing a module, and I'm trying to solve a problem how it should require another module for building itself under CPAN shell. In details, my setup is as follows: I'm authoring module A, which uses module B's config, which has all libraries, include paths, etc stuff needed to build A properly. Basically A's Makefile.PL should be very simple code like this:

WriteMakefile( INC => "$B::Config{INC}", LIB => "$B::Config{LIB}", ... )
Trouble is, if B is NOT installed (yet), I can't read B::Config. Currently I'm making a hack: if B cannot be require'd, I'm creating a Makefile where I do list B as a prerequisite, with empty INC and LIB. CPAN then fetches B, builds and installs it, and returns to A, but it doesn't run Makefile.PL again, just issues "make". To work around that, I'm writing a prefix into the makefile that forcibly re-runs Makefile.PL, hoping that this time B will be available.

That works, but the code is cumbersome, and I'd like to know if I'm missing some simpler technique. Manuals and google gave me BUILD_REQUIRES option, but judging by manual of CPAN::FirstTime, it's rather an option for declaring a prerequisite as a possibly temporal module, so CPAN user can skip installing it if he wishes so.

Also, experimenting with such setup is not easy: I'll need to upload module A to the pause, then try to install it under CPAN, to see if my assumptions works.

So, simply speaking, I'm a bit out of tools when it comes to testing how my module behaves under CPAN environment. Are there any good advices? Thank you!