Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Makefile caveat: tabs not spaces

by bliako (Monsignor)
on Jan 20, 2021 at 14:49 UTC ( [id://11127149]=note: print w/replies, xml ) Need Help??


in reply to let Makefile.PL to do the Readme file for me -- new target?

Apropos Makefile: since time immemorial Makefile uses tabs as part of its syntax. Tabs are important to Makefile (at least in *nix, though later GNU additions make this flexible). 8 or 4 spaces will not do. And so, in Discipulus example:

return <<'MAKE_README'; postamble :: $(PERLRUN) -MPod::Text \ -e "Pod::Text->new (sentence => 1, width => 78)->parse_from_file( +qw( $(TO_INST_PM) Readme) );" MAKE_README

In the here-doc, the space before $(PERLRUN) should be a single (real) tab if we want to be portable, I guess.

But in M$-windows system dmake probably made a compromise? Or it's run with special command-line flags? Because I see there are just 4 spaces and not a single tab.

Apropos2: recently there was a discussion about tabs and spaces in code and how editors can transform these. They were not counting die-hard Makefile.

bw, bliako

Replies are listed 'Best First'.
Re: Makefile caveat: tabs not spaces
by afoken (Chancellor) on Jan 20, 2021 at 23:16 UTC
    But in M$-windows system dmake probably made a compromise? Or it's run with special command-line flags?

    dmake uses a syntax that looks a little bit like GNU make, but it has some nasty differences. Quoting its man page:

    dmake is not compatible with GNU Make. In particular it does not understand GNU Make's macro expansions that query the file system.

    dmake is fully compatible with SYSV AUGMAKE

    And yes, dmake can use spaces instead of tabs:

    OPTIONS

    [...]

    -B
    Enable the use of spaces instead of <tabs> to begin recipe lines. This flag equivalent to the .NOTABS special macro and is further described below.

    [...]

    CONTROL MACROS

    [...]

    .NOTABS
    When set to "yes" enables the use of spaces as well as <tabs> to begin recipe lines. By default a non-group recipe is terminated by a line without any leading white-space or by a line not beggining with a <tab> character. Enabling this mode modifies the first condition of the above termination rule to terminate a non-group recipe with a line that contains only white-space. This mode does not effect the parsing of group recipes bracketed by [].

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      I'm trying to play with the examples given in https://makefiletutorial.com/#default-shell

      But I'm on Windows and have dmake via ActiveState's Perl installed, which is trying to use batch as shell-language.

      Do you happen to know how I can tell dmake to use it's "bash" emulation?

      (I suppose strongly it comes with ActiveState too)

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

      update

      I was able to work around that by using git-bash ... But I'm still curios what the canonical approach may be.

        But I'm still curios what the canonical approach may be

        The win32/makefile.mk (written for dmake) in the perl source contains:
        # # set this to point to cmd.exe (only needed if you use some # alternate shell that doesn't grok cmd.exe style commands) # #SHELL *= g:\winnt\system32\cmd.exe
        I guess therefore that, in your makefile, you might want something like:
        SHELL *= C:\path\to\your_shell.exe
        Cheers,
        Rob
        SHELL
            This macro defines the full path to the executable image to be used as the shell when processing single line recipes. This macro must be defined if recipes requiring the shell for execution are to be used. It is assigned a default value in the startup makefile. Under UNIX this value is /bin/sh. 
        

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-03-29 09:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found