netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH libnetfilter_queue] build: doc: get rid of the need for manual updating of Makefile
@ 2021-07-18  3:52 Duncan Roe
  0 siblings, 0 replies; only message in thread
From: Duncan Roe @ 2021-07-18  3:52 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel

There used to be 3 things in doxygen/Makefile.am that developers had to update:

1. The dependency list (i.e. all C sources)

2. The setgroup lines, which renamed each module man page to be the page for the
   first described function. setgroup also set the target for:

3. The add2group lines, which symlinked pages for other documented functions
   in the group.

The new system eliminates all of the above.

Signed-off-by: Duncan Roe <duncan_roe@optusnet.com.au>
---
 doxygen.cfg.in      |  1 +
 doxygen/Makefile.am | 92 +++++++++++++++------------------------------
 2 files changed, 32 insertions(+), 61 deletions(-)

diff --git a/doxygen.cfg.in b/doxygen.cfg.in
index 4c16e3e..266782e 100644
--- a/doxygen.cfg.in
+++ b/doxygen.cfg.in
@@ -23,5 +23,6 @@ SEARCHENGINE           = NO
 GENERATE_LATEX         = NO
 LATEX_CMD_NAME         = latex
 GENERATE_MAN           = YES
+MAN_LINKS              = YES
 HAVE_DOT               = @HAVE_DOT@
 DOT_TRANSPARENT        = YES
diff --git a/doxygen/Makefile.am b/doxygen/Makefile.am
index b4268a5..29078de 100644
--- a/doxygen/Makefile.am
+++ b/doxygen/Makefile.am
@@ -1,15 +1,6 @@
 if HAVE_DOXYGEN
 
-# Be sure to add new source files to this table
-doc_srcs = $(top_srcdir)/src/libnetfilter_queue.c  \
-           $(top_srcdir)/src/nlmsg.c               \
-           $(top_srcdir)/src/extra/checksum.c      \
-           $(top_srcdir)/src/extra/ipv6.c          \
-           $(top_srcdir)/src/extra/ipv4.c          \
-           $(top_srcdir)/src/extra/tcp.c           \
-           $(top_srcdir)/src/extra/udp.c           \
-           $(top_srcdir)/src/extra/icmp.c          \
-           $(top_srcdir)/src/extra/pktbuff.c
+doc_srcs = $(shell find $(top_srcdir)/src -name '*.c')
 
 doxyfile.stamp: $(doc_srcs) Makefile.am
 	rm -rf html man
@@ -25,59 +16,37 @@ doxyfile.stamp: $(doc_srcs) Makefile.am
 	[ ! -d ../src.distcheck ] || \
 { set -x; cd ..; rm src; mv src.distcheck src; }
 
-# Keep this command up to date after adding new functions and source files.
+# We need to use bash for its associative array facility
+# (`bash -p` prevents import of functions from the environment).
 # The command has to be a single line so the functions work
+# and so `make` gives all lines to `bash -c`
 # (hence ";\" at the end of every line but the last).
-	main() { set -e; cd man/man3; rm -f _*;\
-setgroup LibrarySetup nfq_open;\
-  add2group nfq_close nfq_bind_pf nfq_unbind_pf;\
-setgroup Parsing nfq_get_msg_packet_hdr;\
-  add2group nfq_get_nfmark nfq_get_timestamp nfq_get_indev nfq_get_physindev;\
-  add2group nfq_get_outdev nfq_get_physoutdev nfq_get_indev_name;\
-  add2group nfq_get_physindev_name nfq_get_outdev_name;\
-  add2group nfq_get_physoutdev_name nfq_get_packet_hw;\
-  add2group nfq_get_skbinfo;\
-  add2group nfq_get_uid nfq_get_gid;\
-  add2group nfq_get_secctx nfq_get_payload;\
-setgroup Queue nfq_fd;\
-  add2group nfq_create_queue nfq_destroy_queue nfq_handle_packet nfq_set_mode;\
-  add2group nfq_set_queue_flags nfq_set_queue_maxlen nfq_set_verdict;\
-  add2group nfq_set_verdict2 nfq_set_verdict_batch;\
-  add2group nfq_set_verdict_batch2 nfq_set_verdict_mark;\
-setgroup ipv4 nfq_ip_get_hdr;\
-  add2group nfq_ip_set_transport_header nfq_ip_mangle nfq_ip_snprintf;\
-  setgroup ip_internals nfq_ip_set_checksum;\
-setgroup ipv6 nfq_ip6_get_hdr;\
-  add2group nfq_ip6_set_transport_header nfq_ip6_mangle nfq_ip6_snprintf;\
-setgroup nfq_cfg nfq_nlmsg_cfg_put_cmd;\
-  add2group nfq_nlmsg_cfg_put_params nfq_nlmsg_cfg_put_qmaxlen;\
-setgroup nfq_verd nfq_nlmsg_verdict_put;\
-  add2group nfq_nlmsg_verdict_put_mark nfq_nlmsg_verdict_put_pkt;\
-setgroup nlmsg nfq_nlmsg_parse;\
-  add2group nfq_nlmsg_put;\
-setgroup pktbuff pktb_alloc;\
-  add2group pktb_data pktb_len pktb_mangle pktb_mangled;\
-  add2group pktb_free;\
-  setgroup otherfns pktb_tailroom;\
-    add2group pktb_mac_header pktb_network_header pktb_transport_header;\
-    setgroup uselessfns pktb_push;\
-      add2group pktb_pull pktb_put pktb_trim;\
-setgroup tcp nfq_tcp_get_hdr;\
-  add2group nfq_tcp_get_payload nfq_tcp_get_payload_len;\
-  add2group nfq_tcp_snprintf nfq_tcp_mangle_ipv4 nfq_tcp_mangle_ipv6;\
-  setgroup tcp_internals nfq_tcp_compute_checksum_ipv4;\
-    add2group nfq_tcp_compute_checksum_ipv6;\
-setgroup udp nfq_udp_get_hdr;\
-  add2group nfq_udp_get_payload nfq_udp_get_payload_len;\
-  add2group nfq_udp_mangle_ipv4 nfq_udp_mangle_ipv6 nfq_udp_snprintf;\
-  setgroup udp_internals nfq_udp_compute_checksum_ipv4;\
-    add2group nfq_udp_compute_checksum_ipv6;\
-setgroup Printing nfq_snprintf_xml;\
-setgroup icmp nfq_icmp_get_hdr;\
+	/bin/bash -p -c 'declare -A renamed_page;\
+main(){ set -e; cd man/man3; rm -f _*;\
+  count_real_pages;\
+  rename_real_pages;\
+  make_symlinks;\
 };\
-setgroup() { mv $$1.3 $$2.3; BASE=$$2; };\
-add2group() { for i in $$@; do ln -sf $$BASE.3 $$i.3; done; };\
-main
+count_real_pages(){ page_count=0;\
+  for i in $$(ls -S);\
+  do head -n1 $$i | grep -E -q '^\.so' && break;\
+    page_count=$$(($$page_count + 1));\
+  done;\
+  first_link=$$(($$page_count + 1));\
+};\
+rename_real_pages(){ for i in $$(ls -S | head -n$$page_count);\
+  do for j in $$(ls -S | tail -n+$$first_link);\
+    do grep -E -q $$i$$ $$j && break;\
+    done;\
+    mv -f $$i $$j;\
+    renamed_page[$$i]=$$j;\
+  done;\
+};\
+make_symlinks(){ for j in $$(ls -S | tail -n+$$first_link);\
+  do ln -sf $${renamed_page[$$(cat $$j | cut -f2 -d/)]} $$j;\
+  done;\
+};\
+main'
 
 	touch doxyfile.stamp
 
@@ -88,7 +57,8 @@ clean-local:
 	rm -rf $(top_srcdir)/doxygen/man $(top_srcdir)/doxygen/html
 install-data-local:
 	mkdir -p $(DESTDIR)$(mandir)/man3
-	cp --no-dereference --preserve=links,mode,timestamps man/man3/*.3 $(DESTDIR)$(mandir)/man3/
+	cp --no-dereference --preserve=links,mode,timestamps man/man3/*.3\
+	  $(DESTDIR)$(mandir)/man3/
 
 # make distcheck needs uninstall-local
 uninstall-local:
-- 
2.17.5


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-18  3:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-18  3:52 [PATCH libnetfilter_queue] build: doc: get rid of the need for manual updating of Makefile Duncan Roe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).