[En-Nut-Discussion] Readability modification to Makefiles

Nathan Moore nategoose at gmail.com
Mon Mar 21 22:03:59 CET 2011


> > What does the trick is the following:
> ...
> > %.hex: %.elf
> >       @echo "  [HEX] $@"
> >       @$(BIN) $(BINFLAGS) -O ihex $<  $@
>
> Putting this on every command line has a disadvantage. Sometimes I need
> to inspect the command for 2 reasons:
>
> 1. I want to copy the command to use it "offline" (without calling make).
> 2. Users often report problems, where the command output of make would
> show me, what's wrong.
>
> If I want that output, there would be too many lines in too many files
> to be changed.
>
>
I'm not on a machine with make or BASH installed so I can't test this
(and probably have some syntax
wrong), but what about something like:

%.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


Nathan



More information about the En-Nut-Discussion mailing list