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: Alejandro Colomar
Subject: Re: Conditional broken line in recipe
Date: Sun, 3 Sep 2023 15:25:35 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.1

On 2023-09-03 14:57, Alejandro Colomar wrote:
> On 2023-09-03 14:38, Paul Smith wrote:
>> On Sun, 2023-09-03 at 13:14 +0200, Alejandro Colomar wrote:
>>>> You need to put the ifdef outside the recipe:
>>>
>>> That would hurt readability a little bit.
>>
>> IMO a make preprocessor statement inside a recipe is a code smell and I
>> would find the "outside the recipe" version simpler to understand, but
>> of course this is a personal taste thing.
>>
> 
> The rule is something like this:
> 
> target: source
>       sed 's/%date%/$(shell date)/' <$< |
> ifneq ($(VERSION),)
>       sed 's/%version%/$(VERSION)/' |
> endif
>       cp -T /dev/stdin $@

Heh, I wasn't seeing this, but
VERSION := %version%
would allow running this unconditionally.  Problem solved.  :)

-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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