From aefdbfc43df11a8fc0fbd54161e5065a6ed3d26b Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 14 Jun 2024 12:50:45 +0200 Subject: [PATCH] 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. --- ChangeLog | 8 +++ build-aux/install-reloc | 141 +++++++++++++++++++++++++++------------- 2 files changed, 104 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index cfab56ad0c..bd6d21d2c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-06-14 Bruno Haible + + 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 havelib: Implement --help and --version for all programs. diff --git a/build-aux/install-reloc b/build-aux/install-reloc index 6a4c9faa2d..ea2e5cc6da 100755 --- a/build-aux/install-reloc +++ b/build-aux/install-reloc @@ -16,48 +16,102 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# 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 ." +} + +# 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 +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 -- 2.39.5