missing revision 5b28e182
1dcae5b9eSmrg#! /bin/sh
2dcae5b9eSmrg# Common stub for a few missing GNU programs while installing.
35b28e182Smrg
45b28e182Smrgscriptversion=2009-04-28.21; # UTC
55b28e182Smrg
65b28e182Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
75b28e182Smrg# 2008, 2009 Free Software Foundation, Inc.
8dcae5b9eSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9dcae5b9eSmrg
10dcae5b9eSmrg# This program is free software; you can redistribute it and/or modify
11dcae5b9eSmrg# it under the terms of the GNU General Public License as published by
12dcae5b9eSmrg# the Free Software Foundation; either version 2, or (at your option)
13dcae5b9eSmrg# any later version.
14dcae5b9eSmrg
15dcae5b9eSmrg# This program is distributed in the hope that it will be useful,
16dcae5b9eSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17dcae5b9eSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18dcae5b9eSmrg# GNU General Public License for more details.
19dcae5b9eSmrg
20dcae5b9eSmrg# You should have received a copy of the GNU General Public License
215b28e182Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22dcae5b9eSmrg
23dcae5b9eSmrg# As a special exception to the GNU General Public License, if you
24dcae5b9eSmrg# distribute this file as part of a program that contains a
25dcae5b9eSmrg# configuration script generated by Autoconf, you may include it under
26dcae5b9eSmrg# the same distribution terms that you use for the rest of that program.
27dcae5b9eSmrg
28dcae5b9eSmrgif test $# -eq 0; then
29dcae5b9eSmrg  echo 1>&2 "Try \`$0 --help' for more information"
30dcae5b9eSmrg  exit 1
31dcae5b9eSmrgfi
32dcae5b9eSmrg
33dcae5b9eSmrgrun=:
345b28e182Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
355b28e182Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
36dcae5b9eSmrg
37dcae5b9eSmrg# In the cases where this matters, `missing' is being run in the
38dcae5b9eSmrg# srcdir already.
39dcae5b9eSmrgif test -f configure.ac; then
40dcae5b9eSmrg  configure_ac=configure.ac
41dcae5b9eSmrgelse
42dcae5b9eSmrg  configure_ac=configure.in
43dcae5b9eSmrgfi
44dcae5b9eSmrg
455b28e182Smrgmsg="missing on your system"
465b28e182Smrg
475b28e182Smrgcase $1 in
48dcae5b9eSmrg--run)
49dcae5b9eSmrg  # Try to run requested program, and just exit if it succeeds.
50dcae5b9eSmrg  run=
51dcae5b9eSmrg  shift
52dcae5b9eSmrg  "$@" && exit 0
535b28e182Smrg  # Exit code 63 means version mismatch.  This often happens
545b28e182Smrg  # when the user try to use an ancient version of a tool on
555b28e182Smrg  # a file that requires a minimum version.  In this case we
565b28e182Smrg  # we should proceed has if the program had been absent, or
575b28e182Smrg  # if --run hadn't been passed.
585b28e182Smrg  if test $? = 63; then
595b28e182Smrg    run=:
605b28e182Smrg    msg="probably too old"
615b28e182Smrg  fi
62dcae5b9eSmrg  ;;
63dcae5b9eSmrg
64dcae5b9eSmrg  -h|--h|--he|--hel|--help)
65dcae5b9eSmrg    echo "\
66dcae5b9eSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
67dcae5b9eSmrg
68dcae5b9eSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69dcae5b9eSmrgerror status if there is no known handling for PROGRAM.
70dcae5b9eSmrg
71dcae5b9eSmrgOptions:
72dcae5b9eSmrg  -h, --help      display this help and exit
73dcae5b9eSmrg  -v, --version   output version information and exit
74dcae5b9eSmrg  --run           try to run the given command, and emulate it if it fails
75dcae5b9eSmrg
76dcae5b9eSmrgSupported PROGRAM values:
77dcae5b9eSmrg  aclocal      touch file \`aclocal.m4'
78dcae5b9eSmrg  autoconf     touch file \`configure'
79dcae5b9eSmrg  autoheader   touch file \`config.h.in'
805b28e182Smrg  autom4te     touch the output file, or create a stub one
81dcae5b9eSmrg  automake     touch all \`Makefile.in' files
82dcae5b9eSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
83dcae5b9eSmrg  flex         create \`lex.yy.c', if possible, from existing .c
84dcae5b9eSmrg  help2man     touch the output file
85dcae5b9eSmrg  lex          create \`lex.yy.c', if possible, from existing .c
86dcae5b9eSmrg  makeinfo     touch the output file
87dcae5b9eSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
885b28e182Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
895b28e182Smrg
905b28e182SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
915b28e182Smrg\`g' are ignored when checking the name.
925b28e182Smrg
935b28e182SmrgSend bug reports to <bug-automake@gnu.org>."
945b28e182Smrg    exit $?
95dcae5b9eSmrg    ;;
96dcae5b9eSmrg
97dcae5b9eSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
985b28e182Smrg    echo "missing $scriptversion (GNU Automake)"
995b28e182Smrg    exit $?
100dcae5b9eSmrg    ;;
101dcae5b9eSmrg
102dcae5b9eSmrg  -*)
103dcae5b9eSmrg    echo 1>&2 "$0: Unknown \`$1' option"
104dcae5b9eSmrg    echo 1>&2 "Try \`$0 --help' for more information"
105dcae5b9eSmrg    exit 1
106dcae5b9eSmrg    ;;
107dcae5b9eSmrg
1085b28e182Smrgesac
1095b28e182Smrg
1105b28e182Smrg# normalize program name to check for.
1115b28e182Smrgprogram=`echo "$1" | sed '
1125b28e182Smrg  s/^gnu-//; t
1135b28e182Smrg  s/^gnu//; t
1145b28e182Smrg  s/^g//; t'`
1155b28e182Smrg
1165b28e182Smrg# Now exit if we have it, but it failed.  Also exit now if we
1175b28e182Smrg# don't have it and --version was passed (most likely to detect
1185b28e182Smrg# the program).  This is about non-GNU programs, so use $1 not
1195b28e182Smrg# $program.
1205b28e182Smrgcase $1 in
1215b28e182Smrg  lex*|yacc*)
1225b28e182Smrg    # Not GNU programs, they don't have --version.
1235b28e182Smrg    ;;
1245b28e182Smrg
1255b28e182Smrg  tar*)
1265b28e182Smrg    if test -n "$run"; then
1275b28e182Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
1285b28e182Smrg       exit 1
1295b28e182Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1305b28e182Smrg       exit 1
1315b28e182Smrg    fi
1325b28e182Smrg    ;;
1335b28e182Smrg
1345b28e182Smrg  *)
135dcae5b9eSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
136dcae5b9eSmrg       # We have it, but it failed.
137dcae5b9eSmrg       exit 1
1385b28e182Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1395b28e182Smrg       # Could not run --version or --help.  This is probably someone
1405b28e182Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1415b28e182Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1425b28e182Smrg       exit 1
143dcae5b9eSmrg    fi
1445b28e182Smrg    ;;
1455b28e182Smrgesac
146dcae5b9eSmrg
1475b28e182Smrg# If it does not exist, or fails to run (possibly an outdated version),
1485b28e182Smrg# try to emulate it.
1495b28e182Smrgcase $program in
1505b28e182Smrg  aclocal*)
151dcae5b9eSmrg    echo 1>&2 "\
1525b28e182SmrgWARNING: \`$1' is $msg.  You should only need it if
153dcae5b9eSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
154dcae5b9eSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
155dcae5b9eSmrg         any GNU archive site."
156dcae5b9eSmrg    touch aclocal.m4
157dcae5b9eSmrg    ;;
158dcae5b9eSmrg
1595b28e182Smrg  autoconf*)
160dcae5b9eSmrg    echo 1>&2 "\
1615b28e182SmrgWARNING: \`$1' is $msg.  You should only need it if
162dcae5b9eSmrg         you modified \`${configure_ac}'.  You might want to install the
163dcae5b9eSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
164dcae5b9eSmrg         archive site."
165dcae5b9eSmrg    touch configure
166dcae5b9eSmrg    ;;
167dcae5b9eSmrg
1685b28e182Smrg  autoheader*)
169dcae5b9eSmrg    echo 1>&2 "\
1705b28e182SmrgWARNING: \`$1' is $msg.  You should only need it if
171dcae5b9eSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
172dcae5b9eSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
173dcae5b9eSmrg         from any GNU archive site."
174dcae5b9eSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
175dcae5b9eSmrg    test -z "$files" && files="config.h"
176dcae5b9eSmrg    touch_files=
177dcae5b9eSmrg    for f in $files; do
1785b28e182Smrg      case $f in
179dcae5b9eSmrg      *:*) touch_files="$touch_files "`echo "$f" |
180dcae5b9eSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
181dcae5b9eSmrg      *) touch_files="$touch_files $f.in";;
182dcae5b9eSmrg      esac
183dcae5b9eSmrg    done
184dcae5b9eSmrg    touch $touch_files
185dcae5b9eSmrg    ;;
186dcae5b9eSmrg
187dcae5b9eSmrg  automake*)
188dcae5b9eSmrg    echo 1>&2 "\
1895b28e182SmrgWARNING: \`$1' is $msg.  You should only need it if
190dcae5b9eSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
191dcae5b9eSmrg         You might want to install the \`Automake' and \`Perl' packages.
192dcae5b9eSmrg         Grab them from any GNU archive site."
193dcae5b9eSmrg    find . -type f -name Makefile.am -print |
194dcae5b9eSmrg	   sed 's/\.am$/.in/' |
195dcae5b9eSmrg	   while read f; do touch "$f"; done
196dcae5b9eSmrg    ;;
197dcae5b9eSmrg
1985b28e182Smrg  autom4te*)
199dcae5b9eSmrg    echo 1>&2 "\
2005b28e182SmrgWARNING: \`$1' is needed, but is $msg.
2015b28e182Smrg         You might have modified some files without having the
202dcae5b9eSmrg         proper tools for further handling them.
203dcae5b9eSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
204dcae5b9eSmrg         archive site."
205dcae5b9eSmrg
2065b28e182Smrg    file=`echo "$*" | sed -n "$sed_output"`
2075b28e182Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
208dcae5b9eSmrg    if test -f "$file"; then
209dcae5b9eSmrg	touch $file
210dcae5b9eSmrg    else
211dcae5b9eSmrg	test -z "$file" || exec >$file
212dcae5b9eSmrg	echo "#! /bin/sh"
213dcae5b9eSmrg	echo "# Created by GNU Automake missing as a replacement of"
214dcae5b9eSmrg	echo "#  $ $@"
215dcae5b9eSmrg	echo "exit 0"
216dcae5b9eSmrg	chmod +x $file
217dcae5b9eSmrg	exit 1
218dcae5b9eSmrg    fi
219dcae5b9eSmrg    ;;
220dcae5b9eSmrg
2215b28e182Smrg  bison*|yacc*)
222dcae5b9eSmrg    echo 1>&2 "\
2235b28e182SmrgWARNING: \`$1' $msg.  You should only need it if
224dcae5b9eSmrg         you modified a \`.y' file.  You may need the \`Bison' package
225dcae5b9eSmrg         in order for those modifications to take effect.  You can get
226dcae5b9eSmrg         \`Bison' from any GNU archive site."
227dcae5b9eSmrg    rm -f y.tab.c y.tab.h
2285b28e182Smrg    if test $# -ne 1; then
229dcae5b9eSmrg        eval LASTARG="\${$#}"
2305b28e182Smrg	case $LASTARG in
231dcae5b9eSmrg	*.y)
232dcae5b9eSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2335b28e182Smrg	    if test -f "$SRCFILE"; then
234dcae5b9eSmrg	         cp "$SRCFILE" y.tab.c
235dcae5b9eSmrg	    fi
236dcae5b9eSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2375b28e182Smrg	    if test -f "$SRCFILE"; then
238dcae5b9eSmrg	         cp "$SRCFILE" y.tab.h
239dcae5b9eSmrg	    fi
240dcae5b9eSmrg	  ;;
241dcae5b9eSmrg	esac
242dcae5b9eSmrg    fi
2435b28e182Smrg    if test ! -f y.tab.h; then
244dcae5b9eSmrg	echo >y.tab.h
245dcae5b9eSmrg    fi
2465b28e182Smrg    if test ! -f y.tab.c; then
247dcae5b9eSmrg	echo 'main() { return 0; }' >y.tab.c
248dcae5b9eSmrg    fi
249dcae5b9eSmrg    ;;
250dcae5b9eSmrg
2515b28e182Smrg  lex*|flex*)
252dcae5b9eSmrg    echo 1>&2 "\
2535b28e182SmrgWARNING: \`$1' is $msg.  You should only need it if
254dcae5b9eSmrg         you modified a \`.l' file.  You may need the \`Flex' package
255dcae5b9eSmrg         in order for those modifications to take effect.  You can get
256dcae5b9eSmrg         \`Flex' from any GNU archive site."
257dcae5b9eSmrg    rm -f lex.yy.c
2585b28e182Smrg    if test $# -ne 1; then
259dcae5b9eSmrg        eval LASTARG="\${$#}"
2605b28e182Smrg	case $LASTARG in
261dcae5b9eSmrg	*.l)
262dcae5b9eSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2635b28e182Smrg	    if test -f "$SRCFILE"; then
264dcae5b9eSmrg	         cp "$SRCFILE" lex.yy.c
265dcae5b9eSmrg	    fi
266dcae5b9eSmrg	  ;;
267dcae5b9eSmrg	esac
268dcae5b9eSmrg    fi
2695b28e182Smrg    if test ! -f lex.yy.c; then
270dcae5b9eSmrg	echo 'main() { return 0; }' >lex.yy.c
271dcae5b9eSmrg    fi
272dcae5b9eSmrg    ;;
273dcae5b9eSmrg
2745b28e182Smrg  help2man*)
275dcae5b9eSmrg    echo 1>&2 "\
2765b28e182SmrgWARNING: \`$1' is $msg.  You should only need it if
277dcae5b9eSmrg	 you modified a dependency of a manual page.  You may need the
278dcae5b9eSmrg	 \`Help2man' package in order for those modifications to take
279dcae5b9eSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
280dcae5b9eSmrg
2815b28e182Smrg    file=`echo "$*" | sed -n "$sed_output"`
2825b28e182Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2835b28e182Smrg    if test -f "$file"; then
284dcae5b9eSmrg	touch $file
285dcae5b9eSmrg    else
286dcae5b9eSmrg	test -z "$file" || exec >$file
287dcae5b9eSmrg	echo ".ab help2man is required to generate this page"
2885b28e182Smrg	exit $?
289dcae5b9eSmrg    fi
290dcae5b9eSmrg    ;;
291dcae5b9eSmrg
2925b28e182Smrg  makeinfo*)
293dcae5b9eSmrg    echo 1>&2 "\
2945b28e182SmrgWARNING: \`$1' is $msg.  You should only need it if
295dcae5b9eSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
296dcae5b9eSmrg         indirectly affecting the aspect of the manual.  The spurious
297dcae5b9eSmrg         call might also be the consequence of using a buggy \`make' (AIX,
298dcae5b9eSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
299dcae5b9eSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
3005b28e182Smrg    # The file to touch is that specified with -o ...
3015b28e182Smrg    file=`echo "$*" | sed -n "$sed_output"`
3025b28e182Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
303dcae5b9eSmrg    if test -z "$file"; then
3045b28e182Smrg      # ... or it is the one specified with @setfilename ...
3055b28e182Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
3065b28e182Smrg      file=`sed -n '
3075b28e182Smrg	/^@setfilename/{
3085b28e182Smrg	  s/.* \([^ ]*\) *$/\1/
3095b28e182Smrg	  p
3105b28e182Smrg	  q
3115b28e182Smrg	}' $infile`
3125b28e182Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3135b28e182Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
314dcae5b9eSmrg    fi
3155b28e182Smrg    # If the file does not exist, the user really needs makeinfo;
3165b28e182Smrg    # let's fail without touching anything.
3175b28e182Smrg    test -f $file || exit 1
318dcae5b9eSmrg    touch $file
319dcae5b9eSmrg    ;;
320dcae5b9eSmrg
3215b28e182Smrg  tar*)
322dcae5b9eSmrg    shift
323dcae5b9eSmrg
324dcae5b9eSmrg    # We have already tried tar in the generic part.
325dcae5b9eSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
326dcae5b9eSmrg    # messages.
327dcae5b9eSmrg    if (gnutar --version > /dev/null 2>&1); then
328dcae5b9eSmrg       gnutar "$@" && exit 0
329dcae5b9eSmrg    fi
330dcae5b9eSmrg    if (gtar --version > /dev/null 2>&1); then
331dcae5b9eSmrg       gtar "$@" && exit 0
332dcae5b9eSmrg    fi
333dcae5b9eSmrg    firstarg="$1"
334dcae5b9eSmrg    if shift; then
3355b28e182Smrg	case $firstarg in
336dcae5b9eSmrg	*o*)
337dcae5b9eSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
338dcae5b9eSmrg	    tar "$firstarg" "$@" && exit 0
339dcae5b9eSmrg	    ;;
340dcae5b9eSmrg	esac
3415b28e182Smrg	case $firstarg in
342dcae5b9eSmrg	*h*)
343dcae5b9eSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
344dcae5b9eSmrg	    tar "$firstarg" "$@" && exit 0
345dcae5b9eSmrg	    ;;
346dcae5b9eSmrg	esac
347dcae5b9eSmrg    fi
348dcae5b9eSmrg
349dcae5b9eSmrg    echo 1>&2 "\
350dcae5b9eSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
351dcae5b9eSmrg         You may want to install GNU tar or Free paxutils, or check the
352dcae5b9eSmrg         command line arguments."
353dcae5b9eSmrg    exit 1
354dcae5b9eSmrg    ;;
355dcae5b9eSmrg
356dcae5b9eSmrg  *)
357dcae5b9eSmrg    echo 1>&2 "\
3585b28e182SmrgWARNING: \`$1' is needed, and is $msg.
3595b28e182Smrg         You might have modified some files without having the
360dcae5b9eSmrg         proper tools for further handling them.  Check the \`README' file,
361dcae5b9eSmrg         it often tells you about the needed prerequisites for installing
362dcae5b9eSmrg         this package.  You may also peek at any GNU archive site, in case
363dcae5b9eSmrg         some other package would contain this missing \`$1' program."
364dcae5b9eSmrg    exit 1
365dcae5b9eSmrg    ;;
366dcae5b9eSmrgesac
367dcae5b9eSmrg
368dcae5b9eSmrgexit 0
3695b28e182Smrg
3705b28e182Smrg# Local variables:
3715b28e182Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3725b28e182Smrg# time-stamp-start: "scriptversion="
3735b28e182Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3745b28e182Smrg# time-stamp-time-zone: "UTC"
3755b28e182Smrg# time-stamp-end: "; # UTC"
3765b28e182Smrg# End:
377