1cacd992dSmrg#! /bin/sh
2cacd992dSmrg# Common stub for a few missing GNU programs while installing.
314ddf674Smrg
414ddf674Smrgscriptversion=2009-04-28.21; # UTC
514ddf674Smrg
614ddf674Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
714ddf674Smrg# 2008, 2009 Free Software Foundation, Inc.
8cacd992dSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9cacd992dSmrg
10cacd992dSmrg# This program is free software; you can redistribute it and/or modify
11cacd992dSmrg# it under the terms of the GNU General Public License as published by
12cacd992dSmrg# the Free Software Foundation; either version 2, or (at your option)
13cacd992dSmrg# any later version.
14cacd992dSmrg
15cacd992dSmrg# This program is distributed in the hope that it will be useful,
16cacd992dSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17cacd992dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18cacd992dSmrg# GNU General Public License for more details.
19cacd992dSmrg
20cacd992dSmrg# You should have received a copy of the GNU General Public License
2114ddf674Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22cacd992dSmrg
23cacd992dSmrg# As a special exception to the GNU General Public License, if you
24cacd992dSmrg# distribute this file as part of a program that contains a
25cacd992dSmrg# configuration script generated by Autoconf, you may include it under
26cacd992dSmrg# the same distribution terms that you use for the rest of that program.
27cacd992dSmrg
28cacd992dSmrgif test $# -eq 0; then
29cacd992dSmrg  echo 1>&2 "Try \`$0 --help' for more information"
30cacd992dSmrg  exit 1
31cacd992dSmrgfi
32cacd992dSmrg
33cacd992dSmrgrun=:
3414ddf674Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
3514ddf674Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
36cacd992dSmrg
37cacd992dSmrg# In the cases where this matters, `missing' is being run in the
38cacd992dSmrg# srcdir already.
39cacd992dSmrgif test -f configure.ac; then
40cacd992dSmrg  configure_ac=configure.ac
41cacd992dSmrgelse
42cacd992dSmrg  configure_ac=configure.in
43cacd992dSmrgfi
44cacd992dSmrg
4514ddf674Smrgmsg="missing on your system"
4614ddf674Smrg
4714ddf674Smrgcase $1 in
48cacd992dSmrg--run)
49cacd992dSmrg  # Try to run requested program, and just exit if it succeeds.
50cacd992dSmrg  run=
51cacd992dSmrg  shift
52cacd992dSmrg  "$@" && exit 0
5314ddf674Smrg  # Exit code 63 means version mismatch.  This often happens
5414ddf674Smrg  # when the user try to use an ancient version of a tool on
5514ddf674Smrg  # a file that requires a minimum version.  In this case we
5614ddf674Smrg  # we should proceed has if the program had been absent, or
5714ddf674Smrg  # if --run hadn't been passed.
5814ddf674Smrg  if test $? = 63; then
5914ddf674Smrg    run=:
6014ddf674Smrg    msg="probably too old"
6114ddf674Smrg  fi
62cacd992dSmrg  ;;
63cacd992dSmrg
64cacd992dSmrg  -h|--h|--he|--hel|--help)
65cacd992dSmrg    echo "\
66cacd992dSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
67cacd992dSmrg
68cacd992dSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69cacd992dSmrgerror status if there is no known handling for PROGRAM.
70cacd992dSmrg
71cacd992dSmrgOptions:
72cacd992dSmrg  -h, --help      display this help and exit
73cacd992dSmrg  -v, --version   output version information and exit
74cacd992dSmrg  --run           try to run the given command, and emulate it if it fails
75cacd992dSmrg
76cacd992dSmrgSupported PROGRAM values:
77cacd992dSmrg  aclocal      touch file \`aclocal.m4'
78cacd992dSmrg  autoconf     touch file \`configure'
79cacd992dSmrg  autoheader   touch file \`config.h.in'
8014ddf674Smrg  autom4te     touch the output file, or create a stub one
81cacd992dSmrg  automake     touch all \`Makefile.in' files
82cacd992dSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
83cacd992dSmrg  flex         create \`lex.yy.c', if possible, from existing .c
84cacd992dSmrg  help2man     touch the output file
85cacd992dSmrg  lex          create \`lex.yy.c', if possible, from existing .c
86cacd992dSmrg  makeinfo     touch the output file
87cacd992dSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
8814ddf674Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8914ddf674Smrg
9014ddf674SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
9114ddf674Smrg\`g' are ignored when checking the name.
9214ddf674Smrg
9314ddf674SmrgSend bug reports to <bug-automake@gnu.org>."
9414ddf674Smrg    exit $?
95cacd992dSmrg    ;;
96cacd992dSmrg
97cacd992dSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9814ddf674Smrg    echo "missing $scriptversion (GNU Automake)"
9914ddf674Smrg    exit $?
100cacd992dSmrg    ;;
101cacd992dSmrg
102cacd992dSmrg  -*)
103cacd992dSmrg    echo 1>&2 "$0: Unknown \`$1' option"
104cacd992dSmrg    echo 1>&2 "Try \`$0 --help' for more information"
105cacd992dSmrg    exit 1
106cacd992dSmrg    ;;
107cacd992dSmrg
10814ddf674Smrgesac
10914ddf674Smrg
11014ddf674Smrg# normalize program name to check for.
11114ddf674Smrgprogram=`echo "$1" | sed '
11214ddf674Smrg  s/^gnu-//; t
11314ddf674Smrg  s/^gnu//; t
11414ddf674Smrg  s/^g//; t'`
11514ddf674Smrg
11614ddf674Smrg# Now exit if we have it, but it failed.  Also exit now if we
11714ddf674Smrg# don't have it and --version was passed (most likely to detect
11814ddf674Smrg# the program).  This is about non-GNU programs, so use $1 not
11914ddf674Smrg# $program.
12014ddf674Smrgcase $1 in
12114ddf674Smrg  lex*|yacc*)
12214ddf674Smrg    # Not GNU programs, they don't have --version.
12314ddf674Smrg    ;;
12414ddf674Smrg
12514ddf674Smrg  tar*)
12614ddf674Smrg    if test -n "$run"; then
12714ddf674Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
12814ddf674Smrg       exit 1
12914ddf674Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13014ddf674Smrg       exit 1
13114ddf674Smrg    fi
13214ddf674Smrg    ;;
13314ddf674Smrg
13414ddf674Smrg  *)
135cacd992dSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
136cacd992dSmrg       # We have it, but it failed.
137cacd992dSmrg       exit 1
13814ddf674Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13914ddf674Smrg       # Could not run --version or --help.  This is probably someone
14014ddf674Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
14114ddf674Smrg       # $TOOL exists and not knowing $TOOL uses missing.
14214ddf674Smrg       exit 1
143cacd992dSmrg    fi
14414ddf674Smrg    ;;
14514ddf674Smrgesac
146cacd992dSmrg
14714ddf674Smrg# If it does not exist, or fails to run (possibly an outdated version),
14814ddf674Smrg# try to emulate it.
14914ddf674Smrgcase $program in
15014ddf674Smrg  aclocal*)
151cacd992dSmrg    echo 1>&2 "\
15214ddf674SmrgWARNING: \`$1' is $msg.  You should only need it if
153cacd992dSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
154cacd992dSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
155cacd992dSmrg         any GNU archive site."
156cacd992dSmrg    touch aclocal.m4
157cacd992dSmrg    ;;
158cacd992dSmrg
15914ddf674Smrg  autoconf*)
160cacd992dSmrg    echo 1>&2 "\
16114ddf674SmrgWARNING: \`$1' is $msg.  You should only need it if
162cacd992dSmrg         you modified \`${configure_ac}'.  You might want to install the
163cacd992dSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
164cacd992dSmrg         archive site."
165cacd992dSmrg    touch configure
166cacd992dSmrg    ;;
167cacd992dSmrg
16814ddf674Smrg  autoheader*)
169cacd992dSmrg    echo 1>&2 "\
17014ddf674SmrgWARNING: \`$1' is $msg.  You should only need it if
171cacd992dSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
172cacd992dSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
173cacd992dSmrg         from any GNU archive site."
174cacd992dSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
175cacd992dSmrg    test -z "$files" && files="config.h"
176cacd992dSmrg    touch_files=
177cacd992dSmrg    for f in $files; do
17814ddf674Smrg      case $f in
179cacd992dSmrg      *:*) touch_files="$touch_files "`echo "$f" |
180cacd992dSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
181cacd992dSmrg      *) touch_files="$touch_files $f.in";;
182cacd992dSmrg      esac
183cacd992dSmrg    done
184cacd992dSmrg    touch $touch_files
185cacd992dSmrg    ;;
186cacd992dSmrg
187cacd992dSmrg  automake*)
188cacd992dSmrg    echo 1>&2 "\
18914ddf674SmrgWARNING: \`$1' is $msg.  You should only need it if
190cacd992dSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
191cacd992dSmrg         You might want to install the \`Automake' and \`Perl' packages.
192cacd992dSmrg         Grab them from any GNU archive site."
193cacd992dSmrg    find . -type f -name Makefile.am -print |
194cacd992dSmrg	   sed 's/\.am$/.in/' |
195cacd992dSmrg	   while read f; do touch "$f"; done
196cacd992dSmrg    ;;
197cacd992dSmrg
19814ddf674Smrg  autom4te*)
199cacd992dSmrg    echo 1>&2 "\
20014ddf674SmrgWARNING: \`$1' is needed, but is $msg.
20114ddf674Smrg         You might have modified some files without having the
202cacd992dSmrg         proper tools for further handling them.
203cacd992dSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
204cacd992dSmrg         archive site."
205cacd992dSmrg
20614ddf674Smrg    file=`echo "$*" | sed -n "$sed_output"`
20714ddf674Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
208cacd992dSmrg    if test -f "$file"; then
209cacd992dSmrg	touch $file
210cacd992dSmrg    else
211cacd992dSmrg	test -z "$file" || exec >$file
212cacd992dSmrg	echo "#! /bin/sh"
213cacd992dSmrg	echo "# Created by GNU Automake missing as a replacement of"
214cacd992dSmrg	echo "#  $ $@"
215cacd992dSmrg	echo "exit 0"
216cacd992dSmrg	chmod +x $file
217cacd992dSmrg	exit 1
218cacd992dSmrg    fi
219cacd992dSmrg    ;;
220cacd992dSmrg
22114ddf674Smrg  bison*|yacc*)
222cacd992dSmrg    echo 1>&2 "\
22314ddf674SmrgWARNING: \`$1' $msg.  You should only need it if
224cacd992dSmrg         you modified a \`.y' file.  You may need the \`Bison' package
225cacd992dSmrg         in order for those modifications to take effect.  You can get
226cacd992dSmrg         \`Bison' from any GNU archive site."
227cacd992dSmrg    rm -f y.tab.c y.tab.h
22814ddf674Smrg    if test $# -ne 1; then
229cacd992dSmrg        eval LASTARG="\${$#}"
23014ddf674Smrg	case $LASTARG in
231cacd992dSmrg	*.y)
232cacd992dSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
23314ddf674Smrg	    if test -f "$SRCFILE"; then
234cacd992dSmrg	         cp "$SRCFILE" y.tab.c
235cacd992dSmrg	    fi
236cacd992dSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
23714ddf674Smrg	    if test -f "$SRCFILE"; then
238cacd992dSmrg	         cp "$SRCFILE" y.tab.h
239cacd992dSmrg	    fi
240cacd992dSmrg	  ;;
241cacd992dSmrg	esac
242cacd992dSmrg    fi
24314ddf674Smrg    if test ! -f y.tab.h; then
244cacd992dSmrg	echo >y.tab.h
245cacd992dSmrg    fi
24614ddf674Smrg    if test ! -f y.tab.c; then
247cacd992dSmrg	echo 'main() { return 0; }' >y.tab.c
248cacd992dSmrg    fi
249cacd992dSmrg    ;;
250cacd992dSmrg
25114ddf674Smrg  lex*|flex*)
252cacd992dSmrg    echo 1>&2 "\
25314ddf674SmrgWARNING: \`$1' is $msg.  You should only need it if
254cacd992dSmrg         you modified a \`.l' file.  You may need the \`Flex' package
255cacd992dSmrg         in order for those modifications to take effect.  You can get
256cacd992dSmrg         \`Flex' from any GNU archive site."
257cacd992dSmrg    rm -f lex.yy.c
25814ddf674Smrg    if test $# -ne 1; then
259cacd992dSmrg        eval LASTARG="\${$#}"
26014ddf674Smrg	case $LASTARG in
261cacd992dSmrg	*.l)
262cacd992dSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
26314ddf674Smrg	    if test -f "$SRCFILE"; then
264cacd992dSmrg	         cp "$SRCFILE" lex.yy.c
265cacd992dSmrg	    fi
266cacd992dSmrg	  ;;
267cacd992dSmrg	esac
268cacd992dSmrg    fi
26914ddf674Smrg    if test ! -f lex.yy.c; then
270cacd992dSmrg	echo 'main() { return 0; }' >lex.yy.c
271cacd992dSmrg    fi
272cacd992dSmrg    ;;
273cacd992dSmrg
27414ddf674Smrg  help2man*)
275cacd992dSmrg    echo 1>&2 "\
27614ddf674SmrgWARNING: \`$1' is $msg.  You should only need it if
277cacd992dSmrg	 you modified a dependency of a manual page.  You may need the
278cacd992dSmrg	 \`Help2man' package in order for those modifications to take
279cacd992dSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
280cacd992dSmrg
28114ddf674Smrg    file=`echo "$*" | sed -n "$sed_output"`
28214ddf674Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
28314ddf674Smrg    if test -f "$file"; then
284cacd992dSmrg	touch $file
285cacd992dSmrg    else
286cacd992dSmrg	test -z "$file" || exec >$file
287cacd992dSmrg	echo ".ab help2man is required to generate this page"
28814ddf674Smrg	exit $?
289cacd992dSmrg    fi
290cacd992dSmrg    ;;
291cacd992dSmrg
29214ddf674Smrg  makeinfo*)
293cacd992dSmrg    echo 1>&2 "\
29414ddf674SmrgWARNING: \`$1' is $msg.  You should only need it if
295cacd992dSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
296cacd992dSmrg         indirectly affecting the aspect of the manual.  The spurious
297cacd992dSmrg         call might also be the consequence of using a buggy \`make' (AIX,
298cacd992dSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
299cacd992dSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
30014ddf674Smrg    # The file to touch is that specified with -o ...
30114ddf674Smrg    file=`echo "$*" | sed -n "$sed_output"`
30214ddf674Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
303cacd992dSmrg    if test -z "$file"; then
30414ddf674Smrg      # ... or it is the one specified with @setfilename ...
30514ddf674Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
30614ddf674Smrg      file=`sed -n '
30714ddf674Smrg	/^@setfilename/{
30814ddf674Smrg	  s/.* \([^ ]*\) *$/\1/
30914ddf674Smrg	  p
31014ddf674Smrg	  q
31114ddf674Smrg	}' $infile`
31214ddf674Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
31314ddf674Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
314cacd992dSmrg    fi
31514ddf674Smrg    # If the file does not exist, the user really needs makeinfo;
31614ddf674Smrg    # let's fail without touching anything.
31714ddf674Smrg    test -f $file || exit 1
318cacd992dSmrg    touch $file
319cacd992dSmrg    ;;
320cacd992dSmrg
32114ddf674Smrg  tar*)
322cacd992dSmrg    shift
323cacd992dSmrg
324cacd992dSmrg    # We have already tried tar in the generic part.
325cacd992dSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
326cacd992dSmrg    # messages.
327cacd992dSmrg    if (gnutar --version > /dev/null 2>&1); then
328cacd992dSmrg       gnutar "$@" && exit 0
329cacd992dSmrg    fi
330cacd992dSmrg    if (gtar --version > /dev/null 2>&1); then
331cacd992dSmrg       gtar "$@" && exit 0
332cacd992dSmrg    fi
333cacd992dSmrg    firstarg="$1"
334cacd992dSmrg    if shift; then
33514ddf674Smrg	case $firstarg in
336cacd992dSmrg	*o*)
337cacd992dSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
338cacd992dSmrg	    tar "$firstarg" "$@" && exit 0
339cacd992dSmrg	    ;;
340cacd992dSmrg	esac
34114ddf674Smrg	case $firstarg in
342cacd992dSmrg	*h*)
343cacd992dSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
344cacd992dSmrg	    tar "$firstarg" "$@" && exit 0
345cacd992dSmrg	    ;;
346cacd992dSmrg	esac
347cacd992dSmrg    fi
348cacd992dSmrg
349cacd992dSmrg    echo 1>&2 "\
350cacd992dSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
351cacd992dSmrg         You may want to install GNU tar or Free paxutils, or check the
352cacd992dSmrg         command line arguments."
353cacd992dSmrg    exit 1
354cacd992dSmrg    ;;
355cacd992dSmrg
356cacd992dSmrg  *)
357cacd992dSmrg    echo 1>&2 "\
35814ddf674SmrgWARNING: \`$1' is needed, and is $msg.
35914ddf674Smrg         You might have modified some files without having the
360cacd992dSmrg         proper tools for further handling them.  Check the \`README' file,
361cacd992dSmrg         it often tells you about the needed prerequisites for installing
362cacd992dSmrg         this package.  You may also peek at any GNU archive site, in case
363cacd992dSmrg         some other package would contain this missing \`$1' program."
364cacd992dSmrg    exit 1
365cacd992dSmrg    ;;
366cacd992dSmrgesac
367cacd992dSmrg
368cacd992dSmrgexit 0
36914ddf674Smrg
37014ddf674Smrg# Local variables:
37114ddf674Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
37214ddf674Smrg# time-stamp-start: "scriptversion="
37314ddf674Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
37414ddf674Smrg# time-stamp-time-zone: "UTC"
37514ddf674Smrg# time-stamp-end: "; # UTC"
37614ddf674Smrg# End:
377