]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
doc: support a configurable manual url
authorPádraig Brady <P@draigBrady.com>
Thu, 1 Jan 2026 16:17:16 +0000 (16:17 +0000)
committerPádraig Brady <P@draigBrady.com>
Wed, 21 Jan 2026 13:51:39 +0000 (13:51 +0000)
* configure.ac: Support ./configure --enable-manual-url=...
* src/ls.c (oputs): Adjust accordingly.

configure.ac
src/ls.c

index b605d5ab7a78a96ec452e0ebd4289ae91e15c3d7..ae00396ec42e91952b74ed4021d2c961ff4f57c7 100644 (file)
@@ -153,6 +153,26 @@ if test "$gl_bold_manpages" != no; then
 fi
 AM_CONDITIONAL([BOLD_MAN_REFS], [test "$gl_bold_manpages" != no])
 
+AC_ARG_ENABLE([manual-url],
+  [AS_HELP_STRING([--enable-manual-url@<:@=<url>@:>@],
+     [When generating man pages, or displaying --help, generate hyperlinks
+      from each "--option" to <url>@%:@command-option.  A local file is
+      supported through a file:// URL.  The default URL used is:
+      $PACKAGE_URL/manual/$PACKAGE.html.])],
+  [case $enableval in
+     yes) gl_manual_url=default ;;
+     no) gl_manual_url='' ;;
+     *)  gl_manual_url="$enableval" ;;
+   esac],
+  [gl_manual_url=default]
+)
+if test x"$gl_manual_url" != x; then
+  if test "$gl_manual_url" = default; then
+    gl_manual_url=${PACKAGE_URL}manual/$PACKAGE.html
+  fi
+  AC_DEFINE_UNQUOTED([MANUAL_URL], ["$gl_manual_url"], [URL for full manual])
+fi
+
 AC_ARG_ENABLE([gcc-warnings],
   [AS_HELP_STRING([--enable-gcc-warnings@<:@=TYPE@:>@],
     [control generation of GCC warnings.  The TYPE 'no' disables
index e6f5995dc8567d938d8da9e10d553e259865180f..ed720579309600fc44fd8c29687cab68d959c32e 100644 (file)
--- a/src/ls.c
+++ b/src/ls.c
@@ -5360,8 +5360,8 @@ oputs (char const *option)
   fwrite (option, 1, option_text - option, stdout);
 
   /* write option text.  */
+#ifdef MANUAL_URL
   char const *url_program = streq (PROGRAM_NAME, "[") ? "test" : PROGRAM_NAME;
-  /* Note this can link to a local manual with file://... */
   /* Note single node manual doesn't work for ls, cksum, md5sum, sha*sum,
      but use single node for --help or --version.. */
   if (STREQ_LEN (option_text, "--help", 6)
@@ -5372,10 +5372,11 @@ oputs (char const *option)
     }
   else
     {
-      printf ("\033]8;;%smanual/coreutils.html#%s%.*s", PACKAGE_URL,
-              url_program, (int) anchor_len, option_text);
+      printf ("\033]8;;%s#%s%.*s", MANUAL_URL, url_program,
+              (int) anchor_len, option_text);
     }
   fputs ("\a", stdout);
+#endif
 #ifdef BOLD_MAN_REFS
   /* Note help2man strips this and will reinstate with --bold-refs.  */
   fputs ("\033[1m", stdout);
@@ -5384,8 +5385,11 @@ oputs (char const *option)
 #ifdef BOLD_MAN_REFS
   fputs ("\033[0m", stdout);
 #endif
+#ifdef MANUAL_URL
   fputs ("\033]8;;\a", stdout);
+#endif
 
+  /* write description.  */
   fputs (desc_text, stdout);
 }