missing revision aee7dae4
1ba0eab60Smacallan#! /bin/sh
2ba0eab60Smacallan# Common stub for a few missing GNU programs while installing.
3ba0eab60Smacallan
4aee7dae4Smrgscriptversion=2012-01-06.13; # UTC
5ba0eab60Smacallan
6aee7dae4Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
7aee7dae4Smrg# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
8ba0eab60Smacallan# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9ba0eab60Smacallan
10ba0eab60Smacallan# This program is free software; you can redistribute it and/or modify
11ba0eab60Smacallan# it under the terms of the GNU General Public License as published by
12ba0eab60Smacallan# the Free Software Foundation; either version 2, or (at your option)
13ba0eab60Smacallan# any later version.
14ba0eab60Smacallan
15ba0eab60Smacallan# This program is distributed in the hope that it will be useful,
16ba0eab60Smacallan# but WITHOUT ANY WARRANTY; without even the implied warranty of
17ba0eab60Smacallan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18ba0eab60Smacallan# GNU General Public License for more details.
19ba0eab60Smacallan
20ba0eab60Smacallan# You should have received a copy of the GNU General Public License
21aee7dae4Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22ba0eab60Smacallan
23ba0eab60Smacallan# As a special exception to the GNU General Public License, if you
24ba0eab60Smacallan# distribute this file as part of a program that contains a
25ba0eab60Smacallan# configuration script generated by Autoconf, you may include it under
26ba0eab60Smacallan# the same distribution terms that you use for the rest of that program.
27ba0eab60Smacallan
28ba0eab60Smacallanif test $# -eq 0; then
29ba0eab60Smacallan  echo 1>&2 "Try \`$0 --help' for more information"
30ba0eab60Smacallan  exit 1
31ba0eab60Smacallanfi
32ba0eab60Smacallan
33ba0eab60Smacallanrun=:
34aee7dae4Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
35aee7dae4Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
36ba0eab60Smacallan
37ba0eab60Smacallan# In the cases where this matters, `missing' is being run in the
38ba0eab60Smacallan# srcdir already.
39ba0eab60Smacallanif test -f configure.ac; then
40ba0eab60Smacallan  configure_ac=configure.ac
41ba0eab60Smacallanelse
42ba0eab60Smacallan  configure_ac=configure.in
43ba0eab60Smacallanfi
44ba0eab60Smacallan
45ba0eab60Smacallanmsg="missing on your system"
46ba0eab60Smacallan
47aee7dae4Smrgcase $1 in
48ba0eab60Smacallan--run)
49ba0eab60Smacallan  # Try to run requested program, and just exit if it succeeds.
50ba0eab60Smacallan  run=
51ba0eab60Smacallan  shift
52ba0eab60Smacallan  "$@" && exit 0
53ba0eab60Smacallan  # Exit code 63 means version mismatch.  This often happens
54ba0eab60Smacallan  # when the user try to use an ancient version of a tool on
55ba0eab60Smacallan  # a file that requires a minimum version.  In this case we
56ba0eab60Smacallan  # we should proceed has if the program had been absent, or
57ba0eab60Smacallan  # if --run hadn't been passed.
58ba0eab60Smacallan  if test $? = 63; then
59ba0eab60Smacallan    run=:
60ba0eab60Smacallan    msg="probably too old"
61ba0eab60Smacallan  fi
62ba0eab60Smacallan  ;;
63ba0eab60Smacallan
64ba0eab60Smacallan  -h|--h|--he|--hel|--help)
65ba0eab60Smacallan    echo "\
66ba0eab60Smacallan$0 [OPTION]... PROGRAM [ARGUMENT]...
67ba0eab60Smacallan
68ba0eab60SmacallanHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69ba0eab60Smacallanerror status if there is no known handling for PROGRAM.
70ba0eab60Smacallan
71ba0eab60SmacallanOptions:
72ba0eab60Smacallan  -h, --help      display this help and exit
73ba0eab60Smacallan  -v, --version   output version information and exit
74ba0eab60Smacallan  --run           try to run the given command, and emulate it if it fails
75ba0eab60Smacallan
76ba0eab60SmacallanSupported PROGRAM values:
77ba0eab60Smacallan  aclocal      touch file \`aclocal.m4'
78ba0eab60Smacallan  autoconf     touch file \`configure'
79ba0eab60Smacallan  autoheader   touch file \`config.h.in'
80aee7dae4Smrg  autom4te     touch the output file, or create a stub one
81ba0eab60Smacallan  automake     touch all \`Makefile.in' files
82ba0eab60Smacallan  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
83ba0eab60Smacallan  flex         create \`lex.yy.c', if possible, from existing .c
84ba0eab60Smacallan  help2man     touch the output file
85ba0eab60Smacallan  lex          create \`lex.yy.c', if possible, from existing .c
86ba0eab60Smacallan  makeinfo     touch the output file
87ba0eab60Smacallan  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
88ba0eab60Smacallan
89aee7dae4SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
90aee7dae4Smrg\`g' are ignored when checking the name.
91aee7dae4Smrg
92ba0eab60SmacallanSend bug reports to <bug-automake@gnu.org>."
93ba0eab60Smacallan    exit $?
94ba0eab60Smacallan    ;;
95ba0eab60Smacallan
96ba0eab60Smacallan  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
97ba0eab60Smacallan    echo "missing $scriptversion (GNU Automake)"
98ba0eab60Smacallan    exit $?
99ba0eab60Smacallan    ;;
100ba0eab60Smacallan
101ba0eab60Smacallan  -*)
102ba0eab60Smacallan    echo 1>&2 "$0: Unknown \`$1' option"
103ba0eab60Smacallan    echo 1>&2 "Try \`$0 --help' for more information"
104ba0eab60Smacallan    exit 1
105ba0eab60Smacallan    ;;
106ba0eab60Smacallan
107ba0eab60Smacallanesac
108ba0eab60Smacallan
109aee7dae4Smrg# normalize program name to check for.
110aee7dae4Smrgprogram=`echo "$1" | sed '
111aee7dae4Smrg  s/^gnu-//; t
112aee7dae4Smrg  s/^gnu//; t
113aee7dae4Smrg  s/^g//; t'`
114aee7dae4Smrg
115ba0eab60Smacallan# Now exit if we have it, but it failed.  Also exit now if we
116ba0eab60Smacallan# don't have it and --version was passed (most likely to detect
117aee7dae4Smrg# the program).  This is about non-GNU programs, so use $1 not
118aee7dae4Smrg# $program.
119aee7dae4Smrgcase $1 in
120aee7dae4Smrg  lex*|yacc*)
121ba0eab60Smacallan    # Not GNU programs, they don't have --version.
122ba0eab60Smacallan    ;;
123ba0eab60Smacallan
124ba0eab60Smacallan  *)
125ba0eab60Smacallan    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
126ba0eab60Smacallan       # We have it, but it failed.
127ba0eab60Smacallan       exit 1
128ba0eab60Smacallan    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
129ba0eab60Smacallan       # Could not run --version or --help.  This is probably someone
130ba0eab60Smacallan       # running `$TOOL --version' or `$TOOL --help' to check whether
131ba0eab60Smacallan       # $TOOL exists and not knowing $TOOL uses missing.
132ba0eab60Smacallan       exit 1
133ba0eab60Smacallan    fi
134ba0eab60Smacallan    ;;
135ba0eab60Smacallanesac
136ba0eab60Smacallan
137ba0eab60Smacallan# If it does not exist, or fails to run (possibly an outdated version),
138ba0eab60Smacallan# try to emulate it.
139aee7dae4Smrgcase $program in
140ba0eab60Smacallan  aclocal*)
141ba0eab60Smacallan    echo 1>&2 "\
142ba0eab60SmacallanWARNING: \`$1' is $msg.  You should only need it if
143ba0eab60Smacallan         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
144ba0eab60Smacallan         to install the \`Automake' and \`Perl' packages.  Grab them from
145ba0eab60Smacallan         any GNU archive site."
146ba0eab60Smacallan    touch aclocal.m4
147ba0eab60Smacallan    ;;
148ba0eab60Smacallan
149aee7dae4Smrg  autoconf*)
150ba0eab60Smacallan    echo 1>&2 "\
151ba0eab60SmacallanWARNING: \`$1' is $msg.  You should only need it if
152ba0eab60Smacallan         you modified \`${configure_ac}'.  You might want to install the
153ba0eab60Smacallan         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
154ba0eab60Smacallan         archive site."
155ba0eab60Smacallan    touch configure
156ba0eab60Smacallan    ;;
157ba0eab60Smacallan
158aee7dae4Smrg  autoheader*)
159ba0eab60Smacallan    echo 1>&2 "\
160ba0eab60SmacallanWARNING: \`$1' is $msg.  You should only need it if
161ba0eab60Smacallan         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
162ba0eab60Smacallan         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
163ba0eab60Smacallan         from any GNU archive site."
164ba0eab60Smacallan    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
165ba0eab60Smacallan    test -z "$files" && files="config.h"
166ba0eab60Smacallan    touch_files=
167ba0eab60Smacallan    for f in $files; do
168aee7dae4Smrg      case $f in
169ba0eab60Smacallan      *:*) touch_files="$touch_files "`echo "$f" |
170ba0eab60Smacallan				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
171ba0eab60Smacallan      *) touch_files="$touch_files $f.in";;
172ba0eab60Smacallan      esac
173ba0eab60Smacallan    done
174ba0eab60Smacallan    touch $touch_files
175ba0eab60Smacallan    ;;
176ba0eab60Smacallan
177ba0eab60Smacallan  automake*)
178ba0eab60Smacallan    echo 1>&2 "\
179ba0eab60SmacallanWARNING: \`$1' is $msg.  You should only need it if
180ba0eab60Smacallan         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
181ba0eab60Smacallan         You might want to install the \`Automake' and \`Perl' packages.
182ba0eab60Smacallan         Grab them from any GNU archive site."
183ba0eab60Smacallan    find . -type f -name Makefile.am -print |
184ba0eab60Smacallan	   sed 's/\.am$/.in/' |
185ba0eab60Smacallan	   while read f; do touch "$f"; done
186ba0eab60Smacallan    ;;
187ba0eab60Smacallan
188aee7dae4Smrg  autom4te*)
189ba0eab60Smacallan    echo 1>&2 "\
190ba0eab60SmacallanWARNING: \`$1' is needed, but is $msg.
191ba0eab60Smacallan         You might have modified some files without having the
192ba0eab60Smacallan         proper tools for further handling them.
193ba0eab60Smacallan         You can get \`$1' as part of \`Autoconf' from any GNU
194ba0eab60Smacallan         archive site."
195ba0eab60Smacallan
196aee7dae4Smrg    file=`echo "$*" | sed -n "$sed_output"`
197aee7dae4Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
198ba0eab60Smacallan    if test -f "$file"; then
199ba0eab60Smacallan	touch $file
200ba0eab60Smacallan    else
201ba0eab60Smacallan	test -z "$file" || exec >$file
202ba0eab60Smacallan	echo "#! /bin/sh"
203ba0eab60Smacallan	echo "# Created by GNU Automake missing as a replacement of"
204ba0eab60Smacallan	echo "#  $ $@"
205ba0eab60Smacallan	echo "exit 0"
206ba0eab60Smacallan	chmod +x $file
207ba0eab60Smacallan	exit 1
208ba0eab60Smacallan    fi
209ba0eab60Smacallan    ;;
210ba0eab60Smacallan
211aee7dae4Smrg  bison*|yacc*)
212ba0eab60Smacallan    echo 1>&2 "\
213ba0eab60SmacallanWARNING: \`$1' $msg.  You should only need it if
214ba0eab60Smacallan         you modified a \`.y' file.  You may need the \`Bison' package
215ba0eab60Smacallan         in order for those modifications to take effect.  You can get
216ba0eab60Smacallan         \`Bison' from any GNU archive site."
217ba0eab60Smacallan    rm -f y.tab.c y.tab.h
218aee7dae4Smrg    if test $# -ne 1; then
219aee7dae4Smrg        eval LASTARG=\${$#}
220aee7dae4Smrg	case $LASTARG in
221ba0eab60Smacallan	*.y)
222ba0eab60Smacallan	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
223aee7dae4Smrg	    if test -f "$SRCFILE"; then
224ba0eab60Smacallan	         cp "$SRCFILE" y.tab.c
225ba0eab60Smacallan	    fi
226ba0eab60Smacallan	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
227aee7dae4Smrg	    if test -f "$SRCFILE"; then
228ba0eab60Smacallan	         cp "$SRCFILE" y.tab.h
229ba0eab60Smacallan	    fi
230ba0eab60Smacallan	  ;;
231ba0eab60Smacallan	esac
232ba0eab60Smacallan    fi
233aee7dae4Smrg    if test ! -f y.tab.h; then
234ba0eab60Smacallan	echo >y.tab.h
235ba0eab60Smacallan    fi
236aee7dae4Smrg    if test ! -f y.tab.c; then
237ba0eab60Smacallan	echo 'main() { return 0; }' >y.tab.c
238ba0eab60Smacallan    fi
239ba0eab60Smacallan    ;;
240ba0eab60Smacallan
241aee7dae4Smrg  lex*|flex*)
242ba0eab60Smacallan    echo 1>&2 "\
243ba0eab60SmacallanWARNING: \`$1' is $msg.  You should only need it if
244ba0eab60Smacallan         you modified a \`.l' file.  You may need the \`Flex' package
245ba0eab60Smacallan         in order for those modifications to take effect.  You can get
246ba0eab60Smacallan         \`Flex' from any GNU archive site."
247ba0eab60Smacallan    rm -f lex.yy.c
248aee7dae4Smrg    if test $# -ne 1; then
249aee7dae4Smrg        eval LASTARG=\${$#}
250aee7dae4Smrg	case $LASTARG in
251ba0eab60Smacallan	*.l)
252ba0eab60Smacallan	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
253aee7dae4Smrg	    if test -f "$SRCFILE"; then
254ba0eab60Smacallan	         cp "$SRCFILE" lex.yy.c
255ba0eab60Smacallan	    fi
256ba0eab60Smacallan	  ;;
257ba0eab60Smacallan	esac
258ba0eab60Smacallan    fi
259aee7dae4Smrg    if test ! -f lex.yy.c; then
260ba0eab60Smacallan	echo 'main() { return 0; }' >lex.yy.c
261ba0eab60Smacallan    fi
262ba0eab60Smacallan    ;;
263ba0eab60Smacallan
264aee7dae4Smrg  help2man*)
265ba0eab60Smacallan    echo 1>&2 "\
266ba0eab60SmacallanWARNING: \`$1' is $msg.  You should only need it if
267ba0eab60Smacallan	 you modified a dependency of a manual page.  You may need the
268ba0eab60Smacallan	 \`Help2man' package in order for those modifications to take
269ba0eab60Smacallan	 effect.  You can get \`Help2man' from any GNU archive site."
270ba0eab60Smacallan
271aee7dae4Smrg    file=`echo "$*" | sed -n "$sed_output"`
272aee7dae4Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
273aee7dae4Smrg    if test -f "$file"; then
274ba0eab60Smacallan	touch $file
275ba0eab60Smacallan    else
276ba0eab60Smacallan	test -z "$file" || exec >$file
277ba0eab60Smacallan	echo ".ab help2man is required to generate this page"
278aee7dae4Smrg	exit $?
279ba0eab60Smacallan    fi
280ba0eab60Smacallan    ;;
281ba0eab60Smacallan
282aee7dae4Smrg  makeinfo*)
283ba0eab60Smacallan    echo 1>&2 "\
284ba0eab60SmacallanWARNING: \`$1' is $msg.  You should only need it if
285ba0eab60Smacallan         you modified a \`.texi' or \`.texinfo' file, or any other file
286ba0eab60Smacallan         indirectly affecting the aspect of the manual.  The spurious
287ba0eab60Smacallan         call might also be the consequence of using a buggy \`make' (AIX,
288ba0eab60Smacallan         DU, IRIX).  You might want to install the \`Texinfo' package or
289ba0eab60Smacallan         the \`GNU make' package.  Grab either from any GNU archive site."
290ba0eab60Smacallan    # The file to touch is that specified with -o ...
291aee7dae4Smrg    file=`echo "$*" | sed -n "$sed_output"`
292aee7dae4Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
293ba0eab60Smacallan    if test -z "$file"; then
294ba0eab60Smacallan      # ... or it is the one specified with @setfilename ...
295ba0eab60Smacallan      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
296aee7dae4Smrg      file=`sed -n '
297aee7dae4Smrg	/^@setfilename/{
298aee7dae4Smrg	  s/.* \([^ ]*\) *$/\1/
299aee7dae4Smrg	  p
300aee7dae4Smrg	  q
301aee7dae4Smrg	}' $infile`
302ba0eab60Smacallan      # ... or it is derived from the source name (dir/f.texi becomes f.info)
303ba0eab60Smacallan      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
304ba0eab60Smacallan    fi
305ba0eab60Smacallan    # If the file does not exist, the user really needs makeinfo;
306ba0eab60Smacallan    # let's fail without touching anything.
307ba0eab60Smacallan    test -f $file || exit 1
308ba0eab60Smacallan    touch $file
309ba0eab60Smacallan    ;;
310ba0eab60Smacallan
311ba0eab60Smacallan  *)
312ba0eab60Smacallan    echo 1>&2 "\
313ba0eab60SmacallanWARNING: \`$1' is needed, and is $msg.
314ba0eab60Smacallan         You might have modified some files without having the
315ba0eab60Smacallan         proper tools for further handling them.  Check the \`README' file,
316ba0eab60Smacallan         it often tells you about the needed prerequisites for installing
317ba0eab60Smacallan         this package.  You may also peek at any GNU archive site, in case
318ba0eab60Smacallan         some other package would contain this missing \`$1' program."
319ba0eab60Smacallan    exit 1
320ba0eab60Smacallan    ;;
321ba0eab60Smacallanesac
322ba0eab60Smacallan
323ba0eab60Smacallanexit 0
324ba0eab60Smacallan
325ba0eab60Smacallan# Local variables:
326ba0eab60Smacallan# eval: (add-hook 'write-file-hooks 'time-stamp)
327ba0eab60Smacallan# time-stamp-start: "scriptversion="
328ba0eab60Smacallan# time-stamp-format: "%:y-%02m-%02d.%02H"
329aee7dae4Smrg# time-stamp-time-zone: "UTC"
330aee7dae4Smrg# time-stamp-end: "; # UTC"
331ba0eab60Smacallan# End:
332