bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNU enhancement -- $(xargs cmd, list)


From: Paul D. Smith
Subject: Re: GNU enhancement -- $(xargs cmd, list)
Date: Mon, 6 Nov 2000 10:54:13 -0500

%% Reid Madsen <address@hidden> writes:

  rm> Consider the following:

  rm>     ARGS=$(wildcard *.xx)

  rm>     target:
  rm>       command $(ARGS)

  rm> The above only works if the length of the resulting command line
  rm> is within system limits.  From the shell, you can solve this by:

  rm>   echo *.xx | xargs command

  rm> But the above does not work in make because it expands the
  rm> wildcard, and then launches a command line that is again too long.

You can "fake" this by using $(words ...) to chop the $(ARGS) into
manageable pieces.  Of course, this is not automatically expandable;
once ARGS grows too large you'll have to add another "chop".

You can do this all in one variable with a "define", though.

  rm> I propose that GNUmake add the following function:

  rm>   $(xargs cmd, list)

  rm> Then I could render the intial example as:

  rm>     ARGS=$(wildcard *.xx)

  rm>     target:
  rm>       $(xargs command, $(ARGS))

  rm> Which resolves to:

  rm>   command some_args; command more_args; command even_more_args

This can't work; remember that make passes each line whole to a
subshell.  If the line is too long for any individual shell invocation,
then chopping it up and sending it to one subshell will certainly be too
long.

You'd have to break it up like this:

  target:
        command some_args
        command more_args
        command even_more_args

I.e., each on different lines.

I think this would be pretty hairy.  And, it means $(xargs ...) has a
truly bizarre functionality, much different than any existing GNU make
function.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist



reply via email to

[Prev in Thread] Current Thread [Next in Thread]