Note that there are some explanatory texts on larger screens.

plurals
  1. POWriting contents of makefile (>131000 chars) variable to a file?
    primarykey
    data
    text
    <p>How can I write the contents of a makefile variable to file, without invoking a shell command? The problem is that the contents of the variable is possible longer than the shell allows for a command (i.e. longer than MAX_ARG_STRLEN (131072) characters).</p> <p>In particular, in a makefile I have a variable containing a long list of filenames to process (including their absolute pathes for out-of-source builds). Now I need to write those filenames to a (temporary) file, which I can then pass to another command.</p> <p>So far, we had a rule like (<code>$COLLATED_FILES</code> is the variable containing the paths):</p> <pre><code>$(outdir)/collated-files.tely: $(COLLATED_FILES) $(LYS_TO_TELY) --name=$(outdir)/collated-files.tely --title="$(TITLE)" \ --author="$(AUTHOR)" $^ </code></pre> <p>This breaks if <code>COLLATED_FILES</code> is longer than about 130000 characters, we get the error message:</p> <pre><code>make[2]: execvp: /bin/sh: Argument list too long </code></pre> <p>As a solution, we are now trying to write the contents of the variable to a file and use that file in the <code>$(LYS_TO_TELY)</code> command. Unfortunately, I have not yet found a way to do this without invoking the shell. My attempts include:</p> <pre><code>$(outdir)/collated-files.list: $(COLLATED_FILES) echo "" &gt; $@ $(foreach f,$^,echo $f &gt;&gt; $@;) </code></pre> <p>But this also invokes all <code>echo</code> commands at once in a shell, so the shell command is just as long.</p> <p>Is there any way to write the contents of <code>$(COLLATED_FILES)</code> to a file on disk without passing them on the command line to a shell command?</p> <p>I also searched whether I could pipe the contents of the variable to the shell, but I couldn't find anything in that direction, either...</p>
    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.
    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