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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |