missing revision e4da38af
1659607e0Smrg#! /bin/sh
2e4da38afSmrg# Common stub for a few missing GNU programs while installing.
3659607e0Smrg
4e4da38afSmrgscriptversion=2012-01-06.18; # UTC
5659607e0Smrg
6e4da38afSmrg# Copyright (C) 1996-2012 Free Software Foundation, Inc.
7e4da38afSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8659607e0Smrg
9659607e0Smrg# This program is free software; you can redistribute it and/or modify
10659607e0Smrg# it under the terms of the GNU General Public License as published by
11659607e0Smrg# the Free Software Foundation; either version 2, or (at your option)
12659607e0Smrg# any later version.
13659607e0Smrg
14659607e0Smrg# This program is distributed in the hope that it will be useful,
15659607e0Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
16659607e0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17659607e0Smrg# GNU General Public License for more details.
18659607e0Smrg
19659607e0Smrg# You should have received a copy of the GNU General Public License
20b73be646Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21659607e0Smrg
22659607e0Smrg# As a special exception to the GNU General Public License, if you
23659607e0Smrg# distribute this file as part of a program that contains a
24659607e0Smrg# configuration script generated by Autoconf, you may include it under
25659607e0Smrg# the same distribution terms that you use for the rest of that program.
26659607e0Smrg
27659607e0Smrgif test $# -eq 0; then
28a73597f9Smrg  echo 1>&2 "Try '$0 --help' for more information"
29659607e0Smrg  exit 1
30659607e0Smrgfi
31659607e0Smrg
32e4da38afSmrgrun=:
33e4da38afSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
34e4da38afSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
35659607e0Smrg
36e4da38afSmrg# In the cases where this matters, 'missing' is being run in the
37e4da38afSmrg# srcdir already.
38e4da38afSmrgif test -f configure.ac; then
39e4da38afSmrg  configure_ac=configure.ac
40e4da38afSmrgelse
41e4da38afSmrg  configure_ac=configure.in
42e4da38afSmrgfi
43659607e0Smrg
44e4da38afSmrgmsg="missing on your system"
45e4da38afSmrg
46e4da38afSmrgcase $1 in
47e4da38afSmrg--run)
48e4da38afSmrg  # Try to run requested program, and just exit if it succeeds.
49e4da38afSmrg  run=
50e4da38afSmrg  shift
51e4da38afSmrg  "$@" && exit 0
52e4da38afSmrg  # Exit code 63 means version mismatch.  This often happens
53e4da38afSmrg  # when the user try to use an ancient version of a tool on
54e4da38afSmrg  # a file that requires a minimum version.  In this case we
55e4da38afSmrg  # we should proceed has if the program had been absent, or
56e4da38afSmrg  # if --run hadn't been passed.
57e4da38afSmrg  if test $? = 63; then
58e4da38afSmrg    run=:
59e4da38afSmrg    msg="probably too old"
60e4da38afSmrg  fi
61e4da38afSmrg  ;;
62659607e0Smrg
63659607e0Smrg  -h|--h|--he|--hel|--help)
64659607e0Smrg    echo "\
65659607e0Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
66659607e0Smrg
67e4da38afSmrgHandle 'PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
68e4da38afSmrgerror status if there is no known handling for PROGRAM.
69659607e0Smrg
70659607e0SmrgOptions:
71659607e0Smrg  -h, --help      display this help and exit
72659607e0Smrg  -v, --version   output version information and exit
73e4da38afSmrg  --run           try to run the given command, and emulate it if it fails
74659607e0Smrg
75659607e0SmrgSupported PROGRAM values:
76e4da38afSmrg  aclocal      touch file 'aclocal.m4'
77e4da38afSmrg  autoconf     touch file 'configure'
78e4da38afSmrg  autoheader   touch file 'config.h.in'
79e4da38afSmrg  autom4te     touch the output file, or create a stub one
80e4da38afSmrg  automake     touch all 'Makefile.in' files
81e4da38afSmrg  bison        create 'y.tab.[ch]', if possible, from existing .[ch]
82e4da38afSmrg  flex         create 'lex.yy.c', if possible, from existing .c
83e4da38afSmrg  help2man     touch the output file
84e4da38afSmrg  lex          create 'lex.yy.c', if possible, from existing .c
85e4da38afSmrg  makeinfo     touch the output file
86e4da38afSmrg  yacc         create 'y.tab.[ch]', if possible, from existing .[ch]
87659607e0Smrg
88a73597f9SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
89a73597f9Smrg'g' are ignored when checking the name.
90b73be646Smrg
91659607e0SmrgSend bug reports to <bug-automake@gnu.org>."
92659607e0Smrg    exit $?
93659607e0Smrg    ;;
94659607e0Smrg
95659607e0Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
96659607e0Smrg    echo "missing $scriptversion (GNU Automake)"
97659607e0Smrg    exit $?
98659607e0Smrg    ;;
99659607e0Smrg
100659607e0Smrg  -*)
101e4da38afSmrg    echo 1>&2 "$0: Unknown '$1' option"
102a73597f9Smrg    echo 1>&2 "Try '$0 --help' for more information"
103659607e0Smrg    exit 1
104659607e0Smrg    ;;
105659607e0Smrg
106659607e0Smrgesac
107659607e0Smrg
108e4da38afSmrg# normalize program name to check for.
109e4da38afSmrgprogram=`echo "$1" | sed '
110e4da38afSmrg  s/^gnu-//; t
111e4da38afSmrg  s/^gnu//; t
112e4da38afSmrg  s/^g//; t'`
113e4da38afSmrg
114e4da38afSmrg# Now exit if we have it, but it failed.  Also exit now if we
115e4da38afSmrg# don't have it and --version was passed (most likely to detect
116e4da38afSmrg# the program).  This is about non-GNU programs, so use $1 not
117e4da38afSmrg# $program.
118e4da38afSmrgcase $1 in
119e4da38afSmrg  lex*|yacc*)
120e4da38afSmrg    # Not GNU programs, they don't have --version.
121e4da38afSmrg    ;;
122e4da38afSmrg
123e4da38afSmrg  *)
124e4da38afSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
125e4da38afSmrg       # We have it, but it failed.
126e4da38afSmrg       exit 1
127e4da38afSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
128e4da38afSmrg       # Could not run --version or --help.  This is probably someone
129e4da38afSmrg       # running '$TOOL --version' or '$TOOL --help' to check whether
130e4da38afSmrg       # $TOOL exists and not knowing $TOOL uses missing.
131e4da38afSmrg       exit 1
132e4da38afSmrg    fi
133e4da38afSmrg    ;;
134e4da38afSmrgesac
135e4da38afSmrg
136e4da38afSmrg# If it does not exist, or fails to run (possibly an outdated version),
137e4da38afSmrg# try to emulate it.
138e4da38afSmrgcase $program in
139e4da38afSmrg  aclocal*)
140e4da38afSmrg    echo 1>&2 "\
141e4da38afSmrgWARNING: '$1' is $msg.  You should only need it if
142e4da38afSmrg         you modified 'acinclude.m4' or '${configure_ac}'.  You might want
143e4da38afSmrg         to install the Automake and Perl packages.  Grab them from
144e4da38afSmrg         any GNU archive site."
145e4da38afSmrg    touch aclocal.m4
146e4da38afSmrg    ;;
147e4da38afSmrg
148e4da38afSmrg  autoconf*)
149e4da38afSmrg    echo 1>&2 "\
150e4da38afSmrgWARNING: '$1' is $msg.  You should only need it if
151e4da38afSmrg         you modified '${configure_ac}'.  You might want to install the
152e4da38afSmrg         Autoconf and GNU m4 packages.  Grab them from any GNU
153e4da38afSmrg         archive site."
154e4da38afSmrg    touch configure
155e4da38afSmrg    ;;
156659607e0Smrg
157e4da38afSmrg  autoheader*)
158e4da38afSmrg    echo 1>&2 "\
159e4da38afSmrgWARNING: '$1' is $msg.  You should only need it if
160e4da38afSmrg         you modified 'acconfig.h' or '${configure_ac}'.  You might want
161e4da38afSmrg         to install the Autoconf and GNU m4 packages.  Grab them
162e4da38afSmrg         from any GNU archive site."
163e4da38afSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
164e4da38afSmrg    test -z "$files" && files="config.h"
165e4da38afSmrg    touch_files=
166e4da38afSmrg    for f in $files; do
167e4da38afSmrg      case $f in
168e4da38afSmrg      *:*) touch_files="$touch_files "`echo "$f" |
169e4da38afSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
170e4da38afSmrg      *) touch_files="$touch_files $f.in";;
171e4da38afSmrg      esac
172e4da38afSmrg    done
173e4da38afSmrg    touch $touch_files
174659607e0Smrg    ;;
175e4da38afSmrg
176e4da38afSmrg  automake*)
177e4da38afSmrg    echo 1>&2 "\
178e4da38afSmrgWARNING: '$1' is $msg.  You should only need it if
179e4da38afSmrg         you modified 'Makefile.am', 'acinclude.m4' or '${configure_ac}'.
180e4da38afSmrg         You might want to install the Automake and Perl packages.
181e4da38afSmrg         Grab them from any GNU archive site."
182e4da38afSmrg    find . -type f -name Makefile.am -print |
183e4da38afSmrg	   sed 's/\.am$/.in/' |
184e4da38afSmrg	   while read f; do touch "$f"; done
185e4da38afSmrg    ;;
186e4da38afSmrg
187e4da38afSmrg  autom4te*)
188e4da38afSmrg    echo 1>&2 "\
189e4da38afSmrgWARNING: '$1' is needed, but is $msg.
190e4da38afSmrg         You might have modified some files without having the
191e4da38afSmrg         proper tools for further handling them.
192e4da38afSmrg         You can get '$1' as part of Autoconf from any GNU
193e4da38afSmrg         archive site."
194e4da38afSmrg
195e4da38afSmrg    file=`echo "$*" | sed -n "$sed_output"`
196e4da38afSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
197e4da38afSmrg    if test -f "$file"; then
198e4da38afSmrg	touch $file
199e4da38afSmrg    else
200e4da38afSmrg	test -z "$file" || exec >$file
201e4da38afSmrg	echo "#! /bin/sh"
202e4da38afSmrg	echo "# Created by GNU Automake missing as a replacement of"
203e4da38afSmrg	echo "#  $ $@"
204e4da38afSmrg	echo "exit 0"
205e4da38afSmrg	chmod +x $file
206e4da38afSmrg	exit 1
207e4da38afSmrg    fi
208e4da38afSmrg    ;;
209e4da38afSmrg
210e4da38afSmrg  bison*|yacc*)
211e4da38afSmrg    echo 1>&2 "\
212e4da38afSmrgWARNING: '$1' $msg.  You should only need it if
213e4da38afSmrg         you modified a '.y' file.  You may need the Bison package
214e4da38afSmrg         in order for those modifications to take effect.  You can get
215e4da38afSmrg         Bison from any GNU archive site."
216e4da38afSmrg    rm -f y.tab.c y.tab.h
217e4da38afSmrg    if test $# -ne 1; then
218e4da38afSmrg        eval LASTARG=\${$#}
219e4da38afSmrg	case $LASTARG in
220e4da38afSmrg	*.y)
221e4da38afSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
222e4da38afSmrg	    if test -f "$SRCFILE"; then
223e4da38afSmrg	         cp "$SRCFILE" y.tab.c
224e4da38afSmrg	    fi
225e4da38afSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
226e4da38afSmrg	    if test -f "$SRCFILE"; then
227e4da38afSmrg	         cp "$SRCFILE" y.tab.h
228e4da38afSmrg	    fi
229e4da38afSmrg	  ;;
230e4da38afSmrg	esac
231e4da38afSmrg    fi
232e4da38afSmrg    if test ! -f y.tab.h; then
233e4da38afSmrg	echo >y.tab.h
234e4da38afSmrg    fi
235e4da38afSmrg    if test ! -f y.tab.c; then
236e4da38afSmrg	echo 'main() { return 0; }' >y.tab.c
237e4da38afSmrg    fi
238e4da38afSmrg    ;;
239e4da38afSmrg
240e4da38afSmrg  lex*|flex*)
241e4da38afSmrg    echo 1>&2 "\
242e4da38afSmrgWARNING: '$1' is $msg.  You should only need it if
243e4da38afSmrg         you modified a '.l' file.  You may need the Flex package
244e4da38afSmrg         in order for those modifications to take effect.  You can get
245e4da38afSmrg         Flex from any GNU archive site."
246e4da38afSmrg    rm -f lex.yy.c
247e4da38afSmrg    if test $# -ne 1; then
248e4da38afSmrg        eval LASTARG=\${$#}
249e4da38afSmrg	case $LASTARG in
250e4da38afSmrg	*.l)
251e4da38afSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
252e4da38afSmrg	    if test -f "$SRCFILE"; then
253e4da38afSmrg	         cp "$SRCFILE" lex.yy.c
254e4da38afSmrg	    fi
255e4da38afSmrg	  ;;
256e4da38afSmrg	esac
257e4da38afSmrg    fi
258e4da38afSmrg    if test ! -f lex.yy.c; then
259e4da38afSmrg	echo 'main() { return 0; }' >lex.yy.c
260e4da38afSmrg    fi
261e4da38afSmrg    ;;
262e4da38afSmrg
263e4da38afSmrg  help2man*)
264e4da38afSmrg    echo 1>&2 "\
265e4da38afSmrgWARNING: '$1' is $msg.  You should only need it if
266e4da38afSmrg	 you modified a dependency of a manual page.  You may need the
267e4da38afSmrg	 Help2man package in order for those modifications to take
268e4da38afSmrg	 effect.  You can get Help2man from any GNU archive site."
269e4da38afSmrg
270e4da38afSmrg    file=`echo "$*" | sed -n "$sed_output"`
271e4da38afSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
272e4da38afSmrg    if test -f "$file"; then
273e4da38afSmrg	touch $file
274e4da38afSmrg    else
275e4da38afSmrg	test -z "$file" || exec >$file
276e4da38afSmrg	echo ".ab help2man is required to generate this page"
277e4da38afSmrg	exit $?
278e4da38afSmrg    fi
279e4da38afSmrg    ;;
280e4da38afSmrg
281e4da38afSmrg  makeinfo*)
282e4da38afSmrg    echo 1>&2 "\
283e4da38afSmrgWARNING: '$1' is $msg.  You should only need it if
284e4da38afSmrg         you modified a '.texi' or '.texinfo' file, or any other file
285e4da38afSmrg         indirectly affecting the aspect of the manual.  The spurious
286e4da38afSmrg         call might also be the consequence of using a buggy 'make' (AIX,
287e4da38afSmrg         DU, IRIX).  You might want to install the Texinfo package or
288e4da38afSmrg         the GNU make package.  Grab either from any GNU archive site."
289e4da38afSmrg    # The file to touch is that specified with -o ...
290e4da38afSmrg    file=`echo "$*" | sed -n "$sed_output"`
291e4da38afSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
292e4da38afSmrg    if test -z "$file"; then
293e4da38afSmrg      # ... or it is the one specified with @setfilename ...
294e4da38afSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
295e4da38afSmrg      file=`sed -n '
296e4da38afSmrg	/^@setfilename/{
297e4da38afSmrg	  s/.* \([^ ]*\) *$/\1/
298e4da38afSmrg	  p
299e4da38afSmrg	  q
300e4da38afSmrg	}' $infile`
301e4da38afSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
302e4da38afSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
303e4da38afSmrg    fi
304e4da38afSmrg    # If the file does not exist, the user really needs makeinfo;
305e4da38afSmrg    # let's fail without touching anything.
306e4da38afSmrg    test -f $file || exit 1
307e4da38afSmrg    touch $file
308e4da38afSmrg    ;;
309e4da38afSmrg
310e4da38afSmrg  *)
311e4da38afSmrg    echo 1>&2 "\
312e4da38afSmrgWARNING: '$1' is needed, and is $msg.
313e4da38afSmrg         You might have modified some files without having the
314e4da38afSmrg         proper tools for further handling them.  Check the 'README' file,
315e4da38afSmrg         it often tells you about the needed prerequisites for installing
316e4da38afSmrg         this package.  You may also peek at any GNU archive site, in case
317e4da38afSmrg         some other package would contain this missing '$1' program."
318e4da38afSmrg    exit 1
319e4da38afSmrg    ;;
320e4da38afSmrgesac
321e4da38afSmrg
322e4da38afSmrgexit 0
323659607e0Smrg
324659607e0Smrg# Local variables:
325659607e0Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
326659607e0Smrg# time-stamp-start: "scriptversion="
327659607e0Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
328b73be646Smrg# time-stamp-time-zone: "UTC"
329b73be646Smrg# time-stamp-end: "; # UTC"
330659607e0Smrg# End:
331