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