]> Savannah Git Hosting - gnulib.git/commitdiff
relocatable-prog-wrapper: Implement --help, --version for all programs.
authorBruno Haible <bruno@clisp.org>
Fri, 14 Jun 2024 10:50:45 +0000 (12:50 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 14 Jun 2024 11:34:21 +0000 (13:34 +0200)
* build-aux/install-reloc (func_usage, func_version, func_fatal_error):
New functions.
(progname): Remove variable.
Add command-line option processing.

ChangeLog
build-aux/install-reloc

index cfab56ad0cd9dcccd131c6c54e4f5a76f815ff74..bd6d21d2c03a378dfda892a2667fc4df5ce0d6f6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-06-14  Bruno Haible  <bruno@clisp.org>
+
+       relocatable-prog-wrapper: Implement --help, --version for all programs.
+       * build-aux/install-reloc (func_usage, func_version, func_fatal_error):
+       New functions.
+       (progname): Remove variable.
+       Add command-line option processing.
+
 2024-06-14  Bruno Haible  <bruno@clisp.org>
 
        havelib: Implement --help and --version for all programs.
index 6a4c9faa2dabd9772cc32c1077a70c214487c0b8..ea2e5cc6dad4f8fd3c8e13dec7ffdb7778d39f85 100755 (executable)
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-# Usage 1:
-#   install-reloc -- library_path_var library_path_value prefix destdir \
-#                    compile_command srcdir builddir config_h_dir exeext \
-#                    strip_command \
-#                    install_command... destprog
-# where
-#   - library_path_var is the platform dependent runtime library path variable
-#   - library_path_value is a colon separated list of directories that contain
-#     the libraries at installation time (use this instead of -rpath)
-#   - prefix is the base directory at installation time
-#   - destdir is a string that is prepended to all file names at installation
-#     time; it is already prepended to destprog but not to library_path_value
-#     and prefix
-#   - compile_command is a C compiler compilation and linking command
-#   - srcdir is the directory where to find relocwrapper.c and its dependencies
-#   - builddir is the directory where to find built dependencies (namely,
-#     alloca.h and stdbool.h)
-#   - config_h_dir is the directory where to find config.h
-#   - exeext is platform dependent suffix of executables
-#   - strip_command is the command for stripping executables, or : if no
-#     stripping is desired
-#   - install_command is the install command line, excluding the final destprog
-#   - destprog is the destination program name
-# Usage 2:
-#   env RELOC_LIBRARY_PATH_VAR=library_path_var \
-#       RELOC_LIBRARY_PATH_VALUE=library_path_value \
-#       RELOC_PREFIX=prefix \
-#       RELOC_DESTDIR=destdir \
-#       RELOC_COMPILE_COMMAND=compile_command \
-#       RELOC_SRCDIR=srcdir \
-#       RELOC_BUILDDIR=builddir \
-#       RELOC_CONFIG_H_DIR=config_h_dir \
-#       RELOC_EXEEXT=exeext \
-#       RELOC_STRIP_PROG=strip_command \
-#       RELOC_INSTALL_PROG=install_command... \
-#   install-reloc prog1 ... destprog
-#   where destprog is either the destination program name (when only one program
-#   is specified) or the destination directory for all programs.
-# install-reloc renames destprog to destprog.bin and installs a relocating
-# wrapper in the place of destprog.
+# func_usage
+# outputs to stdout the --help usage message.
+func_usage ()
+{
+  echo "\
+Usage 1:
+  install-reloc -- library_path_var library_path_value prefix destdir \\
+                   compile_command srcdir builddir config_h_dir exeext \\
+                   strip_command \\
+                   install_command... destprog
+where
+  - library_path_var is the platform dependent runtime library path variable
+  - library_path_value is a colon separated list of directories that contain
+    the libraries at installation time (use this instead of -rpath)
+  - prefix is the base directory at installation time
+  - destdir is a string that is prepended to all file names at installation
+    time; it is already prepended to destprog but not to library_path_value
+    and prefix
+  - compile_command is a C compiler compilation and linking command
+  - srcdir is the directory where to find relocwrapper.c and its dependencies
+  - builddir is the directory where to find built dependencies (namely,
+    alloca.h and stdbool.h)
+  - config_h_dir is the directory where to find config.h
+  - exeext is platform dependent suffix of executables
+  - strip_command is the command for stripping executables, or : if no
+    stripping is desired
+  - install_command is the install command line, excluding the final destprog
+  - destprog is the destination program name
+Usage 2:
+  env RELOC_LIBRARY_PATH_VAR=library_path_var \\
+      RELOC_LIBRARY_PATH_VALUE=library_path_value \\
+      RELOC_PREFIX=prefix \\
+      RELOC_DESTDIR=destdir \\
+      RELOC_COMPILE_COMMAND=compile_command \\
+      RELOC_SRCDIR=srcdir \\
+      RELOC_BUILDDIR=builddir \\
+      RELOC_CONFIG_H_DIR=config_h_dir \\
+      RELOC_EXEEXT=exeext \\
+      RELOC_STRIP_PROG=strip_command \\
+      RELOC_INSTALL_PROG=install_command... \\
+  install-reloc prog1 ... destprog
+  where destprog is either the destination program name (when only one program
+  is specified) or the destination directory for all programs.
+Usage 3:
+  install-reloc OPTION
+
+Renames destprog to destprog.bin and installs a relocating wrapper
+in the place of destprog.
+
+Options:
+      --help           print this help and exit
+      --version        print version information and exit
+
+Send patches and bug reports to <bug-gnulib@gnu.org>."
+}
+
+# func_version
+# outputs to stdout the --version message.
+func_version ()
+{
+  echo "install-reloc (GNU gnulib, module relocatable-prog-wrapper)"
+  echo "Copyright (C) 2024 Free Software Foundation, Inc.
+License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law."
+  echo
+  printf 'Written by %s.\n' "Bruno Haible"
+}
+
+# func_fatal_error message
+# outputs to stderr a fatal error message, and terminates the program.
+func_fatal_error ()
+{
+  echo "install-reloc: *** $1" 1>&2
+  echo "install-reloc: *** Stop." 1>&2
+  exit 1
+}
 
-progname=$0
+# Command-line option processing.
+if test $# -eq 1; then
+  case "$1" in
+    --help | --hel | --he | --h )
+      func_usage
+      exit 0 ;;
+   --version | --versio | --versi | --vers | --ver | --ve | --v )
+      func_version
+      exit 0 ;;
+    -- )      # Usage 1
+      break ;;
+    -* )
+      func_fatal_error "unrecognized option: $1"
+      ;;
+    * )       # Usage 2
+      break ;;
+  esac
+fi
 
 if test $# -ge 12 && test "x$1" = "x--"; then
   # Get fixed position arguments.
@@ -99,10 +153,7 @@ else
     strip_prog=$RELOC_STRIP_PROG
     install_prog=$RELOC_INSTALL_PROG # including the "-c" option
   else
-    echo "Usage: $0 -- library_path_var library_path_value prefix destdir" \
-         "compile_command srcdir builddir config_h_dir exeext" \
-         "strip_command" \
-         "install_command... destprog" 1>&2
+    func_usage 1>&2
     exit 1
   fi
 fi