Skip to contentSkip to conversation

Doxygen Build Improvements

PATCH In review Jeremy Sowden 3 participants 11 messages Aug 3, 2022 – Aug 4, 2022 netfilter

lore
Share & tools
lore
#0 lore raw

cover Doxygen Build Improvements

These changes were prompted by Mark Mentovai's request to remove a hard-coded /bin/bash path from the rule that creates the man-page sym-links. Hitherto, the doxygen Makefile has jumped through a number of hoops to make sure everything works with make distcheck and parallel builds. This patch-set makes some doxygen config changes that obviate the need for them, fixes a bug in make clean, updates .gitignore and moves the shell-script out of the Makefile into a separate file for ease of maintenance. In the process, the hard-coded /bin/bash is removed.

One thing I have left is the setting of -p when running the shell-script. The comment reads "bash -p prevents import of functions from the environment". Why is this a problem?

Jeremy Sowden (6):
build: add make dist tar-balls to .gitignore
doc: add .gitignore for Doxygen artefacts
doc: change INPUT doxygen setting to @top_srcdir@
doc: move doxygen config file into doxygen directory
doc: move man-page sym-link shell-script into a separate file
doc: fix doxygen clean-local rule

 .gitignore                               |  3 +-
 configure.ac                             | 15 ++++++-
 doxygen/.gitignore                       |  4 ++
 doxygen/Makefile.am                      | 53 +++---------------------
 doxygen.cfg.in => doxygen/doxygen.cfg.in |  4 +-
 doxygen/finalize_manpages.sh             | 40 ++++++++++++++++++
 6 files changed, 67 insertions(+), 52 deletions(-)
 create mode 100644 doxygen/.gitignore
 rename doxygen.cfg.in => doxygen/doxygen.cfg.in (91%)
 create mode 100644 doxygen/finalize_manpages.sh
Signature · 1 line
2.35.1
#1 lore raw

PATCH 1/6 build: add `make dist` tar-balls to .gitignore

---
 .gitignore | 2 ++
 1 file changed, 2 insertions(+)
.gitignore +2 -0
index 9a7d86c78ae2..0276c98fb3a5 100644
@@ -17,3 +17,5 @@ Makefile.in
 
 /doxygen.cfg
 /libmnl.pc
+
+/libmnl-*.tar.bz2
Signature · 1 line
2.35.1
#2 lore raw

PATCH 2/6 doc: add .gitignore for Doxygen artefacts

In reply to Jeremy Sowden
---
 doxygen/.gitignore | 3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 doxygen/.gitignore
doxygen/.gitignore new file +3 -0
new file mode 100644
index 000000000000..a23345c2c599
@@ -0,0 +1,3 @@
+doxyfile.stamp
+html/
+man/
Signature · 1 line
2.35.1
#3 lore raw

PATCH 3/6 doc: change `INPUT` doxygen setting to `@top_srcdir@`

In reply to Jeremy Sowden

It avoids the need to move src directories in doxygen/Makefile.

---
 doxygen.cfg.in      |  2 +-
 doxygen/Makefile.am | 11 -----------
 2 files changed, 1 insertion(+), 12 deletions(-)
doxygen.cfg.in +1 -1
index ae31dbe4c16c..d6db0048a1f7 100644
@@ -6,7 +6,7 @@ ABBREVIATE_BRIEF       =
 FULL_PATH_NAMES        = NO
 TAB_SIZE               = 8
 OPTIMIZE_OUTPUT_FOR_C  = YES
-INPUT                  = .
+INPUT                  = @top_srcdir@
 FILE_PATTERNS          = */src/*.c
 RECURSIVE              = YES
 EXCLUDE_SYMBOLS        = EXPORT_SYMBOL mnl_nlmsg_batch mnl_socket
doxygen/Makefile.am +0 -11
index 29078dee122a..bca5092b4aec 100644
@@ -4,18 +4,7 @@ doc_srcs = $(shell find $(top_srcdir)/src -name '*.c')
 
 doxyfile.stamp: $(doc_srcs) Makefile.am
 	rm -rf html man
-
-# Test for running under make distcheck.
-# If so, sibling src directory will be empty:
-# move it out of the way and symlink the real one while we run doxygen.
-	[ -f ../src/Makefile.in ] || \
-{ set -x; cd ..; mv src src.distcheck; ln -s $(top_srcdir)/src; }
-
 	cd ..; doxygen doxygen.cfg >/dev/null
-
-	[ ! -d ../src.distcheck ] || \
-{ set -x; cd ..; rm src; mv src.distcheck src; }
-
 # 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
Signature · 1 line
2.35.1
#4 lore raw

PATCH 4/6 doc: move doxygen config file into doxygen directory

In reply to Jeremy Sowden

Now that the INPUT directory is correct, we can update OUTPUT_DIRECTORY to . and we don't need to cd out of the doxygen directory to run doxygen.

---
 .gitignore                               |  1 -
 configure.ac                             | 15 ++++++++++++++-
 doxygen/.gitignore                       |  1 +
 doxygen/Makefile.am                      |  2 +-
 doxygen.cfg.in => doxygen/doxygen.cfg.in |  2 +-
 5 files changed, 17 insertions(+), 4 deletions(-)
 rename doxygen.cfg.in => doxygen/doxygen.cfg.in (95%)
.gitignore +0 -1
index 0276c98fb3a5..b6b8d60db5dc 100644
@@ -15,7 +15,6 @@ Makefile.in
 /libtool
 /stamp-h1
 
-/doxygen.cfg
 /libmnl.pc
 
 /libmnl-*.tar.bz2
configure.ac +14 -1
index 314481dae87e..dcdd4245175e 100644
@@ -27,7 +27,20 @@ regular_CFLAGS="-Wall -Waggregate-return -Wmissing-declarations \
 	-Wformat=2 -pipe"
 AC_SUBST([regular_CPPFLAGS])
 AC_SUBST([regular_CFLAGS])
-AC_CONFIG_FILES([Makefile src/Makefile include/Makefile include/libmnl/Makefile include/linux/Makefile include/linux/netfilter/Makefile examples/Makefile examples/genl/Makefile examples/kobject/Makefile examples/netfilter/Makefile examples/rtnl/Makefile libmnl.pc doxygen.cfg doxygen/Makefile])
+AC_CONFIG_FILES([Makefile
+		 src/Makefile
+		 include/Makefile
+		 include/libmnl/Makefile
+		 include/linux/Makefile
+		 include/linux/netfilter/Makefile
+		 examples/Makefile
+		 examples/genl/Makefile
+		 examples/kobject/Makefile
+		 examples/netfilter/Makefile
+		 examples/rtnl/Makefile
+		 libmnl.pc
+		 doxygen/doxygen.cfg
+		 doxygen/Makefile])
 
 AC_ARG_WITH([doxygen], [AS_HELP_STRING([--with-doxygen],
 	    [create doxygen documentation])],
doxygen/.gitignore +1 -0
index a23345c2c599..2196cf8c442b 100644
@@ -1,3 +1,4 @@
 doxyfile.stamp
+doxygen.cfg
 html/
 man/
doxygen/Makefile.am +1 -1
index bca5092b4aec..3f0b1e9a8ab4 100644
@@ -4,7 +4,7 @@ doc_srcs = $(shell find $(top_srcdir)/src -name '*.c')
 
 doxyfile.stamp: $(doc_srcs) Makefile.am
 	rm -rf html man
-	cd ..; doxygen doxygen.cfg >/dev/null
+	doxygen doxygen.cfg >/dev/null
 # 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
doxygen/doxygen.cfg.in renamed from doxygen.cfg.in +1 -1
similarity index 95%
rename from doxygen.cfg.in
rename to doxygen/doxygen.cfg.in
index d6db0048a1f7..24089ac0cb95 100644
@@ -1,7 +1,7 @@
 # Difference with default Doxyfile 1.8.20
 PROJECT_NAME           = @PACKAGE@
 PROJECT_NUMBER         = @VERSION@
-OUTPUT_DIRECTORY       = doxygen
+OUTPUT_DIRECTORY       = .
 ABBREVIATE_BRIEF       =
 FULL_PATH_NAMES        = NO
 TAB_SIZE               = 8
Signature · 1 line
2.35.1
#5 lore raw

PATCH 5/6 doc: move man-page sym-link shell-script into a separate file

In reply to Jeremy Sowden

We use $(SHELL) to run the script and exec bash if $(SHELL) is something else. We don't hard-code the path to bash.

---
 doxygen/Makefile.am          | 36 +++-----------------------------
 doxygen/finalize_manpages.sh | 40 ++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 33 deletions(-)
 create mode 100644 doxygen/finalize_manpages.sh
doxygen/Makefile.am +3 -33
index 3f0b1e9a8ab4..4770fc788068 100644
@@ -1,42 +1,10 @@
 if HAVE_DOXYGEN
-
 doc_srcs = $(shell find $(top_srcdir)/src -name '*.c')
 
 doxyfile.stamp: $(doc_srcs) Makefile.am
 	rm -rf html man
 	doxygen doxygen.cfg >/dev/null
-# 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).
-	/bin/bash -p -c 'declare -A renamed_page;\
-main(){ set -e; cd man/man3; rm -f _*;\
-  count_real_pages;\
-  rename_real_pages;\
-  make_symlinks;\
-};\
-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'
-
+	$(SHELL) $(top_srcdir)/doxygen/finalize_manpages.sh
 	touch doxyfile.stamp
 
 CLEANFILES = doxyfile.stamp
@@ -53,3 +21,5 @@ install-data-local:
 uninstall-local:
 	rm -r $(DESTDIR)$(mandir) man html doxyfile.stamp
 endif
+
+EXTRA_DIST = finalize_manpages.sh
doxygen/finalize_manpages.sh new file +40 -0
new file mode 100644
index 000000000000..6f230b12cbc0
@@ -0,0 +1,40 @@
+#
+# We need to use bash for its associative array facility
+#
+[ "$BASH" ] || exec bash $0
+#
+# (`bash -p` prevents import of functions from the environment).
+#
+set -p
+
+declare -A renamed_page
+
+main(){ set -e; cd man/man3; rm -f _*
+  count_real_pages
+  rename_real_pages
+  make_symlinks
+}
+
+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
Signature · 1 line
2.35.1
#6 lore raw

Re: [PATCH libmnl 5/6] doc: move man-page sym-link shell-script into a separate file

Quoted 2 lines · Jeremy Sowden

We use $(SHELL) to run the script and exec bash if $(SHELL) is something else. We don't hard-code the path to bash.

Does it matter in practice? I don't recall seeing libmnl targeting a BSD platform where bash prominently isn't /bin/bash.

#7 lore raw

Re: [PATCH libmnl 5/6] doc: move man-page sym-link shell-script into a separate file

Quoted 6 lines · Jan Engelhardt
Quoted 2 lines · Jeremy Sowden

We use $(SHELL) to run the script and exec bash if $(SHELL) is something else. We don't hard-code the path to bash.

Does it matter in practice? I don't recall seeing libmnl targeting a BSD platform where bash prominently isn't /bin/bash.

Apparently, there are cross-building use-cases.

J.

#8 lore raw

PATCH 6/6 doc: fix doxygen `clean-local` rule

In reply to Jeremy Sowden

The html and man directories are created in the current working directory, $(top_builddir)/doxygen, not $(top_srcdir)/doxygen.

Remove doxyfile.stamp in clean-local and remove CLEANFILES in order to do all cleaning in one place.

---
 doxygen/Makefile.am | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
doxygen/Makefile.am +1 -3
index 4770fc788068..90154c2eb869 100644
@@ -7,11 +7,9 @@ doxyfile.stamp: $(doc_srcs) Makefile.am
 	$(SHELL) $(top_srcdir)/doxygen/finalize_manpages.sh
 	touch doxyfile.stamp
 
-CLEANFILES = doxyfile.stamp
-
 all-local: doxyfile.stamp
 clean-local:
-	rm -rf $(top_srcdir)/doxygen/man $(top_srcdir)/doxygen/html
+	rm -rf doxyfile.stamp html man
 install-data-local:
 	mkdir -p $(DESTDIR)$(mandir)/man3
 	cp --no-dereference --preserve=links,mode,timestamps man/man3/*.3\
Signature · 1 line
2.35.1
#9 lore raw
In reply to Jeremy Sowden

Hi Jeremy,

Quoted 32 lines · Jeremy Sowden

These changes were prompted by Mark Mentovai's request to remove a hard-coded /bin/bash path from the rule that creates the man-page sym-links. Hitherto, the doxygen Makefile has jumped through a number of hoops to make sure everything works with make distcheck and parallel builds. This patch-set makes some doxygen config changes that obviate the need for them, fixes a bug in make clean, updates .gitignore and moves the shell-script out of the Makefile into a separate file for ease of maintenance. In the process, the hard-coded /bin/bash is removed.

One thing I have left is the setting of -p when running the shell-script. The comment reads "bash -p prevents import of functions from the environment". Why is this a problem?

Jeremy Sowden (6):
build: add make dist tar-balls to .gitignore
doc: add .gitignore for Doxygen artefacts
doc: change INPUT doxygen setting to @top_srcdir@
doc: move doxygen config file into doxygen directory
doc: move man-page sym-link shell-script into a separate file
doc: fix doxygen clean-local rule

 .gitignore                               |  3 +-
 configure.ac                             | 15 ++++++-
 doxygen/.gitignore                       |  4 ++
 doxygen/Makefile.am                      | 53 +++---------------------
 doxygen.cfg.in => doxygen/doxygen.cfg.in |  4 +-
 doxygen/finalize_manpages.sh             | 40 ++++++++++++++++++
 6 files changed, 67 insertions(+), 52 deletions(-)
 create mode 100644 doxygen/.gitignore
 rename doxygen.cfg.in => doxygen/doxygen.cfg.in (91%)
 create mode 100644 doxygen/finalize_manpages.sh
Quoted 2 lines

--
2.35.1

Thanks for this but ... I think it would be better to use the netfilter-log model.

That way there is no new shell script to maintain - libmnl would pick up libnetfilter-queue's copy.

I found the time-consuming part was checking the new SYNOPSIS lines to be sufficient. I have far less time nowadays (no Covid lockdowns, &c.) but I will try to get it done soon-ish.

In the meantime I think Mark's 1-line patch to the existing mess is adequate.

The bin/bash thing is easily resolved: I've tested this in libnetfilter-queue:

doxygen/build_man.sh line 5

Quoted 9 lines
doxygen/build_man.sh +2 -1
@@ -1,4 +1,5 @@
-#!/bin/bash -p
+#!/bin/sh
+[ -n "$BASH" ] || exec bash -p $0
 
 # Script to process man pages output by doxygen.
 # We need to use bash for its associative array facility.

Cheers ... Duncan.

#10 lore raw
Quoted 43 lines · Duncan Roe
Quoted 33 lines · Jeremy Sowden

These changes were prompted by Mark Mentovai's request to remove a hard-coded /bin/bash path from the rule that creates the man-page sym-links. Hitherto, the doxygen Makefile has jumped through a number of hoops to make sure everything works with make distcheck and parallel builds. This patch-set makes some doxygen config changes that obviate the need for them, fixes a bug in make clean, updates .gitignore and moves the shell-script out of the Makefile into a separate file for ease of maintenance. In the process, the hard-coded /bin/bash is removed.

One thing I have left is the setting of -p when running the shell-script. The comment reads "bash -p prevents import of functions from the environment". Why is this a problem?

Jeremy Sowden (6):
build: add make dist tar-balls to .gitignore
doc: add .gitignore for Doxygen artefacts
doc: change INPUT doxygen setting to @top_srcdir@
doc: move doxygen config file into doxygen directory
doc: move man-page sym-link shell-script into a separate file
doc: fix doxygen clean-local rule

 .gitignore                               |  3 +-
 configure.ac                             | 15 ++++++-
 doxygen/.gitignore                       |  4 ++
 doxygen/Makefile.am                      | 53 +++---------------------
 doxygen.cfg.in => doxygen/doxygen.cfg.in |  4 +-
 doxygen/finalize_manpages.sh             | 40 ++++++++++++++++++
 6 files changed, 67 insertions(+), 52 deletions(-)
 create mode 100644 doxygen/.gitignore
 rename doxygen.cfg.in => doxygen/doxygen.cfg.in (91%)
 create mode 100644 doxygen/finalize_manpages.sh
Quoted 2 lines

--
2.35.1

Thanks for this but ... I think it would be better to use the netfilter-log model.

That way there is no new shell script to maintain - libmnl would pick up libnetfilter-queue's copy.

Quoted 6 lines

I found the time-consuming part was checking the new SYNOPSIS lines to be sufficient. I have far less time nowadays (no Covid lockdowns, &c.) but I will try to get it done soon-ish.

In the meantime I think Mark's 1-line patch to the existing mess is adequate.

Cool.

J.