[En-Nut-Discussion] Readability modification to Makefiles

Ulrich Prinz uprinz2 at netscape.net
Mon Mar 21 22:42:52 CET 2011


Ups, I forgot:

@ tells make to silence the output (stdout) from most of the called
programs and is a function of make. It doesn't silence the output to
stderr, so warnings and errors show up.

2&>1 looks to me like a function of the console/shell and it might not
work at all if you call that under dos console. But I didn't check.

So with this small modification
>>> %.hex: %.elf
>>>       @echo "  [HEX] $@"
>>>       @$(BIN) $(BINFLAGS) -O ihex $<  $@
I am sure it works under dos/win and linux.

> %.elf: $(OBJS)
>        CMD=$(CC) $(OBJS) $(LDFLAGS) -Wl,--start-group $(LIBS)
> $(ADDLIBS) -Wl,--end-group -o $@
>        if `OUTPUT=$CMD 2&>1`; then
>            echo $CMD
>            echo $OUTPUT
>       else
>           # you can do an abbreviated output here
>       fi
This is a rather big change that needs to be spread over dozens of
makefiles and I am not sure it works :)

But after declaration of all called programs as variables and preceding
these variables with the option to be silent, the change would be even less:
>>> %.hex: %.elf
>>>       @echo "  [HEX] $@"
>>>       $(BIN) $(BINFLAGS) -O ihex $<  $@
(Do you see it ?)

The @ will be set globally
BIN=@hexbin or
BIN=@$(TRGT)objcopy

Ulrich




More information about the En-Nut-Discussion mailing list