From 1df1642b706eb6d39f93936e70df22cbdfb0ec36 Mon Sep 17 00:00:00 2001
From: Paul Sokolovsky <pfalcon@users.sourceforge.net>
Date: Fri, 27 Jan 2017 23:42:11 +0300
Subject: [PATCH] zephyr: Allow to have per-board Zephyr config fragments.

To enable options which may be incompatible with other boards, etc.
---
 zephyr/Makefile                    | 7 ++++++-
 zephyr/{prj.conf => prj_base.conf} | 7 -------
 zephyr/prj_qemu_x86.conf           | 6 ++++++
 3 files changed, 12 insertions(+), 8 deletions(-)
 rename zephyr/{prj.conf => prj_base.conf} (68%)
 create mode 100644 zephyr/prj_qemu_x86.conf

diff --git a/zephyr/Makefile b/zephyr/Makefile
index 7f35eefb5..4c28e4da8 100644
--- a/zephyr/Makefile
+++ b/zephyr/Makefile
@@ -62,7 +62,7 @@ CFLAGS = $(KBUILD_CFLAGS) $(NOSTDINC_FLAGS) $(ZEPHYRINCLUDE) \
 
 include ../py/mkrules.mk
 
-$(Z_EXPORTS):
+$(Z_EXPORTS): $(CONF_FILE)
 	$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) CONF_FILE=$(CONF_FILE) initconfig outputexports
 
 GENERIC_TARGETS = all zephyr qemu qemugdb flash debug
@@ -95,3 +95,8 @@ clean: z_clean
 
 z_clean:
 	$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) clean
+
+.PHONY: prj.conf
+prj.conf: prj_base.conf
+	cat $< >$@
+	if [ -f prj_$(BOARD).conf ]; then cat prj_$(BOARD).conf >>$@; fi
diff --git a/zephyr/prj.conf b/zephyr/prj_base.conf
similarity index 68%
rename from zephyr/prj.conf
rename to zephyr/prj_base.conf
index a2fcb64d9..43aedd8fe 100644
--- a/zephyr/prj.conf
+++ b/zephyr/prj_base.conf
@@ -10,10 +10,3 @@ CONFIG_NETWORKING=y
 CONFIG_NET_IPV4=y
 CONFIG_TEST_RANDOM_GENERATOR=y
 CONFIG_NET_NBUF_RX_COUNT=4
-
-# Networking drivers
-# SLIP driver for QEMU
-CONFIG_NET_SLIP_TAP=y
-
-# BOARD-specific config (qemu_x86)
-CONFIG_RAM_SIZE=256
diff --git a/zephyr/prj_qemu_x86.conf b/zephyr/prj_qemu_x86.conf
new file mode 100644
index 000000000..cb90834ac
--- /dev/null
+++ b/zephyr/prj_qemu_x86.conf
@@ -0,0 +1,6 @@
+# Networking drivers
+# SLIP driver for QEMU
+CONFIG_NET_SLIP_TAP=y
+
+# Default RAM easily overflows with uPy and networking
+CONFIG_RAM_SIZE=256
-- 
GitLab