Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: dmake and bash on Win?

by LanX (Saint)
on Jan 21, 2021 at 00:27 UTC ( [id://11127176]=note: print w/replies, xml ) Need Help??


in reply to Re^3: dmake and bash on Win?
in thread let Makefile.PL to do the Readme file for me -- new target?

Thanks ... I know this. :)

The question is which executable to set?

pryrt's example contains shell code and he said it works on Win.

update

> Who knows if it is honoured when set as an "env" var.

yes the ENV is honored, running dmake inside git-bash works.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^5: dmake and bash on Win?
by pryrt (Abbot) on Jan 21, 2021 at 17:10 UTC
    I am not convinced my example contains "shell" code.

    My guess is that you are thinking it's "shell" code because it's using $(PERLRUN) to reference the variable. But $(PERLRUN) is a makefile variable/macro, not a shell variable. MakeMaker creates a plethora of useful macros in its generated Makefile, so that you have platform independent ways of running common linux-shell-style idioms. It's useful to skim through the auto-generated Makefile to see what's available, and how they define those commands. For example, $(ECHO) will run a command to print to the console, but it might not use your OS's builtin echo command, to avoid compatibility issues.

    This super-simplified Makefile.PL works for me:

    # dummy makefile use ExtUtils::MakeMaker; my %mm_args = ( 'NAME' => 'Dummy::Module', ); sub MY::postamble { return <<'__POSTAMBLE__'; pryrt :: $(ECHO) shell is set to "$(SHELL)" $(PERL) -V:myuname -V:make __POSTAMBLE__ } WriteMakefile( %mm_args );

    then, at the command line, since I have a new enough Strawberry that it uses gmake, I run:

    perl Makefile.PL gmake pryrt

    with the output:

    C:\Users\peter.jones\Downloads\TempData\perl>perl Makefile.PL Generating a gmake-style Makefile Writing Makefile for Dummy::Module Writing MYMETA.yml and MYMETA.json C:\Users\peter.jones\Downloads\TempData\perl>gmake pryrt "C:\USR\LOCAL\APPS\BERRYBREW\PERLS\SYSTEM\PERL\BIN\perl.exe" -l -e "bi +nmode STDOUT, qq{:raw}; print qq{@ARGV}" -- shell is set to "C:/Windo +ws/system32/cmd.exe" shell is set to C:/Windows/system32/cmd.exe "C:\USR\LOCAL\APPS\BERRYBREW\PERLS\SYSTEM\PERL\BIN\perl.exe" -V:myunam +e -V:make myuname='Win32 strawberry-perl 5.30.0.1 #1 Thu May 23 12:20:46 2019 x6 +4'; make='gmake';

    Notice that the shell is listed as cmd.exe, but the build system is still properly handling $(ECHO) and $(PERL).

    I know that I've done similar things with older Strawberry Perl versions (even as far back as v5.10) which used dmake instead of gmake, but I don't have that old of a Strawberry Perl that I can use while at $work, so I cannot prove it right now.

    I don't have access to ActiveState Perl nor its build environment. If you want to continue exploring this path, I suggest you try that Makefile.PL and run the sequence with AS's build environment, to see what happens.

      > I am not convinced my example contains "shell" code.

      I was referring to

      skip "rm -rf cover_db"

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        I was referring to skip "rm -rf cover_db"

        Okay, that comes from my distro's Makefile.PL lines 124-129:

        # addition to realclean: also delete coverage database, if testcover w +as run realclean :: $(NOECHO) ( $(TEST_D) cover_db && $(RM_RF) cover_db ) || $(ECHO) r +ealclean:: skip "rm -rf cover_db" $(NOECHO) ( $(TEST_F) LICENSE.pod && $(RM_RF) LICENSE.pod ) || $(E +CHO) realclean:: LICENSE.pod intermediary $(NOECHO) ( $(TEST_F) README.pod && $(RM_RF) README.pod ) || $(ECH +O) realclean:: README.pod intermediary $(NOECHO) ( $(TEST_F) MYMETA.json.lock && $(RM_RF) MYMETA.json.loc +k ) || $(ECHO) realclean:: MYMETA.json.lock temp file

        It is using a variety of macros:

        • the $(NOECHO) macro from MakeMaker, which on cmd.exe prefixes the command with "@" so it won't print the command line first.
        • my $(TEST_D) macro, defined on lines 109-110, which is inspired by the MakeMaker macro $(TEST_F) for testing the existing of a file. When I looked at the Makefile for $(TEST_F) implementation on my system, I saw it used ExtUtils::Command from the ExtUtils::MakeMaker distro, which as described makes versions of common UNIX commands from makefiles, and makes them available to the Makefile, for doing a common linux/bash idiom in non-linux/non-bash shells. I took that inspiration for the $(TEST_D) macro, which tests for directory existence using the same module/idiom
        • the $(RM_RF) is a MakeMaker-defined macro, which again can use ExtUtils::Command for its implementation on systems that don't know rm -rf, and may just expand to rm -rf on systems that do know it
        • The || works on both Windows and Linux for only running the second command if the first command fails, and && for only running the second if the first passes. I don't know how portable it is beyond those (I have never run a rule with the || or && syntax on any system other than Windows or Linux -- I do my development mostly on Windows with occasionally running things on Linux, so that's where I run my custom makefile targets; CI and the CPAN smoketesters run my Makefiles on a variety of other systems, but those just run the standard targets for the make/test sequence).
        • $(ECHO) resolves to a ExtUtils::Command call on my system.

        By using the macro variables that MakeMaker defines in the Makefile instead of literally using common UNIX-style commands, you can write rules that are much less dependent upon the system you are on, the availability of bash, etc., and will work cross-platform but will still look and behave like the linux commands that many are used to using.

        Again, I recommend looking through the Makefile that perl Makefile.PL generates in your build environment; using that, you can see what macros are available to you, and how they are implemented on your system.

Re^5: dmake and bash on Win?
by bliako (Monsignor) on Jan 21, 2021 at 00:46 UTC

    If you run dmake from a CMD (not via git-bash). Then either add a line SHELL=c:...\bash.exe at the beginning of the Makefile (I guess!) or set an windows-ENV var SHELL to point to the bash executable. Of course you need to have that bash.exe somewhere. HTH. Over and out :) I had enough of windows contact for this year!

    p.s. Another monk had your woes: Intrepid's scratchpad and seems to have made some progress.

      OK, let me rephrase my question ... ;)

      Which bash???

      If Perl distributions create makefiles with ba/shell code, they must assume that there is either pre-installed shell or that dmake is bundled with some emulation magic.

      I know that newer Wins come with a Linux subsystem, but this is older...

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        OH THE PENNY DROPPED!

        I have no idea, sorry. Perhaps you can shell out a pipe with a sleep and check, if it succeeds, what the task manager says.

        p.s. joke :) : if unix was sushi

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11127176]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-24 06:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found