Module: sip-router
Branch: master
Commit: 9dbb14fef6eb0dafff363eb3061e293de45bf7af
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9dbb14f…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Aug 30 23:02:48 2010 +0200
doc: rpc_list: improve DEFS parsing
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).
---
doc/rpc_list/Makefile | 23 +++++++++++++++++++----
1 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/doc/rpc_list/Makefile b/doc/rpc_list/Makefile
index ac6e31a..bf9f5bf 100644
--- a/doc/rpc_list/Makefile
+++ b/doc/rpc_list/Makefile
@@ -137,13 +137,26 @@ get_make_idefs=$(subst ^LF^,$(LF),$(shell sed \
# get all the lines from the makefile containing variable definitions.
+# It will also return conditionals and try to filter out possible rules.
# WARNING: does not work with all sed implementation (tested with GNU sed).
# It uses a hack to restore the LFs (LFs are removed by $(shell)): LFs are
# replaced with '^LF^' and then ^LF^ is subst'ed back to a real LF.
-get_make_vars=$(subst ^LF^,$(LF),$(shell sed \
- -ne '/^[\t ]*[A-Za-z0-9_-]\+[\t ]*[+:]\?=.*[^\]$$/H'\
- -ne '/^[\t ]*[A-Za-z0-9_-]\+[\t ]*[+:]\?=.*\\$$/,/\(^$$\)\|\([^\]$$\)/H'\
- -ne '$${g;s/\n/^LF^/g;p}'\
+get_make_vars=$(subst ^LF^,$(LF),$(shell sed -n \
+ -e ': start' \
+ -e '/^\(ifeq\|ifneq\|else\|endif\)[\t ]*\($$\|.*[^\]$$\)/{H;d}' \
+ -e '/^\(ifeq\|ifneq\|else\|endif\)[\t ]\+.*[\]$$/,/[^\]$$/{H;d}' \
+ -e '/^[a-zA-Z._/$$][a-zA-Z0-9._()/$$ \t-]*:\([^=]\|$$\)/b eat_rule' \
+ -e '/^[\t ]*[A-Za-z._][A-Za-z0-9._-]*[\t ]*[+:]\?=.*[^\]$$/{H;d}' \
+ -e '/^[\t ]*[A-Za-z._][A-Za-z0-9._-]*[\t
]*[+:]\?=.*\\$$/,/\(^$$\)\|\([^\]$$\)/{H;d}' \
+ -e ': end' \
+ -e '$${g;s/\n/^LF^/g;p}'\
+ -e 'b' \
+ -e ': eat_rule' \
+ -e '$$b end' \
+ -e 'n' \
+ -e '/^[a-zA-Z._/$$][a-zA-Z0-9._()/$$ \t-]*:\([^=]\|$$\)/b eat_rule' \
+ -e '/^[\t]/b eat_rule' \
+ -e 'b start' \
< $(1)/Makefile ))
@@ -159,6 +172,8 @@ INCLUDES:=
# extract all the includes and defs from the module makefile and
# evaluate them
$$(eval $$(call get_make_vars,$$(dir $$(call get_prereq,$(1)))))
+# override COREPATH (we know better)
+COREPATH=../..
# save the result in a per group e_idefs_<grp_name> var
$$(eval e_idefs_$$(call get_grp,$(1)):=$$(DEFS) $$(INCLUDES))