Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

How to properly use ExtUtils::MakeMaker PL_FILES attribute?

by glasswalk3r (Friar)
on May 27, 2017 at 00:13 UTC ( [id://1191332]=perlquestion: print w/replies, xml ) Need Help??

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

Hello Monks

The ExtUtils::MakeMaker Pod says the following regarding PL_FILES attribute:

MakeMaker can run programs to generate files for you at build time. By default any file named *.PL (except Makefile.PL and Build.PL) in the top level directory will be assumed to be a Perl program and run passing its own basename in as an argument. This basename is actually a build target, and there is an intention, but not a requirement, that the *.PL file make the file passed to to as an argument.
PL files are normally run after pm_to_blib and include INST_LIB and INST_ARCH in their @INC, so the just built modules can be accessed... unless the PL file is making a module (or anything else in PM) in which case it is run before pm_to_blib and does not include INST_LIB and INST_ARCH in its @INC.

Since I'm looking for to generate a module after the Makefile.PL is executed (so all dependencies would be properly addressed), I would need this module before the pm_to_blib phase, but it seems we have some implicit control over there. Is there any way to guarantee when the PL files will be executed within the Makefile (before or after pm_to_blib)?

Thanks!

Alceu Rodrigues de Freitas Junior
---------------------------------
"You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill

Replies are listed 'Best First'.
Re: How to properly use ExtUtils::MakeMaker PL_FILES attribute?
by Anonymous Monk on May 27, 2017 at 01:21 UTC

    I've yet to see a single module where it makes sense for it to be generated before the user tries to install it -- the author is supposed to do that before he uploads the distribution

    But, here's the secret,  MyModuleGenerator(); WriteMakefile...

      I've yet to see a single module where it makes sense for it to be generated before the user tries to install it -- the author is supposed to do that before he uploads the distribution

      See Linux::NFS::BigDir.

      But, here's the secret, MyModuleGenerator(); WriteMakefile...

      That will not work: I have declared prereqs that I need to generate the module. After Makefile.PL is executed, I should have them available and then the related code requires to have constant from C header files, which I can't (easily) figure out where they are (h2ph doesn't work properly).

      So, short long story, I can't have Makefile.PL doing that for me (can't use or require something that is declared as a prereqs and is still not available).

      I tried using the .PL file, but it is not generating the module (output) as implied here and it's running after the pm_to_lib.

      I'm starting considering using Module::Build instead...

      Alceu Rodrigues de Freitas Junior
      ---------------------------------
      "You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill
        I should have them available and then the related code requires to have constant from C header files, which I can't (easily) figure out where they are (h2ph doesn't work properly

        It's quite possible that I underestimate the complexity of the problem.
        1) Can't the PL file that generates the module place it in blib (creating the 'blib' directory if it's not already existent)?
        2) If the C header files are not found by default, then surely it's up to the user to make them locatable - eg by setting the relevant environment variable, or providing INC arg to Makefile.PL.

        Cheers,
        Rob

        can't use or require something that is declared as a prereqs and is still not available).

        Yes you can, thats what META files are for, you simply tell writemakefile the depends, when you make dist METAL files are generated, then when user try to install cpan/cpanp/cpanm notice from metal files what the "BUILD_REQUIRES" ...

        See Linux::NFS::BigDir.

        Is that the module you're working on?

        How often in the past 20 years has that number you're fetching from the header changed? It should be easy to lookup

        Instead of generating a throwaway module so you can inline a constant, you should be generate a data file, using the "official" way for data files File::ShareDir / File::ShareDir::Install ...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1191332]
Approved by Athanasius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-03-29 10:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found