missing revision 165cb819
1100ae103Smrg#! /bin/sh
2100ae103Smrg# Common stub for a few missing GNU programs while installing.
3100ae103Smrg
4165cb819Smrgscriptversion=2009-04-28.21; # UTC
5100ae103Smrg
6165cb819Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
7165cb819Smrg# 2008, 2009 Free Software Foundation, Inc.
8100ae103Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9100ae103Smrg
10100ae103Smrg# This program is free software; you can redistribute it and/or modify
11100ae103Smrg# it under the terms of the GNU General Public License as published by
12100ae103Smrg# the Free Software Foundation; either version 2, or (at your option)
13100ae103Smrg# any later version.
14100ae103Smrg
15100ae103Smrg# This program is distributed in the hope that it will be useful,
16100ae103Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17100ae103Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18100ae103Smrg# GNU General Public License for more details.
19100ae103Smrg
20100ae103Smrg# You should have received a copy of the GNU General Public License
21165cb819Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22100ae103Smrg
23100ae103Smrg# As a special exception to the GNU General Public License, if you
24100ae103Smrg# distribute this file as part of a program that contains a
25100ae103Smrg# configuration script generated by Autoconf, you may include it under
26100ae103Smrg# the same distribution terms that you use for the rest of that program.
27100ae103Smrg
28100ae103Smrgif test $# -eq 0; then
29100ae103Smrg  echo 1>&2 "Try \`$0 --help' for more information"
30100ae103Smrg  exit 1
31100ae103Smrgfi
32100ae103Smrg
33100ae103Smrgrun=:
34165cb819Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
35165cb819Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
36100ae103Smrg
37100ae103Smrg# In the cases where this matters, `missing' is being run in the
38100ae103Smrg# srcdir already.
39100ae103Smrgif test -f configure.ac; then
40100ae103Smrg  configure_ac=configure.ac
41100ae103Smrgelse
42100ae103Smrg  configure_ac=configure.in
43100ae103Smrgfi
44100ae103Smrg
45100ae103Smrgmsg="missing on your system"
46100ae103Smrg
47165cb819Smrgcase $1 in
48100ae103Smrg--run)
49100ae103Smrg  # Try to run requested program, and just exit if it succeeds.
50100ae103Smrg  run=
51100ae103Smrg  shift
52100ae103Smrg  "$@" && exit 0
53100ae103Smrg  # Exit code 63 means version mismatch.  This often happens
54100ae103Smrg  # when the user try to use an ancient version of a tool on
55100ae103Smrg  # a file that requires a minimum version.  In this case we
56100ae103Smrg  # we should proceed has if the program had been absent, or
57100ae103Smrg  # if --run hadn't been passed.
58100ae103Smrg  if test $? = 63; then
59100ae103Smrg    run=:
60100ae103Smrg    msg="probably too old"
61100ae103Smrg  fi
62100ae103Smrg  ;;
63100ae103Smrg
64100ae103Smrg  -h|--h|--he|--hel|--help)
65100ae103Smrg    echo "\
66100ae103Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
67100ae103Smrg
68100ae103SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69100ae103Smrgerror status if there is no known handling for PROGRAM.
70100ae103Smrg
71100ae103SmrgOptions:
72100ae103Smrg  -h, --help      display this help and exit
73100ae103Smrg  -v, --version   output version information and exit
74100ae103Smrg  --run           try to run the given command, and emulate it if it fails
75100ae103Smrg
76100ae103SmrgSupported PROGRAM values:
77100ae103Smrg  aclocal      touch file \`aclocal.m4'
78100ae103Smrg  autoconf     touch file \`configure'
79100ae103Smrg  autoheader   touch file \`config.h.in'
80165cb819Smrg  autom4te     touch the output file, or create a stub one
81100ae103Smrg  automake     touch all \`Makefile.in' files
82100ae103Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
83100ae103Smrg  flex         create \`lex.yy.c', if possible, from existing .c
84100ae103Smrg  help2man     touch the output file
85100ae103Smrg  lex          create \`lex.yy.c', if possible, from existing .c
86100ae103Smrg  makeinfo     touch the output file
87100ae103Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
88100ae103Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
89100ae103Smrg
90165cb819SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
91165cb819Smrg\`g' are ignored when checking the name.
92165cb819Smrg
93100ae103SmrgSend bug reports to <bug-automake@gnu.org>."
94100ae103Smrg    exit $?
95100ae103Smrg    ;;
96100ae103Smrg
97100ae103Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
98100ae103Smrg    echo "missing $scriptversion (GNU Automake)"
99100ae103Smrg    exit $?
100100ae103Smrg    ;;
101100ae103Smrg
102100ae103Smrg  -*)
103100ae103Smrg    echo 1>&2 "$0: Unknown \`$1' option"
104100ae103Smrg    echo 1>&2 "Try \`$0 --help' for more information"
105100ae103Smrg    exit 1
106100ae103Smrg    ;;
107100ae103Smrg
108100ae103Smrgesac
109100ae103Smrg
110165cb819Smrg# normalize program name to check for.
111165cb819Smrgprogram=`echo "$1" | sed '
112165cb819Smrg  s/^gnu-//; t
113165cb819Smrg  s/^gnu//; t
114165cb819Smrg  s/^g//; t'`
115165cb819Smrg
116100ae103Smrg# Now exit if we have it, but it failed.  Also exit now if we
117100ae103Smrg# don't have it and --version was passed (most likely to detect
118165cb819Smrg# the program).  This is about non-GNU programs, so use $1 not
119165cb819Smrg# $program.
120165cb819Smrgcase $1 in
121165cb819Smrg  lex*|yacc*)
122100ae103Smrg    # Not GNU programs, they don't have --version.
123100ae103Smrg    ;;
124100ae103Smrg
125165cb819Smrg  tar*)
126100ae103Smrg    if test -n "$run"; then
127100ae103Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
128100ae103Smrg       exit 1
129100ae103Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
130100ae103Smrg       exit 1
131100ae103Smrg    fi
132100ae103Smrg    ;;
133100ae103Smrg
134100ae103Smrg  *)
135100ae103Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
136100ae103Smrg       # We have it, but it failed.
137100ae103Smrg       exit 1
138100ae103Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
139100ae103Smrg       # Could not run --version or --help.  This is probably someone
140100ae103Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
141100ae103Smrg       # $TOOL exists and not knowing $TOOL uses missing.
142100ae103Smrg       exit 1
143100ae103Smrg    fi
144100ae103Smrg    ;;
145100ae103Smrgesac
146100ae103Smrg
147100ae103Smrg# If it does not exist, or fails to run (possibly an outdated version),
148100ae103Smrg# try to emulate it.
149165cb819Smrgcase $program in
150100ae103Smrg  aclocal*)
151100ae103Smrg    echo 1>&2 "\
152100ae103SmrgWARNING: \`$1' is $msg.  You should only need it if
153100ae103Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
154100ae103Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
155100ae103Smrg         any GNU archive site."
156100ae103Smrg    touch aclocal.m4
157100ae103Smrg    ;;
158100ae103Smrg
159165cb819Smrg  autoconf*)
160100ae103Smrg    echo 1>&2 "\
161100ae103SmrgWARNING: \`$1' is $msg.  You should only need it if
162100ae103Smrg         you modified \`${configure_ac}'.  You might want to install the
163100ae103Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
164100ae103Smrg         archive site."
165100ae103Smrg    touch configure
166100ae103Smrg    ;;
167100ae103Smrg
168165cb819Smrg  autoheader*)
169100ae103Smrg    echo 1>&2 "\
170100ae103SmrgWARNING: \`$1' is $msg.  You should only need it if
171100ae103Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
172100ae103Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
173100ae103Smrg         from any GNU archive site."
174100ae103Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
175100ae103Smrg    test -z "$files" && files="config.h"
176100ae103Smrg    touch_files=
177100ae103Smrg    for f in $files; do
178165cb819Smrg      case $f in
179100ae103Smrg      *:*) touch_files="$touch_files "`echo "$f" |
180100ae103Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
181100ae103Smrg      *) touch_files="$touch_files $f.in";;
182100ae103Smrg      esac
183100ae103Smrg    done
184100ae103Smrg    touch $touch_files
185100ae103Smrg    ;;
186100ae103Smrg
187100ae103Smrg  automake*)
188100ae103Smrg    echo 1>&2 "\
189100ae103SmrgWARNING: \`$1' is $msg.  You should only need it if
190100ae103Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
191100ae103Smrg         You might want to install the \`Automake' and \`Perl' packages.
192100ae103Smrg         Grab them from any GNU archive site."
193100ae103Smrg    find . -type f -name Makefile.am -print |
194100ae103Smrg	   sed 's/\.am$/.in/' |
195100ae103Smrg	   while read f; do touch "$f"; done
196100ae103Smrg    ;;
197100ae103Smrg
198165cb819Smrg  autom4te*)
199100ae103Smrg    echo 1>&2 "\
200100ae103SmrgWARNING: \`$1' is needed, but is $msg.
201100ae103Smrg         You might have modified some files without having the
202100ae103Smrg         proper tools for further handling them.
203100ae103Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
204100ae103Smrg         archive site."
205100ae103Smrg
206165cb819Smrg    file=`echo "$*" | sed -n "$sed_output"`
207165cb819Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
208100ae103Smrg    if test -f "$file"; then
209100ae103Smrg	touch $file
210100ae103Smrg    else
211100ae103Smrg	test -z "$file" || exec >$file
212100ae103Smrg	echo "#! /bin/sh"
213100ae103Smrg	echo "# Created by GNU Automake missing as a replacement of"
214100ae103Smrg	echo "#  $ $@"
215100ae103Smrg	echo "exit 0"
216100ae103Smrg	chmod +x $file
217100ae103Smrg	exit 1
218100ae103Smrg    fi
219100ae103Smrg    ;;
220100ae103Smrg
221165cb819Smrg  bison*|yacc*)
222100ae103Smrg    echo 1>&2 "\
223100ae103SmrgWARNING: \`$1' $msg.  You should only need it if
224100ae103Smrg         you modified a \`.y' file.  You may need the \`Bison' package
225100ae103Smrg         in order for those modifications to take effect.  You can get
226100ae103Smrg         \`Bison' from any GNU archive site."
227100ae103Smrg    rm -f y.tab.c y.tab.h
228165cb819Smrg    if test $# -ne 1; then
229100ae103Smrg        eval LASTARG="\${$#}"
230165cb819Smrg	case $LASTARG in
231100ae103Smrg	*.y)
232100ae103Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
233165cb819Smrg	    if test -f "$SRCFILE"; then
234100ae103Smrg	         cp "$SRCFILE" y.tab.c
235100ae103Smrg	    fi
236100ae103Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
237165cb819Smrg	    if test -f "$SRCFILE"; then
238100ae103Smrg	         cp "$SRCFILE" y.tab.h
239100ae103Smrg	    fi
240100ae103Smrg	  ;;
241100ae103Smrg	esac
242100ae103Smrg    fi
243165cb819Smrg    if test ! -f y.tab.h; then
244100ae103Smrg	echo >y.tab.h
245100ae103Smrg    fi
246165cb819Smrg    if test ! -f y.tab.c; then
247100ae103Smrg	echo 'main() { return 0; }' >y.tab.c
248100ae103Smrg    fi
249100ae103Smrg    ;;
250100ae103Smrg
251165cb819Smrg  lex*|flex*)
252100ae103Smrg    echo 1>&2 "\
253100ae103SmrgWARNING: \`$1' is $msg.  You should only need it if
254100ae103Smrg         you modified a \`.l' file.  You may need the \`Flex' package
255100ae103Smrg         in order for those modifications to take effect.  You can get
256100ae103Smrg         \`Flex' from any GNU archive site."
257100ae103Smrg    rm -f lex.yy.c
258165cb819Smrg    if test $# -ne 1; then
259100ae103Smrg        eval LASTARG="\${$#}"
260165cb819Smrg	case $LASTARG in
261100ae103Smrg	*.l)
262100ae103Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
263165cb819Smrg	    if test -f "$SRCFILE"; then
264100ae103Smrg	         cp "$SRCFILE" lex.yy.c
265100ae103Smrg	    fi
266100ae103Smrg	  ;;
267100ae103Smrg	esac
268100ae103Smrg    fi
269165cb819Smrg    if test ! -f lex.yy.c; then
270100ae103Smrg	echo 'main() { return 0; }' >lex.yy.c
271100ae103Smrg    fi
272100ae103Smrg    ;;
273100ae103Smrg
274165cb819Smrg  help2man*)
275100ae103Smrg    echo 1>&2 "\
276100ae103SmrgWARNING: \`$1' is $msg.  You should only need it if
277100ae103Smrg	 you modified a dependency of a manual page.  You may need the
278100ae103Smrg	 \`Help2man' package in order for those modifications to take
279100ae103Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
280100ae103Smrg
281165cb819Smrg    file=`echo "$*" | sed -n "$sed_output"`
282165cb819Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
283165cb819Smrg    if test -f "$file"; then
284100ae103Smrg	touch $file
285100ae103Smrg    else
286100ae103Smrg	test -z "$file" || exec >$file
287100ae103Smrg	echo ".ab help2man is required to generate this page"
288165cb819Smrg	exit $?
289100ae103Smrg    fi
290100ae103Smrg    ;;
291100ae103Smrg
292165cb819Smrg  makeinfo*)
293100ae103Smrg    echo 1>&2 "\
294100ae103SmrgWARNING: \`$1' is $msg.  You should only need it if
295100ae103Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
296100ae103Smrg         indirectly affecting the aspect of the manual.  The spurious
297100ae103Smrg         call might also be the consequence of using a buggy \`make' (AIX,
298100ae103Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
299100ae103Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
300100ae103Smrg    # The file to touch is that specified with -o ...
301165cb819Smrg    file=`echo "$*" | sed -n "$sed_output"`
302165cb819Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
303100ae103Smrg    if test -z "$file"; then
304100ae103Smrg      # ... or it is the one specified with @setfilename ...
305100ae103Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
306165cb819Smrg      file=`sed -n '
307165cb819Smrg	/^@setfilename/{
308165cb819Smrg	  s/.* \([^ ]*\) *$/\1/
309165cb819Smrg	  p
310165cb819Smrg	  q
311165cb819Smrg	}' $infile`
312100ae103Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
313100ae103Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
314100ae103Smrg    fi
315100ae103Smrg    # If the file does not exist, the user really needs makeinfo;
316100ae103Smrg    # let's fail without touching anything.
317100ae103Smrg    test -f $file || exit 1
318100ae103Smrg    touch $file
319100ae103Smrg    ;;
320100ae103Smrg
321165cb819Smrg  tar*)
322100ae103Smrg    shift
323100ae103Smrg
324100ae103Smrg    # We have already tried tar in the generic part.
325100ae103Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
326100ae103Smrg    # messages.
327100ae103Smrg    if (gnutar --version > /dev/null 2>&1); then
328100ae103Smrg       gnutar "$@" && exit 0
329100ae103Smrg    fi
330100ae103Smrg    if (gtar --version > /dev/null 2>&1); then
331100ae103Smrg       gtar "$@" && exit 0
332100ae103Smrg    fi
333100ae103Smrg    firstarg="$1"
334100ae103Smrg    if shift; then
335165cb819Smrg	case $firstarg in
336100ae103Smrg	*o*)
337100ae103Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
338100ae103Smrg	    tar "$firstarg" "$@" && exit 0
339100ae103Smrg	    ;;
340100ae103Smrg	esac
341165cb819Smrg	case $firstarg in
342100ae103Smrg	*h*)
343100ae103Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
344100ae103Smrg	    tar "$firstarg" "$@" && exit 0
345100ae103Smrg	    ;;
346100ae103Smrg	esac
347100ae103Smrg    fi
348100ae103Smrg
349100ae103Smrg    echo 1>&2 "\
350100ae103SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
351100ae103Smrg         You may want to install GNU tar or Free paxutils, or check the
352100ae103Smrg         command line arguments."
353100ae103Smrg    exit 1
354100ae103Smrg    ;;
355100ae103Smrg
356100ae103Smrg  *)
357100ae103Smrg    echo 1>&2 "\
358100ae103SmrgWARNING: \`$1' is needed, and is $msg.
359100ae103Smrg         You might have modified some files without having the
360100ae103Smrg         proper tools for further handling them.  Check the \`README' file,
361100ae103Smrg         it often tells you about the needed prerequisites for installing
362100ae103Smrg         this package.  You may also peek at any GNU archive site, in case
363100ae103Smrg         some other package would contain this missing \`$1' program."
364100ae103Smrg    exit 1
365100ae103Smrg    ;;
366100ae103Smrgesac
367100ae103Smrg
368100ae103Smrgexit 0
369100ae103Smrg
370100ae103Smrg# Local variables:
371100ae103Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
372100ae103Smrg# time-stamp-start: "scriptversion="
373100ae103Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
374165cb819Smrg# time-stamp-time-zone: "UTC"
375165cb819Smrg# time-stamp-end: "; # UTC"
376100ae103Smrg# End:
377