in reply to some questions about example 4 of perlxstut

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

Replies are listed 'Best First'.
Re^2: some questions about example 4 of perlxstut
by syphilis (Archbishop) on Jun 30, 2019 at 14:32 UTC
    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".

    I'm fairly confident that the creation of "mylib/Makefile" depends solely upon the existence of mylib/Makefile.PL. (But "confidence" != "expertise".)
    I think the line $(MYEXTLIB): mylib/Makefile comes into play when "libmylib.a" is created during the "make" stage.

    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

    This is also something that I'm not seeing.
    For me "mylib/Makefile" is being created by the perl Makefile.PL step. Did you first create mylib/Makefile.PL ?

    Cheers,
    Rob

      You are right, I see Writing Makefile for Mytest2::mylib after running perl Makefile.PL in Mytest2 dir. I don't know why I did not see it before and had to add the extra rule.

Re^2: some questions about example 4 of perlxstut
by daxim (Curate) on Jul 01, 2019 at 06:56 UTC
Re^2: some questions about example 4 of perlxstut
by Anonymous Monk on Jul 01, 2019 at 00:35 UTC