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