Re: Conditional broken line in recipe

Alejandro Colomar <[email protected]>
Newsgroups gmane.comp.gnu.make.general
Organization Linux
Message-ID <[email protected]>
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
OpenPGP_signature (application/pgp-signature, 833 B) - not displayed
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.