From 0c75990d6ebbe4e2bf8329c695a848bc1171feeb Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 8 Jul 2017 21:36:16 +0300 Subject: [PATCH] zephyr/Makefile: Rework dependencies and "clean" target. Got tired of running rm -rf manually. Make should clean, and should clean fast. Also, fix always-running config-related commands (by having per-board merged configs). --- zephyr/Makefile | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/zephyr/Makefile b/zephyr/Makefile index 9e8cb31d0a..32ccd6f1de 100644 --- a/zephyr/Makefile +++ b/zephyr/Makefile @@ -8,7 +8,7 @@ # To build a "minimal" configuration, use "make-minimal" wrapper. BOARD ?= qemu_x86 -CONF_FILE = prj.conf +CONF_FILE = prj_$(BOARD)_merged.conf OUTDIR_PREFIX = $(BOARD) # Default heap size is 16KB, which is on conservative side, to let @@ -19,7 +19,9 @@ FROZEN_DIR = scripts # Zephyr (generated) config files - must be defined before include below Z_EXPORTS = outdir/$(OUTDIR_PREFIX)/Makefile.export +ifneq ($(MAKECMDGOALS), clean) include $(Z_EXPORTS) +endif include ../py/mkenv.mk include ../py/py.mk @@ -56,12 +58,12 @@ CFLAGS = $(KBUILD_CFLAGS) $(NOSTDINC_FLAGS) $(ZEPHYRINCLUDE) \ include ../py/mkrules.mk +# We use single target here ($(Z_EXPORTS)) for simplicity, but actually +# number of things get generated here: 'initconfig' generates C header for +# Kconfig configuration, 'outputexports' generates make environment with CC, +# etc., and 'lib' generates other headers which may be included by zephyr.h, +# e.g. DTS-related. $(Z_EXPORTS): $(CONF_FILE) - # We use single target here ($(Z_EXPORTS)) for simplicity, but actually - # number of things get generated here: 'initconfig' generates C header for - # Kconfig configuration, 'outputexports' generates make environment with CC, - # etc., and 'lib' generates other headers which may be included by zephyr.h, - # e.g. DTS-related. $(MAKE) -f Makefile.zephyr BOARD=$(BOARD) CONF_FILE=$(CONF_FILE) initconfig outputexports lib GENERIC_TARGETS = all zephyr run qemu qemugdb flash debug debugserver @@ -84,14 +86,14 @@ build/genhdr/qstr.i.last: | $(Z_EXPORTS) # If we recreate libmicropython, also cause zephyr.bin relink LIBMICROPYTHON_EXTRA_CMD = -$(RM) -f outdir/$(OUTDIR_PREFIX)/zephyr.lnk -# Clean Zephyr things too -clean: z_clean +# MicroPython's global clean cleans everything, fast +CLEAN_EXTRA = outdir +# Clean Zephyr things in Zephyr way z_clean: $(MAKE) -f Makefile.zephyr BOARD=$(BOARD) clean -.PHONY: prj.conf -prj.conf: prj_base.conf +$(CONF_FILE): prj_base.conf prj_$(BOARD).conf $(PYTHON) makeprj.py prj_base.conf prj_$(BOARD).conf $@ test: