automake
[Top][All Lists]
Advanced

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

Re: if-else if condition in Makefile.am


From: Eric Blake
Subject: Re: if-else if condition in Makefile.am
Date: Wed, 28 Nov 2018 20:36:35 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0

On 11/28/18 7:08 PM, Deepa Ballari wrote:
Hello,
How do I write if-else-if condition (or nested if condition) in Makefile.am?
Code:
if NEWLIB_NANO_FORMATTED_IO
LIBADD_OBJS = \
     $(lpfx)nano-vfprintf_float.$(oext)    \
     $(lpfx)nano-svfprintf.$(oext)        \
..
else if NEWLIB_FORMATTED_IO
LIBADD_OBJS = \
     $(lpfx)newlib-vfprintf.$(oext) $(lpfx)newlib-vfprintf_longdouble.$(oext) \
else
LIBADD_OBJS = \
..
     $(lpfx)svfiwscanf.$(oext) $(lpfx)svfwscanf.$(oext) \
     $(lpfx)vfiwscanf.$(oext) $(lpfx)vfwscanf.$(oext)
endif

if NEWLIB_NANO_FORMATTED_IO
LIBADD_OBJS = ...
else !NEWLIB_NANO_FORMATTED_IO
if NEWLIB_FORMATTED_IO
LIBADD_OBJS = ...
else !NEWLIB_FORMATTED_IO
LIBADD_OBJS = ...
endif !NEWLIB_FORMATTED_IO
endif !NEWLIB_NANO_FORMATTED_IO

You just have to nest things on separate lines, with one endif per if/[else]. The comments after else and endif are optional, but I find they make it a lot easier to reason about things when dealing with nested conditionals.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



reply via email to

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