| 1 |
|
| 2 |
COREPATH=../../../src |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
CFG2TXT=../../scripts/cdefs2doc/dump_selects.pl |
| 7 |
CFG2DOCBOOK=../../scripts/cdefs2doc/dump_selects.pl |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
CFG2TXT_EXTRA_OPTS=--core $(COREPATH)/core/select_core.c |
| 12 |
CFG2DOCBOOK_EXTRA_OPTS=--core $(COREPATH)/core/select_core.c |
| 13 |
|
| 14 |
|
| 15 |
txt_output_dir=. |
| 16 |
|
| 17 |
docbook_output_dir=docbook |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
files_list= \ |
| 26 |
$(COREPATH)/core/select_core.c:core \ |
| 27 |
$(COREPATH)/modules/avp/avp.c:avp \ |
| 28 |
$(COREPATH)/modules/cnxcc/cnxcc_mod.c:cnxcc \ |
| 29 |
$(COREPATH)/modules/db2_ops/db2_ops.c:db2_ops \ |
| 30 |
$(COREPATH)/modules/nathelper/nathelper.c:nathelper \ |
| 31 |
$(COREPATH)/modules/textopsx/textopsx.c:textopsx \ |
| 32 |
$(COREPATH)/modules/timer/timer.c:timer \ |
| 33 |
$(COREPATH)/modules/tls/tls_select.c:tls \ |
| 34 |
$(COREPATH)/modules/tm/select.c:tm \ |
| 35 |
$(COREPATH)/modules/xmlrpc/xmlrpc.c:xmlrpc |
| 36 |
|
| 37 |
grp_exclude=pa iptrtpproxy |
| 38 |
|
| 39 |
file_exclude= $(COREPATH)/obsolete/ |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
ifeq ($(group_override),1) |
| 54 |
override force_grp=force- |
| 55 |
else |
| 56 |
override force_grp= |
| 57 |
endif |
| 58 |
|
| 59 |
|
| 60 |
gcc=gcc |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
c_defs=-DNAME='\"kamailio\"' -DVERSION='\"5.1.0-dev3\"' -DARCH='\"x86_64\"' \ |
| 65 |
-DOS='linux_' -DOS_QUOTED='\"linux\"' -DCOMPILER='\"gcc 4.9.2\"' \ |
| 66 |
-D__CPU_x86_64 -D__OS_linux -DSER_VER=5001000 \ |
| 67 |
-DCFG_DIR='\"/usr/local/etc/kamailio/\"' \ |
| 68 |
-DRUN_DIR='\"/run/kamailio/\"' -DPKG_MALLOC -DSHM_MEM -DSHM_MMAP \ |
| 69 |
-DDNS_IP_HACK -DUSE_MCAST -DUSE_TCP -DDISABLE_NAGLE -DHAVE_RESOLV_RES \ |
| 70 |
-DUSE_DNS_CACHE -DUSE_DNS_FAILOVER -DUSE_DST_BLOCKLIST -DUSE_NAPTR \ |
| 71 |
-DMEM_JOIN_FREE -DF_MALLOC -DQ_MALLOC -DTLSF_MALLOC \ |
| 72 |
-DDBG_SR_MEMORY -DUSE_TLS -DTLS_HOOKS -DUSE_CORE_STATS -DSTATISTICS \ |
| 73 |
-DMALLOC_STATS -DWITH_AS_SUPPORT -DUSE_SCTP -DFAST_LOCK -DADAPTIVE_WAIT \ |
| 74 |
-DADAPTIVE_WAIT_LOOPS=1024 -DCC_GCC_LIKE_ASM -DHAVE_GETHOSTBYNAME2 \ |
| 75 |
-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD -DHAVE_MSG_NOSIGNAL \ |
| 76 |
-DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H -DHAVE_TIMEGM \ |
| 77 |
-DHAVE_SCHED_SETSCHEDULER -DHAVE_IP_MREQN -DHAVE_EPOLL -DHAVE_SIGIO_RT \ |
| 78 |
-DSIGINFO64_WORKAROUND -DUSE_FUTEX -DHAVE_SELECT |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
LOCALBASE=/usr/local |
| 83 |
SYSBASE=/usr |
| 84 |
|
| 85 |
filter_files=$(subst .h:,.c:, $(filter-out $(addsuffix %,$(file_exclude)),\ |
| 86 |
$(filter-out $(addprefix %:,$(grp_exclude)),$(1))) ) |
| 87 |
|
| 88 |
|
| 89 |
flist=$(call filter_files,$(files_list)) |
| 90 |
|
| 91 |
|
| 92 |
check_fname_grp=$(if $(filter-out 2,$(words $(subst :, ,$(1)))),\ |
| 93 |
$(error bad format "$(1)", it should be filename:grp)) |
| 94 |
|
| 95 |
|
| 96 |
get_prereq=$(firstword $(subst :, ,$(1))) |
| 97 |
|
| 98 |
|
| 99 |
get_listed_grp=$(word 2, $(subst :, ,$(1))) |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
get_bname=$(basename $(notdir $(call get_prereq,$(1)))) |
| 105 |
|
| 106 |
|
| 107 |
get_grp=$(strip $(if $(grp_f_$(call get_bname,$(1))), \ |
| 108 |
$(grp_f_$(call get_bname,$(1))),\ |
| 109 |
$(if $(grp_g_$(call get_listed_grp,$(1))),\ |
| 110 |
$(grp_g_$(call get_listed_grp,$(1))),\ |
| 111 |
$(call get_listed_grp,$(1))) ) ) |
| 112 |
|
| 113 |
|
| 114 |
get_target=select_$(call get_grp,$(1)) |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
define LF |
| 119 |
|
| 120 |
|
| 121 |
endef |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
get_make_idefs=$(subst ^LF^,$(LF),$(shell sed \ |
| 128 |
-ne '/^[\t ]*\(DEFS\|INCLUDES\)[\t ]*[+:]\?=.*[^\]$$/H'\ |
| 129 |
-ne '/^[\t ]*\(DEFS\|INCLUDES\)[\t ]*[+:]\?=.*\\$$/,/\(^$$\)\|\([^\]$$\)/H'\ |
| 130 |
-ne '$${g;s/\n/^LF^/g;p}'\ |
| 131 |
< $(1)/Makefile )) |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
get_make_vars=$(subst ^LF^,$(LF),$(shell sed -n \ |
| 140 |
-e ': start' \ |
| 141 |
-e '/^\(ifeq\|ifneq\|else\|endif\)[\t ]*\($$\|.*[^\]$$\)/{H;b end}' \ |
| 142 |
-e '/^\(ifeq\|ifneq\|else\|endif\)[\t ]\+.*[\]$$/,/[^\]$$/{H;b end}' \ |
| 143 |
-e '/^[a-zA-Z._/$$][a-zA-Z0-9._()/$$ \t-]*:\([^=]\|$$\)/b eat_rule' \ |
| 144 |
-e '/^[\t ]*[A-Za-z._][A-Za-z0-9._-]*[\t ]*[+:]\?=.*[^\]$$/{H;b end}' \ |
| 145 |
-e '/^[\t ]*[A-Za-z._][A-Za-z0-9._-]*[\t ]*[+:]\?=.*\\$$/,/\(^$$\)\|\([^\]$$\)/{H;b end}' \ |
| 146 |
-e ': end' \ |
| 147 |
-e '$${g;s/\n/^LF^/g;p}'\ |
| 148 |
-e 'b' \ |
| 149 |
-e ': eat_rule' \ |
| 150 |
-e '$$b end' \ |
| 151 |
-e 'n' \ |
| 152 |
-e '/^[a-zA-Z._/$$][a-zA-Z0-9._()/$$ \t-]*:\([^=]\|$$\)/b eat_rule' \ |
| 153 |
-e '/^[\t]/b eat_rule' \ |
| 154 |
-e 'b start' \ |
| 155 |
< $(1)/Makefile )) |
| 156 |
|
| 157 |
|
| 158 |
define mk_rules |
| 159 |
|
| 160 |
$(call check_fname_grp, $(1)) |
| 161 |
|
| 162 |
#$$(info generating select_$$(call get_grp,$(1)).txt: $$(call get_prereq,$(1))) |
| 163 |
|
| 164 |
|
| 165 |
DEFS:= |
| 166 |
INCLUDES:= |
| 167 |
# extract all the includes and defs from the module makefile and |
| 168 |
# evaluate them |
| 169 |
$$(eval $$(call get_make_vars,$$(dir $$(call get_prereq,$(1))))) |
| 170 |
# override COREPATH (we know better) |
| 171 |
COREPATH=../../../src |
| 172 |
# save the result in a per group e_idefs_<grp_name> var |
| 173 |
$$(eval e_idefs_$$(call get_grp,$(1)):=$$(DEFS) $$(INCLUDES)) |
| 174 |
|
| 175 |
# debugging: |
| 176 |
#$$(info eval: $$(call get_make_vars,$$(dir $$(call get_prereq,$(1))))) |
| 177 |
#$$(info e_idefs_$$(call get_grp,$(1))=$$(e_idefs_$$(call get_grp,$(1)))) |
| 178 |
|
| 179 |
$(txt_output_dir)/$$(call get_target,$(1)).txt: \ |
| 180 |
$$(call get_prereq,$(1)) Makefile $(CFG2TXT) |
| 181 |
$(CFG2TXT) --file $$< --$(force_grp)grp=$$(call get_grp,$(1)) \ |
| 182 |
--gcc="$(gcc)" --txt $(CFG2TXT_EXTRA_OPTS) \ |
| 183 |
--defs="$(c_defs) $$(e_idefs_$$(call get_grp,$(1)))" \ |
| 184 |
> "$$@" || (rm -f "$$@"; exit 1) |
| 185 |
|
| 186 |
$(docbook_output_dir)/$$(call get_target,$(1)).xml: \ |
| 187 |
$$(call get_prereq,$(1)) Makefile $(CFG2TXT) |
| 188 |
$(CFG2DOCBOOK) --file $$< --$(force_grp)grp=$$(call get_grp,$(1)) \ |
| 189 |
--gcc="$(gcc)" --docbook $(CFG2DOCBOOK_EXTRA_OPTS) \ |
| 190 |
--defs="$(c_defs) $$(e_idefs_$$(call get_grp,$(1)))" \ |
| 191 |
> "$$@" || (rm -f "$$@"; exit 1) |
| 192 |
|
| 193 |
|
| 194 |
clean_$$(call get_target,$(1)).txt: |
| 195 |
rm -f "$(txt_output_dir)/$$(call get_target,$(1)).txt" |
| 196 |
|
| 197 |
clean_$$(call get_target,$(1)).xml: |
| 198 |
rm -f "$(docbook_output_dir)/$$(call get_target,$(1)).xml" |
| 199 |
|
| 200 |
txt: $(txt_output_dir)/$$(call get_target,$(1)).txt |
| 201 |
|
| 202 |
docbook: $(docbook_output_dir)/$$(call get_target,$(1)).xml |
| 203 |
|
| 204 |
clean_txt: clean_$$(call get_target,$(1)).txt |
| 205 |
|
| 206 |
clean_docbook: clean_$$(call get_target,$(1)).xml |
| 207 |
|
| 208 |
|
| 209 |
endef |
| 210 |
|
| 211 |
find_sel_files_cmd= find $(COREPATH) -type f -name "*.[ch]" \ |
| 212 |
-exec grep "select_row_t[ ][a-zA-Z0-9_][a-zA-Z0-9_]*\[\][ ]*=" \ |
| 213 |
/dev/null {} \; \ |
| 214 |
| cut -d: -f1 |
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
gen_file_grp_cmd=\ |
| 222 |
sed -e "s!\(.*/modules[^/]*/\([^/][^/]*\)/.*\)! \1:\2!" \ |
| 223 |
-e "s!^\([^ ].*/\([^/.]*\)[^/]*$$\)!\1:\2!" \ |
| 224 |
-e "s!^\([^ :]*\):\(.*\)_select[_]*!\1:\2!" \ |
| 225 |
-e "s!^\([^ :]*\):\(.*\)select[_]*!\1:\2!" \ |
| 226 |
-e "s!^\([^ :]*\):\(.*\)_declaration[_]*!\1:\2!" \ |
| 227 |
-e "s!^\([^ :]*\):\(.*\)_table[_]*!\1:\2!" \ |
| 228 |
-e "s!^\([^ :]*\):\(.*\)_sel[_]*!\1:\2!" \ |
| 229 |
-e "s!^\([^ :]*\):\(.*\)sel[_]*!\1:\2!" \ |
| 230 |
|
| 231 |
# special vars for generating the list of files or updates |
| 232 |
found_lst=$(shell $(find_sel_files_cmd) | $(gen_file_grp_cmd)) |
| 233 |
# filtered found lst |
| 234 |
f_found_lst=$(call filter_files,$(found_lst)) |
| 235 |
diff_lst=$(filter-out $(flist),$(f_found_lst)) |
| 236 |
|
| 237 |
|
| 238 |
get_core_files=$(filter-out $(COREPATH)/modules% $(COREPATH)/lib%,$(1)) |
| 239 |
sort_files=$(sort $(call get_core_files,$(1)))\ |
| 240 |
$(sort $(filter-out $(call get_core_files,$(1)),$(1))) |
| 241 |
|
| 242 |
|
| 243 |
subst_corepath=$(patsubst $(patsubst %/,%,$(COREPATH))/%,\$$(COREPATH)/%,$(1)) |
| 244 |
|
| 245 |
|
| 246 |
# help will be the default rule (on-purpose since without having a patched |
| 247 |
|
| 248 |
.PHONY: help |
| 249 |
help: |
| 250 |
@echo "To regenerate $(foreach f,$(flist),$(call get_target,$f).{txt,xml})" |
| 251 |
@echo "type: $(MAKE) all ." |
| 252 |
@echo "or to regenerate all the select lists by searching all" |
| 253 |
@echo " the source files for definitions, type: $(MAKE) autogen ." |
| 254 |
@echo "NOTE: you need the GCC:TranslationUnit perl module with an " |
| 255 |
@echo "extra patch applied (see $(CFG2TXT) --patch)." |
| 256 |
|
| 257 |
.PHONY: txt |
| 258 |
txt: |
| 259 |
|
| 260 |
.PHONY: docbook |
| 261 |
docbook: |
| 262 |
|
| 263 |
.PHONY: clean_txt |
| 264 |
clean_txt: |
| 265 |
|
| 266 |
.PHONY: clean_docbook |
| 267 |
clean_docbook: |
| 268 |
|
| 269 |
|
| 270 |
.PHONY: all |
| 271 |
all: txt $(docbook_output_dir)/select_list.xml |
| 272 |
|
| 273 |
.PHONY: clean |
| 274 |
clean: clean_txt clean_docbook |
| 275 |
@rm -f $(docbook_output_dir)/select_list.xml |
| 276 |
|
| 277 |
.PHONY: proper |
| 278 |
proper: |
| 279 |
@rm -f $(txt_output_dir)/select_*.txt |
| 280 |
@rm -f $(docbook_output_dir)/select_*.xml |
| 281 |
|
| 282 |
repo_ver="sip-router"\ |
| 283 |
"git-$(shell git rev-parse --verify --short=6 HEAD 2>/dev/null)" |
| 284 |
ifeq ($(repo_ver),git-) |
| 285 |
repo_ver="sip-router unknown" |
| 286 |
endif |
| 287 |
|
| 288 |
$(docbook_output_dir)/select_list.xml: Makefile \ |
| 289 |
$(foreach f,$(flist),$(docbook_output_dir)/$(call get_target,$f).xml) |
| 290 |
@echo '<?xml version="1.0" encoding="UTF-8"?>' >$@ |
| 291 |
@echo '<!-- this file is autogenerated, do not edit! -->' >>$@ |
| 292 |
@echo '<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"' >>$@ |
| 293 |
@echo ' "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"' >>$@ |
| 294 |
@echo ' [ <!ENTITY % local.common.attrib' >>$@ |
| 295 |
@echo " \"xmlns:xi CDATA #FIXED 'http://www.w3.org/2001/XInclude'\">]">>$@ |
| 296 |
@echo '>' >>$@ |
| 297 |
@echo '<book id="select_list"'\ |
| 298 |
'xmlns:xi="http://www.w3.org/2001/XInclude">' >>$@ |
| 299 |
@echo ' <title>Select List</title>' >>$@ |
| 300 |
@echo ' <bookinfo>' >>$@ |
| 301 |
@echo ' <productname class="trade">kamailio.org</productname>' >>$@ |
| 302 |
@echo ' <authorgroup>' >>$@ |
| 303 |
@echo ' <author>' >>$@ |
| 304 |
@echo ' <firstname>Kamailio</firstname>' >>$@ |
| 305 |
@echo ' <surname>Development Team</surname>' >>$@ |
| 306 |
@echo ' <affiliation><orgname>https://www.kamailio.org</orgname></affiliation>' >>$@ |
| 307 |
@echo ' <address>[email protected]</address>' >>$@ |
| 308 |
@echo ' </author>' >>$@ |
| 309 |
@echo ' </authorgroup>' >>$@ |
| 310 |
@echo ' <copyright>' >>$@ |
| 311 |
@echo ' <year>2008-2017</year>' >>$@ |
| 312 |
@echo ' <holder>Kamailio Project</holder>' >>$@ |
| 313 |
@echo ' </copyright>' >>$@ |
| 314 |
@echo ' </bookinfo>' >>$@ |
| 315 |
@echo ' <xi:include href="intro.xml"/>' >>$@ |
| 316 |
@$(foreach f,$(flist),\ |
| 317 |
echo ' <xi:include'\ |
| 318 |
'href="'$(call get_target,$f).xml'"/>' \ |
| 319 |
>>$@ ; ) |
| 320 |
@echo '</book>' >>$@ |
| 321 |
|
| 322 |
|
| 323 |
.PHONY: find |
| 324 |
find: |
| 325 |
@$(find_sel_files_cmd) |
| 326 |
|
| 327 |
|
| 328 |
.PHONY: print-lst |
| 329 |
print-lst: |
| 330 |
@$(find_sel_files_cmd) | $(gen_file_grp_cmd) |
| 331 |
|
| 332 |
|
| 333 |
.PHONY: gen-file-list |
| 334 |
.PHONY: gen-files_list |
| 335 |
.PHONY: gen_files_list |
| 336 |
gen-file-list gen-files-list gen_files_list: |
| 337 |
@$(foreach f,$(call subst_corepath,$(call sort_files,$(f_found_lst))),\ |
| 338 |
echo "$f \\";) |
| 339 |
|
| 340 |
.PHONY: check-list |
| 341 |
.PHONY: update-list |
| 342 |
.PHONY: diff-list |
| 343 |
check-list update-list diff-list: |
| 344 |
@$(foreach f,$(call subst_corepath,$(call sort_files,$(diff_lst))),\ |
| 345 |
echo "$f \\";) |
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
.PHONY: autogen |
| 350 |
autogen: |
| 351 |
@$(MAKE) all files_list="$(call sort_files,$(f_found_lst))" |
| 352 |
|
| 353 |
$(foreach f,$(flist),$(eval $(call mk_rules,$(f)))) |