Doxygen Build Improvements
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
PATCH 1/6 build: add `make dist` tar-balls to .gitignore
--- .gitignore | 2 ++ 1 file changed, 2 insertions(+)
.gitignore +2 -0
@@ -17,3 +17,5 @@ Makefile.in /doxygen.cfg /libmnl.pc + +/libmnl-*.tar.bz2
Signature · 1 line
2.35.1
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
@@ -0,0 +1,3 @@ +doxyfile.stamp +html/ +man/
Signature · 1 line
2.35.1
PATCH 3/6 doc: change `INPUT` doxygen setting to `@top_srcdir@`
In reply to Jeremy SowdenIt 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
@@ -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
@@ -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
PATCH 4/6 doc: move doxygen config file into doxygen directory
In reply to Jeremy SowdenNow 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
@@ -15,7 +15,6 @@ Makefile.in /libtool /stamp-h1 -/doxygen.cfg /libmnl.pc /libmnl-*.tar.bz2
configure.ac +14 -1
@@ -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
@@ -1,3 +1,4 @@ doxyfile.stamp +doxygen.cfg html/ man/
doxygen/Makefile.am +1 -1
@@ -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
@@ -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
PATCH 5/6 doc: move man-page sym-link shell-script into a separate file
In reply to Jeremy SowdenWe 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
@@ -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
@@ -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
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.
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.
PATCH 6/6 doc: fix doxygen `clean-local` rule
In reply to Jeremy SowdenThe 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
@@ -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
Hi Jeremy,
Quoted 32 lines · Jeremy Sowden
These changes were prompted by Mark Mentovai's request to remove a hard-coded
/bin/bashpath from the rule that creates the man-page sym-links. Hitherto, the doxygenMakefilehas jumped through a number of hoops to make sure everything works withmake distcheckand parallel builds. This patch-set makes some doxygen config changes that obviate the need for them, fixes a bug inmake clean, updates .gitignore and moves the shell-script out of theMakefileinto a separate file for ease of maintenance. In the process, the hard-coded/bin/bashis removed.One thing I have left is the setting of
-pwhen running the shell-script. The comment reads "bash -pprevents import of functions from the environment". Why is this a problem?Jeremy Sowden (6):
build: addmake disttar-balls to .gitignore
doc: add .gitignore for Doxygen artefacts
doc: changeINPUTdoxygen 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 doxygenclean-localrule.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.
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/bashpath from the rule that creates the man-page sym-links. Hitherto, the doxygenMakefilehas jumped through a number of hoops to make sure everything works withmake distcheckand parallel builds. This patch-set makes some doxygen config changes that obviate the need for them, fixes a bug inmake clean, updates .gitignore and moves the shell-script out of theMakefileinto a separate file for ease of maintenance. In the process, the hard-coded/bin/bashis removed.One thing I have left is the setting of
-pwhen running the shell-script. The comment reads "bash -pprevents import of functions from the environment". Why is this a problem?Jeremy Sowden (6):
build: addmake disttar-balls to .gitignore
doc: add .gitignore for Doxygen artefacts
doc: changeINPUTdoxygen 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 doxygenclean-localrule.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.shQuoted 2 lines
--
2.35.1Thanks 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.