in reply to Re: Benchmarks target in Makefile
in thread Benchmarks target in Makefile

got it thanks!

sub MY::postamble { return <<'POSTAMBLE'; bench :: benchmarks/*.b $(NOECHO) /usr/bin/env perl '$<' POSTAMBLE } WriteMakefile( INSTALL_BASE => blablabla )

However, I tried to do this:

sub MY::postamble { return <<'POSTAMBLE'; bench :: $(BENCHMARKS) $(NOECHO) /usr/bin/env perl '$<' POSTAMBLE } WriteMakefile( INSTALL_BASE => blablabla ... postamble => { BENCHMARKS => 'benchmarks/*.b' } );

But I did not see any '$(BENCHMARKS)' var set in the Makefile. Is that the correct use of postamble you think?

Replies are listed 'Best First'.
Re^3: Benchmarks target in Makefile
by pryrt (Abbot) on Jun 19, 2018 at 16:20 UTC

    Based on my reading of ExtUtils::MakeMaker:

    postamble: Anything put here will be passed to MY::postamble() if you have one

    ... and the

    sub MY::postamble { my (undef,%h) = @_; ...
    start to my function that I linked earlier, I believe that MM passes the hash as args to the subroutine, not as variables in the Makefile, so I would suggest something like (untested):
    sub MY::postamble { my (undef,%h) = @_; my $ret = "bench :: $h{BENCHMARKS}\n"; $ret .= <<'POSTAMBLE'; $(NOECHO) /usr/bin/env perl '$<' POSTAMBLE return $ret; } WriteMakefile( INSTALL_BASE => blablabla ... postamble => { BENCHMARKS => 'benchmarks/*.b' } );

      thanks it works.

      Based on what you supplied, inserting into the Makefile a variable which holds all benchmark files $(BENCHMARKS), works this way:

      return "BENCHMARKS=$h{BENCHMARKS}\n" . <<'POSTAMBLE'; bench :: $(BENCHMARKS) $(NOECHO) /usr/bin/env perl '$<' POSTAMBLE