Module: sip-router
Branch: andrei/cdefs2doc
Commit: 34d34985de850287caf9f17fddeee015f0101f52
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=34d34985de850287caf9f17fddeee015f0101f52

Author: Andrei Pelinescu-Onciul <[email protected]>
Committer: Andrei Pelinescu-Onciul <[email protected]>
Date:   Wed Feb 17 22:31:43 2010 +0100

doc: cfg_list: support for generating docbook output

- make docbook will generate the cfg lists in docbook format
- make all will generate both txt and docbook
- generate docbook index file (cfg_var_list.xml)
- configurable output directories (txt_output_dir and
  docbook_output_dir)

---

 doc/cfg_list/Makefile |   84 ++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 73 insertions(+), 11 deletions(-)

diff --git a/doc/cfg_list/Makefile b/doc/cfg_list/Makefile
index 881f735..9283a50 100644
--- a/doc/cfg_list/Makefile
+++ b/doc/cfg_list/Makefile
@@ -4,6 +4,12 @@ COREPATH=../..
 #include $(COREPATH)/Makefile.defs
 
 CFG2TXT=../scripts/cdefs2doc/dump_cfg_defs.pl
+CFG2DOCBOOK=../scripts/cdefs2doc/dump_cfg_defs.pl
+
+# output directory for generated txt files
+txt_output_dir=.
+# output directory for generated docbook xml files
+docbook_output_dir=docbook
 
 # list of files contanining cfg defs in the following format:
 # <filename>:<cfg_grp_name> 
@@ -65,7 +71,7 @@ get_grp=$(strip $(if $(grp_f_$(call get_bname,$(1))), \
                                                $(call get_listed_grp,$(1))) ) )
 
 # get target from file:grp (get_target(file:grp) => cfg_grp.txt)
-get_target=cfg_$(call get_grp,$(1)).txt
+get_target=cfg_$(call get_grp,$(1))
 
 define  mk_rules
 
@@ -73,17 +79,30 @@ $(call check_fname_grp, $(1))
 
 #$$(info generating cfg_$$(call get_grp,$(1)).txt: $$(call get_prereq,$(1)))
 
-$$(call get_target,$(1)): $$(call get_prereq,$(1)) Makefile $(CFG2TXT)
+$(txt_output_dir)/$$(call get_target,$(1)).txt: \
+                                                               $$(call 
get_prereq,$(1)) Makefile $(CFG2TXT)
        $(CFG2TXT) --file $$< --$(force_grp)grp=$$(call get_grp,$(1)) \
-               --gcc="$(gcc)"  > "$$@" ||  (rm -f "$$@"; exit 1)
+               --gcc="$(gcc)" --txt > "$$@" ||  (rm -f "$$@"; exit 1)
+
+$(docbook_output_dir)/$$(call get_target,$(1)).xml: \
+                                                               $$(call 
get_prereq,$(1)) Makefile $(CFG2TXT)
+       $(CFG2DOCBOOK) --file $$< --$(force_grp)grp=$$(call get_grp,$(1)) \
+               --gcc="$(gcc)" --docbook > "$$@" ||  (rm -f "$$@"; exit 1)
+
+
+clean_$$(call get_target,$(1)).txt:
+       rm -f "$(txt_output_dir)/$$(call get_target,$(1)).txt"
 
+clean_$$(call get_target,$(1)).xml:
+       rm -f "$(docbook_output_dir)/$$(call get_target,$(1)).xml"
 
-clean_$$(call get_target,$(1)):
-       rm -f "$$(call get_target,$(1))"
+txt: $(txt_output_dir)/$$(call get_target,$(1)).txt
 
-all: $$(call get_target,$(1))
+docbook: $(docbook_output_dir)/$$(call get_target,$(1)).xml
 
-clean: clean_$$(call get_target,$(1))
+clean_txt: clean_$$(call get_target,$(1)).txt
+
+clean_docbook: clean_$$(call get_target,$(1)).xml
 
 
 endef
@@ -93,22 +112,65 @@ endef
 # GCC:TranslationUnit module, make all won't work)
 .PHONY: help
 help:
-       @echo "To regenerate $(foreach f,$(flist),$(call get_target,$f) )"
+       @echo "To regenerate $(foreach f,$(flist),$(call 
get_target,$f).{txt,xml})"
        @echo "type: $(MAKE) all ."
        @echo "or to regenerate all the cfg documentation by searching all"
        @echo " the source files for definitions, type: $(MAKE) autogen ."
        @echo "NOTE: you need the GCC:TranslationUnit perl module with an "
        @echo "extra patch applied (see $(CFG2TXT) --patch)."
 
+.PHONY: txt
+txt:
+
+.PHONY: docbook
+docbook:
+
+.PHONY: clean_txt
+clean_txt:
+
+.PHONY: clean_docbook
+clean_docbook:
+
+
 .PHONY: all
-all:
+all: txt $(docbook_output_dir)/cfg_var_list.xml
 
 .PHONY: clean
-clean:
+clean: clean_txt clean_docbook
+       @rm -f $(docbook_output_dir)/cfg_var_list.xml
 
 .PHONY: proper
 proper:
-       @rm -f cfg_*.txt
+       @rm -f $(txt_output_dir)/cfg_*.txt
+       @rm -f $(docbook_output_dir)/cfg_*.xml
+
+repo_ver="sip-router"\
+       "git-$(shell  git rev-parse --verify --short=6 HEAD 2>/dev/null)"
+ifeq ($(repo_ver),git-)
+repo_ver="sip-router unknown"
+endif
+
+$(docbook_output_dir)/cfg_var_list.xml: \
+               $(foreach f,$(flist),$(docbook_output_dir)/$(call 
get_target,$f).xml)
+       @echo '<?xml version="1.0" encoding="UTF-8"?>' >$@
+       @echo '<!-- this file is autogenerated, do not edit! -->' >>$@
+       @echo '<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"' 
>>$@
+       @echo ' "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd";>' >>$@
+       @echo '<book id="cfg_var_list"'\
+               'xmlns:xi="http://www.w3.org/2001/XInclude";>' >>$@
+       @echo ' <title>RPC Exports List</title>' >>$@
+       @echo ' <info><revhistory><revision>' >>$@
+       @echo '         <revnumber>'$(repo_ver)'</revnumber>' >>$@
+       @echo '         <revremark>' >>$@
+       @echo "                 Automatically generated by:">>$@
+       @echo "                 $(MAKE) -C doc/cfg_list $(MAKECMDGOALS)" >>$@
+       @echo '         </revremark>' >>$@
+       @echo ' </revision></revhistory></info>' >>$@
+       @$(foreach f,$(flist),\
+               echo '          <xi:include'\
+                       'href="'$(call get_target,$f).xml'"/>' \
+                       >>$@ ; )
+       @echo '</book>' >>$@
 
 find_cfg_files_cmd= find $(COREPATH) -type f -name "*.c" \
                -exec grep "cfg_def_t[   ][a-zA-Z0-9_]*\[\][     ]*=" /dev/null 
{} \; \


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to