瀏覽代碼

doc: rpc_list: parse DEFS from the modules Makefiles

Get all the variable definitions from each module Makefile and
evaluate them to get proper DEFS and INCLUDES (using sed to
extract the variable definitions from the Makefiles, some hack to
preserve the LFs and $(eval) to evaluate them in the current
context).
The DEFS and INCLUDES will be passed to the documentation
generating script (dump_rpcs.pl) as extra arguments for gcc. This
way the proper defines and includes will be used for each module.
Fixes rpc list generation failure for modules with kamailio module
interface or with non-standard include dirs.
Andrei Pelinescu-Onciul 15 年之前
父節點
當前提交
5e67b01516
共有 1 個文件被更改,包括 65 次插入3 次删除
  1. 65 3
      doc/rpc_list/Makefile

+ 65 - 3
doc/rpc_list/Makefile

@@ -69,7 +69,23 @@ override force_grp=
 endif
 endif
 
 
 # command used for gcc (contains extra includes)
 # command used for gcc (contains extra includes)
-gcc=gcc -I$(COREPATH)/lib -I/usr/include/libxml2
+gcc=gcc
+#-I$(COREPATH)/lib -I$(COREPATH) -I/usr/include/libxml2
+
+# defines used by gcc
+c_defs=-D__CPU_i386 -D__OS_linux -DSER_VER=2099099 -DPKG_MALLOC -DSHM_MEM  \
+		-DSHM_MMAP -DDNS_IP_HACK -DUSE_IPV6 -DUSE_MCAST -DUSE_TCP \
+		-DUSE_DNS_CACHE -DUSE_DNS_FAILOVER -DUSE_DST_BLACKLIST -DUSE_NAPTR \
+		-DUSE_TLS -DTLS_HOOKS -DFAST_LOCK   -DCC_GCC_LIKE_ASM \
+		-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
+		-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
+		-DHAVE_SCHED_SETSCHEDULER -DHAVE_EPOLL -DUSE_SCTP -DNAME='\"ser\"' \
+		-DVERSION='\"2.99.99-pre3\"' -DARCH='\"i386\"' -DOS_QUOTED='\"linux\"'
+
+
+# common makefile vars used in defs
+LOCALBASE=/usr/local
+SYSBASE=/usr
 
 
 filter_files=$(filter-out $(addsuffix %,$(file_exclude)),\
 filter_files=$(filter-out $(addsuffix %,$(file_exclude)),\
 				$(filter-out $(addprefix %:,$(grp_exclude)),$(1)))
 				$(filter-out $(addprefix %:,$(grp_exclude)),$(1)))
@@ -102,21 +118,67 @@ get_grp=$(strip $(if $(grp_f_$(call get_bname,$(1))), \
 # get target from file:grp (get_target(file:grp) => rpc_grp.txt)
 # get target from file:grp (get_target(file:grp) => rpc_grp.txt)
 get_target=rpc_$(call get_grp,$(1))
 get_target=rpc_$(call get_grp,$(1))
 
 
+
+# $(LF) definition (do not remove)
+define LF
+
+
+endef
+
+# get all the lines containing DEFS or INCLUDES definitions from the Makefile.
+# 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_idefs=$(subst ^LF^,$(LF),$(shell sed \
+ -ne '/^[\t ]*\(DEFS\|INCLUDES\)[\t ]*[+:]\?=.*[^\]$$/H'\
+ -ne '/^[\t ]*\(DEFS\|INCLUDES\)[\t ]*[+:]\?=.*\\$$/,/\(^$$\)\|\([^\]$$\)/H'\
+ -ne '$${g;s/\n/^LF^/g;p}'\
+< $(1)/Makefile ))
+
+
+# get all the lines from the makefile containing variable definitions.
+# 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}'\
+< $(1)/Makefile ))
+
+
 define  mk_rules
 define  mk_rules
 
 
 $(call check_fname_grp, $(1))
 $(call check_fname_grp, $(1))
 
 
 #$$(info generating rpc_$$(call get_grp,$(1)).txt: $$(call get_prereq,$(1)))
 #$$(info generating rpc_$$(call get_grp,$(1)).txt: $$(call get_prereq,$(1)))
 
 
+
+DEFS:=
+INCLUDES:=
+# extract all the includes and defs from the module makefile and
+# evaluate them
+$$(eval $$(call get_make_vars,$$(dir $$(call get_prereq,$(1)))))
+# save the result in a per group e_idefs_<grp_name> var
+$$(eval e_idefs_$$(call get_grp,$(1)):=$$(DEFS) $$(INCLUDES))
+
+# debugging:
+#$$(info eval: $$(call get_make_vars,$$(dir $$(call get_prereq,$(1)))))
+#$$(info e_idefs_$$(call get_grp,$(1))=$$(e_idefs_$$(call get_grp,$(1))))
+
 $(txt_output_dir)/$$(call get_target,$(1)).txt: \
 $(txt_output_dir)/$$(call get_target,$(1)).txt: \
 								$$(call get_prereq,$(1)) Makefile $(CFG2TXT)
 								$$(call get_prereq,$(1)) Makefile $(CFG2TXT)
 	$(CFG2TXT) --file $$< --$(force_grp)grp=$$(call get_grp,$(1)) \
 	$(CFG2TXT) --file $$< --$(force_grp)grp=$$(call get_grp,$(1)) \
-		--gcc="$(gcc)" --txt > "$$@" ||  (rm -f "$$@"; exit 1)
+		--gcc="$(gcc)" --txt \
+		--defs="$(c_defs) $$(e_idefs_$$(call get_grp,$(1)))" \
+		> "$$@" || (rm -f "$$@"; exit 1)
 
 
 $(docbook_output_dir)/$$(call get_target,$(1)).xml: \
 $(docbook_output_dir)/$$(call get_target,$(1)).xml: \
 								$$(call get_prereq,$(1)) Makefile $(CFG2TXT)
 								$$(call get_prereq,$(1)) Makefile $(CFG2TXT)
 	$(CFG2DOCBOOK) --file $$< --$(force_grp)grp=$$(call get_grp,$(1)) \
 	$(CFG2DOCBOOK) --file $$< --$(force_grp)grp=$$(call get_grp,$(1)) \
-		--gcc="$(gcc)" --docbook > "$$@" ||  (rm -f "$$@"; exit 1)
+		--gcc="$(gcc)" --docbook \
+		--defs="$(c_defs) $$(e_idefs_$$(call get_grp,$(1)))" \
+		> "$$@" || (rm -f "$$@"; exit 1)
 
 
 
 
 clean_$$(call get_target,$(1)).txt:
 clean_$$(call get_target,$(1)).txt: