17e6fb56fSmrg#! /bin/sh
2983b4bf2Smrg# Common stub for a few missing GNU programs while installing.
37e6fb56fSmrg
4983b4bf2Smrgscriptversion=2012-01-06.13; # UTC
57e6fb56fSmrg
6983b4bf2Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
7983b4bf2Smrg# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
8983b4bf2Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
97e6fb56fSmrg
107e6fb56fSmrg# This program is free software; you can redistribute it and/or modify
117e6fb56fSmrg# it under the terms of the GNU General Public License as published by
127e6fb56fSmrg# the Free Software Foundation; either version 2, or (at your option)
137e6fb56fSmrg# any later version.
147e6fb56fSmrg
157e6fb56fSmrg# This program is distributed in the hope that it will be useful,
167e6fb56fSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
177e6fb56fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
187e6fb56fSmrg# GNU General Public License for more details.
197e6fb56fSmrg
207e6fb56fSmrg# You should have received a copy of the GNU General Public License
217e6fb56fSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
227e6fb56fSmrg
237e6fb56fSmrg# As a special exception to the GNU General Public License, if you
247e6fb56fSmrg# distribute this file as part of a program that contains a
257e6fb56fSmrg# configuration script generated by Autoconf, you may include it under
267e6fb56fSmrg# the same distribution terms that you use for the rest of that program.
277e6fb56fSmrg
287e6fb56fSmrgif test $# -eq 0; then
29983b4bf2Smrg  echo 1>&2 "Try \`$0 --help' for more information"
307e6fb56fSmrg  exit 1
317e6fb56fSmrgfi
327e6fb56fSmrg
33983b4bf2Smrgrun=:
34983b4bf2Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
35983b4bf2Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
367e6fb56fSmrg
37983b4bf2Smrg# In the cases where this matters, `missing' is being run in the
38983b4bf2Smrg# srcdir already.
39983b4bf2Smrgif test -f configure.ac; then
40983b4bf2Smrg  configure_ac=configure.ac
41983b4bf2Smrgelse
42983b4bf2Smrg  configure_ac=configure.in
43983b4bf2Smrgfi
447e6fb56fSmrg
45983b4bf2Smrgmsg="missing on your system"
46983b4bf2Smrg
47983b4bf2Smrgcase $1 in
48983b4bf2Smrg--run)
49983b4bf2Smrg  # Try to run requested program, and just exit if it succeeds.
50983b4bf2Smrg  run=
51983b4bf2Smrg  shift
52983b4bf2Smrg  "$@" && exit 0
53983b4bf2Smrg  # Exit code 63 means version mismatch.  This often happens
54983b4bf2Smrg  # when the user try to use an ancient version of a tool on
55983b4bf2Smrg  # a file that requires a minimum version.  In this case we
56983b4bf2Smrg  # we should proceed has if the program had been absent, or
57983b4bf2Smrg  # if --run hadn't been passed.
58983b4bf2Smrg  if test $? = 63; then
59983b4bf2Smrg    run=:
60983b4bf2Smrg    msg="probably too old"
61983b4bf2Smrg  fi
62983b4bf2Smrg  ;;
637e6fb56fSmrg
647e6fb56fSmrg  -h|--h|--he|--hel|--help)
657e6fb56fSmrg    echo "\
667e6fb56fSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
677e6fb56fSmrg
68983b4bf2SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69983b4bf2Smrgerror status if there is no known handling for PROGRAM.
707e6fb56fSmrg
717e6fb56fSmrgOptions:
727e6fb56fSmrg  -h, --help      display this help and exit
737e6fb56fSmrg  -v, --version   output version information and exit
74983b4bf2Smrg  --run           try to run the given command, and emulate it if it fails
757e6fb56fSmrg
767e6fb56fSmrgSupported PROGRAM values:
77983b4bf2Smrg  aclocal      touch file \`aclocal.m4'
78983b4bf2Smrg  autoconf     touch file \`configure'
79983b4bf2Smrg  autoheader   touch file \`config.h.in'
80983b4bf2Smrg  autom4te     touch the output file, or create a stub one
81983b4bf2Smrg  automake     touch all \`Makefile.in' files
82983b4bf2Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
83983b4bf2Smrg  flex         create \`lex.yy.c', if possible, from existing .c
84983b4bf2Smrg  help2man     touch the output file
85983b4bf2Smrg  lex          create \`lex.yy.c', if possible, from existing .c
86983b4bf2Smrg  makeinfo     touch the output file
87983b4bf2Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
887e6fb56fSmrg
89983b4bf2SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
90983b4bf2Smrg\`g' are ignored when checking the name.
917e6fb56fSmrg
927e6fb56fSmrgSend bug reports to <bug-automake@gnu.org>."
937e6fb56fSmrg    exit $?
947e6fb56fSmrg    ;;
957e6fb56fSmrg
967e6fb56fSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
977e6fb56fSmrg    echo "missing $scriptversion (GNU Automake)"
987e6fb56fSmrg    exit $?
997e6fb56fSmrg    ;;
1007e6fb56fSmrg
1017e6fb56fSmrg  -*)
102983b4bf2Smrg    echo 1>&2 "$0: Unknown \`$1' option"
103983b4bf2Smrg    echo 1>&2 "Try \`$0 --help' for more information"
1047e6fb56fSmrg    exit 1
1057e6fb56fSmrg    ;;
1067e6fb56fSmrg
1077e6fb56fSmrgesac
1087e6fb56fSmrg
109983b4bf2Smrg# normalize program name to check for.
110983b4bf2Smrgprogram=`echo "$1" | sed '
111983b4bf2Smrg  s/^gnu-//; t
112983b4bf2Smrg  s/^gnu//; t
113983b4bf2Smrg  s/^g//; t'`
114983b4bf2Smrg
115983b4bf2Smrg# Now exit if we have it, but it failed.  Also exit now if we
116983b4bf2Smrg# don't have it and --version was passed (most likely to detect
117983b4bf2Smrg# the program).  This is about non-GNU programs, so use $1 not
118983b4bf2Smrg# $program.
119983b4bf2Smrgcase $1 in
120983b4bf2Smrg  lex*|yacc*)
121983b4bf2Smrg    # Not GNU programs, they don't have --version.
122983b4bf2Smrg    ;;
123983b4bf2Smrg
124983b4bf2Smrg  *)
125983b4bf2Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
126983b4bf2Smrg       # We have it, but it failed.
127983b4bf2Smrg       exit 1
128983b4bf2Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
129983b4bf2Smrg       # Could not run --version or --help.  This is probably someone
130983b4bf2Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
131983b4bf2Smrg       # $TOOL exists and not knowing $TOOL uses missing.
132983b4bf2Smrg       exit 1
133983b4bf2Smrg    fi
134983b4bf2Smrg    ;;
135983b4bf2Smrgesac
136983b4bf2Smrg
137983b4bf2Smrg# If it does not exist, or fails to run (possibly an outdated version),
138983b4bf2Smrg# try to emulate it.
139983b4bf2Smrgcase $program in
140983b4bf2Smrg  aclocal*)
141983b4bf2Smrg    echo 1>&2 "\
142983b4bf2SmrgWARNING: \`$1' is $msg.  You should only need it if
143983b4bf2Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
144983b4bf2Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
145983b4bf2Smrg         any GNU archive site."
146983b4bf2Smrg    touch aclocal.m4
147983b4bf2Smrg    ;;
148983b4bf2Smrg
149983b4bf2Smrg  autoconf*)
150983b4bf2Smrg    echo 1>&2 "\
151983b4bf2SmrgWARNING: \`$1' is $msg.  You should only need it if
152983b4bf2Smrg         you modified \`${configure_ac}'.  You might want to install the
153983b4bf2Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
154983b4bf2Smrg         archive site."
155983b4bf2Smrg    touch configure
156983b4bf2Smrg    ;;
1577e6fb56fSmrg
158983b4bf2Smrg  autoheader*)
159983b4bf2Smrg    echo 1>&2 "\
160983b4bf2SmrgWARNING: \`$1' is $msg.  You should only need it if
161983b4bf2Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
162983b4bf2Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
163983b4bf2Smrg         from any GNU archive site."
164983b4bf2Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
165983b4bf2Smrg    test -z "$files" && files="config.h"
166983b4bf2Smrg    touch_files=
167983b4bf2Smrg    for f in $files; do
168983b4bf2Smrg      case $f in
169983b4bf2Smrg      *:*) touch_files="$touch_files "`echo "$f" |
170983b4bf2Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
171983b4bf2Smrg      *) touch_files="$touch_files $f.in";;
172983b4bf2Smrg      esac
173983b4bf2Smrg    done
174983b4bf2Smrg    touch $touch_files
1757e6fb56fSmrg    ;;
176983b4bf2Smrg
177983b4bf2Smrg  automake*)
178983b4bf2Smrg    echo 1>&2 "\
179983b4bf2SmrgWARNING: \`$1' is $msg.  You should only need it if
180983b4bf2Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
181983b4bf2Smrg         You might want to install the \`Automake' and \`Perl' packages.
182983b4bf2Smrg         Grab them from any GNU archive site."
183983b4bf2Smrg    find . -type f -name Makefile.am -print |
184983b4bf2Smrg	   sed 's/\.am$/.in/' |
185983b4bf2Smrg	   while read f; do touch "$f"; done
186983b4bf2Smrg    ;;
187983b4bf2Smrg
188983b4bf2Smrg  autom4te*)
189983b4bf2Smrg    echo 1>&2 "\
190983b4bf2SmrgWARNING: \`$1' is needed, but is $msg.
191983b4bf2Smrg         You might have modified some files without having the
192983b4bf2Smrg         proper tools for further handling them.
193983b4bf2Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
194983b4bf2Smrg         archive site."
195983b4bf2Smrg
196983b4bf2Smrg    file=`echo "$*" | sed -n "$sed_output"`
197983b4bf2Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
198983b4bf2Smrg    if test -f "$file"; then
199983b4bf2Smrg	touch $file
200983b4bf2Smrg    else
201983b4bf2Smrg	test -z "$file" || exec >$file
202983b4bf2Smrg	echo "#! /bin/sh"
203983b4bf2Smrg	echo "# Created by GNU Automake missing as a replacement of"
204983b4bf2Smrg	echo "#  $ $@"
205983b4bf2Smrg	echo "exit 0"
206983b4bf2Smrg	chmod +x $file
207983b4bf2Smrg	exit 1
208983b4bf2Smrg    fi
209983b4bf2Smrg    ;;
210983b4bf2Smrg
211983b4bf2Smrg  bison*|yacc*)
212983b4bf2Smrg    echo 1>&2 "\
213983b4bf2SmrgWARNING: \`$1' $msg.  You should only need it if
214983b4bf2Smrg         you modified a \`.y' file.  You may need the \`Bison' package
215983b4bf2Smrg         in order for those modifications to take effect.  You can get
216983b4bf2Smrg         \`Bison' from any GNU archive site."
217983b4bf2Smrg    rm -f y.tab.c y.tab.h
218983b4bf2Smrg    if test $# -ne 1; then
219983b4bf2Smrg        eval LASTARG=\${$#}
220983b4bf2Smrg	case $LASTARG in
221983b4bf2Smrg	*.y)
222983b4bf2Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
223983b4bf2Smrg	    if test -f "$SRCFILE"; then
224983b4bf2Smrg	         cp "$SRCFILE" y.tab.c
225983b4bf2Smrg	    fi
226983b4bf2Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
227983b4bf2Smrg	    if test -f "$SRCFILE"; then
228983b4bf2Smrg	         cp "$SRCFILE" y.tab.h
229983b4bf2Smrg	    fi
230983b4bf2Smrg	  ;;
231983b4bf2Smrg	esac
232983b4bf2Smrg    fi
233983b4bf2Smrg    if test ! -f y.tab.h; then
234983b4bf2Smrg	echo >y.tab.h
235983b4bf2Smrg    fi
236983b4bf2Smrg    if test ! -f y.tab.c; then
237983b4bf2Smrg	echo 'main() { return 0; }' >y.tab.c
238983b4bf2Smrg    fi
239983b4bf2Smrg    ;;
240983b4bf2Smrg
241983b4bf2Smrg  lex*|flex*)
242983b4bf2Smrg    echo 1>&2 "\
243983b4bf2SmrgWARNING: \`$1' is $msg.  You should only need it if
244983b4bf2Smrg         you modified a \`.l' file.  You may need the \`Flex' package
245983b4bf2Smrg         in order for those modifications to take effect.  You can get
246983b4bf2Smrg         \`Flex' from any GNU archive site."
247983b4bf2Smrg    rm -f lex.yy.c
248983b4bf2Smrg    if test $# -ne 1; then
249983b4bf2Smrg        eval LASTARG=\${$#}
250983b4bf2Smrg	case $LASTARG in
251983b4bf2Smrg	*.l)
252983b4bf2Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
253983b4bf2Smrg	    if test -f "$SRCFILE"; then
254983b4bf2Smrg	         cp "$SRCFILE" lex.yy.c
255983b4bf2Smrg	    fi
256983b4bf2Smrg	  ;;
257983b4bf2Smrg	esac
258983b4bf2Smrg    fi
259983b4bf2Smrg    if test ! -f lex.yy.c; then
260983b4bf2Smrg	echo 'main() { return 0; }' >lex.yy.c
261983b4bf2Smrg    fi
262983b4bf2Smrg    ;;
263983b4bf2Smrg
264983b4bf2Smrg  help2man*)
265983b4bf2Smrg    echo 1>&2 "\
266983b4bf2SmrgWARNING: \`$1' is $msg.  You should only need it if
267983b4bf2Smrg	 you modified a dependency of a manual page.  You may need the
268983b4bf2Smrg	 \`Help2man' package in order for those modifications to take
269983b4bf2Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
270983b4bf2Smrg
271983b4bf2Smrg    file=`echo "$*" | sed -n "$sed_output"`
272983b4bf2Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
273983b4bf2Smrg    if test -f "$file"; then
274983b4bf2Smrg	touch $file
275983b4bf2Smrg    else
276983b4bf2Smrg	test -z "$file" || exec >$file
277983b4bf2Smrg	echo ".ab help2man is required to generate this page"
278983b4bf2Smrg	exit $?
279983b4bf2Smrg    fi
280983b4bf2Smrg    ;;
281983b4bf2Smrg
282983b4bf2Smrg  makeinfo*)
283983b4bf2Smrg    echo 1>&2 "\
284983b4bf2SmrgWARNING: \`$1' is $msg.  You should only need it if
285983b4bf2Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
286983b4bf2Smrg         indirectly affecting the aspect of the manual.  The spurious
287983b4bf2Smrg         call might also be the consequence of using a buggy \`make' (AIX,
288983b4bf2Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
289983b4bf2Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
290983b4bf2Smrg    # The file to touch is that specified with -o ...
291983b4bf2Smrg    file=`echo "$*" | sed -n "$sed_output"`
292983b4bf2Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
293983b4bf2Smrg    if test -z "$file"; then
294983b4bf2Smrg      # ... or it is the one specified with @setfilename ...
295983b4bf2Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
296983b4bf2Smrg      file=`sed -n '
297983b4bf2Smrg	/^@setfilename/{
298983b4bf2Smrg	  s/.* \([^ ]*\) *$/\1/
299983b4bf2Smrg	  p
300983b4bf2Smrg	  q
301983b4bf2Smrg	}' $infile`
302983b4bf2Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
303983b4bf2Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
304983b4bf2Smrg    fi
305983b4bf2Smrg    # If the file does not exist, the user really needs makeinfo;
306983b4bf2Smrg    # let's fail without touching anything.
307983b4bf2Smrg    test -f $file || exit 1
308983b4bf2Smrg    touch $file
309983b4bf2Smrg    ;;
310983b4bf2Smrg
311983b4bf2Smrg  *)
312983b4bf2Smrg    echo 1>&2 "\
313983b4bf2SmrgWARNING: \`$1' is needed, and is $msg.
314983b4bf2Smrg         You might have modified some files without having the
315983b4bf2Smrg         proper tools for further handling them.  Check the \`README' file,
316983b4bf2Smrg         it often tells you about the needed prerequisites for installing
317983b4bf2Smrg         this package.  You may also peek at any GNU archive site, in case
318983b4bf2Smrg         some other package would contain this missing \`$1' program."
319983b4bf2Smrg    exit 1
320983b4bf2Smrg    ;;
321983b4bf2Smrgesac
322983b4bf2Smrg
323983b4bf2Smrgexit 0
3247e6fb56fSmrg
3257e6fb56fSmrg# Local variables:
3267e6fb56fSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3277e6fb56fSmrg# time-stamp-start: "scriptversion="
3287e6fb56fSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3297e6fb56fSmrg# time-stamp-time-zone: "UTC"
3307e6fb56fSmrg# time-stamp-end: "; # UTC"
3317e6fb56fSmrg# End:
332