i came across following shell script as part of makefile in u-boot.
what it does and how is it evaluated
cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
> /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
it is called as
PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,\
$(call cc-option,-malignment-traps,))
The code runs the
ifcommand.iftakes one argument: A command to execute ($(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1).If the command succeeds, the
thenpart is executed (echo "$(1)"). If the command fails, theelsepart is executed (echo "$(2)").In your case, the compiler is started with some options which it might not support (
$1is-mshort-load-bytes).Since
$2is empty, the result will either be the option (if the compiler supports it) or the empty string.