Browse code

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 authored on 30/08/2010 11:46:33
Showing 1 changed files
... ...
@@ -69,7 +69,23 @@ override force_grp=
69 69
 endif
70 70
 
71 71
 # command used for gcc (contains extra includes)
72
-gcc=gcc -I$(COREPATH)/lib -I/usr/include/libxml2
72
+gcc=gcc
73
+#-I$(COREPATH)/lib -I$(COREPATH) -I/usr/include/libxml2
74
+
75
+# defines used by gcc
76
+c_defs=-D__CPU_i386 -D__OS_linux -DSER_VER=2099099 -DPKG_MALLOC -DSHM_MEM  \
77
+		-DSHM_MMAP -DDNS_IP_HACK -DUSE_IPV6 -DUSE_MCAST -DUSE_TCP \
78
+		-DUSE_DNS_CACHE -DUSE_DNS_FAILOVER -DUSE_DST_BLACKLIST -DUSE_NAPTR \
79
+		-DUSE_TLS -DTLS_HOOKS -DFAST_LOCK   -DCC_GCC_LIKE_ASM \
80
+		-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
81
+		-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
82
+		-DHAVE_SCHED_SETSCHEDULER -DHAVE_EPOLL -DUSE_SCTP -DNAME='\"ser\"' \
83
+		-DVERSION='\"2.99.99-pre3\"' -DARCH='\"i386\"' -DOS_QUOTED='\"linux\"'
84
+
85
+
86
+# common makefile vars used in defs
87
+LOCALBASE=/usr/local
88
+SYSBASE=/usr
73 89
 
74 90
 filter_files=$(filter-out $(addsuffix %,$(file_exclude)),\
75 91
 				$(filter-out $(addprefix %:,$(grp_exclude)),$(1)))
... ...
@@ -102,21 +118,67 @@ get_grp=$(strip $(if $(grp_f_$(call get_bname,$(1))), \
102 118
 # get target from file:grp (get_target(file:grp) => rpc_grp.txt)
103 119
 get_target=rpc_$(call get_grp,$(1))
104 120
 
121
+
122
+# $(LF) definition (do not remove)
123
+define LF
124
+
125
+
126
+endef
127
+
128
+# get all the lines containing DEFS or INCLUDES definitions from the Makefile.
129
+# WARNING: does not work with all sed implementation (tested with GNU sed).
130
+# It uses a hack to restore the LFs (LFs are removed by $(shell)): LFs are
131
+# replaced with '^LF^' and then ^LF^ is subst'ed back to a real LF.
132
+get_make_idefs=$(subst ^LF^,$(LF),$(shell sed \
133
+ -ne '/^[\t ]*\(DEFS\|INCLUDES\)[\t ]*[+:]\?=.*[^\]$$/H'\
134
+ -ne '/^[\t ]*\(DEFS\|INCLUDES\)[\t ]*[+:]\?=.*\\$$/,/\(^$$\)\|\([^\]$$\)/H'\
135
+ -ne '$${g;s/\n/^LF^/g;p}'\
136
+< $(1)/Makefile ))
137
+
138
+
139
+# get all the lines from the makefile containing variable definitions.
140
+# WARNING: does not work with all sed implementation (tested with GNU sed).
141
+# It uses a hack to restore the LFs (LFs are removed by $(shell)): LFs are
142
+# 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}'\
147
+< $(1)/Makefile ))
148
+
149
+
105 150
 define  mk_rules
106 151
 
107 152
 $(call check_fname_grp, $(1))
108 153
 
109 154
 #$$(info generating rpc_$$(call get_grp,$(1)).txt: $$(call get_prereq,$(1)))
110 155
 
156
+
157
+DEFS:=
158
+INCLUDES:=
159
+# extract all the includes and defs from the module makefile and
160
+# evaluate them
161
+$$(eval $$(call get_make_vars,$$(dir $$(call get_prereq,$(1)))))
162
+# save the result in a per group e_idefs_<grp_name> var
163
+$$(eval e_idefs_$$(call get_grp,$(1)):=$$(DEFS) $$(INCLUDES))
164
+
165
+# debugging:
166
+#$$(info eval: $$(call get_make_vars,$$(dir $$(call get_prereq,$(1)))))
167
+#$$(info e_idefs_$$(call get_grp,$(1))=$$(e_idefs_$$(call get_grp,$(1))))
168
+
111 169
 $(txt_output_dir)/$$(call get_target,$(1)).txt: \
112 170
 								$$(call get_prereq,$(1)) Makefile $(CFG2TXT)
113 171
 	$(CFG2TXT) --file $$< --$(force_grp)grp=$$(call get_grp,$(1)) \
114
-		--gcc="$(gcc)" --txt > "$$@" ||  (rm -f "$$@"; exit 1)
172
+		--gcc="$(gcc)" --txt \
173
+		--defs="$(c_defs) $$(e_idefs_$$(call get_grp,$(1)))" \
174
+		> "$$@" || (rm -f "$$@"; exit 1)
115 175
 
116 176
 $(docbook_output_dir)/$$(call get_target,$(1)).xml: \
117 177
 								$$(call get_prereq,$(1)) Makefile $(CFG2TXT)
118 178
 	$(CFG2DOCBOOK) --file $$< --$(force_grp)grp=$$(call get_grp,$(1)) \
119
-		--gcc="$(gcc)" --docbook > "$$@" ||  (rm -f "$$@"; exit 1)
179
+		--gcc="$(gcc)" --docbook \
180
+		--defs="$(c_defs) $$(e_idefs_$$(call get_grp,$(1)))" \
181
+		> "$$@" || (rm -f "$$@"; exit 1)
120 182
 
121 183
 
122 184
 clean_$$(call get_target,$(1)).txt: