aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorKarl Palsson2012-10-30 10:03:12 +0000
committerKarl Palsson2012-10-30 10:03:12 +0000
commit90cdddd96b62005ab1ad6816bf31a885df4e8695 (patch)
tree34eb758fc34195026453ae8444406ce57e9174c0 /Makefile
parenta1f4c29872980f84a06c0bc610b1314c43187f06 (diff)
Allow make to build libs/examples in parallel.
You cannot issue make inside a for loop if you want to let it run in parallel. Performance increases seen: 10:03 < zyp> I tested make all -j8 without your change, it takes 8.7s 10:03 < zyp> so on my cpu, your change gives >2x speedup My own cpu gives more modest speed increases, of only about 20%.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile35
1 files changed, 18 insertions, 17 deletions
diff --git a/Makefile b/Makefile
index 6cb4b11..37e4a23 100644
--- a/Makefile
+++ b/Makefile
@@ -51,21 +51,21 @@ cleanheaders:
./scripts/irq2nvic_h --remove $$yamlfile ; \
done
-lib: generatedheaders
- $(Q)for i in $(addprefix $@/,$(TARGETS)); do \
- if [ -d $$i ]; then \
- printf " BUILD $$i\n"; \
- $(MAKE) -C $$i SRCLIBDIR=$(SRCLIBDIR) || exit $?; \
- fi; \
- done
+LIB_DIRS:=$(wildcard $(addprefix lib/,$(TARGETS)))
+$(LIB_DIRS): generatedheaders
+ @printf " BUILD $@\n";
+ $(Q)$(MAKE) --directory=$@ SRCLIBDIR=$(SRCLIBDIR)
-examples: lib
- $(Q)for i in $(addsuffix /*/*,$(addprefix $@/,$(TARGETS))); do \
- if [ -d $$i ]; then \
- printf " BUILD $$i\n"; \
- $(MAKE) -C $$i || exit $?; \
- fi; \
- done
+lib: $(LIB_DIRS)
+ $(Q)true
+
+EXAMPLE_DIRS:=$(sort $(dir $(wildcard $(addsuffix /*/*/Makefile,$(addprefix examples/,$(TARGETS))))))
+$(EXAMPLE_DIRS): lib
+ @printf " BUILD $@\n";
+ $(Q)$(MAKE) --directory=$@
+
+examples: $(EXAMPLE_DIRS)
+ $(Q)true
install: lib
@printf " INSTALL headers\n"
@@ -86,9 +86,10 @@ install: lib
doc:
$(Q)$(MAKE) -C doc doc
+# Bleh http://www.makelinux.net/make3/make3-CHP-6-SECT-1#make3-CHP-6-SECT-1
clean: cleanheaders
- $(Q)for i in $(addprefix lib/,$(TARGETS)) \
- $(addsuffix /*/*,$(addprefix examples/,$(TARGETS))); do \
+ $(Q)for i in $(LIB_DIRS) \
+ $(EXAMPLE_DIRS); do \
if [ -d $$i ]; then \
printf " CLEAN $$i\n"; \
$(MAKE) -C $$i clean SRCLIBDIR=$(SRCLIBDIR) || exit $?; \
@@ -97,5 +98,5 @@ clean: cleanheaders
@printf " CLEAN doxygen\n"
$(Q)$(MAKE) -C doc clean
-.PHONY: build lib examples install doc clean generatedheaders cleanheaders
+.PHONY: build lib $(LIB_DIRS) examples $(EXAMPLE_DIRS) install doc clean generatedheaders cleanheaders