missing revision fba89afe
19f606849Smrg#! /bin/sh
29f606849Smrg# Common stub for a few missing GNU programs while installing.
39f606849Smrg
4fba89afeSmrgscriptversion=2009-04-28.21; # UTC
59f606849Smrg
6fba89afeSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
7fba89afeSmrg# 2008, 2009 Free Software Foundation, Inc.
89f606849Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
99f606849Smrg
109f606849Smrg# This program is free software; you can redistribute it and/or modify
119f606849Smrg# it under the terms of the GNU General Public License as published by
129f606849Smrg# the Free Software Foundation; either version 2, or (at your option)
139f606849Smrg# any later version.
149f606849Smrg
159f606849Smrg# This program is distributed in the hope that it will be useful,
169f606849Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
179f606849Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
189f606849Smrg# GNU General Public License for more details.
199f606849Smrg
209f606849Smrg# You should have received a copy of the GNU General Public License
21fba89afeSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
229f606849Smrg
239f606849Smrg# As a special exception to the GNU General Public License, if you
249f606849Smrg# distribute this file as part of a program that contains a
259f606849Smrg# configuration script generated by Autoconf, you may include it under
269f606849Smrg# the same distribution terms that you use for the rest of that program.
279f606849Smrg
289f606849Smrgif test $# -eq 0; then
299f606849Smrg  echo 1>&2 "Try \`$0 --help' for more information"
309f606849Smrg  exit 1
319f606849Smrgfi
329f606849Smrg
339f606849Smrgrun=:
349f606849Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
359f606849Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
369f606849Smrg
379f606849Smrg# In the cases where this matters, `missing' is being run in the
389f606849Smrg# srcdir already.
399f606849Smrgif test -f configure.ac; then
409f606849Smrg  configure_ac=configure.ac
419f606849Smrgelse
429f606849Smrg  configure_ac=configure.in
439f606849Smrgfi
449f606849Smrg
459f606849Smrgmsg="missing on your system"
469f606849Smrg
479f606849Smrgcase $1 in
489f606849Smrg--run)
499f606849Smrg  # Try to run requested program, and just exit if it succeeds.
509f606849Smrg  run=
519f606849Smrg  shift
529f606849Smrg  "$@" && exit 0
539f606849Smrg  # Exit code 63 means version mismatch.  This often happens
549f606849Smrg  # when the user try to use an ancient version of a tool on
559f606849Smrg  # a file that requires a minimum version.  In this case we
569f606849Smrg  # we should proceed has if the program had been absent, or
579f606849Smrg  # if --run hadn't been passed.
589f606849Smrg  if test $? = 63; then
599f606849Smrg    run=:
609f606849Smrg    msg="probably too old"
619f606849Smrg  fi
629f606849Smrg  ;;
639f606849Smrg
649f606849Smrg  -h|--h|--he|--hel|--help)
659f606849Smrg    echo "\
669f606849Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
679f606849Smrg
689f606849SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
699f606849Smrgerror status if there is no known handling for PROGRAM.
709f606849Smrg
719f606849SmrgOptions:
729f606849Smrg  -h, --help      display this help and exit
739f606849Smrg  -v, --version   output version information and exit
749f606849Smrg  --run           try to run the given command, and emulate it if it fails
759f606849Smrg
769f606849SmrgSupported PROGRAM values:
779f606849Smrg  aclocal      touch file \`aclocal.m4'
789f606849Smrg  autoconf     touch file \`configure'
799f606849Smrg  autoheader   touch file \`config.h.in'
809f606849Smrg  autom4te     touch the output file, or create a stub one
819f606849Smrg  automake     touch all \`Makefile.in' files
829f606849Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
839f606849Smrg  flex         create \`lex.yy.c', if possible, from existing .c
849f606849Smrg  help2man     touch the output file
859f606849Smrg  lex          create \`lex.yy.c', if possible, from existing .c
869f606849Smrg  makeinfo     touch the output file
879f606849Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
889f606849Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
899f606849Smrg
90fba89afeSmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
91fba89afeSmrg\`g' are ignored when checking the name.
92fba89afeSmrg
939f606849SmrgSend bug reports to <bug-automake@gnu.org>."
949f606849Smrg    exit $?
959f606849Smrg    ;;
969f606849Smrg
979f606849Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
989f606849Smrg    echo "missing $scriptversion (GNU Automake)"
999f606849Smrg    exit $?
1009f606849Smrg    ;;
1019f606849Smrg
1029f606849Smrg  -*)
1039f606849Smrg    echo 1>&2 "$0: Unknown \`$1' option"
1049f606849Smrg    echo 1>&2 "Try \`$0 --help' for more information"
1059f606849Smrg    exit 1
1069f606849Smrg    ;;
1079f606849Smrg
1089f606849Smrgesac
1099f606849Smrg
110fba89afeSmrg# normalize program name to check for.
111fba89afeSmrgprogram=`echo "$1" | sed '
112fba89afeSmrg  s/^gnu-//; t
113fba89afeSmrg  s/^gnu//; t
114fba89afeSmrg  s/^g//; t'`
115fba89afeSmrg
1169f606849Smrg# Now exit if we have it, but it failed.  Also exit now if we
1179f606849Smrg# don't have it and --version was passed (most likely to detect
118fba89afeSmrg# the program).  This is about non-GNU programs, so use $1 not
119fba89afeSmrg# $program.
1209f606849Smrgcase $1 in
121fba89afeSmrg  lex*|yacc*)
1229f606849Smrg    # Not GNU programs, they don't have --version.
1239f606849Smrg    ;;
1249f606849Smrg
125fba89afeSmrg  tar*)
1269f606849Smrg    if test -n "$run"; then
1279f606849Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
1289f606849Smrg       exit 1
1299f606849Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1309f606849Smrg       exit 1
1319f606849Smrg    fi
1329f606849Smrg    ;;
1339f606849Smrg
1349f606849Smrg  *)
1359f606849Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1369f606849Smrg       # We have it, but it failed.
1379f606849Smrg       exit 1
1389f606849Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1399f606849Smrg       # Could not run --version or --help.  This is probably someone
1409f606849Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1419f606849Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1429f606849Smrg       exit 1
1439f606849Smrg    fi
1449f606849Smrg    ;;
1459f606849Smrgesac
1469f606849Smrg
1479f606849Smrg# If it does not exist, or fails to run (possibly an outdated version),
1489f606849Smrg# try to emulate it.
149fba89afeSmrgcase $program in
1509f606849Smrg  aclocal*)
1519f606849Smrg    echo 1>&2 "\
1529f606849SmrgWARNING: \`$1' is $msg.  You should only need it if
1539f606849Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1549f606849Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1559f606849Smrg         any GNU archive site."
1569f606849Smrg    touch aclocal.m4
1579f606849Smrg    ;;
1589f606849Smrg
159fba89afeSmrg  autoconf*)
1609f606849Smrg    echo 1>&2 "\
1619f606849SmrgWARNING: \`$1' is $msg.  You should only need it if
1629f606849Smrg         you modified \`${configure_ac}'.  You might want to install the
1639f606849Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1649f606849Smrg         archive site."
1659f606849Smrg    touch configure
1669f606849Smrg    ;;
1679f606849Smrg
168fba89afeSmrg  autoheader*)
1699f606849Smrg    echo 1>&2 "\
1709f606849SmrgWARNING: \`$1' is $msg.  You should only need it if
1719f606849Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1729f606849Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1739f606849Smrg         from any GNU archive site."
1749f606849Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1759f606849Smrg    test -z "$files" && files="config.h"
1769f606849Smrg    touch_files=
1779f606849Smrg    for f in $files; do
1789f606849Smrg      case $f in
1799f606849Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1809f606849Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1819f606849Smrg      *) touch_files="$touch_files $f.in";;
1829f606849Smrg      esac
1839f606849Smrg    done
1849f606849Smrg    touch $touch_files
1859f606849Smrg    ;;
1869f606849Smrg
1879f606849Smrg  automake*)
1889f606849Smrg    echo 1>&2 "\
1899f606849SmrgWARNING: \`$1' is $msg.  You should only need it if
1909f606849Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1919f606849Smrg         You might want to install the \`Automake' and \`Perl' packages.
1929f606849Smrg         Grab them from any GNU archive site."
1939f606849Smrg    find . -type f -name Makefile.am -print |
1949f606849Smrg	   sed 's/\.am$/.in/' |
1959f606849Smrg	   while read f; do touch "$f"; done
1969f606849Smrg    ;;
1979f606849Smrg
198fba89afeSmrg  autom4te*)
1999f606849Smrg    echo 1>&2 "\
2009f606849SmrgWARNING: \`$1' is needed, but is $msg.
2019f606849Smrg         You might have modified some files without having the
2029f606849Smrg         proper tools for further handling them.
2039f606849Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
2049f606849Smrg         archive site."
2059f606849Smrg
2069f606849Smrg    file=`echo "$*" | sed -n "$sed_output"`
2079f606849Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2089f606849Smrg    if test -f "$file"; then
2099f606849Smrg	touch $file
2109f606849Smrg    else
2119f606849Smrg	test -z "$file" || exec >$file
2129f606849Smrg	echo "#! /bin/sh"
2139f606849Smrg	echo "# Created by GNU Automake missing as a replacement of"
2149f606849Smrg	echo "#  $ $@"
2159f606849Smrg	echo "exit 0"
2169f606849Smrg	chmod +x $file
2179f606849Smrg	exit 1
2189f606849Smrg    fi
2199f606849Smrg    ;;
2209f606849Smrg
221fba89afeSmrg  bison*|yacc*)
2229f606849Smrg    echo 1>&2 "\
2239f606849SmrgWARNING: \`$1' $msg.  You should only need it if
2249f606849Smrg         you modified a \`.y' file.  You may need the \`Bison' package
2259f606849Smrg         in order for those modifications to take effect.  You can get
2269f606849Smrg         \`Bison' from any GNU archive site."
2279f606849Smrg    rm -f y.tab.c y.tab.h
2289f606849Smrg    if test $# -ne 1; then
2299f606849Smrg        eval LASTARG="\${$#}"
2309f606849Smrg	case $LASTARG in
2319f606849Smrg	*.y)
2329f606849Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2339f606849Smrg	    if test -f "$SRCFILE"; then
2349f606849Smrg	         cp "$SRCFILE" y.tab.c
2359f606849Smrg	    fi
2369f606849Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2379f606849Smrg	    if test -f "$SRCFILE"; then
2389f606849Smrg	         cp "$SRCFILE" y.tab.h
2399f606849Smrg	    fi
2409f606849Smrg	  ;;
2419f606849Smrg	esac
2429f606849Smrg    fi
2439f606849Smrg    if test ! -f y.tab.h; then
2449f606849Smrg	echo >y.tab.h
2459f606849Smrg    fi
2469f606849Smrg    if test ! -f y.tab.c; then
2479f606849Smrg	echo 'main() { return 0; }' >y.tab.c
2489f606849Smrg    fi
2499f606849Smrg    ;;
2509f606849Smrg
251fba89afeSmrg  lex*|flex*)
2529f606849Smrg    echo 1>&2 "\
2539f606849SmrgWARNING: \`$1' is $msg.  You should only need it if
2549f606849Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2559f606849Smrg         in order for those modifications to take effect.  You can get
2569f606849Smrg         \`Flex' from any GNU archive site."
2579f606849Smrg    rm -f lex.yy.c
2589f606849Smrg    if test $# -ne 1; then
2599f606849Smrg        eval LASTARG="\${$#}"
2609f606849Smrg	case $LASTARG in
2619f606849Smrg	*.l)
2629f606849Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2639f606849Smrg	    if test -f "$SRCFILE"; then
2649f606849Smrg	         cp "$SRCFILE" lex.yy.c
2659f606849Smrg	    fi
2669f606849Smrg	  ;;
2679f606849Smrg	esac
2689f606849Smrg    fi
2699f606849Smrg    if test ! -f lex.yy.c; then
2709f606849Smrg	echo 'main() { return 0; }' >lex.yy.c
2719f606849Smrg    fi
2729f606849Smrg    ;;
2739f606849Smrg
274fba89afeSmrg  help2man*)
2759f606849Smrg    echo 1>&2 "\
2769f606849SmrgWARNING: \`$1' is $msg.  You should only need it if
2779f606849Smrg	 you modified a dependency of a manual page.  You may need the
2789f606849Smrg	 \`Help2man' package in order for those modifications to take
2799f606849Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2809f606849Smrg
2819f606849Smrg    file=`echo "$*" | sed -n "$sed_output"`
2829f606849Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2839f606849Smrg    if test -f "$file"; then
2849f606849Smrg	touch $file
2859f606849Smrg    else
2869f606849Smrg	test -z "$file" || exec >$file
2879f606849Smrg	echo ".ab help2man is required to generate this page"
288fba89afeSmrg	exit $?
2899f606849Smrg    fi
2909f606849Smrg    ;;
2919f606849Smrg
292fba89afeSmrg  makeinfo*)
2939f606849Smrg    echo 1>&2 "\
2949f606849SmrgWARNING: \`$1' is $msg.  You should only need it if
2959f606849Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2969f606849Smrg         indirectly affecting the aspect of the manual.  The spurious
2979f606849Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2989f606849Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2999f606849Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
3009f606849Smrg    # The file to touch is that specified with -o ...
3019f606849Smrg    file=`echo "$*" | sed -n "$sed_output"`
3029f606849Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
3039f606849Smrg    if test -z "$file"; then
3049f606849Smrg      # ... or it is the one specified with @setfilename ...
3059f606849Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
3069f606849Smrg      file=`sed -n '
3079f606849Smrg	/^@setfilename/{
3089f606849Smrg	  s/.* \([^ ]*\) *$/\1/
3099f606849Smrg	  p
3109f606849Smrg	  q
3119f606849Smrg	}' $infile`
3129f606849Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3139f606849Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3149f606849Smrg    fi
3159f606849Smrg    # If the file does not exist, the user really needs makeinfo;
3169f606849Smrg    # let's fail without touching anything.
3179f606849Smrg    test -f $file || exit 1
3189f606849Smrg    touch $file
3199f606849Smrg    ;;
3209f606849Smrg
321fba89afeSmrg  tar*)
3229f606849Smrg    shift
3239f606849Smrg
3249f606849Smrg    # We have already tried tar in the generic part.
3259f606849Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
3269f606849Smrg    # messages.
3279f606849Smrg    if (gnutar --version > /dev/null 2>&1); then
3289f606849Smrg       gnutar "$@" && exit 0
3299f606849Smrg    fi
3309f606849Smrg    if (gtar --version > /dev/null 2>&1); then
3319f606849Smrg       gtar "$@" && exit 0
3329f606849Smrg    fi
3339f606849Smrg    firstarg="$1"
3349f606849Smrg    if shift; then
3359f606849Smrg	case $firstarg in
3369f606849Smrg	*o*)
3379f606849Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3389f606849Smrg	    tar "$firstarg" "$@" && exit 0
3399f606849Smrg	    ;;
3409f606849Smrg	esac
3419f606849Smrg	case $firstarg in
3429f606849Smrg	*h*)
3439f606849Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3449f606849Smrg	    tar "$firstarg" "$@" && exit 0
3459f606849Smrg	    ;;
3469f606849Smrg	esac
3479f606849Smrg    fi
3489f606849Smrg
3499f606849Smrg    echo 1>&2 "\
3509f606849SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3519f606849Smrg         You may want to install GNU tar or Free paxutils, or check the
3529f606849Smrg         command line arguments."
3539f606849Smrg    exit 1
3549f606849Smrg    ;;
3559f606849Smrg
3569f606849Smrg  *)
3579f606849Smrg    echo 1>&2 "\
3589f606849SmrgWARNING: \`$1' is needed, and is $msg.
3599f606849Smrg         You might have modified some files without having the
3609f606849Smrg         proper tools for further handling them.  Check the \`README' file,
3619f606849Smrg         it often tells you about the needed prerequisites for installing
3629f606849Smrg         this package.  You may also peek at any GNU archive site, in case
3639f606849Smrg         some other package would contain this missing \`$1' program."
3649f606849Smrg    exit 1
3659f606849Smrg    ;;
3669f606849Smrgesac
3679f606849Smrg
3689f606849Smrgexit 0
3699f606849Smrg
3709f606849Smrg# Local variables:
3719f606849Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3729f606849Smrg# time-stamp-start: "scriptversion="
3739f606849Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
374fba89afeSmrg# time-stamp-time-zone: "UTC"
375fba89afeSmrg# time-stamp-end: "; # UTC"
3769f606849Smrg# End:
377