summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Sowden <jeremy@azazel.net>2022-08-03 21:12:46 +0100
committerFlorian Westphal <fw@strlen.de>2022-09-21 10:37:52 +0200
commitd9bd111c99a054db24e3b7d0cc19cead5a593643 (patch)
treef490c11219907c44b1ef78b68cb3f499e9aa01a0
parentcd533815917043584546a6d1a4da6f163a56ad3e (diff)
doc: move man-page sym-link shell-script into a separate file
We use `$(SHELL)` to run the script and exec bash if `$(SHELL)` is something else. We don't hard-code the path to bash. Signed-off-by: Jeremy Sowden <jeremy@azazel.net> Signed-off-by: Florian Westphal <fw@strlen.de>
-rw-r--r--doxygen/Makefile.am36
-rw-r--r--doxygen/finalize_manpages.sh40
2 files changed, 43 insertions, 33 deletions
diff --git a/doxygen/Makefile.am b/doxygen/Makefile.am
index e4fc0eb..4770fc7 100644
--- a/doxygen/Makefile.am
+++ b/doxygen/Makefile.am
@@ -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).
- 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
diff --git a/doxygen/finalize_manpages.sh b/doxygen/finalize_manpages.sh
new file mode 100644
index 0000000..6f230b1
--- /dev/null
+++ b/doxygen/finalize_manpages.sh
@@ -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