When getting all the makefile variables from the Makefiles obey
also the conditionals (ifdef, ifndef) and make sure all the
makefiles rules are filtered out (to avoid miss-interpreting a
shell variable assignment in a rule as a makefile variable).
... | ... |
@@ -137,13 +137,26 @@ get_make_idefs=$(subst ^LF^,$(LF),$(shell sed \ |
137 | 137 |
|
138 | 138 |
|
139 | 139 |
# get all the lines from the makefile containing variable definitions. |
140 |
+# It will also return conditionals and try to filter out possible rules. |
|
140 | 141 |
# WARNING: does not work with all sed implementation (tested with GNU sed). |
141 | 142 |
# It uses a hack to restore the LFs (LFs are removed by $(shell)): LFs are |
142 | 143 |
# replaced with '^LF^' and then ^LF^ is subst'ed back to a real LF. |
143 |
-get_make_vars=$(subst ^LF^,$(LF),$(shell sed \ |
|
144 |
- -ne '/^[\t ]*[A-Za-z0-9_-]\+[\t ]*[+:]\?=.*[^\]$$/H'\ |
|
145 |
- -ne '/^[\t ]*[A-Za-z0-9_-]\+[\t ]*[+:]\?=.*\\$$/,/\(^$$\)\|\([^\]$$\)/H'\ |
|
146 |
- -ne '$${g;s/\n/^LF^/g;p}'\ |
|
144 |
+get_make_vars=$(subst ^LF^,$(LF),$(shell sed -n \ |
|
145 |
+ -e ': start' \ |
|
146 |
+ -e '/^\(ifeq\|ifneq\|else\|endif\)[\t ]*\($$\|.*[^\]$$\)/{H;d}' \ |
|
147 |
+ -e '/^\(ifeq\|ifneq\|else\|endif\)[\t ]\+.*[\]$$/,/[^\]$$/{H;d}' \ |
|
148 |
+ -e '/^[a-zA-Z._/$$][a-zA-Z0-9._()/$$ \t-]*:\([^=]\|$$\)/b eat_rule' \ |
|
149 |
+ -e '/^[\t ]*[A-Za-z._][A-Za-z0-9._-]*[\t ]*[+:]\?=.*[^\]$$/{H;d}' \ |
|
150 |
+ -e '/^[\t ]*[A-Za-z._][A-Za-z0-9._-]*[\t ]*[+:]\?=.*\\$$/,/\(^$$\)\|\([^\]$$\)/{H;d}' \ |
|
151 |
+ -e ': end' \ |
|
152 |
+ -e '$${g;s/\n/^LF^/g;p}'\ |
|
153 |
+ -e 'b' \ |
|
154 |
+ -e ': eat_rule' \ |
|
155 |
+ -e '$$b end' \ |
|
156 |
+ -e 'n' \ |
|
157 |
+ -e '/^[a-zA-Z._/$$][a-zA-Z0-9._()/$$ \t-]*:\([^=]\|$$\)/b eat_rule' \ |
|
158 |
+ -e '/^[\t]/b eat_rule' \ |
|
159 |
+ -e 'b start' \ |
|
147 | 160 |
< $(1)/Makefile )) |
148 | 161 |
|
149 | 162 |
|
... | ... |
@@ -159,6 +172,8 @@ INCLUDES:= |
159 | 172 |
# extract all the includes and defs from the module makefile and |
160 | 173 |
# evaluate them |
161 | 174 |
$$(eval $$(call get_make_vars,$$(dir $$(call get_prereq,$(1))))) |
175 |
+# override COREPATH (we know better) |
|
176 |
+COREPATH=../.. |
|
162 | 177 |
# save the result in a per group e_idefs_<grp_name> var |
163 | 178 |
$$(eval e_idefs_$$(call get_grp,$(1)):=$$(DEFS) $$(INCLUDES)) |
164 | 179 |
|