missing revision c9710b42
12c393a42Smrg#! /bin/sh
22c393a42Smrg# Common stub for a few missing GNU programs while installing.
32c393a42Smrg
4c9710b42Smrgscriptversion=2012-01-06.18; # UTC
52c393a42Smrg
6c9710b42Smrg# Copyright (C) 1996-2012 Free Software Foundation, Inc.
72c393a42Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
82c393a42Smrg
92c393a42Smrg# This program is free software; you can redistribute it and/or modify
102c393a42Smrg# it under the terms of the GNU General Public License as published by
112c393a42Smrg# the Free Software Foundation; either version 2, or (at your option)
122c393a42Smrg# any later version.
132c393a42Smrg
142c393a42Smrg# This program is distributed in the hope that it will be useful,
152c393a42Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
162c393a42Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
172c393a42Smrg# GNU General Public License for more details.
182c393a42Smrg
192c393a42Smrg# You should have received a copy of the GNU General Public License
20a6844aabSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
212c393a42Smrg
222c393a42Smrg# As a special exception to the GNU General Public License, if you
232c393a42Smrg# distribute this file as part of a program that contains a
242c393a42Smrg# configuration script generated by Autoconf, you may include it under
252c393a42Smrg# the same distribution terms that you use for the rest of that program.
262c393a42Smrg
272c393a42Smrgif test $# -eq 0; then
28c9710b42Smrg  echo 1>&2 "Try '$0 --help' for more information"
292c393a42Smrg  exit 1
302c393a42Smrgfi
312c393a42Smrg
322c393a42Smrgrun=:
33a6844aabSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
34a6844aabSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
352c393a42Smrg
36c9710b42Smrg# In the cases where this matters, 'missing' is being run in the
372c393a42Smrg# srcdir already.
382c393a42Smrgif test -f configure.ac; then
392c393a42Smrg  configure_ac=configure.ac
402c393a42Smrgelse
412c393a42Smrg  configure_ac=configure.in
422c393a42Smrgfi
432c393a42Smrg
442c393a42Smrgmsg="missing on your system"
452c393a42Smrg
46a6844aabSmrgcase $1 in
472c393a42Smrg--run)
482c393a42Smrg  # Try to run requested program, and just exit if it succeeds.
492c393a42Smrg  run=
502c393a42Smrg  shift
512c393a42Smrg  "$@" && exit 0
522c393a42Smrg  # Exit code 63 means version mismatch.  This often happens
532c393a42Smrg  # when the user try to use an ancient version of a tool on
542c393a42Smrg  # a file that requires a minimum version.  In this case we
552c393a42Smrg  # we should proceed has if the program had been absent, or
562c393a42Smrg  # if --run hadn't been passed.
572c393a42Smrg  if test $? = 63; then
582c393a42Smrg    run=:
592c393a42Smrg    msg="probably too old"
602c393a42Smrg  fi
612c393a42Smrg  ;;
622c393a42Smrg
632c393a42Smrg  -h|--h|--he|--hel|--help)
642c393a42Smrg    echo "\
652c393a42Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
662c393a42Smrg
67c9710b42SmrgHandle 'PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
682c393a42Smrgerror status if there is no known handling for PROGRAM.
692c393a42Smrg
702c393a42SmrgOptions:
712c393a42Smrg  -h, --help      display this help and exit
722c393a42Smrg  -v, --version   output version information and exit
732c393a42Smrg  --run           try to run the given command, and emulate it if it fails
742c393a42Smrg
752c393a42SmrgSupported PROGRAM values:
76c9710b42Smrg  aclocal      touch file 'aclocal.m4'
77c9710b42Smrg  autoconf     touch file 'configure'
78c9710b42Smrg  autoheader   touch file 'config.h.in'
79a6844aabSmrg  autom4te     touch the output file, or create a stub one
80c9710b42Smrg  automake     touch all 'Makefile.in' files
81c9710b42Smrg  bison        create 'y.tab.[ch]', if possible, from existing .[ch]
82c9710b42Smrg  flex         create 'lex.yy.c', if possible, from existing .c
832c393a42Smrg  help2man     touch the output file
84c9710b42Smrg  lex          create 'lex.yy.c', if possible, from existing .c
852c393a42Smrg  makeinfo     touch the output file
86c9710b42Smrg  yacc         create 'y.tab.[ch]', if possible, from existing .[ch]
872c393a42Smrg
88c9710b42SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
89c9710b42Smrg'g' are ignored when checking the name.
90a6844aabSmrg
912c393a42SmrgSend bug reports to <bug-automake@gnu.org>."
922c393a42Smrg    exit $?
932c393a42Smrg    ;;
942c393a42Smrg
952c393a42Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
962c393a42Smrg    echo "missing $scriptversion (GNU Automake)"
972c393a42Smrg    exit $?
982c393a42Smrg    ;;
992c393a42Smrg
1002c393a42Smrg  -*)
101c9710b42Smrg    echo 1>&2 "$0: Unknown '$1' option"
102c9710b42Smrg    echo 1>&2 "Try '$0 --help' for more information"
1032c393a42Smrg    exit 1
1042c393a42Smrg    ;;
1052c393a42Smrg
1062c393a42Smrgesac
1072c393a42Smrg
108a6844aabSmrg# normalize program name to check for.
109a6844aabSmrgprogram=`echo "$1" | sed '
110a6844aabSmrg  s/^gnu-//; t
111a6844aabSmrg  s/^gnu//; t
112a6844aabSmrg  s/^g//; t'`
113a6844aabSmrg
1142c393a42Smrg# Now exit if we have it, but it failed.  Also exit now if we
1152c393a42Smrg# don't have it and --version was passed (most likely to detect
116a6844aabSmrg# the program).  This is about non-GNU programs, so use $1 not
117a6844aabSmrg# $program.
118a6844aabSmrgcase $1 in
119a6844aabSmrg  lex*|yacc*)
1202c393a42Smrg    # Not GNU programs, they don't have --version.
1212c393a42Smrg    ;;
1222c393a42Smrg
1232c393a42Smrg  *)
1242c393a42Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1252c393a42Smrg       # We have it, but it failed.
1262c393a42Smrg       exit 1
1272c393a42Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1282c393a42Smrg       # Could not run --version or --help.  This is probably someone
129c9710b42Smrg       # running '$TOOL --version' or '$TOOL --help' to check whether
1302c393a42Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1312c393a42Smrg       exit 1
1322c393a42Smrg    fi
1332c393a42Smrg    ;;
1342c393a42Smrgesac
1352c393a42Smrg
1362c393a42Smrg# If it does not exist, or fails to run (possibly an outdated version),
1372c393a42Smrg# try to emulate it.
138a6844aabSmrgcase $program in
1392c393a42Smrg  aclocal*)
1402c393a42Smrg    echo 1>&2 "\
141c9710b42SmrgWARNING: '$1' is $msg.  You should only need it if
142c9710b42Smrg         you modified 'acinclude.m4' or '${configure_ac}'.  You might want
143c9710b42Smrg         to install the Automake and Perl packages.  Grab them from
1442c393a42Smrg         any GNU archive site."
1452c393a42Smrg    touch aclocal.m4
1462c393a42Smrg    ;;
1472c393a42Smrg
148a6844aabSmrg  autoconf*)
1492c393a42Smrg    echo 1>&2 "\
150c9710b42SmrgWARNING: '$1' is $msg.  You should only need it if
151c9710b42Smrg         you modified '${configure_ac}'.  You might want to install the
152c9710b42Smrg         Autoconf and GNU m4 packages.  Grab them from any GNU
1532c393a42Smrg         archive site."
1542c393a42Smrg    touch configure
1552c393a42Smrg    ;;
1562c393a42Smrg
157a6844aabSmrg  autoheader*)
1582c393a42Smrg    echo 1>&2 "\
159c9710b42SmrgWARNING: '$1' is $msg.  You should only need it if
160c9710b42Smrg         you modified 'acconfig.h' or '${configure_ac}'.  You might want
161c9710b42Smrg         to install the Autoconf and GNU m4 packages.  Grab them
1622c393a42Smrg         from any GNU archive site."
1632c393a42Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1642c393a42Smrg    test -z "$files" && files="config.h"
1652c393a42Smrg    touch_files=
1662c393a42Smrg    for f in $files; do
167a6844aabSmrg      case $f in
1682c393a42Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1692c393a42Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1702c393a42Smrg      *) touch_files="$touch_files $f.in";;
1712c393a42Smrg      esac
1722c393a42Smrg    done
1732c393a42Smrg    touch $touch_files
1742c393a42Smrg    ;;
1752c393a42Smrg
1762c393a42Smrg  automake*)
1772c393a42Smrg    echo 1>&2 "\
178c9710b42SmrgWARNING: '$1' is $msg.  You should only need it if
179c9710b42Smrg         you modified 'Makefile.am', 'acinclude.m4' or '${configure_ac}'.
180c9710b42Smrg         You might want to install the Automake and Perl packages.
1812c393a42Smrg         Grab them from any GNU archive site."
1822c393a42Smrg    find . -type f -name Makefile.am -print |
1832c393a42Smrg	   sed 's/\.am$/.in/' |
1842c393a42Smrg	   while read f; do touch "$f"; done
1852c393a42Smrg    ;;
1862c393a42Smrg
187a6844aabSmrg  autom4te*)
1882c393a42Smrg    echo 1>&2 "\
189c9710b42SmrgWARNING: '$1' is needed, but is $msg.
1902c393a42Smrg         You might have modified some files without having the
1912c393a42Smrg         proper tools for further handling them.
192c9710b42Smrg         You can get '$1' as part of Autoconf from any GNU
1932c393a42Smrg         archive site."
1942c393a42Smrg
195a6844aabSmrg    file=`echo "$*" | sed -n "$sed_output"`
196a6844aabSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
1972c393a42Smrg    if test -f "$file"; then
1982c393a42Smrg	touch $file
1992c393a42Smrg    else
2002c393a42Smrg	test -z "$file" || exec >$file
2012c393a42Smrg	echo "#! /bin/sh"
2022c393a42Smrg	echo "# Created by GNU Automake missing as a replacement of"
2032c393a42Smrg	echo "#  $ $@"
2042c393a42Smrg	echo "exit 0"
2052c393a42Smrg	chmod +x $file
2062c393a42Smrg	exit 1
2072c393a42Smrg    fi
2082c393a42Smrg    ;;
2092c393a42Smrg
210a6844aabSmrg  bison*|yacc*)
2112c393a42Smrg    echo 1>&2 "\
212c9710b42SmrgWARNING: '$1' $msg.  You should only need it if
213c9710b42Smrg         you modified a '.y' file.  You may need the Bison package
2142c393a42Smrg         in order for those modifications to take effect.  You can get
215c9710b42Smrg         Bison from any GNU archive site."
2162c393a42Smrg    rm -f y.tab.c y.tab.h
217a6844aabSmrg    if test $# -ne 1; then
218ca08ab68Smrg        eval LASTARG=\${$#}
219a6844aabSmrg	case $LASTARG in
2202c393a42Smrg	*.y)
2212c393a42Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
222a6844aabSmrg	    if test -f "$SRCFILE"; then
2232c393a42Smrg	         cp "$SRCFILE" y.tab.c
2242c393a42Smrg	    fi
2252c393a42Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
226a6844aabSmrg	    if test -f "$SRCFILE"; then
2272c393a42Smrg	         cp "$SRCFILE" y.tab.h
2282c393a42Smrg	    fi
2292c393a42Smrg	  ;;
2302c393a42Smrg	esac
2312c393a42Smrg    fi
232a6844aabSmrg    if test ! -f y.tab.h; then
2332c393a42Smrg	echo >y.tab.h
2342c393a42Smrg    fi
235a6844aabSmrg    if test ! -f y.tab.c; then
2362c393a42Smrg	echo 'main() { return 0; }' >y.tab.c
2372c393a42Smrg    fi
2382c393a42Smrg    ;;
2392c393a42Smrg
240a6844aabSmrg  lex*|flex*)
2412c393a42Smrg    echo 1>&2 "\
242c9710b42SmrgWARNING: '$1' is $msg.  You should only need it if
243c9710b42Smrg         you modified a '.l' file.  You may need the Flex package
2442c393a42Smrg         in order for those modifications to take effect.  You can get
245c9710b42Smrg         Flex from any GNU archive site."
2462c393a42Smrg    rm -f lex.yy.c
247a6844aabSmrg    if test $# -ne 1; then
248ca08ab68Smrg        eval LASTARG=\${$#}
249a6844aabSmrg	case $LASTARG in
2502c393a42Smrg	*.l)
2512c393a42Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
252a6844aabSmrg	    if test -f "$SRCFILE"; then
2532c393a42Smrg	         cp "$SRCFILE" lex.yy.c
2542c393a42Smrg	    fi
2552c393a42Smrg	  ;;
2562c393a42Smrg	esac
2572c393a42Smrg    fi
258a6844aabSmrg    if test ! -f lex.yy.c; then
2592c393a42Smrg	echo 'main() { return 0; }' >lex.yy.c
2602c393a42Smrg    fi
2612c393a42Smrg    ;;
2622c393a42Smrg
263a6844aabSmrg  help2man*)
2642c393a42Smrg    echo 1>&2 "\
265c9710b42SmrgWARNING: '$1' is $msg.  You should only need it if
2662c393a42Smrg	 you modified a dependency of a manual page.  You may need the
267c9710b42Smrg	 Help2man package in order for those modifications to take
268c9710b42Smrg	 effect.  You can get Help2man from any GNU archive site."
2692c393a42Smrg
270a6844aabSmrg    file=`echo "$*" | sed -n "$sed_output"`
271a6844aabSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
272a6844aabSmrg    if test -f "$file"; then
2732c393a42Smrg	touch $file
2742c393a42Smrg    else
2752c393a42Smrg	test -z "$file" || exec >$file
2762c393a42Smrg	echo ".ab help2man is required to generate this page"
277a6844aabSmrg	exit $?
2782c393a42Smrg    fi
2792c393a42Smrg    ;;
2802c393a42Smrg
281a6844aabSmrg  makeinfo*)
2822c393a42Smrg    echo 1>&2 "\
283c9710b42SmrgWARNING: '$1' is $msg.  You should only need it if
284c9710b42Smrg         you modified a '.texi' or '.texinfo' file, or any other file
2852c393a42Smrg         indirectly affecting the aspect of the manual.  The spurious
286c9710b42Smrg         call might also be the consequence of using a buggy 'make' (AIX,
287c9710b42Smrg         DU, IRIX).  You might want to install the Texinfo package or
288c9710b42Smrg         the GNU make package.  Grab either from any GNU archive site."
2892c393a42Smrg    # The file to touch is that specified with -o ...
290a6844aabSmrg    file=`echo "$*" | sed -n "$sed_output"`
291a6844aabSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2922c393a42Smrg    if test -z "$file"; then
2932c393a42Smrg      # ... or it is the one specified with @setfilename ...
2942c393a42Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
295a6844aabSmrg      file=`sed -n '
296a6844aabSmrg	/^@setfilename/{
297a6844aabSmrg	  s/.* \([^ ]*\) *$/\1/
298a6844aabSmrg	  p
299a6844aabSmrg	  q
300a6844aabSmrg	}' $infile`
3012c393a42Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3022c393a42Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3032c393a42Smrg    fi
3042c393a42Smrg    # If the file does not exist, the user really needs makeinfo;
3052c393a42Smrg    # let's fail without touching anything.
3062c393a42Smrg    test -f $file || exit 1
3072c393a42Smrg    touch $file
3082c393a42Smrg    ;;
3092c393a42Smrg
3102c393a42Smrg  *)
3112c393a42Smrg    echo 1>&2 "\
312c9710b42SmrgWARNING: '$1' is needed, and is $msg.
3132c393a42Smrg         You might have modified some files without having the
314c9710b42Smrg         proper tools for further handling them.  Check the 'README' file,
3152c393a42Smrg         it often tells you about the needed prerequisites for installing
3162c393a42Smrg         this package.  You may also peek at any GNU archive site, in case
317c9710b42Smrg         some other package would contain this missing '$1' program."
3182c393a42Smrg    exit 1
3192c393a42Smrg    ;;
3202c393a42Smrgesac
3212c393a42Smrg
3222c393a42Smrgexit 0
3232c393a42Smrg
3242c393a42Smrg# Local variables:
3252c393a42Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3262c393a42Smrg# time-stamp-start: "scriptversion="
3272c393a42Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
328a6844aabSmrg# time-stamp-time-zone: "UTC"
329a6844aabSmrg# time-stamp-end: "; # UTC"
3302c393a42Smrg# End:
331