missing revision 54b44505
14a041c5bSmacallan#! /bin/sh
24a041c5bSmacallan# Common stub for a few missing GNU programs while installing.
34a041c5bSmacallan
454b44505Smrgscriptversion=2012-01-06.18; # UTC
54a041c5bSmacallan
654b44505Smrg# Copyright (C) 1996-2012 Free Software Foundation, Inc.
74a041c5bSmacallan# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
84a041c5bSmacallan
94a041c5bSmacallan# This program is free software; you can redistribute it and/or modify
104a041c5bSmacallan# it under the terms of the GNU General Public License as published by
114a041c5bSmacallan# the Free Software Foundation; either version 2, or (at your option)
124a041c5bSmacallan# any later version.
134a041c5bSmacallan
144a041c5bSmacallan# This program is distributed in the hope that it will be useful,
154a041c5bSmacallan# but WITHOUT ANY WARRANTY; without even the implied warranty of
164a041c5bSmacallan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
174a041c5bSmacallan# GNU General Public License for more details.
184a041c5bSmacallan
194a041c5bSmacallan# You should have received a copy of the GNU General Public License
2054b44505Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
214a041c5bSmacallan
224a041c5bSmacallan# As a special exception to the GNU General Public License, if you
234a041c5bSmacallan# distribute this file as part of a program that contains a
244a041c5bSmacallan# configuration script generated by Autoconf, you may include it under
254a041c5bSmacallan# the same distribution terms that you use for the rest of that program.
264a041c5bSmacallan
274a041c5bSmacallanif test $# -eq 0; then
2854b44505Smrg  echo 1>&2 "Try '$0 --help' for more information"
294a041c5bSmacallan  exit 1
304a041c5bSmacallanfi
314a041c5bSmacallan
324a041c5bSmacallanrun=:
334a041c5bSmacallansed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
344a041c5bSmacallansed_minuso='s/.* -o \([^ ]*\).*/\1/p'
354a041c5bSmacallan
3654b44505Smrg# In the cases where this matters, 'missing' is being run in the
374a041c5bSmacallan# srcdir already.
384a041c5bSmacallanif test -f configure.ac; then
394a041c5bSmacallan  configure_ac=configure.ac
404a041c5bSmacallanelse
414a041c5bSmacallan  configure_ac=configure.in
424a041c5bSmacallanfi
434a041c5bSmacallan
444a041c5bSmacallanmsg="missing on your system"
454a041c5bSmacallan
464a041c5bSmacallancase $1 in
474a041c5bSmacallan--run)
484a041c5bSmacallan  # Try to run requested program, and just exit if it succeeds.
494a041c5bSmacallan  run=
504a041c5bSmacallan  shift
514a041c5bSmacallan  "$@" && exit 0
524a041c5bSmacallan  # Exit code 63 means version mismatch.  This often happens
534a041c5bSmacallan  # when the user try to use an ancient version of a tool on
544a041c5bSmacallan  # a file that requires a minimum version.  In this case we
554a041c5bSmacallan  # we should proceed has if the program had been absent, or
564a041c5bSmacallan  # if --run hadn't been passed.
574a041c5bSmacallan  if test $? = 63; then
584a041c5bSmacallan    run=:
594a041c5bSmacallan    msg="probably too old"
604a041c5bSmacallan  fi
614a041c5bSmacallan  ;;
624a041c5bSmacallan
634a041c5bSmacallan  -h|--h|--he|--hel|--help)
644a041c5bSmacallan    echo "\
654a041c5bSmacallan$0 [OPTION]... PROGRAM [ARGUMENT]...
664a041c5bSmacallan
6754b44505SmrgHandle 'PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
684a041c5bSmacallanerror status if there is no known handling for PROGRAM.
694a041c5bSmacallan
704a041c5bSmacallanOptions:
714a041c5bSmacallan  -h, --help      display this help and exit
724a041c5bSmacallan  -v, --version   output version information and exit
734a041c5bSmacallan  --run           try to run the given command, and emulate it if it fails
744a041c5bSmacallan
754a041c5bSmacallanSupported PROGRAM values:
7654b44505Smrg  aclocal      touch file 'aclocal.m4'
7754b44505Smrg  autoconf     touch file 'configure'
7854b44505Smrg  autoheader   touch file 'config.h.in'
794a041c5bSmacallan  autom4te     touch the output file, or create a stub one
8054b44505Smrg  automake     touch all 'Makefile.in' files
8154b44505Smrg  bison        create 'y.tab.[ch]', if possible, from existing .[ch]
8254b44505Smrg  flex         create 'lex.yy.c', if possible, from existing .c
834a041c5bSmacallan  help2man     touch the output file
8454b44505Smrg  lex          create 'lex.yy.c', if possible, from existing .c
854a041c5bSmacallan  makeinfo     touch the output file
8654b44505Smrg  yacc         create 'y.tab.[ch]', if possible, from existing .[ch]
8754b44505Smrg
8854b44505SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
8954b44505Smrg'g' are ignored when checking the name.
904a041c5bSmacallan
914a041c5bSmacallanSend bug reports to <bug-automake@gnu.org>."
924a041c5bSmacallan    exit $?
934a041c5bSmacallan    ;;
944a041c5bSmacallan
954a041c5bSmacallan  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
964a041c5bSmacallan    echo "missing $scriptversion (GNU Automake)"
974a041c5bSmacallan    exit $?
984a041c5bSmacallan    ;;
994a041c5bSmacallan
1004a041c5bSmacallan  -*)
10154b44505Smrg    echo 1>&2 "$0: Unknown '$1' option"
10254b44505Smrg    echo 1>&2 "Try '$0 --help' for more information"
1034a041c5bSmacallan    exit 1
1044a041c5bSmacallan    ;;
1054a041c5bSmacallan
1064a041c5bSmacallanesac
1074a041c5bSmacallan
10854b44505Smrg# normalize program name to check for.
10954b44505Smrgprogram=`echo "$1" | sed '
11054b44505Smrg  s/^gnu-//; t
11154b44505Smrg  s/^gnu//; t
11254b44505Smrg  s/^g//; t'`
11354b44505Smrg
1144a041c5bSmacallan# Now exit if we have it, but it failed.  Also exit now if we
1154a041c5bSmacallan# don't have it and --version was passed (most likely to detect
11654b44505Smrg# the program).  This is about non-GNU programs, so use $1 not
11754b44505Smrg# $program.
1184a041c5bSmacallancase $1 in
11954b44505Smrg  lex*|yacc*)
1204a041c5bSmacallan    # Not GNU programs, they don't have --version.
1214a041c5bSmacallan    ;;
1224a041c5bSmacallan
1234a041c5bSmacallan  *)
1244a041c5bSmacallan    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1254a041c5bSmacallan       # We have it, but it failed.
1264a041c5bSmacallan       exit 1
1274a041c5bSmacallan    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1284a041c5bSmacallan       # Could not run --version or --help.  This is probably someone
12954b44505Smrg       # running '$TOOL --version' or '$TOOL --help' to check whether
1304a041c5bSmacallan       # $TOOL exists and not knowing $TOOL uses missing.
1314a041c5bSmacallan       exit 1
1324a041c5bSmacallan    fi
1334a041c5bSmacallan    ;;
1344a041c5bSmacallanesac
1354a041c5bSmacallan
1364a041c5bSmacallan# If it does not exist, or fails to run (possibly an outdated version),
1374a041c5bSmacallan# try to emulate it.
13854b44505Smrgcase $program in
1394a041c5bSmacallan  aclocal*)
1404a041c5bSmacallan    echo 1>&2 "\
14154b44505SmrgWARNING: '$1' is $msg.  You should only need it if
14254b44505Smrg         you modified 'acinclude.m4' or '${configure_ac}'.  You might want
14354b44505Smrg         to install the Automake and Perl packages.  Grab them from
1444a041c5bSmacallan         any GNU archive site."
1454a041c5bSmacallan    touch aclocal.m4
1464a041c5bSmacallan    ;;
1474a041c5bSmacallan
14854b44505Smrg  autoconf*)
1494a041c5bSmacallan    echo 1>&2 "\
15054b44505SmrgWARNING: '$1' is $msg.  You should only need it if
15154b44505Smrg         you modified '${configure_ac}'.  You might want to install the
15254b44505Smrg         Autoconf and GNU m4 packages.  Grab them from any GNU
1534a041c5bSmacallan         archive site."
1544a041c5bSmacallan    touch configure
1554a041c5bSmacallan    ;;
1564a041c5bSmacallan
15754b44505Smrg  autoheader*)
1584a041c5bSmacallan    echo 1>&2 "\
15954b44505SmrgWARNING: '$1' is $msg.  You should only need it if
16054b44505Smrg         you modified 'acconfig.h' or '${configure_ac}'.  You might want
16154b44505Smrg         to install the Autoconf and GNU m4 packages.  Grab them
1624a041c5bSmacallan         from any GNU archive site."
1634a041c5bSmacallan    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1644a041c5bSmacallan    test -z "$files" && files="config.h"
1654a041c5bSmacallan    touch_files=
1664a041c5bSmacallan    for f in $files; do
1674a041c5bSmacallan      case $f in
1684a041c5bSmacallan      *:*) touch_files="$touch_files "`echo "$f" |
1694a041c5bSmacallan				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1704a041c5bSmacallan      *) touch_files="$touch_files $f.in";;
1714a041c5bSmacallan      esac
1724a041c5bSmacallan    done
1734a041c5bSmacallan    touch $touch_files
1744a041c5bSmacallan    ;;
1754a041c5bSmacallan
1764a041c5bSmacallan  automake*)
1774a041c5bSmacallan    echo 1>&2 "\
17854b44505SmrgWARNING: '$1' is $msg.  You should only need it if
17954b44505Smrg         you modified 'Makefile.am', 'acinclude.m4' or '${configure_ac}'.
18054b44505Smrg         You might want to install the Automake and Perl packages.
1814a041c5bSmacallan         Grab them from any GNU archive site."
1824a041c5bSmacallan    find . -type f -name Makefile.am -print |
1834a041c5bSmacallan	   sed 's/\.am$/.in/' |
1844a041c5bSmacallan	   while read f; do touch "$f"; done
1854a041c5bSmacallan    ;;
1864a041c5bSmacallan
18754b44505Smrg  autom4te*)
1884a041c5bSmacallan    echo 1>&2 "\
18954b44505SmrgWARNING: '$1' is needed, but is $msg.
1904a041c5bSmacallan         You might have modified some files without having the
1914a041c5bSmacallan         proper tools for further handling them.
19254b44505Smrg         You can get '$1' as part of Autoconf from any GNU
1934a041c5bSmacallan         archive site."
1944a041c5bSmacallan
1954a041c5bSmacallan    file=`echo "$*" | sed -n "$sed_output"`
1964a041c5bSmacallan    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
1974a041c5bSmacallan    if test -f "$file"; then
1984a041c5bSmacallan	touch $file
1994a041c5bSmacallan    else
2004a041c5bSmacallan	test -z "$file" || exec >$file
2014a041c5bSmacallan	echo "#! /bin/sh"
2024a041c5bSmacallan	echo "# Created by GNU Automake missing as a replacement of"
2034a041c5bSmacallan	echo "#  $ $@"
2044a041c5bSmacallan	echo "exit 0"
2054a041c5bSmacallan	chmod +x $file
2064a041c5bSmacallan	exit 1
2074a041c5bSmacallan    fi
2084a041c5bSmacallan    ;;
2094a041c5bSmacallan
21054b44505Smrg  bison*|yacc*)
2114a041c5bSmacallan    echo 1>&2 "\
21254b44505SmrgWARNING: '$1' $msg.  You should only need it if
21354b44505Smrg         you modified a '.y' file.  You may need the Bison package
2144a041c5bSmacallan         in order for those modifications to take effect.  You can get
21554b44505Smrg         Bison from any GNU archive site."
2164a041c5bSmacallan    rm -f y.tab.c y.tab.h
2174a041c5bSmacallan    if test $# -ne 1; then
21854b44505Smrg        eval LASTARG=\${$#}
2194a041c5bSmacallan	case $LASTARG in
2204a041c5bSmacallan	*.y)
2214a041c5bSmacallan	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2224a041c5bSmacallan	    if test -f "$SRCFILE"; then
2234a041c5bSmacallan	         cp "$SRCFILE" y.tab.c
2244a041c5bSmacallan	    fi
2254a041c5bSmacallan	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2264a041c5bSmacallan	    if test -f "$SRCFILE"; then
2274a041c5bSmacallan	         cp "$SRCFILE" y.tab.h
2284a041c5bSmacallan	    fi
2294a041c5bSmacallan	  ;;
2304a041c5bSmacallan	esac
2314a041c5bSmacallan    fi
2324a041c5bSmacallan    if test ! -f y.tab.h; then
2334a041c5bSmacallan	echo >y.tab.h
2344a041c5bSmacallan    fi
2354a041c5bSmacallan    if test ! -f y.tab.c; then
2364a041c5bSmacallan	echo 'main() { return 0; }' >y.tab.c
2374a041c5bSmacallan    fi
2384a041c5bSmacallan    ;;
2394a041c5bSmacallan
24054b44505Smrg  lex*|flex*)
2414a041c5bSmacallan    echo 1>&2 "\
24254b44505SmrgWARNING: '$1' is $msg.  You should only need it if
24354b44505Smrg         you modified a '.l' file.  You may need the Flex package
2444a041c5bSmacallan         in order for those modifications to take effect.  You can get
24554b44505Smrg         Flex from any GNU archive site."
2464a041c5bSmacallan    rm -f lex.yy.c
2474a041c5bSmacallan    if test $# -ne 1; then
24854b44505Smrg        eval LASTARG=\${$#}
2494a041c5bSmacallan	case $LASTARG in
2504a041c5bSmacallan	*.l)
2514a041c5bSmacallan	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2524a041c5bSmacallan	    if test -f "$SRCFILE"; then
2534a041c5bSmacallan	         cp "$SRCFILE" lex.yy.c
2544a041c5bSmacallan	    fi
2554a041c5bSmacallan	  ;;
2564a041c5bSmacallan	esac
2574a041c5bSmacallan    fi
2584a041c5bSmacallan    if test ! -f lex.yy.c; then
2594a041c5bSmacallan	echo 'main() { return 0; }' >lex.yy.c
2604a041c5bSmacallan    fi
2614a041c5bSmacallan    ;;
2624a041c5bSmacallan
26354b44505Smrg  help2man*)
2644a041c5bSmacallan    echo 1>&2 "\
26554b44505SmrgWARNING: '$1' is $msg.  You should only need it if
2664a041c5bSmacallan	 you modified a dependency of a manual page.  You may need the
26754b44505Smrg	 Help2man package in order for those modifications to take
26854b44505Smrg	 effect.  You can get Help2man from any GNU archive site."
2694a041c5bSmacallan
2704a041c5bSmacallan    file=`echo "$*" | sed -n "$sed_output"`
2714a041c5bSmacallan    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2724a041c5bSmacallan    if test -f "$file"; then
2734a041c5bSmacallan	touch $file
2744a041c5bSmacallan    else
2754a041c5bSmacallan	test -z "$file" || exec >$file
2764a041c5bSmacallan	echo ".ab help2man is required to generate this page"
27754b44505Smrg	exit $?
2784a041c5bSmacallan    fi
2794a041c5bSmacallan    ;;
2804a041c5bSmacallan
28154b44505Smrg  makeinfo*)
2824a041c5bSmacallan    echo 1>&2 "\
28354b44505SmrgWARNING: '$1' is $msg.  You should only need it if
28454b44505Smrg         you modified a '.texi' or '.texinfo' file, or any other file
2854a041c5bSmacallan         indirectly affecting the aspect of the manual.  The spurious
28654b44505Smrg         call might also be the consequence of using a buggy 'make' (AIX,
28754b44505Smrg         DU, IRIX).  You might want to install the Texinfo package or
28854b44505Smrg         the GNU make package.  Grab either from any GNU archive site."
2894a041c5bSmacallan    # The file to touch is that specified with -o ...
2904a041c5bSmacallan    file=`echo "$*" | sed -n "$sed_output"`
2914a041c5bSmacallan    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2924a041c5bSmacallan    if test -z "$file"; then
2934a041c5bSmacallan      # ... or it is the one specified with @setfilename ...
2944a041c5bSmacallan      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2954a041c5bSmacallan      file=`sed -n '
2964a041c5bSmacallan	/^@setfilename/{
2974a041c5bSmacallan	  s/.* \([^ ]*\) *$/\1/
2984a041c5bSmacallan	  p
2994a041c5bSmacallan	  q
3004a041c5bSmacallan	}' $infile`
3014a041c5bSmacallan      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3024a041c5bSmacallan      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3034a041c5bSmacallan    fi
3044a041c5bSmacallan    # If the file does not exist, the user really needs makeinfo;
3054a041c5bSmacallan    # let's fail without touching anything.
3064a041c5bSmacallan    test -f $file || exit 1
3074a041c5bSmacallan    touch $file
3084a041c5bSmacallan    ;;
3094a041c5bSmacallan
3104a041c5bSmacallan  *)
3114a041c5bSmacallan    echo 1>&2 "\
31254b44505SmrgWARNING: '$1' is needed, and is $msg.
3134a041c5bSmacallan         You might have modified some files without having the
31454b44505Smrg         proper tools for further handling them.  Check the 'README' file,
3154a041c5bSmacallan         it often tells you about the needed prerequisites for installing
3164a041c5bSmacallan         this package.  You may also peek at any GNU archive site, in case
31754b44505Smrg         some other package would contain this missing '$1' program."
3184a041c5bSmacallan    exit 1
3194a041c5bSmacallan    ;;
3204a041c5bSmacallanesac
3214a041c5bSmacallan
3224a041c5bSmacallanexit 0
3234a041c5bSmacallan
3244a041c5bSmacallan# Local variables:
3254a041c5bSmacallan# eval: (add-hook 'write-file-hooks 'time-stamp)
3264a041c5bSmacallan# time-stamp-start: "scriptversion="
3274a041c5bSmacallan# time-stamp-format: "%:y-%02m-%02d.%02H"
32854b44505Smrg# time-stamp-time-zone: "UTC"
32954b44505Smrg# time-stamp-end: "; # UTC"
3304a041c5bSmacallan# End:
331