From 3af1f8d43d481b4d904ca85fdfb96c7bbee3705b Mon Sep 17 00:00:00 2001 From: Frantisek Burian Date: Thu, 13 Feb 2014 19:35:18 +0100 Subject: [PATCH] [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. --- Makefile | 18 ++++++++++++++++-- examples/Makefile.rules | 10 ++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 8d780a2..a7873bd 100644 --- a/Makefile +++ b/Makefile @@ -33,9 +33,22 @@ MAKEFLAGS += --no-print-directory endif OPENCM3_DIR := $(realpath libopencm3) +EXAMPLE_RULES = elf 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 lib: @@ -54,7 +67,7 @@ lib: EXAMPLE_DIRS:=$(sort $(dir $(wildcard $(addsuffix /*/*/Makefile,$(addprefix examples/,$(TARGETS)))))) $(EXAMPLE_DIRS): lib @printf " BUILD $@\n"; - $(Q)$(MAKE) --directory=$@ OPENCM3_DIR=$(OPENCM3_DIR) + $(Q)$(MAKE) --directory=$@ OPENCM3_DIR=$(OPENCM3_DIR) $(EXAMPLE_RULES) examples: $(EXAMPLE_DIRS) $(Q)true @@ -79,5 +92,6 @@ styleclean: $(EXAMPLE_DIRS:=.styleclean) $(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 diff --git a/examples/Makefile.rules b/examples/Makefile.rules index 055f0a3..293ed84 100644 --- a/examples/Makefile.rules +++ b/examples/Makefile.rules @@ -123,7 +123,13 @@ LDLIBS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group .SECONDEXPANSION: .SECONDARY: -all: images +all: elf + +elf: $(BINARY).elf +bin: $(BINARY).bin +hex: $(BINARY).hex +srec: $(BINARY).srec +list: $(BINARY).list images: $(BINARY).images flash: $(BINARY).flash @@ -228,6 +234,6 @@ else $(*).elf endif -.PHONY: images clean stylecheck styleclean +.PHONY: images clean stylecheck styleclean elf bin hex srec list -include $(OBJS:.o=.d) \ No newline at end of file