[BUILD] Make the binaries only needed for the user

User can specify which binaries he needs on the commandline.

'make hex' will build examples with generating hex file
'make hex bin' will build hex and bin output
'make images' will build all images as in previous versions of buildsystem
'make all' or 'make' will build only elf (+ map) files

This will have huge impact on build speed.
This commit is contained in:
Frantisek Burian
2014-02-13 19:35:18 +01:00
parent 3f47411e24
commit 3af1f8d43d
2 changed files with 24 additions and 4 deletions

View File

@@ -33,9 +33,22 @@ MAKEFLAGS += --no-print-directory
endif endif
OPENCM3_DIR := $(realpath libopencm3) OPENCM3_DIR := $(realpath libopencm3)
EXAMPLE_RULES = elf
all: build all: build
bin: EXAMPLE_RULES += bin
hex: EXAMPLE_RULES += hex
srec: EXAMPLE_RULES += srec
list: EXAMPLE_RULES += list
images: EXAMPLE_RULES += images
bin: build
hex: build
srec: build
list: build
images: build
build: lib examples build: lib examples
lib: lib:
@@ -54,7 +67,7 @@ lib:
EXAMPLE_DIRS:=$(sort $(dir $(wildcard $(addsuffix /*/*/Makefile,$(addprefix examples/,$(TARGETS)))))) EXAMPLE_DIRS:=$(sort $(dir $(wildcard $(addsuffix /*/*/Makefile,$(addprefix examples/,$(TARGETS))))))
$(EXAMPLE_DIRS): lib $(EXAMPLE_DIRS): lib
@printf " BUILD $@\n"; @printf " BUILD $@\n";
$(Q)$(MAKE) --directory=$@ OPENCM3_DIR=$(OPENCM3_DIR) $(Q)$(MAKE) --directory=$@ OPENCM3_DIR=$(OPENCM3_DIR) $(EXAMPLE_RULES)
examples: $(EXAMPLE_DIRS) examples: $(EXAMPLE_DIRS)
$(Q)true $(Q)true
@@ -79,5 +92,6 @@ styleclean: $(EXAMPLE_DIRS:=.styleclean)
$(Q)$(MAKE) -C $* stylecheck OPENCM3_DIR=$(OPENCM3_DIR) $(Q)$(MAKE) -C $* stylecheck OPENCM3_DIR=$(OPENCM3_DIR)
.PHONY: build lib examples $(EXAMPLE_DIRS) install clean stylecheck styleclean .PHONY: build lib examples $(EXAMPLE_DIRS) install clean stylecheck styleclean \
bin hex srec list images

View File

@@ -123,7 +123,13 @@ LDLIBS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
.SECONDEXPANSION: .SECONDEXPANSION:
.SECONDARY: .SECONDARY:
all: images all: elf
elf: $(BINARY).elf
bin: $(BINARY).bin
hex: $(BINARY).hex
srec: $(BINARY).srec
list: $(BINARY).list
images: $(BINARY).images images: $(BINARY).images
flash: $(BINARY).flash flash: $(BINARY).flash
@@ -228,6 +234,6 @@ else
$(*).elf $(*).elf
endif endif
.PHONY: images clean stylecheck styleclean .PHONY: images clean stylecheck styleclean elf bin hex srec list
-include $(OBJS:.o=.d) -include $(OBJS:.o=.d)