missing revision a73597f9
1659607e0Smrg#! /bin/sh
2659607e0Smrg# Common stub for a few missing GNU programs while installing.
3659607e0Smrg
4a73597f9Smrgscriptversion=2012-01-06.18; # UTC
5659607e0Smrg
6a73597f9Smrg# Copyright (C) 1996-2012 Free Software Foundation, Inc.
7659607e0Smrg# 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
32659607e0Smrgrun=:
33659607e0Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
34659607e0Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
35659607e0Smrg
36a73597f9Smrg# In the cases where this matters, 'missing' is being run in the
37659607e0Smrg# srcdir already.
38659607e0Smrgif test -f configure.ac; then
39659607e0Smrg  configure_ac=configure.ac
40659607e0Smrgelse
41659607e0Smrg  configure_ac=configure.in
42659607e0Smrgfi
43659607e0Smrg
44659607e0Smrgmsg="missing on your system"
45659607e0Smrg
46659607e0Smrgcase $1 in
47659607e0Smrg--run)
48659607e0Smrg  # Try to run requested program, and just exit if it succeeds.
49659607e0Smrg  run=
50659607e0Smrg  shift
51659607e0Smrg  "$@" && exit 0
52659607e0Smrg  # Exit code 63 means version mismatch.  This often happens
53659607e0Smrg  # when the user try to use an ancient version of a tool on
54659607e0Smrg  # a file that requires a minimum version.  In this case we
55659607e0Smrg  # we should proceed has if the program had been absent, or
56659607e0Smrg  # if --run hadn't been passed.
57659607e0Smrg  if test $? = 63; then
58659607e0Smrg    run=:
59659607e0Smrg    msg="probably too old"
60659607e0Smrg  fi
61659607e0Smrg  ;;
62659607e0Smrg
63659607e0Smrg  -h|--h|--he|--hel|--help)
64659607e0Smrg    echo "\
65659607e0Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
66659607e0Smrg
67a73597f9SmrgHandle 'PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
68659607e0Smrgerror 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
73659607e0Smrg  --run           try to run the given command, and emulate it if it fails
74659607e0Smrg
75659607e0SmrgSupported PROGRAM values:
76a73597f9Smrg  aclocal      touch file 'aclocal.m4'
77a73597f9Smrg  autoconf     touch file 'configure'
78a73597f9Smrg  autoheader   touch file 'config.h.in'
79659607e0Smrg  autom4te     touch the output file, or create a stub one
80a73597f9Smrg  automake     touch all 'Makefile.in' files
81a73597f9Smrg  bison        create 'y.tab.[ch]', if possible, from existing .[ch]
82a73597f9Smrg  flex         create 'lex.yy.c', if possible, from existing .c
83659607e0Smrg  help2man     touch the output file
84a73597f9Smrg  lex          create 'lex.yy.c', if possible, from existing .c
85659607e0Smrg  makeinfo     touch the output file
86a73597f9Smrg  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  -*)
101a73597f9Smrg    echo 1>&2 "$0: Unknown '$1' option"
102a73597f9Smrg    echo 1>&2 "Try '$0 --help' for more information"
103659607e0Smrg    exit 1
104659607e0Smrg    ;;
105659607e0Smrg
106659607e0Smrgesac
107659607e0Smrg
108b73be646Smrg# normalize program name to check for.
109b73be646Smrgprogram=`echo "$1" | sed '
110b73be646Smrg  s/^gnu-//; t
111b73be646Smrg  s/^gnu//; t
112b73be646Smrg  s/^g//; t'`
113b73be646Smrg
114659607e0Smrg# Now exit if we have it, but it failed.  Also exit now if we
115659607e0Smrg# don't have it and --version was passed (most likely to detect
116b73be646Smrg# the program).  This is about non-GNU programs, so use $1 not
117b73be646Smrg# $program.
118659607e0Smrgcase $1 in
119b73be646Smrg  lex*|yacc*)
120659607e0Smrg    # Not GNU programs, they don't have --version.
121659607e0Smrg    ;;
122659607e0Smrg
123659607e0Smrg  *)
124659607e0Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
125659607e0Smrg       # We have it, but it failed.
126659607e0Smrg       exit 1
127659607e0Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
128659607e0Smrg       # Could not run --version or --help.  This is probably someone
129a73597f9Smrg       # running '$TOOL --version' or '$TOOL --help' to check whether
130659607e0Smrg       # $TOOL exists and not knowing $TOOL uses missing.
131659607e0Smrg       exit 1
132659607e0Smrg    fi
133659607e0Smrg    ;;
134659607e0Smrgesac
135659607e0Smrg
136659607e0Smrg# If it does not exist, or fails to run (possibly an outdated version),
137659607e0Smrg# try to emulate it.
138b73be646Smrgcase $program in
139659607e0Smrg  aclocal*)
140659607e0Smrg    echo 1>&2 "\
141a73597f9SmrgWARNING: '$1' is $msg.  You should only need it if
142a73597f9Smrg         you modified 'acinclude.m4' or '${configure_ac}'.  You might want
143a73597f9Smrg         to install the Automake and Perl packages.  Grab them from
144659607e0Smrg         any GNU archive site."
145659607e0Smrg    touch aclocal.m4
146659607e0Smrg    ;;
147659607e0Smrg
148b73be646Smrg  autoconf*)
149659607e0Smrg    echo 1>&2 "\
150a73597f9SmrgWARNING: '$1' is $msg.  You should only need it if
151a73597f9Smrg         you modified '${configure_ac}'.  You might want to install the
152a73597f9Smrg         Autoconf and GNU m4 packages.  Grab them from any GNU
153659607e0Smrg         archive site."
154659607e0Smrg    touch configure
155659607e0Smrg    ;;
156659607e0Smrg
157b73be646Smrg  autoheader*)
158659607e0Smrg    echo 1>&2 "\
159a73597f9SmrgWARNING: '$1' is $msg.  You should only need it if
160a73597f9Smrg         you modified 'acconfig.h' or '${configure_ac}'.  You might want
161a73597f9Smrg         to install the Autoconf and GNU m4 packages.  Grab them
162659607e0Smrg         from any GNU archive site."
163659607e0Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
164659607e0Smrg    test -z "$files" && files="config.h"
165659607e0Smrg    touch_files=
166659607e0Smrg    for f in $files; do
167659607e0Smrg      case $f in
168659607e0Smrg      *:*) touch_files="$touch_files "`echo "$f" |
169659607e0Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
170659607e0Smrg      *) touch_files="$touch_files $f.in";;
171659607e0Smrg      esac
172659607e0Smrg    done
173659607e0Smrg    touch $touch_files
174659607e0Smrg    ;;
175659607e0Smrg
176659607e0Smrg  automake*)
177659607e0Smrg    echo 1>&2 "\
178a73597f9SmrgWARNING: '$1' is $msg.  You should only need it if
179a73597f9Smrg         you modified 'Makefile.am', 'acinclude.m4' or '${configure_ac}'.
180a73597f9Smrg         You might want to install the Automake and Perl packages.
181659607e0Smrg         Grab them from any GNU archive site."
182659607e0Smrg    find . -type f -name Makefile.am -print |
183659607e0Smrg	   sed 's/\.am$/.in/' |
184659607e0Smrg	   while read f; do touch "$f"; done
185659607e0Smrg    ;;
186659607e0Smrg
187b73be646Smrg  autom4te*)
188659607e0Smrg    echo 1>&2 "\
189a73597f9SmrgWARNING: '$1' is needed, but is $msg.
190659607e0Smrg         You might have modified some files without having the
191659607e0Smrg         proper tools for further handling them.
192a73597f9Smrg         You can get '$1' as part of Autoconf from any GNU
193659607e0Smrg         archive site."
194659607e0Smrg
195659607e0Smrg    file=`echo "$*" | sed -n "$sed_output"`
196659607e0Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
197659607e0Smrg    if test -f "$file"; then
198659607e0Smrg	touch $file
199659607e0Smrg    else
200659607e0Smrg	test -z "$file" || exec >$file
201659607e0Smrg	echo "#! /bin/sh"
202659607e0Smrg	echo "# Created by GNU Automake missing as a replacement of"
203659607e0Smrg	echo "#  $ $@"
204659607e0Smrg	echo "exit 0"
205659607e0Smrg	chmod +x $file
206659607e0Smrg	exit 1
207659607e0Smrg    fi
208659607e0Smrg    ;;
209659607e0Smrg
210b73be646Smrg  bison*|yacc*)
211659607e0Smrg    echo 1>&2 "\
212a73597f9SmrgWARNING: '$1' $msg.  You should only need it if
213a73597f9Smrg         you modified a '.y' file.  You may need the Bison package
214659607e0Smrg         in order for those modifications to take effect.  You can get
215a73597f9Smrg         Bison from any GNU archive site."
216659607e0Smrg    rm -f y.tab.c y.tab.h
217659607e0Smrg    if test $# -ne 1; then
218a73597f9Smrg        eval LASTARG=\${$#}
219659607e0Smrg	case $LASTARG in
220659607e0Smrg	*.y)
221659607e0Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
222659607e0Smrg	    if test -f "$SRCFILE"; then
223659607e0Smrg	         cp "$SRCFILE" y.tab.c
224659607e0Smrg	    fi
225659607e0Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
226659607e0Smrg	    if test -f "$SRCFILE"; then
227659607e0Smrg	         cp "$SRCFILE" y.tab.h
228659607e0Smrg	    fi
229659607e0Smrg	  ;;
230659607e0Smrg	esac
231659607e0Smrg    fi
232659607e0Smrg    if test ! -f y.tab.h; then
233659607e0Smrg	echo >y.tab.h
234659607e0Smrg    fi
235659607e0Smrg    if test ! -f y.tab.c; then
236659607e0Smrg	echo 'main() { return 0; }' >y.tab.c
237659607e0Smrg    fi
238659607e0Smrg    ;;
239659607e0Smrg
240b73be646Smrg  lex*|flex*)
241659607e0Smrg    echo 1>&2 "\
242a73597f9SmrgWARNING: '$1' is $msg.  You should only need it if
243a73597f9Smrg         you modified a '.l' file.  You may need the Flex package
244659607e0Smrg         in order for those modifications to take effect.  You can get
245a73597f9Smrg         Flex from any GNU archive site."
246659607e0Smrg    rm -f lex.yy.c
247659607e0Smrg    if test $# -ne 1; then
248a73597f9Smrg        eval LASTARG=\${$#}
249659607e0Smrg	case $LASTARG in
250659607e0Smrg	*.l)
251659607e0Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
252659607e0Smrg	    if test -f "$SRCFILE"; then
253659607e0Smrg	         cp "$SRCFILE" lex.yy.c
254659607e0Smrg	    fi
255659607e0Smrg	  ;;
256659607e0Smrg	esac
257659607e0Smrg    fi
258659607e0Smrg    if test ! -f lex.yy.c; then
259659607e0Smrg	echo 'main() { return 0; }' >lex.yy.c
260659607e0Smrg    fi
261659607e0Smrg    ;;
262659607e0Smrg
263b73be646Smrg  help2man*)
264659607e0Smrg    echo 1>&2 "\
265a73597f9SmrgWARNING: '$1' is $msg.  You should only need it if
266659607e0Smrg	 you modified a dependency of a manual page.  You may need the
267a73597f9Smrg	 Help2man package in order for those modifications to take
268a73597f9Smrg	 effect.  You can get Help2man from any GNU archive site."
269659607e0Smrg
270659607e0Smrg    file=`echo "$*" | sed -n "$sed_output"`
271659607e0Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
272659607e0Smrg    if test -f "$file"; then
273659607e0Smrg	touch $file
274659607e0Smrg    else
275659607e0Smrg	test -z "$file" || exec >$file
276659607e0Smrg	echo ".ab help2man is required to generate this page"
277b73be646Smrg	exit $?
278659607e0Smrg    fi
279659607e0Smrg    ;;
280659607e0Smrg
281b73be646Smrg  makeinfo*)
282659607e0Smrg    echo 1>&2 "\
283a73597f9SmrgWARNING: '$1' is $msg.  You should only need it if
284a73597f9Smrg         you modified a '.texi' or '.texinfo' file, or any other file
285659607e0Smrg         indirectly affecting the aspect of the manual.  The spurious
286a73597f9Smrg         call might also be the consequence of using a buggy 'make' (AIX,
287a73597f9Smrg         DU, IRIX).  You might want to install the Texinfo package or
288a73597f9Smrg         the GNU make package.  Grab either from any GNU archive site."
289659607e0Smrg    # The file to touch is that specified with -o ...
290659607e0Smrg    file=`echo "$*" | sed -n "$sed_output"`
291659607e0Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
292659607e0Smrg    if test -z "$file"; then
293659607e0Smrg      # ... or it is the one specified with @setfilename ...
294659607e0Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
295659607e0Smrg      file=`sed -n '
296659607e0Smrg	/^@setfilename/{
297659607e0Smrg	  s/.* \([^ ]*\) *$/\1/
298659607e0Smrg	  p
299659607e0Smrg	  q
300659607e0Smrg	}' $infile`
301659607e0Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
302659607e0Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
303659607e0Smrg    fi
304659607e0Smrg    # If the file does not exist, the user really needs makeinfo;
305659607e0Smrg    # let's fail without touching anything.
306659607e0Smrg    test -f $file || exit 1
307659607e0Smrg    touch $file
308659607e0Smrg    ;;
309659607e0Smrg
310659607e0Smrg  *)
311659607e0Smrg    echo 1>&2 "\
312a73597f9SmrgWARNING: '$1' is needed, and is $msg.
313659607e0Smrg         You might have modified some files without having the
314a73597f9Smrg         proper tools for further handling them.  Check the 'README' file,
315659607e0Smrg         it often tells you about the needed prerequisites for installing
316659607e0Smrg         this package.  You may also peek at any GNU archive site, in case
317a73597f9Smrg         some other package would contain this missing '$1' program."
318659607e0Smrg    exit 1
319659607e0Smrg    ;;
320659607e0Smrgesac
321659607e0Smrg
322659607e0Smrgexit 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