This is what I can answer:

1. What is $(PASSTHRU)? I neither find it on EU::MM pod nor on make manpage, but I find a PASTHRU on makefile in mylib directory, is the same?
sub MY::postamble { ' $(MYEXTLIB): mylib/Makefile cd mylib && $(MAKE) $(PASSTHRU) '; }

In the above code, what's in single quotes(*) is to be added verbatim to Makefile. It says that the requirement mylib.a depends on the Makefile in mylib dir. And in order to produce the requirement, make should enter mylib dir and run make command with the PASSTHRU argument which will be empty if it has not been defined at all.

Essentially it looks to me an attempt to pass current make's parameters to the make spawn inside the mylib dir. Which, in my case, does not work - it's always empty. So, when I say make dynamic, it makes dynamic in Mytest2 dir but just make which defaults to make static in mylib and it creates a mess. The GNU-make variable $(MAKECMDGOALS) contains the target initially make was called with, e.g. "all" or "dynamic" for make all or make dynamic. See also https://www.gnu.org/software/make/manual/html_node/Recursion.html

2. Why when I run perl Makefile.PL on Mytest2 level, there also build a makefile on Mytest2/mylib directory? I don't see any command about this on Makefile.PL on Mytest2. 

As I said, the line $(MYEXTLIB): mylib/Makefile means that the requirement MYEXTLIB depends on "mylib/Makefile" which in itself can be a requirement with its own rules on how to be satisfied and therefore somehow create "mylib/Makefile". Maybe I am running this tutorial wrong but for me, "mylib/Makefile" is not created automatically whenever I run perl Makefile.PL && make in Mytest2 dir. There is no rule on how to make it in Makefile. However, if I add this to the postamble section of Makefile.PL, a Makefile in mylib is created automatically when needed:

sub MY::postamble { <<'EXA'; mylib/Makefile: mylib/Makefile.PL echo "ZZZZZZZZ" cd mylib && perl Makefile.PL $(MYEXTLIB): mylib/Makefile echo "XXXXXXXXXXXXX pass is '$(PASSTHRU)' for GNU make, this tells + me the target to pass thru '$(MAKECMDGOALS)'" cd mylib && $(MAKE) $(PASSTHRU) EXA

Note (*): better use the here-doc method rather than single quotes which will fail if you use single quotes in your Makefile stamble (e.g. "echo pass is ...")

Note to anyone trying this tutorial: I seriously got bitten by copy-pasting code from perlxstut via firefox 60+. For me, each line of the code within the code-tags at https://perldoc.perl.org is pre-fixed with 4 spaces followed by a tab which renders the space-sensitive Makefile stabs useless. They were simply ignored.

bw, bliako


In reply to Re: some questions about example 4 of perlxstut by bliako
in thread some questions about example 4 of perlxstut by Anonymous Monk

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.