missing revision 3f6d0e1d
1692f60a7Smrg#! /bin/sh
2692f60a7Smrg# Common stub for a few missing GNU programs while installing.
3692f60a7Smrg
43f6d0e1dSmrgscriptversion=2012-01-06.13; # UTC
5692f60a7Smrg
63f6d0e1dSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
73f6d0e1dSmrg# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
8692f60a7Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9692f60a7Smrg
10692f60a7Smrg# This program is free software; you can redistribute it and/or modify
11692f60a7Smrg# it under the terms of the GNU General Public License as published by
12692f60a7Smrg# the Free Software Foundation; either version 2, or (at your option)
13692f60a7Smrg# any later version.
14692f60a7Smrg
15692f60a7Smrg# This program is distributed in the hope that it will be useful,
16692f60a7Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17692f60a7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18692f60a7Smrg# GNU General Public License for more details.
19692f60a7Smrg
20692f60a7Smrg# You should have received a copy of the GNU General Public License
213f6d0e1dSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22692f60a7Smrg
23692f60a7Smrg# As a special exception to the GNU General Public License, if you
24692f60a7Smrg# distribute this file as part of a program that contains a
25692f60a7Smrg# configuration script generated by Autoconf, you may include it under
26692f60a7Smrg# the same distribution terms that you use for the rest of that program.
27692f60a7Smrg
28692f60a7Smrgif test $# -eq 0; then
29692f60a7Smrg  echo 1>&2 "Try \`$0 --help' for more information"
30692f60a7Smrg  exit 1
31692f60a7Smrgfi
32692f60a7Smrg
33692f60a7Smrgrun=:
3454569438Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
3554569438Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
36692f60a7Smrg
37692f60a7Smrg# In the cases where this matters, `missing' is being run in the
38692f60a7Smrg# srcdir already.
39692f60a7Smrgif test -f configure.ac; then
40692f60a7Smrg  configure_ac=configure.ac
41692f60a7Smrgelse
42692f60a7Smrg  configure_ac=configure.in
43692f60a7Smrgfi
44692f60a7Smrg
45692f60a7Smrgmsg="missing on your system"
46692f60a7Smrg
4754569438Smrgcase $1 in
48692f60a7Smrg--run)
49692f60a7Smrg  # Try to run requested program, and just exit if it succeeds.
50692f60a7Smrg  run=
51692f60a7Smrg  shift
52692f60a7Smrg  "$@" && exit 0
53692f60a7Smrg  # Exit code 63 means version mismatch.  This often happens
54692f60a7Smrg  # when the user try to use an ancient version of a tool on
55692f60a7Smrg  # a file that requires a minimum version.  In this case we
56692f60a7Smrg  # we should proceed has if the program had been absent, or
57692f60a7Smrg  # if --run hadn't been passed.
58692f60a7Smrg  if test $? = 63; then
59692f60a7Smrg    run=:
60692f60a7Smrg    msg="probably too old"
61692f60a7Smrg  fi
62692f60a7Smrg  ;;
63692f60a7Smrg
64692f60a7Smrg  -h|--h|--he|--hel|--help)
65692f60a7Smrg    echo "\
66692f60a7Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
67692f60a7Smrg
68692f60a7SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69692f60a7Smrgerror status if there is no known handling for PROGRAM.
70692f60a7Smrg
71692f60a7SmrgOptions:
72692f60a7Smrg  -h, --help      display this help and exit
73692f60a7Smrg  -v, --version   output version information and exit
74692f60a7Smrg  --run           try to run the given command, and emulate it if it fails
75692f60a7Smrg
76692f60a7SmrgSupported PROGRAM values:
77692f60a7Smrg  aclocal      touch file \`aclocal.m4'
78692f60a7Smrg  autoconf     touch file \`configure'
79692f60a7Smrg  autoheader   touch file \`config.h.in'
8054569438Smrg  autom4te     touch the output file, or create a stub one
81692f60a7Smrg  automake     touch all \`Makefile.in' files
82692f60a7Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
83692f60a7Smrg  flex         create \`lex.yy.c', if possible, from existing .c
84692f60a7Smrg  help2man     touch the output file
85692f60a7Smrg  lex          create \`lex.yy.c', if possible, from existing .c
86692f60a7Smrg  makeinfo     touch the output file
87692f60a7Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
88692f60a7Smrg
893f6d0e1dSmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
903f6d0e1dSmrg\`g' are ignored when checking the name.
913f6d0e1dSmrg
92692f60a7SmrgSend bug reports to <bug-automake@gnu.org>."
93692f60a7Smrg    exit $?
94692f60a7Smrg    ;;
95692f60a7Smrg
96692f60a7Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
97692f60a7Smrg    echo "missing $scriptversion (GNU Automake)"
98692f60a7Smrg    exit $?
99692f60a7Smrg    ;;
100692f60a7Smrg
101692f60a7Smrg  -*)
102692f60a7Smrg    echo 1>&2 "$0: Unknown \`$1' option"
103692f60a7Smrg    echo 1>&2 "Try \`$0 --help' for more information"
104692f60a7Smrg    exit 1
105692f60a7Smrg    ;;
106692f60a7Smrg
107692f60a7Smrgesac
108692f60a7Smrg
1093f6d0e1dSmrg# normalize program name to check for.
1103f6d0e1dSmrgprogram=`echo "$1" | sed '
1113f6d0e1dSmrg  s/^gnu-//; t
1123f6d0e1dSmrg  s/^gnu//; t
1133f6d0e1dSmrg  s/^g//; t'`
1143f6d0e1dSmrg
115692f60a7Smrg# Now exit if we have it, but it failed.  Also exit now if we
116692f60a7Smrg# don't have it and --version was passed (most likely to detect
1173f6d0e1dSmrg# the program).  This is about non-GNU programs, so use $1 not
1183f6d0e1dSmrg# $program.
11954569438Smrgcase $1 in
1203f6d0e1dSmrg  lex*|yacc*)
121692f60a7Smrg    # Not GNU programs, they don't have --version.
122692f60a7Smrg    ;;
123692f60a7Smrg
124692f60a7Smrg  *)
125692f60a7Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
126692f60a7Smrg       # We have it, but it failed.
127692f60a7Smrg       exit 1
128692f60a7Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
129692f60a7Smrg       # Could not run --version or --help.  This is probably someone
130692f60a7Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
131692f60a7Smrg       # $TOOL exists and not knowing $TOOL uses missing.
132692f60a7Smrg       exit 1
133692f60a7Smrg    fi
134692f60a7Smrg    ;;
135692f60a7Smrgesac
136692f60a7Smrg
137692f60a7Smrg# If it does not exist, or fails to run (possibly an outdated version),
138692f60a7Smrg# try to emulate it.
1393f6d0e1dSmrgcase $program in
140692f60a7Smrg  aclocal*)
141692f60a7Smrg    echo 1>&2 "\
142692f60a7SmrgWARNING: \`$1' is $msg.  You should only need it if
143692f60a7Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
144692f60a7Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
145692f60a7Smrg         any GNU archive site."
146692f60a7Smrg    touch aclocal.m4
147692f60a7Smrg    ;;
148692f60a7Smrg
1493f6d0e1dSmrg  autoconf*)
150692f60a7Smrg    echo 1>&2 "\
151692f60a7SmrgWARNING: \`$1' is $msg.  You should only need it if
152692f60a7Smrg         you modified \`${configure_ac}'.  You might want to install the
153692f60a7Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
154692f60a7Smrg         archive site."
155692f60a7Smrg    touch configure
156692f60a7Smrg    ;;
157692f60a7Smrg
1583f6d0e1dSmrg  autoheader*)
159692f60a7Smrg    echo 1>&2 "\
160692f60a7SmrgWARNING: \`$1' is $msg.  You should only need it if
161692f60a7Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
162692f60a7Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
163692f60a7Smrg         from any GNU archive site."
164692f60a7Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
165692f60a7Smrg    test -z "$files" && files="config.h"
166692f60a7Smrg    touch_files=
167692f60a7Smrg    for f in $files; do
16854569438Smrg      case $f in
169692f60a7Smrg      *:*) touch_files="$touch_files "`echo "$f" |
170692f60a7Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
171692f60a7Smrg      *) touch_files="$touch_files $f.in";;
172692f60a7Smrg      esac
173692f60a7Smrg    done
174692f60a7Smrg    touch $touch_files
175692f60a7Smrg    ;;
176692f60a7Smrg
177692f60a7Smrg  automake*)
178692f60a7Smrg    echo 1>&2 "\
179692f60a7SmrgWARNING: \`$1' is $msg.  You should only need it if
180692f60a7Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
181692f60a7Smrg         You might want to install the \`Automake' and \`Perl' packages.
182692f60a7Smrg         Grab them from any GNU archive site."
183692f60a7Smrg    find . -type f -name Makefile.am -print |
184692f60a7Smrg	   sed 's/\.am$/.in/' |
185692f60a7Smrg	   while read f; do touch "$f"; done
186692f60a7Smrg    ;;
187692f60a7Smrg
1883f6d0e1dSmrg  autom4te*)
189692f60a7Smrg    echo 1>&2 "\
190692f60a7SmrgWARNING: \`$1' is needed, but is $msg.
191692f60a7Smrg         You might have modified some files without having the
192692f60a7Smrg         proper tools for further handling them.
193692f60a7Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
194692f60a7Smrg         archive site."
195692f60a7Smrg
19654569438Smrg    file=`echo "$*" | sed -n "$sed_output"`
19754569438Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
198692f60a7Smrg    if test -f "$file"; then
199692f60a7Smrg	touch $file
200692f60a7Smrg    else
201692f60a7Smrg	test -z "$file" || exec >$file
202692f60a7Smrg	echo "#! /bin/sh"
203692f60a7Smrg	echo "# Created by GNU Automake missing as a replacement of"
204692f60a7Smrg	echo "#  $ $@"
205692f60a7Smrg	echo "exit 0"
206692f60a7Smrg	chmod +x $file
207692f60a7Smrg	exit 1
208692f60a7Smrg    fi
209692f60a7Smrg    ;;
210692f60a7Smrg
2113f6d0e1dSmrg  bison*|yacc*)
212692f60a7Smrg    echo 1>&2 "\
213692f60a7SmrgWARNING: \`$1' $msg.  You should only need it if
214692f60a7Smrg         you modified a \`.y' file.  You may need the \`Bison' package
215692f60a7Smrg         in order for those modifications to take effect.  You can get
216692f60a7Smrg         \`Bison' from any GNU archive site."
217692f60a7Smrg    rm -f y.tab.c y.tab.h
21854569438Smrg    if test $# -ne 1; then
2193f6d0e1dSmrg        eval LASTARG=\${$#}
22054569438Smrg	case $LASTARG in
221692f60a7Smrg	*.y)
222692f60a7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
22354569438Smrg	    if test -f "$SRCFILE"; then
224692f60a7Smrg	         cp "$SRCFILE" y.tab.c
225692f60a7Smrg	    fi
226692f60a7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
22754569438Smrg	    if test -f "$SRCFILE"; then
228692f60a7Smrg	         cp "$SRCFILE" y.tab.h
229692f60a7Smrg	    fi
230692f60a7Smrg	  ;;
231692f60a7Smrg	esac
232692f60a7Smrg    fi
23354569438Smrg    if test ! -f y.tab.h; then
234692f60a7Smrg	echo >y.tab.h
235692f60a7Smrg    fi
23654569438Smrg    if test ! -f y.tab.c; then
237692f60a7Smrg	echo 'main() { return 0; }' >y.tab.c
238692f60a7Smrg    fi
239692f60a7Smrg    ;;
240692f60a7Smrg
2413f6d0e1dSmrg  lex*|flex*)
242692f60a7Smrg    echo 1>&2 "\
243692f60a7SmrgWARNING: \`$1' is $msg.  You should only need it if
244692f60a7Smrg         you modified a \`.l' file.  You may need the \`Flex' package
245692f60a7Smrg         in order for those modifications to take effect.  You can get
246692f60a7Smrg         \`Flex' from any GNU archive site."
247692f60a7Smrg    rm -f lex.yy.c
24854569438Smrg    if test $# -ne 1; then
2493f6d0e1dSmrg        eval LASTARG=\${$#}
25054569438Smrg	case $LASTARG in
251692f60a7Smrg	*.l)
252692f60a7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
25354569438Smrg	    if test -f "$SRCFILE"; then
254692f60a7Smrg	         cp "$SRCFILE" lex.yy.c
255692f60a7Smrg	    fi
256692f60a7Smrg	  ;;
257692f60a7Smrg	esac
258692f60a7Smrg    fi
25954569438Smrg    if test ! -f lex.yy.c; then
260692f60a7Smrg	echo 'main() { return 0; }' >lex.yy.c
261692f60a7Smrg    fi
262692f60a7Smrg    ;;
263692f60a7Smrg
2643f6d0e1dSmrg  help2man*)
265692f60a7Smrg    echo 1>&2 "\
266692f60a7SmrgWARNING: \`$1' is $msg.  You should only need it if
267692f60a7Smrg	 you modified a dependency of a manual page.  You may need the
268692f60a7Smrg	 \`Help2man' package in order for those modifications to take
269692f60a7Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
270692f60a7Smrg
27154569438Smrg    file=`echo "$*" | sed -n "$sed_output"`
27254569438Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
27354569438Smrg    if test -f "$file"; then
274692f60a7Smrg	touch $file
275692f60a7Smrg    else
276692f60a7Smrg	test -z "$file" || exec >$file
277692f60a7Smrg	echo ".ab help2man is required to generate this page"
2783f6d0e1dSmrg	exit $?
279692f60a7Smrg    fi
280692f60a7Smrg    ;;
281692f60a7Smrg
2823f6d0e1dSmrg  makeinfo*)
283692f60a7Smrg    echo 1>&2 "\
284692f60a7SmrgWARNING: \`$1' is $msg.  You should only need it if
285692f60a7Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
286692f60a7Smrg         indirectly affecting the aspect of the manual.  The spurious
287692f60a7Smrg         call might also be the consequence of using a buggy \`make' (AIX,
288692f60a7Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
289692f60a7Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
290692f60a7Smrg    # The file to touch is that specified with -o ...
29154569438Smrg    file=`echo "$*" | sed -n "$sed_output"`
29254569438Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
293692f60a7Smrg    if test -z "$file"; then
294692f60a7Smrg      # ... or it is the one specified with @setfilename ...
295692f60a7Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
29654569438Smrg      file=`sed -n '
29754569438Smrg	/^@setfilename/{
29854569438Smrg	  s/.* \([^ ]*\) *$/\1/
29954569438Smrg	  p
30054569438Smrg	  q
30154569438Smrg	}' $infile`
302692f60a7Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
303692f60a7Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
304692f60a7Smrg    fi
305692f60a7Smrg    # If the file does not exist, the user really needs makeinfo;
306692f60a7Smrg    # let's fail without touching anything.
307692f60a7Smrg    test -f $file || exit 1
308692f60a7Smrg    touch $file
309692f60a7Smrg    ;;
310692f60a7Smrg
311692f60a7Smrg  *)
312692f60a7Smrg    echo 1>&2 "\
313692f60a7SmrgWARNING: \`$1' is needed, and is $msg.
314692f60a7Smrg         You might have modified some files without having the
315692f60a7Smrg         proper tools for further handling them.  Check the \`README' file,
316692f60a7Smrg         it often tells you about the needed prerequisites for installing
317692f60a7Smrg         this package.  You may also peek at any GNU archive site, in case
318692f60a7Smrg         some other package would contain this missing \`$1' program."
319692f60a7Smrg    exit 1
320692f60a7Smrg    ;;
321692f60a7Smrgesac
322692f60a7Smrg
323692f60a7Smrgexit 0
324692f60a7Smrg
325692f60a7Smrg# Local variables:
326692f60a7Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
327692f60a7Smrg# time-stamp-start: "scriptversion="
328692f60a7Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3293f6d0e1dSmrg# time-stamp-time-zone: "UTC"
3303f6d0e1dSmrg# time-stamp-end: "; # UTC"
331692f60a7Smrg# End:
332