| 1 | #! /bin/sh |
| 2 | # Common stub for a few missing GNU programs while installing. |
| 3 | # Copyright 2010-2017,2023 Thomas E. Dickey |
| 4 | # Copyright 1996, 1997, 1999, 2000 Free Software Foundation, Inc. |
| 5 | # Originally by Fran,cois Pinard <[email protected]>, 1996. |
| 6 | |
| 7 | # This program is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation; either version 2, or (at your option) |
| 10 | # any later version. |
| 11 | |
| 12 | # This program is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | |
| 17 | # You should have received a copy of the GNU General Public License |
| 18 | # along with this program; if not, write to the Free Software |
| 19 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 20 | # 02111-1307, USA. |
| 21 | |
| 22 | # As a special exception to the GNU General Public License, if you |
| 23 | # distribute this file as part of a program that contains a |
| 24 | # configuration script generated by Autoconf, you may include it under |
| 25 | # the same distribution terms that you use for the rest of that program. |
| 26 | |
| 27 | if test $# -eq 0; then |
| 28 | echo 1>&2 "Try \`$0 --help' for more information" |
| 29 | exit 1 |
| 30 | fi |
| 31 | |
| 32 | run=: |
| 33 | |
| 34 | # In the cases where this matters, `missing' is being run in the |
| 35 | # srcdir already. |
| 36 | if test -f configure.ac; then |
| 37 | configure_ac=configure.ac |
| 38 | else |
| 39 | configure_ac=configure.in |
| 40 | fi |
| 41 | |
| 42 | case "$1" in |
| 43 | --run) |
| 44 | # Try to run requested program, and just exit if it succeeds. |
| 45 | run= |
| 46 | shift |
| 47 | "$@" && exit 0 |
| 48 | ;; |
| 49 | esac |
| 50 | |
| 51 | # If it does not exist, or fails to run (possibly an outdated version), |
| 52 | # try to emulate it. |
| 53 | case "$1" in |
| 54 | |
| 55 | -h|--h|--he|--hel|--help) |
| 56 | echo "\ |
| 57 | $0 [OPTION]... PROGRAM [ARGUMENT]... |
| 58 | |
| 59 | Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an |
| 60 | error status if there is no known handling for PROGRAM. |
| 61 | |
| 62 | Options: |
| 63 | -h, --help display this help and exit |
| 64 | -v, --version output version information and exit |
| 65 | --run try to run the given command, and emulate it if it fails |
| 66 | |
| 67 | Supported PROGRAM values: |
| 68 | aclocal touch file \`aclocal.m4' |
| 69 | autoconf touch file \`configure' |
| 70 | autoheader touch file \`config.h.in' |
| 71 | bison create \`y.tab.[ch]', if possible, from existing .[ch] |
| 72 | flex create \`lex.yy.c', if possible, from existing .c |
| 73 | help2man touch the output file |
| 74 | lex create \`lex.yy.c', if possible, from existing .c |
| 75 | makeinfo touch the output file |
| 76 | tar try tar, gnutar, gtar, then tar without non-portable flags |
| 77 | yacc create \`y.tab.[ch]', if possible, from existing .[ch]" |
| 78 | ;; |
| 79 | |
| 80 | -*) |
| 81 | echo 1>&2 "$0: Unknown \`$1' option" |
| 82 | echo 1>&2 "Try \`$0 --help' for more information" |
| 83 | exit 1 |
| 84 | ;; |
| 85 | |
| 86 | aclocal*) |
| 87 | echo 1>&2 "\ |
| 88 | WARNING: \`$1' is missing on your system. You should only need it if |
| 89 | you modified \`acinclude.m4' or \`${configure_ac}'." |
| 90 | touch aclocal.m4 |
| 91 | ;; |
| 92 | |
| 93 | autoconf*) |
| 94 | echo 1>&2 "\ |
| 95 | WARNING: \`$1' is missing on your system. You should only need it if |
| 96 | you modified \`${configure_ac}'." |
| 97 | touch configure |
| 98 | ;; |
| 99 | |
| 100 | autoheader*) |
| 101 | echo 1>&2 "\ |
| 102 | WARNING: \`$1' is missing on your system. You should only need it if |
| 103 | you modified \`acconfig.h' or \`${configure_ac}'." |
| 104 | files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` |
| 105 | test -z "$files" && files="config.h" |
| 106 | touch_files= |
| 107 | for f in $files; do |
| 108 | case "$f" in |
| 109 | *:*) touch_files="$touch_files "`echo "$f" | |
| 110 | sed -e 's/^[^:]*://' -e 's/:.*//'`;; |
| 111 | *) touch_files="$touch_files $f.in";; |
| 112 | esac |
| 113 | done |
| 114 | touch $touch_files |
| 115 | ;; |
| 116 | |
| 117 | bison|yacc) |
| 118 | echo 1>&2 "\ |
| 119 | WARNING: \`$1' is missing on your system. You should only need it if |
| 120 | you modified a \`.y' file. You may need the \`Bison' package |
| 121 | in order for those modifications to take effect. You can get |
| 122 | \`Bison' from any GNU archive site." |
| 123 | rm -f y.tab.c y.tab.h |
| 124 | if [ $# -ne 1 ]; then |
| 125 | eval LASTARG="\${$#}" |
| 126 | case "$LASTARG" in |
| 127 | *.y) |
| 128 | SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` |
| 129 | if [ -f "$SRCFILE" ]; then |
| 130 | cp "$SRCFILE" y.tab.c |
| 131 | fi |
| 132 | SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` |
| 133 | if [ -f "$SRCFILE" ]; then |
| 134 | cp "$SRCFILE" y.tab.h |
| 135 | fi |
| 136 | ;; |
| 137 | esac |
| 138 | fi |
| 139 | if [ ! -f y.tab.h ]; then |
| 140 | echo >y.tab.h |
| 141 | fi |
| 142 | if [ ! -f y.tab.c ]; then |
| 143 | echo 'int main(void) { return 0; }' >y.tab.c |
| 144 | fi |
| 145 | ;; |
| 146 | |
| 147 | lex|flex) |
| 148 | echo 1>&2 "\ |
| 149 | WARNING: \`$1' is missing on your system. You should only need it if |
| 150 | you modified a \`.l' file. You may need the \`Flex' package |
| 151 | in order for those modifications to take effect. You can get |
| 152 | \`Flex' from any GNU archive site." |
| 153 | rm -f lex.yy.c |
| 154 | if [ $# -ne 1 ]; then |
| 155 | eval LASTARG="\${$#}" |
| 156 | case "$LASTARG" in |
| 157 | *.l) |
| 158 | SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` |
| 159 | if [ -f "$SRCFILE" ]; then |
| 160 | cp "$SRCFILE" lex.yy.c |
| 161 | fi |
| 162 | ;; |
| 163 | esac |
| 164 | fi |
| 165 | if [ ! -f lex.yy.c ]; then |
| 166 | echo 'int main(void) { return 0; }' >lex.yy.c |
| 167 | fi |
| 168 | ;; |
| 169 | |
| 170 | help2man) |
| 171 | echo 1>&2 "\ |
| 172 | WARNING: \`$1' is missing on your system. You should only need it if |
| 173 | you modified a dependency of a manual page. You may need the |
| 174 | \`Help2man' package in order for those modifications to take |
| 175 | effect. You can get \`Help2man' from any GNU archive site." |
| 176 | |
| 177 | file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` |
| 178 | if test -z "$file"; then |
| 179 | file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` |
| 180 | fi |
| 181 | if [ -f "$file" ]; then |
| 182 | touch $file |
| 183 | else |
| 184 | test -z "$file" || exec >$file |
| 185 | echo ".ab help2man is required to generate this page" |
| 186 | exit 1 |
| 187 | fi |
| 188 | ;; |
| 189 | |
| 190 | makeinfo) |
| 191 | if test -z "$run" && (makeinfo --version > /dev/null 2>&1); then |
| 192 | # We have makeinfo, but it failed. |
| 193 | exit 1 |
| 194 | fi |
| 195 | |
| 196 | echo 1>&2 "\ |
| 197 | WARNING: \`$1' is missing on your system. You should only need it if |
| 198 | you modified a \`.texi' or \`.texinfo' file, or any other file |
| 199 | indirectly affecting the aspect of the manual. The spurious |
| 200 | call might also be the consequence of using a buggy \`make' (AIX, |
| 201 | DU, IRIX). You might want to install the \`Texinfo' package or |
| 202 | the \`GNU make' package. Grab either from any GNU archive site." |
| 203 | file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` |
| 204 | if test -z "$file"; then |
| 205 | file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` |
| 206 | file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` |
| 207 | fi |
| 208 | touch $file |
| 209 | ;; |
| 210 | |
| 211 | tar) |
| 212 | shift |
| 213 | if test -n "$run"; then |
| 214 | echo 1>&2 "ERROR: \`tar' requires --run" |
| 215 | exit 1 |
| 216 | fi |
| 217 | |
| 218 | # We have already tried tar in the generic part. |
| 219 | # Look for gnutar/gtar before invocation to avoid ugly error |
| 220 | # messages. |
| 221 | if (gnutar --version > /dev/null 2>&1); then |
| 222 | gnutar ${1+"$@"} && exit 0 |
| 223 | fi |
| 224 | if (gtar --version > /dev/null 2>&1); then |
| 225 | gtar ${1+"$@"} && exit 0 |
| 226 | fi |
| 227 | firstarg="$1" |
| 228 | if shift; then |
| 229 | case "$firstarg" in |
| 230 | *o*) |
| 231 | firstarg=`echo "$firstarg" | sed s/o//` |
| 232 | tar "$firstarg" ${1+"$@"} && exit 0 |
| 233 | ;; |
| 234 | esac |
| 235 | case "$firstarg" in |
| 236 | *h*) |
| 237 | firstarg=`echo "$firstarg" | sed s/h//` |
| 238 | tar "$firstarg" ${1+"$@"} && exit 0 |
| 239 | ;; |
| 240 | esac |
| 241 | fi |
| 242 | |
| 243 | echo 1>&2 "\ |
| 244 | WARNING: I can't seem to be able to run \`tar' with the given arguments. |
| 245 | You may want to install GNU tar or Free paxutils, or check the |
| 246 | command line arguments." |
| 247 | exit 1 |
| 248 | ;; |
| 249 | |
| 250 | *) |
| 251 | echo 1>&2 "\ |
| 252 | WARNING: \`$1' is needed, and you do not seem to have it handy on your |
| 253 | system. You might have modified some files without having the |
| 254 | proper tools for further handling them. Check the \`README' file, |
| 255 | it often tells you about the needed prerequirements for installing |
| 256 | this package. You may also peek at any GNU archive site, in case |
| 257 | some other package would contain this missing \`$1' program." |
| 258 | exit 1 |
| 259 | ;; |
| 260 | esac |
| 261 | |
| 262 | exit 0 |