[Top][All Lists]

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

Re: How do I do this?

From: Paul D. Smith
Subject: Re: How do I do this?
Date: Thu, 13 Nov 2003 08:26:03 -0500

%% "Andy Voelkel" <address@hidden> writes:

  av> The "if" and "for" functions in GNU make don't do what I'm used
  av> to.  Specifically, they don't seem friendly with command lines,
  av> when you want many command lines to be executed.

These are _MAKE_ functions, not shell operations.  They have all the
same restrictions as any other make function or variable.

  av> all: 
  av>   $(if TRUE, \
  av>   echo "first command" \
  av>   echo "second command" \
  av>   )

You don't actually have multiple lines here: you have one line.  That's
what the backslash means: it means ignore this newline as if it wasn't
even there.

  av> The $(if) command removes the newlines, which isn't what I want.

Not precisely: the backslashes remove the newlines.  Of course without
them you'll get a syntax error since the $(if ...) isn't closed.

  av> Is there a way to get this sort of thing to work?

It _MIGHT_ work if you put the multiple lines in a define/endef (that's
what they're for) then used it:

  define ECHOS
        echo "first command"
        echo "second command"

        $(if TRUE, $(ECHOS))

but, I'm not sure.  This _will_ work though:

        $(if TRUE, echo "first command"; echo "second command")

assuming your shell is a Bourne shell or variant thereof, of course.

Failing that you'll have to use shell if statements, not make if

        if [ -n TRUE ]; then \
          echo "first command"; \
          echo "second command"; \

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "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]