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