Skip to content

Commit 0c75990

Browse files
committed
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).
1 parent f69ab79 commit 0c75990

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

zephyr/Makefile

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# To build a "minimal" configuration, use "make-minimal" wrapper.
99

1010
BOARD ?= qemu_x86
11-
CONF_FILE = prj.conf
11+
CONF_FILE = prj_$(BOARD)_merged.conf
1212
OUTDIR_PREFIX = $(BOARD)
1313

1414
# Default heap size is 16KB, which is on conservative side, to let
@@ -19,7 +19,9 @@ FROZEN_DIR = scripts
1919

2020
# Zephyr (generated) config files - must be defined before include below
2121
Z_EXPORTS = outdir/$(OUTDIR_PREFIX)/Makefile.export
22+
ifneq ($(MAKECMDGOALS), clean)
2223
include $(Z_EXPORTS)
24+
endif
2325

2426
include ../py/mkenv.mk
2527
include ../py/py.mk
@@ -56,12 +58,12 @@ CFLAGS = $(KBUILD_CFLAGS) $(NOSTDINC_FLAGS) $(ZEPHYRINCLUDE) \
5658

5759
include ../py/mkrules.mk
5860

61+
# We use single target here ($(Z_EXPORTS)) for simplicity, but actually
62+
# number of things get generated here: 'initconfig' generates C header for
63+
# Kconfig configuration, 'outputexports' generates make environment with CC,
64+
# etc., and 'lib' generates other headers which may be included by zephyr.h,
65+
# e.g. DTS-related.
5966
$(Z_EXPORTS): $(CONF_FILE)
60-
# We use single target here ($(Z_EXPORTS)) for simplicity, but actually
61-
# number of things get generated here: 'initconfig' generates C header for
62-
# Kconfig configuration, 'outputexports' generates make environment with CC,
63-
# etc., and 'lib' generates other headers which may be included by zephyr.h,
64-
# e.g. DTS-related.
6567
$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) CONF_FILE=$(CONF_FILE) initconfig outputexports lib
6668

6769
GENERIC_TARGETS = all zephyr run qemu qemugdb flash debug debugserver
@@ -84,14 +86,14 @@ build/genhdr/qstr.i.last: | $(Z_EXPORTS)
8486
# If we recreate libmicropython, also cause zephyr.bin relink
8587
LIBMICROPYTHON_EXTRA_CMD = -$(RM) -f outdir/$(OUTDIR_PREFIX)/zephyr.lnk
8688

87-
# Clean Zephyr things too
88-
clean: z_clean
89+
# MicroPython's global clean cleans everything, fast
90+
CLEAN_EXTRA = outdir
8991

92+
# Clean Zephyr things in Zephyr way
9093
z_clean:
9194
$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) clean
9295

93-
.PHONY: prj.conf
94-
prj.conf: prj_base.conf
96+
$(CONF_FILE): prj_base.conf prj_$(BOARD).conf
9597
$(PYTHON) makeprj.py prj_base.conf prj_$(BOARD).conf $@
9698

9799
test:

0 commit comments

Comments
 (0)