missing revision 7821949a
1de2362d3Smrg#! /bin/sh
27821949aSmrg# Common stub for a few missing GNU programs while installing.
3de2362d3Smrg
47821949aSmrgscriptversion=2009-04-28.21; # UTC
5de2362d3Smrg
67821949aSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
77821949aSmrg# 2008, 2009 Free Software Foundation, Inc.
87821949aSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9de2362d3Smrg
10de2362d3Smrg# This program is free software; you can redistribute it and/or modify
11de2362d3Smrg# it under the terms of the GNU General Public License as published by
12de2362d3Smrg# the Free Software Foundation; either version 2, or (at your option)
13de2362d3Smrg# any later version.
14de2362d3Smrg
15de2362d3Smrg# This program is distributed in the hope that it will be useful,
16de2362d3Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17de2362d3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18de2362d3Smrg# GNU General Public License for more details.
19de2362d3Smrg
20de2362d3Smrg# You should have received a copy of the GNU General Public License
210d16fef4Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22de2362d3Smrg
23de2362d3Smrg# As a special exception to the GNU General Public License, if you
24de2362d3Smrg# distribute this file as part of a program that contains a
25de2362d3Smrg# configuration script generated by Autoconf, you may include it under
26de2362d3Smrg# the same distribution terms that you use for the rest of that program.
27de2362d3Smrg
28de2362d3Smrgif test $# -eq 0; then
297821949aSmrg  echo 1>&2 "Try \`$0 --help' for more information"
30de2362d3Smrg  exit 1
31de2362d3Smrgfi
32de2362d3Smrg
337821949aSmrgrun=:
347821949aSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
357821949aSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
36de2362d3Smrg
377821949aSmrg# In the cases where this matters, `missing' is being run in the
387821949aSmrg# srcdir already.
397821949aSmrgif test -f configure.ac; then
407821949aSmrg  configure_ac=configure.ac
417821949aSmrgelse
427821949aSmrg  configure_ac=configure.in
437821949aSmrgfi
44de2362d3Smrg
457821949aSmrgmsg="missing on your system"
467821949aSmrg
477821949aSmrgcase $1 in
487821949aSmrg--run)
497821949aSmrg  # Try to run requested program, and just exit if it succeeds.
507821949aSmrg  run=
517821949aSmrg  shift
527821949aSmrg  "$@" && exit 0
537821949aSmrg  # Exit code 63 means version mismatch.  This often happens
547821949aSmrg  # when the user try to use an ancient version of a tool on
557821949aSmrg  # a file that requires a minimum version.  In this case we
567821949aSmrg  # we should proceed has if the program had been absent, or
577821949aSmrg  # if --run hadn't been passed.
587821949aSmrg  if test $? = 63; then
597821949aSmrg    run=:
607821949aSmrg    msg="probably too old"
617821949aSmrg  fi
627821949aSmrg  ;;
63de2362d3Smrg
64de2362d3Smrg  -h|--h|--he|--hel|--help)
65de2362d3Smrg    echo "\
66de2362d3Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
67de2362d3Smrg
687821949aSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
697821949aSmrgerror status if there is no known handling for PROGRAM.
70de2362d3Smrg
71de2362d3SmrgOptions:
72de2362d3Smrg  -h, --help      display this help and exit
73de2362d3Smrg  -v, --version   output version information and exit
747821949aSmrg  --run           try to run the given command, and emulate it if it fails
75de2362d3Smrg
76de2362d3SmrgSupported PROGRAM values:
777821949aSmrg  aclocal      touch file \`aclocal.m4'
787821949aSmrg  autoconf     touch file \`configure'
797821949aSmrg  autoheader   touch file \`config.h.in'
807821949aSmrg  autom4te     touch the output file, or create a stub one
817821949aSmrg  automake     touch all \`Makefile.in' files
827821949aSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
837821949aSmrg  flex         create \`lex.yy.c', if possible, from existing .c
847821949aSmrg  help2man     touch the output file
857821949aSmrg  lex          create \`lex.yy.c', if possible, from existing .c
867821949aSmrg  makeinfo     touch the output file
877821949aSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
887821949aSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
890d16fef4Smrg
907821949aSmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
917821949aSmrg\`g' are ignored when checking the name.
92de2362d3Smrg
93de2362d3SmrgSend bug reports to <bug-automake@gnu.org>."
94de2362d3Smrg    exit $?
95de2362d3Smrg    ;;
96de2362d3Smrg
97de2362d3Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
98de2362d3Smrg    echo "missing $scriptversion (GNU Automake)"
99de2362d3Smrg    exit $?
100de2362d3Smrg    ;;
101de2362d3Smrg
102de2362d3Smrg  -*)
1037821949aSmrg    echo 1>&2 "$0: Unknown \`$1' option"
1047821949aSmrg    echo 1>&2 "Try \`$0 --help' for more information"
105de2362d3Smrg    exit 1
106de2362d3Smrg    ;;
107de2362d3Smrg
108de2362d3Smrgesac
109de2362d3Smrg
1107821949aSmrg# normalize program name to check for.
1117821949aSmrgprogram=`echo "$1" | sed '
1127821949aSmrg  s/^gnu-//; t
1137821949aSmrg  s/^gnu//; t
1147821949aSmrg  s/^g//; t'`
1157821949aSmrg
1167821949aSmrg# Now exit if we have it, but it failed.  Also exit now if we
1177821949aSmrg# don't have it and --version was passed (most likely to detect
1187821949aSmrg# the program).  This is about non-GNU programs, so use $1 not
1197821949aSmrg# $program.
1207821949aSmrgcase $1 in
1217821949aSmrg  lex*|yacc*)
1227821949aSmrg    # Not GNU programs, they don't have --version.
1237821949aSmrg    ;;
1247821949aSmrg
1257821949aSmrg  tar*)
1267821949aSmrg    if test -n "$run"; then
1277821949aSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
1287821949aSmrg       exit 1
1297821949aSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1307821949aSmrg       exit 1
1317821949aSmrg    fi
1327821949aSmrg    ;;
1337821949aSmrg
1347821949aSmrg  *)
1357821949aSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1367821949aSmrg       # We have it, but it failed.
1377821949aSmrg       exit 1
1387821949aSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1397821949aSmrg       # Could not run --version or --help.  This is probably someone
1407821949aSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1417821949aSmrg       # $TOOL exists and not knowing $TOOL uses missing.
1427821949aSmrg       exit 1
1437821949aSmrg    fi
1447821949aSmrg    ;;
1457821949aSmrgesac
1467821949aSmrg
1477821949aSmrg# If it does not exist, or fails to run (possibly an outdated version),
1487821949aSmrg# try to emulate it.
1497821949aSmrgcase $program in
1507821949aSmrg  aclocal*)
1517821949aSmrg    echo 1>&2 "\
1527821949aSmrgWARNING: \`$1' is $msg.  You should only need it if
1537821949aSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1547821949aSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1557821949aSmrg         any GNU archive site."
1567821949aSmrg    touch aclocal.m4
1577821949aSmrg    ;;
1587821949aSmrg
1597821949aSmrg  autoconf*)
1607821949aSmrg    echo 1>&2 "\
1617821949aSmrgWARNING: \`$1' is $msg.  You should only need it if
1627821949aSmrg         you modified \`${configure_ac}'.  You might want to install the
1637821949aSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1647821949aSmrg         archive site."
1657821949aSmrg    touch configure
1667821949aSmrg    ;;
1677821949aSmrg
1687821949aSmrg  autoheader*)
1697821949aSmrg    echo 1>&2 "\
1707821949aSmrgWARNING: \`$1' is $msg.  You should only need it if
1717821949aSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1727821949aSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1737821949aSmrg         from any GNU archive site."
1747821949aSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1757821949aSmrg    test -z "$files" && files="config.h"
1767821949aSmrg    touch_files=
1777821949aSmrg    for f in $files; do
1787821949aSmrg      case $f in
1797821949aSmrg      *:*) touch_files="$touch_files "`echo "$f" |
1807821949aSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1817821949aSmrg      *) touch_files="$touch_files $f.in";;
1827821949aSmrg      esac
1837821949aSmrg    done
1847821949aSmrg    touch $touch_files
1857821949aSmrg    ;;
1867821949aSmrg
1877821949aSmrg  automake*)
1887821949aSmrg    echo 1>&2 "\
1897821949aSmrgWARNING: \`$1' is $msg.  You should only need it if
1907821949aSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1917821949aSmrg         You might want to install the \`Automake' and \`Perl' packages.
1927821949aSmrg         Grab them from any GNU archive site."
1937821949aSmrg    find . -type f -name Makefile.am -print |
1947821949aSmrg	   sed 's/\.am$/.in/' |
1957821949aSmrg	   while read f; do touch "$f"; done
1967821949aSmrg    ;;
1977821949aSmrg
1987821949aSmrg  autom4te*)
1997821949aSmrg    echo 1>&2 "\
2007821949aSmrgWARNING: \`$1' is needed, but is $msg.
2017821949aSmrg         You might have modified some files without having the
2027821949aSmrg         proper tools for further handling them.
2037821949aSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
2047821949aSmrg         archive site."
2057821949aSmrg
2067821949aSmrg    file=`echo "$*" | sed -n "$sed_output"`
2077821949aSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2087821949aSmrg    if test -f "$file"; then
2097821949aSmrg	touch $file
2107821949aSmrg    else
2117821949aSmrg	test -z "$file" || exec >$file
2127821949aSmrg	echo "#! /bin/sh"
2137821949aSmrg	echo "# Created by GNU Automake missing as a replacement of"
2147821949aSmrg	echo "#  $ $@"
2157821949aSmrg	echo "exit 0"
2167821949aSmrg	chmod +x $file
2177821949aSmrg	exit 1
2187821949aSmrg    fi
2197821949aSmrg    ;;
2207821949aSmrg
2217821949aSmrg  bison*|yacc*)
2227821949aSmrg    echo 1>&2 "\
2237821949aSmrgWARNING: \`$1' $msg.  You should only need it if
2247821949aSmrg         you modified a \`.y' file.  You may need the \`Bison' package
2257821949aSmrg         in order for those modifications to take effect.  You can get
2267821949aSmrg         \`Bison' from any GNU archive site."
2277821949aSmrg    rm -f y.tab.c y.tab.h
2287821949aSmrg    if test $# -ne 1; then
2297821949aSmrg        eval LASTARG="\${$#}"
2307821949aSmrg	case $LASTARG in
2317821949aSmrg	*.y)
2327821949aSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2337821949aSmrg	    if test -f "$SRCFILE"; then
2347821949aSmrg	         cp "$SRCFILE" y.tab.c
2357821949aSmrg	    fi
2367821949aSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2377821949aSmrg	    if test -f "$SRCFILE"; then
2387821949aSmrg	         cp "$SRCFILE" y.tab.h
2397821949aSmrg	    fi
2407821949aSmrg	  ;;
2417821949aSmrg	esac
2427821949aSmrg    fi
2437821949aSmrg    if test ! -f y.tab.h; then
2447821949aSmrg	echo >y.tab.h
2457821949aSmrg    fi
2467821949aSmrg    if test ! -f y.tab.c; then
2477821949aSmrg	echo 'main() { return 0; }' >y.tab.c
2487821949aSmrg    fi
2497821949aSmrg    ;;
2507821949aSmrg
2517821949aSmrg  lex*|flex*)
2527821949aSmrg    echo 1>&2 "\
2537821949aSmrgWARNING: \`$1' is $msg.  You should only need it if
2547821949aSmrg         you modified a \`.l' file.  You may need the \`Flex' package
2557821949aSmrg         in order for those modifications to take effect.  You can get
2567821949aSmrg         \`Flex' from any GNU archive site."
2577821949aSmrg    rm -f lex.yy.c
2587821949aSmrg    if test $# -ne 1; then
2597821949aSmrg        eval LASTARG="\${$#}"
2607821949aSmrg	case $LASTARG in
2617821949aSmrg	*.l)
2627821949aSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2637821949aSmrg	    if test -f "$SRCFILE"; then
2647821949aSmrg	         cp "$SRCFILE" lex.yy.c
2657821949aSmrg	    fi
2667821949aSmrg	  ;;
2677821949aSmrg	esac
2687821949aSmrg    fi
2697821949aSmrg    if test ! -f lex.yy.c; then
2707821949aSmrg	echo 'main() { return 0; }' >lex.yy.c
2717821949aSmrg    fi
2727821949aSmrg    ;;
2737821949aSmrg
2747821949aSmrg  help2man*)
2757821949aSmrg    echo 1>&2 "\
2767821949aSmrgWARNING: \`$1' is $msg.  You should only need it if
2777821949aSmrg	 you modified a dependency of a manual page.  You may need the
2787821949aSmrg	 \`Help2man' package in order for those modifications to take
2797821949aSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
2807821949aSmrg
2817821949aSmrg    file=`echo "$*" | sed -n "$sed_output"`
2827821949aSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2837821949aSmrg    if test -f "$file"; then
2847821949aSmrg	touch $file
2857821949aSmrg    else
2867821949aSmrg	test -z "$file" || exec >$file
2877821949aSmrg	echo ".ab help2man is required to generate this page"
2887821949aSmrg	exit $?
2897821949aSmrg    fi
2907821949aSmrg    ;;
2917821949aSmrg
2927821949aSmrg  makeinfo*)
2937821949aSmrg    echo 1>&2 "\
2947821949aSmrgWARNING: \`$1' is $msg.  You should only need it if
2957821949aSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2967821949aSmrg         indirectly affecting the aspect of the manual.  The spurious
2977821949aSmrg         call might also be the consequence of using a buggy \`make' (AIX,
2987821949aSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2997821949aSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
3007821949aSmrg    # The file to touch is that specified with -o ...
3017821949aSmrg    file=`echo "$*" | sed -n "$sed_output"`
3027821949aSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
3037821949aSmrg    if test -z "$file"; then
3047821949aSmrg      # ... or it is the one specified with @setfilename ...
3057821949aSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
3067821949aSmrg      file=`sed -n '
3077821949aSmrg	/^@setfilename/{
3087821949aSmrg	  s/.* \([^ ]*\) *$/\1/
3097821949aSmrg	  p
3107821949aSmrg	  q
3117821949aSmrg	}' $infile`
3127821949aSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3137821949aSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3147821949aSmrg    fi
3157821949aSmrg    # If the file does not exist, the user really needs makeinfo;
3167821949aSmrg    # let's fail without touching anything.
3177821949aSmrg    test -f $file || exit 1
3187821949aSmrg    touch $file
3197821949aSmrg    ;;
3207821949aSmrg
3217821949aSmrg  tar*)
3227821949aSmrg    shift
3237821949aSmrg
3247821949aSmrg    # We have already tried tar in the generic part.
3257821949aSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
3267821949aSmrg    # messages.
3277821949aSmrg    if (gnutar --version > /dev/null 2>&1); then
3287821949aSmrg       gnutar "$@" && exit 0
3297821949aSmrg    fi
3307821949aSmrg    if (gtar --version > /dev/null 2>&1); then
3317821949aSmrg       gtar "$@" && exit 0
3327821949aSmrg    fi
3337821949aSmrg    firstarg="$1"
3347821949aSmrg    if shift; then
3357821949aSmrg	case $firstarg in
3367821949aSmrg	*o*)
3377821949aSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
3387821949aSmrg	    tar "$firstarg" "$@" && exit 0
3397821949aSmrg	    ;;
3407821949aSmrg	esac
3417821949aSmrg	case $firstarg in
3427821949aSmrg	*h*)
3437821949aSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
3447821949aSmrg	    tar "$firstarg" "$@" && exit 0
3457821949aSmrg	    ;;
3467821949aSmrg	esac
3477821949aSmrg    fi
3487821949aSmrg
3497821949aSmrg    echo 1>&2 "\
3507821949aSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3517821949aSmrg         You may want to install GNU tar or Free paxutils, or check the
3527821949aSmrg         command line arguments."
3537821949aSmrg    exit 1
3547821949aSmrg    ;;
3557821949aSmrg
3567821949aSmrg  *)
3577821949aSmrg    echo 1>&2 "\
3587821949aSmrgWARNING: \`$1' is needed, and is $msg.
3597821949aSmrg         You might have modified some files without having the
3607821949aSmrg         proper tools for further handling them.  Check the \`README' file,
3617821949aSmrg         it often tells you about the needed prerequisites for installing
3627821949aSmrg         this package.  You may also peek at any GNU archive site, in case
3637821949aSmrg         some other package would contain this missing \`$1' program."
3647821949aSmrg    exit 1
3657821949aSmrg    ;;
3667821949aSmrgesac
367de2362d3Smrg
3687821949aSmrgexit 0
369de2362d3Smrg
370de2362d3Smrg# Local variables:
371de2362d3Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
372de2362d3Smrg# time-stamp-start: "scriptversion="
373de2362d3Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3740d16fef4Smrg# time-stamp-time-zone: "UTC"
3750d16fef4Smrg# time-stamp-end: "; # UTC"
376de2362d3Smrg# End:
377