Note that there are some explanatory texts on larger screens.

plurals
  1. PO`echo.` Fails in Make on Windows
    primarykey
    data
    text
    <h3>Background</h3> <p>I'm attempting to write a semi-portable Makefile that will be used on Windows without MinGW or Cygwin. As a result I pretty much have to stick to standard commands provided by Windows. I'm aware of UnxUtils, but I'd like to avoid using them as much as possible. Additionally, I'd like to avoid having to write any special batch scripts if I can help it. The solution will be used on many different computers by people that aren't particularly familiar with Linux, Windows, or command-line build systems, so environment paths can't be relied on and additional installations aren't possible. The solution will replace an existing system that's severely lacking in some of the more advanced make system features which are approaching necessity so I'm trying to minimize impact of changes by avoiding any new software installs.</p> <h3>Problem</h3> <p>The problem I'm encountering has to do with how make interprets shell commands used as part of a rule. I simply want to <code>echo</code> a blank-line in a way that can also be redirected to a file as part of a few different rules. In Windows, the only way to echo a blank line is to add a <code>.</code> immediately after the echo command, without any spaces: <code>echo.</code>. When provided as a line in a rule it causes issues though.</p> <pre><code>some_rule : @echo. @echo Text going to file &gt; someFile.txt @echo. &gt;&gt; someFile.txt @echo Other text going to a file &gt;&gt; someFile.txt </code></pre> <p>In the example provided, the first line <code>@echo.</code> and the third line, <code>@echo. &gt;&gt; someFile.txt</code>, cause an error:</p> <pre><code>process_begin: CreateProcess(NULL, echo., ...) failed. </code></pre> <p>I've seen some explanations that say there shouldn't be a space on the third line and it should instead be <code>@echo.&gt;&gt; someFile.txt</code>, but that makes no difference when I tested it.</p> <h3>Explanation</h3> <p>I'm pretty sure the issue comes from the fact that make implements a manual look up of the implicit shell command and is detecting <code>echo.</code> as the command rather than <code>echo</code>. The resulting error is that it didn't find <code>echo..exe</code> or the equivalent as either a command or executable in the environment path, triggering the error indicated above.</p> <h3>Question</h3> <p>How do I implement a command as part of a makefile rule to output a blank line such that it would work in the case above? My actual makefile looks more like the following, and I'm hoping to replace either the <code>ECHO</code> variable so it operates more like the Linux version of echo, or the <code>NEWLINE</code> variable so it can actually output a blank line in a way that allows it to either be printed to the terminal or redirected to a file.</p> <pre><code>NEWLINE=echo. ECHO=echo SILENT=@ some_rule : $(SILENT)$(NEWLINE) $(SILENT)$(ECHO) Text going to file &gt; someFile.txt $(SILENT)$(NEWLINE) &gt;&gt; someFile.txt $(SILENT)$(ECHO) Other text going to a file &gt;&gt; someFile.txt </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload