Pretty-print the output by default.

This makes it a lot easier to see what's going on, and let me find
some problems.  Use "make Q=" or set Q= blank in your user Makefile
to see the full commands.
This commit is contained in:
Jim Paris 2010-09-24 18:21:29 -04:00
parent 87e628b897
commit 0c163122da
3 changed files with 36 additions and 13 deletions

View file

@ -5,6 +5,12 @@
all: $(addsuffix _$(BOARD).bin, $(TARGETS) $(TARGETS_ROMVARS))
.PHONY: all
# Pretty print output. Use "make Q=" to see full commands
Q ?= @
define pretty
@printf "%8s %s\n" "$1" "$2"
endef
# Don't delete intermediate targets
.SECONDARY:
@ -46,6 +52,7 @@ AFLAGS ?= -Wa,-gstabs $(CFLAGS)
# Misc tool options
OBJCOPYFLAGS ?= --gap-fill=0xff
ARFLAGS = cr
#####
@ -58,7 +65,8 @@ include $(MC1322X)/src/Makefile.src
# that links $(SRCLIB) as well as target-specific rules that link $(SRCLIB_ROMVARS)
define build_elf_rule
$(1)_$$(BOARD).elf: $$(OBJDIR)/$(1).o $$(OBJDIR)/board.a $$(MC1322X)/lib/libmc1322x.a $(2)
$$(CC) $$(LDFLAGS) -o $$@ -Wl,--start-group $$^ -lm -Wl,--end-group
$$(call pretty,LINK,$$@)
$$Q$$(CC) $$(LDFLAGS) -o $$@ -Wl,--start-group $$^ -lm -Wl,--end-group
endef
# Targets that need space for rom variables:
$(foreach t, $(TARGETS_ROMVARS), $(eval $(call build_elf_rule,$(t),$(SRCLIB_ROMVARS))))
@ -67,25 +75,35 @@ $(eval $(call build_elf_rule,%,$(SRCLIB)))
# Generic rules
%.srec: %.elf
$(OBJCOPY) $(OBJCOPYFLAGS) -O srec $< $@
$(call pretty,OBJCOPY,$@)
$Q$(OBJCOPY) $(OBJCOPYFLAGS) -O srec $< $@
%.ihex: %.elf
$(OBJCOPY) $(OBJCOPYFLAGS) -O ihex $< $@
$(call pretty,OBJCOPY,$@)
$Q$(OBJCOPY) $(OBJCOPYFLAGS) -O ihex $< $@
%.bin: %.elf
$(OBJCOPY) $(OBJCOPYFLAGS) -O binary $< $@
$(call pretty,OBJCOPY,$@)
$Q$(OBJCOPY) $(OBJCOPYFLAGS) -O binary $< $@
%.dis: %.elf
$(OBJDUMP) -Sd $< > $@ || rm -f $@
$(call pretty,OBJDUMP,$@)
$Q$(OBJDUMP) -Sd $< > $@ || rm -f $@
%.o: %.c
$(CC) $(CFLAGS) $(CFLAGS_THUMB) -MMD -c -o $@ $<
$(call pretty,CC,$@)
$Q$(CC) $(CFLAGS) $(CFLAGS_THUMB) -MMD -c -o $@ $<
@$(FINALIZE_DEPENDENCY)
%.o: %.S
$(CC) $(AFLAGS) -MMD -c -o $@ $<
$(call pretty,AS,$@)
$Q$(CC) $(AFLAGS) -MMD -c -o $@ $<
@$(FINALIZE_DEPENDENCY)
(%): %
$(call pretty,AR,$@($<))
@$(AR) $(ARFLAGS) $@ $<
# Fix the dependencies generated for a particular target .o
# See http://make.paulandlesley.org/autodep.html#advanced
define FINALIZE_DEPENDENCY

View file

@ -7,19 +7,22 @@ CFLAGS += -I$(OBJDIR) -I$(MC1322X)/board -DBOARD=$(BOARD)
# Create directory and board.h include
$(OBJDIR)/board.h:
mkdir -p $(OBJDIR)
echo '/* This file was automatically generated */' > $(OBJDIR)/board.h
echo '#include "$(BOARD).h"' >> $(OBJDIR)/board.h
$(call pretty,GEN,$@)
$(Q)mkdir -p $(OBJDIR)
$(Q)echo '/* This file was automatically generated */' > $(OBJDIR)/board.h
$(Q)echo '#include "$(BOARD).h"' >> $(OBJDIR)/board.h
# $(OBJDIR)/board.a contains all the objects defined in COBJS
$(OBJDIR)/board.a: $(OBJDIR)/board.h $(OBJDIR)/board.a($(addprefix $(OBJDIR)/, $(COBJS)))
# And is built from files in the parent directory
$(OBJDIR)/%.o: %.c $(OBJDIR)/board.h
$(CC) $(CFLAGS) $(CFLAGS_THUMB) -MMD -c -o $@ $<
$(call pretty,CC,$@)
$Q$(CC) $(CFLAGS) $(CFLAGS_THUMB) -MMD -c -o $@ $<
@$(FINALIZE_DEPENDENCY)
$(OBJDIR)/%.o: %.S $(OBJDIR)/board.h
$(call pretty,AS,$@)
$(CC) $(AFLAGS) -MMD -c -o $@ $<
@$(FINALIZE_DEPENDENCY)

View file

@ -16,12 +16,14 @@ $(SRCLIB): $(SRCLIB)($(SRC_OBJS) $(START))
# ISR is built without thumb
$(ISR): $(ISR:.o=.c)
$(CC) $(CFLAGS) -MMD -c -o $@ $<
$(call pretty,CC (isr),$@)
$Q$(CC) $(CFLAGS) -MMD -c -o $@ $<
@$(FINALIZE_DEPENDENCY)
# start-romvars.o is built from start.S with the right flags
$(MC1322X)/src/start-romvars.o: $(MC1322X)/src/start.S
$(CC) $(AFLAGS) -MMD -DUSE_ROM_VARS -c -o $@ $<
$(call pretty,CC (romvars),$@)
$Q$(CC) $(AFLAGS) -MMD -DUSE_ROM_VARS -c -o $@ $<
@$(FINALIZE_DEPENDENCY)
ifneq ($(MAKECMDGOALS),clean)