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