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