help-make
[Top][All Lists]
Advanced

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

Re: Conditional broken line in recipe


From: Bahman Movaqar
Subject: Re: Conditional broken line in recipe
Date: Sun, 03 Sep 2023 05:00:28 -0700
User-agent: Evolution 3.48.4

On Sun, 2023-09-03 at 01:00 +0200, Alejandro Colomar wrote:
> Hi!
> 
> Is something like this possible?
> 
> target:
>         foo \
> ifeq (...)
>         | bar \
> endif
>         | baz

I'm afraid not.  The way I approach similar situations is this pattern:


<code>

ifeq (...)

define target._conditional-piece
bar
endef

else

define target._conditional-piece
baz
endef

endif

###

target:
        foo \
        | $(target._conditional-piece)

</code>


The main advantage IMO is for debugging; ie when your run `make -pnr
target' the output contains only the version of `target._conditional-
piece` which you'd be interested in based on the condition.  Much in
the same vein as your pseudo-code.

Additionally, I find this easier to adapt than converting all to
.ONESHELL.  YMMV

--
Bahman



reply via email to

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