From 0dc85c9f86735c35cf14555482b2c8923cf31a6a Mon Sep 17 00:00:00 2001
From: Paul Sokolovsky <pfalcon@users.sourceforge.net>
Date: Tue, 19 Apr 2016 12:18:46 +0300
Subject: [PATCH] py/mkrules.mk: Try to detect and emulate make -B behavior for
 qstr extraction.

If make -B is run, the rule is run with $? empty. Extract fron all file in
this case. But this gets fragile, really "make clean" should be used instead
with such build complexity.
---
 py/mkrules.mk | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/py/mkrules.mk b/py/mkrules.mk
index 9a739b8b7..068d37055 100644
--- a/py/mkrules.mk
+++ b/py/mkrules.mk
@@ -83,7 +83,12 @@ $(OBJ): | $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/mpversion.h
 
 $(HEADER_BUILD)/qstr.i.last: $(SRC_QSTR) | $(HEADER_BUILD)/mpversion.h
 	$(ECHO) "GEN $@"
-	$(Q)$(CPP) $(QSTR_GEN_EXTRA_CFLAGS) $(CFLAGS) $? >$(HEADER_BUILD)/qstr.i.last
+	if [ "$?" == "" ]; then \
+	    echo "QSTR Looks like -B used, trying to emulate"; \
+	    $(Q)$(CPP) $(QSTR_GEN_EXTRA_CFLAGS) $(CFLAGS) $^ >$(HEADER_BUILD)/qstr.i.last; \
+	else \
+	    $(Q)$(CPP) $(QSTR_GEN_EXTRA_CFLAGS) $(CFLAGS) $? >$(HEADER_BUILD)/qstr.i.last; \
+	fi
 
 $(QSTR_DEFS_COLLECTED): $(HEADER_BUILD)/qstr.i.last
 	$(ECHO) "GEN $@"
-- 
GitLab