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