in reply to Re: 2nd run of WriteMakefile ignores MY overloads
in thread 2nd run of WriteMakefile ignores MY overloads

The LINKTYPE macro is generated cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Any.pm#l2097 in perl.git, but can be set in many places see , cpan/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker.pm#l1430 in perl.git, cpan/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker.pm#l1925 in perl.git.

I am trying to do this with CPAN quality. I am using certain compiler (not linker) flags for VC and GCC which would break the build for a static XS library that is linked into a perl or there would be conflicts in linking with perl's full set of OS/compiler libraries, so I have to know LINKTYPE before the final makefile is written to the disk. EUMM parses command line arguments in addition the makefile.pl hash, see cpan/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker.pm#l587 in perl.git, trying to write code to figure the logic between $Config, %param, environmental variables, and cmd line args in exactly the same way as EUMM makes no sense, and rely on EUMM's precedence of all these options staying stable over time makes no sense. CCFLAGS and OPTIMIZE can be guessed in makefile.pl to be either in the WriteMakefile param hash or the $Config value, if the end user sets it on command line to makefile.pl, oh well, it doesn't work but its not obvious that you should set it on the cmd line. LINKTYPE's options doc's say to use the command line argument cpan/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker.pm#l1430 in perl.git. Running EUMM twice is the cleanest solution, but the MY package isn't processed on the 2nd run of EUMM, I dont know why.

MY package postamble is called from /cpan/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker.pm#l691 in perl.git] on the first run. On the 2nd run, the "push @{$self->{RESULT}}, $self->maketext_filter($self->$method( %a ));" call jumps to cpan/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker.pm#l967 in perl.git and then to cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Unix.pm#l2865 in perl.git not my MY package postample. I dont know enough about Perl's OOP to figure out whats going on. I know EUMM generates new class names each time it runs (PACK001, PACK002). I am using EUMM 6.56.

I will see if anyone on PM can figure out whats wrong before I go to RT. Last resort is %INC hacking and clearing the EUMM symbol table and reloading EUMM, not clean either.
  • Comment on Re^2: 2nd run of WriteMakefile ignores MY overloads

Replies are listed 'Best First'.
Re^3: 2nd run of WriteMakefile ignores MY overloads
by Anonymous Monk on Apr 05, 2012 at 03:54 UTC

    I was right, you don't need to run it twice :)

    http://search.cpan.org/dist/PAR-Packer/MANIFEST http://cpansearch.perl.org/src/RSCHUPP/PAR-Packer-1.013/myldr/Makefile.PL redefines CFLAGS (and friends) in postamble, after MakeMaker has expanded all the stuff ( LINKTYPE and everything )

    $ h2xs -AX -n Bunk ... sub MY::postamble { use Data::Dump(); warn join "\n", Data::Dump::pp(@_), "postamble @_ ", Data::Dump::pp( $_[0]->{ARGS}, $_[0]->{LINKTYPE} ); "" } ... $ perl Bunk/Makefile.PL ... postamble PACK001=HASH(0xa556a4) ( { ABSTRACT_FROM => "lib/Bunk.pm", AUTHOR => ["A. U. Thor <a.u.thor\@a.galaxy.far.far.away>"], NAME => "Bunk", PREREQ_PM => {}, VERSION_FROM => "lib/Bunk.pm", }, "dynamic", ) at Bunk\Makefile.PL line 15. Writing Makefile for Bunk Writing MYMETA.yml and MYMETA.json $ perl Bunk/Makefile.PL LINKTYPE=static ... postamble PACK001=HASH(0xa556c4) ( { ABSTRACT_FROM => "lib/Bunk.pm", AUTHOR => ["A. U. Thor <a.u.thor\@a.galaxy.far.far.away>"], LINKTYPE => "static", NAME => "Bunk", PREREQ_PM => {}, VERSION_FROM => "lib/Bunk.pm", }, "static", ) at Bunk\Makefile.PL line 15. Writing Makefile for Bunk Writing MYMETA.yml and MYMETA.json

    The PACK001=HASH(0xa556c4) gives a hint as to why calling WriteMakefile twice doesn't work -- MakeMaker is eeeew

    :) MakeMaker Is DOOMED! but Module::Build doesn't support static linking

      The PACK001=HASH(0xa556c4) gives a hint as to why calling WriteMakefile twice doesn't work -- MakeMaker is eeeew

      ... All I can say. PAR Packer isn't remotely near a normal XS library. You can define macros again in postamble, but the makefile becomes unreadable to mere mortals. No core dual lifes use Module::Build as of Perl 5.12. I wont be the first.

      I figured out the problem. EUMM deletes or something, I can't tell whats going on, the MY package methods after inheriting them, see cpan/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker.pm#l966 in perl.git. Why? I have no idea. Workaround in Makefile.pl below. My problem is resolved.
      use 5.010000; use ExtUtils::MakeMaker; use Config qw(%Config); use Data::Dumper; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. %param = ( NAME => 'MM123', VERSION_FROM => 'lib/MM123.pm', # finds $VERSION PREREQ_PM => {}, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'lib/MM123.pm', # retrieve abstract from modu +le AUTHOR => 'A. U. Thor <a.u.thor@a.galaxy.far.far.away>' +) : ()), # e.g., '-lm' DEFINE => '', # e.g., '-DHAVE_SOMETHING' INC => '-I.', # e.g., '-I. -I/usr/include/other' ); *MY::postamble = sub { print "postamble hook worked\n"; return ' # POSTAMBLE WORKED '; }; WriteMakefile(%param); *MY::postamble = sub { print "postamble hook worked\n"; return ' # POSTAMBLE WORKED '; }; WriteMakefile(%param);
      C:\pl\mmbug>perl makefile.pl WARNING: Setting ABSTRACT via file 'lib/MM123.pm' failed at C:/perl512/lib/ExtUtils/MakeMaker.pm line 583 postamble hook worked Writing Makefile for MM123 WARNING: Setting ABSTRACT via file 'lib/MM123.pm' failed at C:/perl512/lib/ExtUtils/MakeMaker.pm line 583 postamble hook worked Writing Makefile for MM123 C:\pl\mmbug>

        You just gotta love that schwern, deleting symbols is awesome