summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan Laurie <dlaurie@chromium.org>2013-07-23 08:06:08 -0700
committerChromeBot <chrome-bot@google.com>2013-07-23 08:14:10 -0700
commit8ae59d7e58c9b3c6c2291db4e3cc89587ee8d981 (patch)
treee0966e8ee3682a6ad606d592ecc58f31375d5c95
parente4e6a0814bcf2e982ed4c5a7da83e185ef2118f5 (diff)
downloadchrome-ec-8ae59d7e58c9b3c6c2291db4e3cc89587ee8d981.tar.gz
Fix extracting CONFIG tokens from config.h
We need to use cpp -dM instead of -dN, because -dN doesn't process #undef statements. That is, if you have " #define CONFIG_FOO" " #undef CONFIG_FOO" then -dN will happily print both lines, which results in CONFIG_FOO being defined when processing the makefile. -dM processes the defines and undefs so that the resulting list of macros only includes those that are defined. We didn't notice this before, because we temporarily commented out config statements instead of #undef'ing them - or the configs which were undef'd only resulted in conditional non-compilation of pieces of code inside a file instead of the whole file not being compiled. This change also tidily alphabetizes the resulting configs. It also better filters CONFIGs to ensure that " #define __CROS_EC_CONFIG_CHIP_H" does not show up as a CONFIG_CHIP_H token, as it did previously. BUG=chrome-os-partner:20985 BRANCH=none (though may be needed if any future cherry-picked change requires undefining a CONFIG) TEST=Add #undef CONFIG_ADC to the end of config.h and see that the ADC module is not compiled. Also helps to add $(info $(_flag_cfg)) to the Makefile to see the list of tokens, and verify that CONFIG_ADC is not among them. Original-Change-Id: I18db60099e87857473ba54c3c9fff1116d4f1a93 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/62230 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit d48828757de2274938cf8ec862689c935adaae33) Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Change-Id: Ibfb59271656827842755cfaaebb5025bc492f4b9 Reviewed-on: https://gerrit.chromium.org/gerrit/63018
-rw-r--r--Makefile6
1 files changed, 4 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 50e057d699..582d0a5c16 100644
--- a/Makefile
+++ b/Makefile
@@ -35,8 +35,10 @@ else
endif
_tsk_cfg:=$(foreach t,$(_tsk_lst) ,HAS_TASK_$(t))
CPPFLAGS+=$(foreach t,$(_tsk_cfg),-D$(t))
-_flag_cfg:=$(shell $(CPP) $(CPPFLAGS) -P -dN -Ichip/$(CHIP) -Iboard/$(BOARD) \
- include/config.h | grep -o "CONFIG_.*")
+_flag_cfg:=$(shell $(CPP) $(CPPFLAGS) -P -dM -Ichip/$(CHIP) -Iboard/$(BOARD) \
+ include/config.h | grep -o "\#define CONFIG_[A-Za-z0-9_]*" | \
+ cut -c9- | sort)
+
$(foreach c,$(_tsk_cfg) $(_flag_cfg),$(eval $(c)=y))
$(eval BOARD_$(BOARD)=y)