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