Re: Conditional broken line in recipe

Paul Smith <[email protected]>
Newsgroups gmane.comp.gnu.make.general
Message-ID <[email protected]>
On Sun, 2023-09-03 at 01:00 +0200, Alejandro Colomar wrote:
> Is something like this possible?
> 
> target:
> 	foo \
> ifeq (...)
> 	| bar \
> endif
> 	| baz

I'm sure you've tried it and discovered the answer is "no".  The
backslash will append the next line to the previous line and it won't
be considered a make statement.

You need to put the ifdef outside the recipe:

    ifeq (...)
      BAR = | bar
    else
      BAR =
    endif

    target:
            foo $(BAR) | baz
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.