xref: /openbsd-src/gnu/usr.bin/binutils-2.17/missing (revision 3d8817e467ea46cf4772788d6804dd293abfb01a)
1*3d8817e4Smiod#! /bin/sh
2*3d8817e4Smiod# Common stub for a few missing GNU programs while installing.
3*3d8817e4Smiod
4*3d8817e4Smiodscriptversion=2005-06-08.21
5*3d8817e4Smiod
6*3d8817e4Smiod# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
7*3d8817e4Smiod#   Free Software Foundation, Inc.
8*3d8817e4Smiod# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9*3d8817e4Smiod
10*3d8817e4Smiod# This program is free software; you can redistribute it and/or modify
11*3d8817e4Smiod# it under the terms of the GNU General Public License as published by
12*3d8817e4Smiod# the Free Software Foundation; either version 2, or (at your option)
13*3d8817e4Smiod# any later version.
14*3d8817e4Smiod
15*3d8817e4Smiod# This program is distributed in the hope that it will be useful,
16*3d8817e4Smiod# but WITHOUT ANY WARRANTY; without even the implied warranty of
17*3d8817e4Smiod# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*3d8817e4Smiod# GNU General Public License for more details.
19*3d8817e4Smiod
20*3d8817e4Smiod# You should have received a copy of the GNU General Public License
21*3d8817e4Smiod# along with this program; if not, write to the Free Software
22*3d8817e4Smiod# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23*3d8817e4Smiod# 02110-1301, USA.
24*3d8817e4Smiod
25*3d8817e4Smiod# As a special exception to the GNU General Public License, if you
26*3d8817e4Smiod# distribute this file as part of a program that contains a
27*3d8817e4Smiod# configuration script generated by Autoconf, you may include it under
28*3d8817e4Smiod# the same distribution terms that you use for the rest of that program.
29*3d8817e4Smiod
30*3d8817e4Smiodif test $# -eq 0; then
31*3d8817e4Smiod  echo 1>&2 "Try \`$0 --help' for more information"
32*3d8817e4Smiod  exit 1
33*3d8817e4Smiodfi
34*3d8817e4Smiod
35*3d8817e4Smiodrun=:
36*3d8817e4Smiod
37*3d8817e4Smiod# In the cases where this matters, `missing' is being run in the
38*3d8817e4Smiod# srcdir already.
39*3d8817e4Smiodif test -f configure.ac; then
40*3d8817e4Smiod  configure_ac=configure.ac
41*3d8817e4Smiodelse
42*3d8817e4Smiod  configure_ac=configure.in
43*3d8817e4Smiodfi
44*3d8817e4Smiod
45*3d8817e4Smiodmsg="missing on your system"
46*3d8817e4Smiod
47*3d8817e4Smiodcase "$1" in
48*3d8817e4Smiod--run)
49*3d8817e4Smiod  # Try to run requested program, and just exit if it succeeds.
50*3d8817e4Smiod  run=
51*3d8817e4Smiod  shift
52*3d8817e4Smiod  "$@" && exit 0
53*3d8817e4Smiod  # Exit code 63 means version mismatch.  This often happens
54*3d8817e4Smiod  # when the user try to use an ancient version of a tool on
55*3d8817e4Smiod  # a file that requires a minimum version.  In this case we
56*3d8817e4Smiod  # we should proceed has if the program had been absent, or
57*3d8817e4Smiod  # if --run hadn't been passed.
58*3d8817e4Smiod  if test $? = 63; then
59*3d8817e4Smiod    run=:
60*3d8817e4Smiod    msg="probably too old"
61*3d8817e4Smiod  fi
62*3d8817e4Smiod  ;;
63*3d8817e4Smiod
64*3d8817e4Smiod  -h|--h|--he|--hel|--help)
65*3d8817e4Smiod    echo "\
66*3d8817e4Smiod$0 [OPTION]... PROGRAM [ARGUMENT]...
67*3d8817e4Smiod
68*3d8817e4SmiodHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69*3d8817e4Smioderror status if there is no known handling for PROGRAM.
70*3d8817e4Smiod
71*3d8817e4SmiodOptions:
72*3d8817e4Smiod  -h, --help      display this help and exit
73*3d8817e4Smiod  -v, --version   output version information and exit
74*3d8817e4Smiod  --run           try to run the given command, and emulate it if it fails
75*3d8817e4Smiod
76*3d8817e4SmiodSupported PROGRAM values:
77*3d8817e4Smiod  aclocal      touch file \`aclocal.m4'
78*3d8817e4Smiod  autoconf     touch file \`configure'
79*3d8817e4Smiod  autoheader   touch file \`config.h.in'
80*3d8817e4Smiod  automake     touch all \`Makefile.in' files
81*3d8817e4Smiod  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
82*3d8817e4Smiod  flex         create \`lex.yy.c', if possible, from existing .c
83*3d8817e4Smiod  help2man     touch the output file
84*3d8817e4Smiod  lex          create \`lex.yy.c', if possible, from existing .c
85*3d8817e4Smiod  makeinfo     touch the output file
86*3d8817e4Smiod  tar          try tar, gnutar, gtar, then tar without non-portable flags
87*3d8817e4Smiod  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
88*3d8817e4Smiod
89*3d8817e4SmiodSend bug reports to <bug-automake@gnu.org>."
90*3d8817e4Smiod    exit $?
91*3d8817e4Smiod    ;;
92*3d8817e4Smiod
93*3d8817e4Smiod  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
94*3d8817e4Smiod    echo "missing $scriptversion (GNU Automake)"
95*3d8817e4Smiod    exit $?
96*3d8817e4Smiod    ;;
97*3d8817e4Smiod
98*3d8817e4Smiod  -*)
99*3d8817e4Smiod    echo 1>&2 "$0: Unknown \`$1' option"
100*3d8817e4Smiod    echo 1>&2 "Try \`$0 --help' for more information"
101*3d8817e4Smiod    exit 1
102*3d8817e4Smiod    ;;
103*3d8817e4Smiod
104*3d8817e4Smiodesac
105*3d8817e4Smiod
106*3d8817e4Smiod# Now exit if we have it, but it failed.  Also exit now if we
107*3d8817e4Smiod# don't have it and --version was passed (most likely to detect
108*3d8817e4Smiod# the program).
109*3d8817e4Smiodcase "$1" in
110*3d8817e4Smiod  lex|yacc)
111*3d8817e4Smiod    # Not GNU programs, they don't have --version.
112*3d8817e4Smiod    ;;
113*3d8817e4Smiod
114*3d8817e4Smiod  tar)
115*3d8817e4Smiod    if test -n "$run"; then
116*3d8817e4Smiod       echo 1>&2 "ERROR: \`tar' requires --run"
117*3d8817e4Smiod       exit 1
118*3d8817e4Smiod    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
119*3d8817e4Smiod       exit 1
120*3d8817e4Smiod    fi
121*3d8817e4Smiod    ;;
122*3d8817e4Smiod
123*3d8817e4Smiod  *)
124*3d8817e4Smiod    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
125*3d8817e4Smiod       # We have it, but it failed.
126*3d8817e4Smiod       exit 1
127*3d8817e4Smiod    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
128*3d8817e4Smiod       # Could not run --version or --help.  This is probably someone
129*3d8817e4Smiod       # running `$TOOL --version' or `$TOOL --help' to check whether
130*3d8817e4Smiod       # $TOOL exists and not knowing $TOOL uses missing.
131*3d8817e4Smiod       exit 1
132*3d8817e4Smiod    fi
133*3d8817e4Smiod    ;;
134*3d8817e4Smiodesac
135*3d8817e4Smiod
136*3d8817e4Smiod# If it does not exist, or fails to run (possibly an outdated version),
137*3d8817e4Smiod# try to emulate it.
138*3d8817e4Smiodcase "$1" in
139*3d8817e4Smiod  aclocal*)
140*3d8817e4Smiod    echo 1>&2 "\
141*3d8817e4SmiodWARNING: \`$1' is $msg.  You should only need it if
142*3d8817e4Smiod         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
143*3d8817e4Smiod         to install the \`Automake' and \`Perl' packages.  Grab them from
144*3d8817e4Smiod         any GNU archive site."
145*3d8817e4Smiod    touch aclocal.m4
146*3d8817e4Smiod    ;;
147*3d8817e4Smiod
148*3d8817e4Smiod  autoconf)
149*3d8817e4Smiod    echo 1>&2 "\
150*3d8817e4SmiodWARNING: \`$1' is $msg.  You should only need it if
151*3d8817e4Smiod         you modified \`${configure_ac}'.  You might want to install the
152*3d8817e4Smiod         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
153*3d8817e4Smiod         archive site."
154*3d8817e4Smiod    touch configure
155*3d8817e4Smiod    ;;
156*3d8817e4Smiod
157*3d8817e4Smiod  autoheader)
158*3d8817e4Smiod    echo 1>&2 "\
159*3d8817e4SmiodWARNING: \`$1' is $msg.  You should only need it if
160*3d8817e4Smiod         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
161*3d8817e4Smiod         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
162*3d8817e4Smiod         from any GNU archive site."
163*3d8817e4Smiod    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
164*3d8817e4Smiod    test -z "$files" && files="config.h"
165*3d8817e4Smiod    touch_files=
166*3d8817e4Smiod    for f in $files; do
167*3d8817e4Smiod      case "$f" in
168*3d8817e4Smiod      *:*) touch_files="$touch_files "`echo "$f" |
169*3d8817e4Smiod				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
170*3d8817e4Smiod      *) touch_files="$touch_files $f.in";;
171*3d8817e4Smiod      esac
172*3d8817e4Smiod    done
173*3d8817e4Smiod    touch $touch_files
174*3d8817e4Smiod    ;;
175*3d8817e4Smiod
176*3d8817e4Smiod  automake*)
177*3d8817e4Smiod    echo 1>&2 "\
178*3d8817e4SmiodWARNING: \`$1' is $msg.  You should only need it if
179*3d8817e4Smiod         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
180*3d8817e4Smiod         You might want to install the \`Automake' and \`Perl' packages.
181*3d8817e4Smiod         Grab them from any GNU archive site."
182*3d8817e4Smiod    find . -type f -name Makefile.am -print |
183*3d8817e4Smiod	   sed 's/\.am$/.in/' |
184*3d8817e4Smiod	   while read f; do touch "$f"; done
185*3d8817e4Smiod    ;;
186*3d8817e4Smiod
187*3d8817e4Smiod  autom4te)
188*3d8817e4Smiod    echo 1>&2 "\
189*3d8817e4SmiodWARNING: \`$1' is needed, but is $msg.
190*3d8817e4Smiod         You might have modified some files without having the
191*3d8817e4Smiod         proper tools for further handling them.
192*3d8817e4Smiod         You can get \`$1' as part of \`Autoconf' from any GNU
193*3d8817e4Smiod         archive site."
194*3d8817e4Smiod
195*3d8817e4Smiod    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
196*3d8817e4Smiod    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
197*3d8817e4Smiod    if test -f "$file"; then
198*3d8817e4Smiod	touch $file
199*3d8817e4Smiod    else
200*3d8817e4Smiod	test -z "$file" || exec >$file
201*3d8817e4Smiod	echo "#! /bin/sh"
202*3d8817e4Smiod	echo "# Created by GNU Automake missing as a replacement of"
203*3d8817e4Smiod	echo "#  $ $@"
204*3d8817e4Smiod	echo "exit 0"
205*3d8817e4Smiod	chmod +x $file
206*3d8817e4Smiod	exit 1
207*3d8817e4Smiod    fi
208*3d8817e4Smiod    ;;
209*3d8817e4Smiod
210*3d8817e4Smiod  bison|yacc)
211*3d8817e4Smiod    echo 1>&2 "\
212*3d8817e4SmiodWARNING: \`$1' $msg.  You should only need it if
213*3d8817e4Smiod         you modified a \`.y' file.  You may need the \`Bison' package
214*3d8817e4Smiod         in order for those modifications to take effect.  You can get
215*3d8817e4Smiod         \`Bison' from any GNU archive site."
216*3d8817e4Smiod    rm -f y.tab.c y.tab.h
217*3d8817e4Smiod    if [ $# -ne 1 ]; then
218*3d8817e4Smiod        eval LASTARG="\${$#}"
219*3d8817e4Smiod	case "$LASTARG" in
220*3d8817e4Smiod	*.y)
221*3d8817e4Smiod	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
222*3d8817e4Smiod	    if [ -f "$SRCFILE" ]; then
223*3d8817e4Smiod	         cp "$SRCFILE" y.tab.c
224*3d8817e4Smiod	    fi
225*3d8817e4Smiod	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
226*3d8817e4Smiod	    if [ -f "$SRCFILE" ]; then
227*3d8817e4Smiod	         cp "$SRCFILE" y.tab.h
228*3d8817e4Smiod	    fi
229*3d8817e4Smiod	  ;;
230*3d8817e4Smiod	esac
231*3d8817e4Smiod    fi
232*3d8817e4Smiod    if [ ! -f y.tab.h ]; then
233*3d8817e4Smiod	echo >y.tab.h
234*3d8817e4Smiod    fi
235*3d8817e4Smiod    if [ ! -f y.tab.c ]; then
236*3d8817e4Smiod	echo 'main() { return 0; }' >y.tab.c
237*3d8817e4Smiod    fi
238*3d8817e4Smiod    ;;
239*3d8817e4Smiod
240*3d8817e4Smiod  lex|flex)
241*3d8817e4Smiod    echo 1>&2 "\
242*3d8817e4SmiodWARNING: \`$1' is $msg.  You should only need it if
243*3d8817e4Smiod         you modified a \`.l' file.  You may need the \`Flex' package
244*3d8817e4Smiod         in order for those modifications to take effect.  You can get
245*3d8817e4Smiod         \`Flex' from any GNU archive site."
246*3d8817e4Smiod    rm -f lex.yy.c
247*3d8817e4Smiod    if [ $# -ne 1 ]; then
248*3d8817e4Smiod        eval LASTARG="\${$#}"
249*3d8817e4Smiod	case "$LASTARG" in
250*3d8817e4Smiod	*.l)
251*3d8817e4Smiod	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
252*3d8817e4Smiod	    if [ -f "$SRCFILE" ]; then
253*3d8817e4Smiod	         cp "$SRCFILE" lex.yy.c
254*3d8817e4Smiod	    fi
255*3d8817e4Smiod	  ;;
256*3d8817e4Smiod	esac
257*3d8817e4Smiod    fi
258*3d8817e4Smiod    if [ ! -f lex.yy.c ]; then
259*3d8817e4Smiod	echo 'main() { return 0; }' >lex.yy.c
260*3d8817e4Smiod    fi
261*3d8817e4Smiod    ;;
262*3d8817e4Smiod
263*3d8817e4Smiod  help2man)
264*3d8817e4Smiod    echo 1>&2 "\
265*3d8817e4SmiodWARNING: \`$1' is $msg.  You should only need it if
266*3d8817e4Smiod	 you modified a dependency of a manual page.  You may need the
267*3d8817e4Smiod	 \`Help2man' package in order for those modifications to take
268*3d8817e4Smiod	 effect.  You can get \`Help2man' from any GNU archive site."
269*3d8817e4Smiod
270*3d8817e4Smiod    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
271*3d8817e4Smiod    if test -z "$file"; then
272*3d8817e4Smiod	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
273*3d8817e4Smiod    fi
274*3d8817e4Smiod    if [ -f "$file" ]; then
275*3d8817e4Smiod	touch $file
276*3d8817e4Smiod    else
277*3d8817e4Smiod	test -z "$file" || exec >$file
278*3d8817e4Smiod	echo ".ab help2man is required to generate this page"
279*3d8817e4Smiod	exit 1
280*3d8817e4Smiod    fi
281*3d8817e4Smiod    ;;
282*3d8817e4Smiod
283*3d8817e4Smiod  makeinfo)
284*3d8817e4Smiod    echo 1>&2 "\
285*3d8817e4SmiodWARNING: \`$1' is $msg.  You should only need it if
286*3d8817e4Smiod         you modified a \`.texi' or \`.texinfo' file, or any other file
287*3d8817e4Smiod         indirectly affecting the aspect of the manual.  The spurious
288*3d8817e4Smiod         call might also be the consequence of using a buggy \`make' (AIX,
289*3d8817e4Smiod         DU, IRIX).  You might want to install the \`Texinfo' package or
290*3d8817e4Smiod         the \`GNU make' package.  Grab either from any GNU archive site."
291*3d8817e4Smiod    # The file to touch is that specified with -o ...
292*3d8817e4Smiod    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
293*3d8817e4Smiod    if test -z "$file"; then
294*3d8817e4Smiod      # ... or it is the one specified with @setfilename ...
295*3d8817e4Smiod      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
296*3d8817e4Smiod      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
297*3d8817e4Smiod      # ... or it is derived from the source name (dir/f.texi becomes f.info)
298*3d8817e4Smiod      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
299*3d8817e4Smiod    fi
300*3d8817e4Smiod    # If the file does not exist, the user really needs makeinfo;
301*3d8817e4Smiod    # let's fail without touching anything.
302*3d8817e4Smiod    test -f $file || exit 1
303*3d8817e4Smiod    touch $file
304*3d8817e4Smiod    ;;
305*3d8817e4Smiod
306*3d8817e4Smiod  tar)
307*3d8817e4Smiod    shift
308*3d8817e4Smiod
309*3d8817e4Smiod    # We have already tried tar in the generic part.
310*3d8817e4Smiod    # Look for gnutar/gtar before invocation to avoid ugly error
311*3d8817e4Smiod    # messages.
312*3d8817e4Smiod    if (gnutar --version > /dev/null 2>&1); then
313*3d8817e4Smiod       gnutar "$@" && exit 0
314*3d8817e4Smiod    fi
315*3d8817e4Smiod    if (gtar --version > /dev/null 2>&1); then
316*3d8817e4Smiod       gtar "$@" && exit 0
317*3d8817e4Smiod    fi
318*3d8817e4Smiod    firstarg="$1"
319*3d8817e4Smiod    if shift; then
320*3d8817e4Smiod	case "$firstarg" in
321*3d8817e4Smiod	*o*)
322*3d8817e4Smiod	    firstarg=`echo "$firstarg" | sed s/o//`
323*3d8817e4Smiod	    tar "$firstarg" "$@" && exit 0
324*3d8817e4Smiod	    ;;
325*3d8817e4Smiod	esac
326*3d8817e4Smiod	case "$firstarg" in
327*3d8817e4Smiod	*h*)
328*3d8817e4Smiod	    firstarg=`echo "$firstarg" | sed s/h//`
329*3d8817e4Smiod	    tar "$firstarg" "$@" && exit 0
330*3d8817e4Smiod	    ;;
331*3d8817e4Smiod	esac
332*3d8817e4Smiod    fi
333*3d8817e4Smiod
334*3d8817e4Smiod    echo 1>&2 "\
335*3d8817e4SmiodWARNING: I can't seem to be able to run \`tar' with the given arguments.
336*3d8817e4Smiod         You may want to install GNU tar or Free paxutils, or check the
337*3d8817e4Smiod         command line arguments."
338*3d8817e4Smiod    exit 1
339*3d8817e4Smiod    ;;
340*3d8817e4Smiod
341*3d8817e4Smiod  *)
342*3d8817e4Smiod    echo 1>&2 "\
343*3d8817e4SmiodWARNING: \`$1' is needed, and is $msg.
344*3d8817e4Smiod         You might have modified some files without having the
345*3d8817e4Smiod         proper tools for further handling them.  Check the \`README' file,
346*3d8817e4Smiod         it often tells you about the needed prerequisites for installing
347*3d8817e4Smiod         this package.  You may also peek at any GNU archive site, in case
348*3d8817e4Smiod         some other package would contain this missing \`$1' program."
349*3d8817e4Smiod    exit 1
350*3d8817e4Smiod    ;;
351*3d8817e4Smiodesac
352*3d8817e4Smiod
353*3d8817e4Smiodexit 0
354*3d8817e4Smiod
355*3d8817e4Smiod# Local variables:
356*3d8817e4Smiod# eval: (add-hook 'write-file-hooks 'time-stamp)
357*3d8817e4Smiod# time-stamp-start: "scriptversion="
358*3d8817e4Smiod# time-stamp-format: "%:y-%02m-%02d.%02H"
359*3d8817e4Smiod# time-stamp-end: "$"
360*3d8817e4Smiod# End:
361