missing revision 3e72ca8c
1ee3138f1Smrg#! /bin/sh
2ee3138f1Smrg# Common stub for a few missing GNU programs while installing.
3ee3138f1Smrg
43e72ca8cSmrgscriptversion=2012-01-06.18; # UTC
5ee3138f1Smrg
63e72ca8cSmrg# Copyright (C) 1996-2012 Free Software Foundation, Inc.
7ee3138f1Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8ee3138f1Smrg
9ee3138f1Smrg# This program is free software; you can redistribute it and/or modify
10ee3138f1Smrg# it under the terms of the GNU General Public License as published by
11ee3138f1Smrg# the Free Software Foundation; either version 2, or (at your option)
12ee3138f1Smrg# any later version.
13ee3138f1Smrg
14ee3138f1Smrg# This program is distributed in the hope that it will be useful,
15ee3138f1Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
16ee3138f1Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17ee3138f1Smrg# GNU General Public License for more details.
18ee3138f1Smrg
19ee3138f1Smrg# You should have received a copy of the GNU General Public License
2034977a2fSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21ee3138f1Smrg
22ee3138f1Smrg# As a special exception to the GNU General Public License, if you
23ee3138f1Smrg# distribute this file as part of a program that contains a
24ee3138f1Smrg# configuration script generated by Autoconf, you may include it under
25ee3138f1Smrg# the same distribution terms that you use for the rest of that program.
26ee3138f1Smrg
27ee3138f1Smrgif test $# -eq 0; then
283e72ca8cSmrg  echo 1>&2 "Try '$0 --help' for more information"
29ee3138f1Smrg  exit 1
30ee3138f1Smrgfi
31ee3138f1Smrg
32ee3138f1Smrgrun=:
33ee3138f1Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
34ee3138f1Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
35ee3138f1Smrg
363e72ca8cSmrg# In the cases where this matters, 'missing' is being run in the
37ee3138f1Smrg# srcdir already.
38ee3138f1Smrgif test -f configure.ac; then
39ee3138f1Smrg  configure_ac=configure.ac
40ee3138f1Smrgelse
41ee3138f1Smrg  configure_ac=configure.in
42ee3138f1Smrgfi
43ee3138f1Smrg
44ee3138f1Smrgmsg="missing on your system"
45ee3138f1Smrg
46ee3138f1Smrgcase $1 in
47ee3138f1Smrg--run)
48ee3138f1Smrg  # Try to run requested program, and just exit if it succeeds.
49ee3138f1Smrg  run=
50ee3138f1Smrg  shift
51ee3138f1Smrg  "$@" && exit 0
52ee3138f1Smrg  # Exit code 63 means version mismatch.  This often happens
53ee3138f1Smrg  # when the user try to use an ancient version of a tool on
54ee3138f1Smrg  # a file that requires a minimum version.  In this case we
55ee3138f1Smrg  # we should proceed has if the program had been absent, or
56ee3138f1Smrg  # if --run hadn't been passed.
57ee3138f1Smrg  if test $? = 63; then
58ee3138f1Smrg    run=:
59ee3138f1Smrg    msg="probably too old"
60ee3138f1Smrg  fi
61ee3138f1Smrg  ;;
62ee3138f1Smrg
63ee3138f1Smrg  -h|--h|--he|--hel|--help)
64ee3138f1Smrg    echo "\
65ee3138f1Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
66ee3138f1Smrg
673e72ca8cSmrgHandle 'PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
68ee3138f1Smrgerror status if there is no known handling for PROGRAM.
69ee3138f1Smrg
70ee3138f1SmrgOptions:
71ee3138f1Smrg  -h, --help      display this help and exit
72ee3138f1Smrg  -v, --version   output version information and exit
73ee3138f1Smrg  --run           try to run the given command, and emulate it if it fails
74ee3138f1Smrg
75ee3138f1SmrgSupported PROGRAM values:
763e72ca8cSmrg  aclocal      touch file 'aclocal.m4'
773e72ca8cSmrg  autoconf     touch file 'configure'
783e72ca8cSmrg  autoheader   touch file 'config.h.in'
79ee3138f1Smrg  autom4te     touch the output file, or create a stub one
803e72ca8cSmrg  automake     touch all 'Makefile.in' files
813e72ca8cSmrg  bison        create 'y.tab.[ch]', if possible, from existing .[ch]
823e72ca8cSmrg  flex         create 'lex.yy.c', if possible, from existing .c
83ee3138f1Smrg  help2man     touch the output file
843e72ca8cSmrg  lex          create 'lex.yy.c', if possible, from existing .c
85ee3138f1Smrg  makeinfo     touch the output file
863e72ca8cSmrg  yacc         create 'y.tab.[ch]', if possible, from existing .[ch]
87ee3138f1Smrg
883e72ca8cSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
893e72ca8cSmrg'g' are ignored when checking the name.
9034977a2fSmrg
91ee3138f1SmrgSend bug reports to <bug-automake@gnu.org>."
92ee3138f1Smrg    exit $?
93ee3138f1Smrg    ;;
94ee3138f1Smrg
95ee3138f1Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
96ee3138f1Smrg    echo "missing $scriptversion (GNU Automake)"
97ee3138f1Smrg    exit $?
98ee3138f1Smrg    ;;
99ee3138f1Smrg
100ee3138f1Smrg  -*)
1013e72ca8cSmrg    echo 1>&2 "$0: Unknown '$1' option"
1023e72ca8cSmrg    echo 1>&2 "Try '$0 --help' for more information"
103ee3138f1Smrg    exit 1
104ee3138f1Smrg    ;;
105ee3138f1Smrg
106ee3138f1Smrgesac
107ee3138f1Smrg
10834977a2fSmrg# normalize program name to check for.
10934977a2fSmrgprogram=`echo "$1" | sed '
11034977a2fSmrg  s/^gnu-//; t
11134977a2fSmrg  s/^gnu//; t
11234977a2fSmrg  s/^g//; t'`
11334977a2fSmrg
114ee3138f1Smrg# Now exit if we have it, but it failed.  Also exit now if we
115ee3138f1Smrg# don't have it and --version was passed (most likely to detect
11634977a2fSmrg# the program).  This is about non-GNU programs, so use $1 not
11734977a2fSmrg# $program.
118ee3138f1Smrgcase $1 in
11934977a2fSmrg  lex*|yacc*)
120ee3138f1Smrg    # Not GNU programs, they don't have --version.
121ee3138f1Smrg    ;;
122ee3138f1Smrg
123ee3138f1Smrg  *)
124ee3138f1Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
125ee3138f1Smrg       # We have it, but it failed.
126ee3138f1Smrg       exit 1
127ee3138f1Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
128ee3138f1Smrg       # Could not run --version or --help.  This is probably someone
1293e72ca8cSmrg       # running '$TOOL --version' or '$TOOL --help' to check whether
130ee3138f1Smrg       # $TOOL exists and not knowing $TOOL uses missing.
131ee3138f1Smrg       exit 1
132ee3138f1Smrg    fi
133ee3138f1Smrg    ;;
134ee3138f1Smrgesac
135ee3138f1Smrg
136ee3138f1Smrg# If it does not exist, or fails to run (possibly an outdated version),
137ee3138f1Smrg# try to emulate it.
13834977a2fSmrgcase $program in
139ee3138f1Smrg  aclocal*)
140ee3138f1Smrg    echo 1>&2 "\
1413e72ca8cSmrgWARNING: '$1' is $msg.  You should only need it if
1423e72ca8cSmrg         you modified 'acinclude.m4' or '${configure_ac}'.  You might want
1433e72ca8cSmrg         to install the Automake and Perl packages.  Grab them from
144ee3138f1Smrg         any GNU archive site."
145ee3138f1Smrg    touch aclocal.m4
146ee3138f1Smrg    ;;
147ee3138f1Smrg
14834977a2fSmrg  autoconf*)
149ee3138f1Smrg    echo 1>&2 "\
1503e72ca8cSmrgWARNING: '$1' is $msg.  You should only need it if
1513e72ca8cSmrg         you modified '${configure_ac}'.  You might want to install the
1523e72ca8cSmrg         Autoconf and GNU m4 packages.  Grab them from any GNU
153ee3138f1Smrg         archive site."
154ee3138f1Smrg    touch configure
155ee3138f1Smrg    ;;
156ee3138f1Smrg
15734977a2fSmrg  autoheader*)
158ee3138f1Smrg    echo 1>&2 "\
1593e72ca8cSmrgWARNING: '$1' is $msg.  You should only need it if
1603e72ca8cSmrg         you modified 'acconfig.h' or '${configure_ac}'.  You might want
1613e72ca8cSmrg         to install the Autoconf and GNU m4 packages.  Grab them
162ee3138f1Smrg         from any GNU archive site."
163ee3138f1Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
164ee3138f1Smrg    test -z "$files" && files="config.h"
165ee3138f1Smrg    touch_files=
166ee3138f1Smrg    for f in $files; do
167ee3138f1Smrg      case $f in
168ee3138f1Smrg      *:*) touch_files="$touch_files "`echo "$f" |
169ee3138f1Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
170ee3138f1Smrg      *) touch_files="$touch_files $f.in";;
171ee3138f1Smrg      esac
172ee3138f1Smrg    done
173ee3138f1Smrg    touch $touch_files
174ee3138f1Smrg    ;;
175ee3138f1Smrg
176ee3138f1Smrg  automake*)
177ee3138f1Smrg    echo 1>&2 "\
1783e72ca8cSmrgWARNING: '$1' is $msg.  You should only need it if
1793e72ca8cSmrg         you modified 'Makefile.am', 'acinclude.m4' or '${configure_ac}'.
1803e72ca8cSmrg         You might want to install the Automake and Perl packages.
181ee3138f1Smrg         Grab them from any GNU archive site."
182ee3138f1Smrg    find . -type f -name Makefile.am -print |
183ee3138f1Smrg	   sed 's/\.am$/.in/' |
184ee3138f1Smrg	   while read f; do touch "$f"; done
185ee3138f1Smrg    ;;
186ee3138f1Smrg
18734977a2fSmrg  autom4te*)
188ee3138f1Smrg    echo 1>&2 "\
1893e72ca8cSmrgWARNING: '$1' is needed, but is $msg.
190ee3138f1Smrg         You might have modified some files without having the
191ee3138f1Smrg         proper tools for further handling them.
1923e72ca8cSmrg         You can get '$1' as part of Autoconf from any GNU
193ee3138f1Smrg         archive site."
194ee3138f1Smrg
195ee3138f1Smrg    file=`echo "$*" | sed -n "$sed_output"`
196ee3138f1Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
197ee3138f1Smrg    if test -f "$file"; then
198ee3138f1Smrg	touch $file
199ee3138f1Smrg    else
200ee3138f1Smrg	test -z "$file" || exec >$file
201ee3138f1Smrg	echo "#! /bin/sh"
202ee3138f1Smrg	echo "# Created by GNU Automake missing as a replacement of"
203ee3138f1Smrg	echo "#  $ $@"
204ee3138f1Smrg	echo "exit 0"
205ee3138f1Smrg	chmod +x $file
206ee3138f1Smrg	exit 1
207ee3138f1Smrg    fi
208ee3138f1Smrg    ;;
209ee3138f1Smrg
21034977a2fSmrg  bison*|yacc*)
211ee3138f1Smrg    echo 1>&2 "\
2123e72ca8cSmrgWARNING: '$1' $msg.  You should only need it if
2133e72ca8cSmrg         you modified a '.y' file.  You may need the Bison package
214ee3138f1Smrg         in order for those modifications to take effect.  You can get
2153e72ca8cSmrg         Bison from any GNU archive site."
216ee3138f1Smrg    rm -f y.tab.c y.tab.h
217ee3138f1Smrg    if test $# -ne 1; then
2183e72ca8cSmrg        eval LASTARG=\${$#}
219ee3138f1Smrg	case $LASTARG in
220ee3138f1Smrg	*.y)
221ee3138f1Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
222ee3138f1Smrg	    if test -f "$SRCFILE"; then
223ee3138f1Smrg	         cp "$SRCFILE" y.tab.c
224ee3138f1Smrg	    fi
225ee3138f1Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
226ee3138f1Smrg	    if test -f "$SRCFILE"; then
227ee3138f1Smrg	         cp "$SRCFILE" y.tab.h
228ee3138f1Smrg	    fi
229ee3138f1Smrg	  ;;
230ee3138f1Smrg	esac
231ee3138f1Smrg    fi
232ee3138f1Smrg    if test ! -f y.tab.h; then
233ee3138f1Smrg	echo >y.tab.h
234ee3138f1Smrg    fi
235ee3138f1Smrg    if test ! -f y.tab.c; then
236ee3138f1Smrg	echo 'main() { return 0; }' >y.tab.c
237ee3138f1Smrg    fi
238ee3138f1Smrg    ;;
239ee3138f1Smrg
24034977a2fSmrg  lex*|flex*)
241ee3138f1Smrg    echo 1>&2 "\
2423e72ca8cSmrgWARNING: '$1' is $msg.  You should only need it if
2433e72ca8cSmrg         you modified a '.l' file.  You may need the Flex package
244ee3138f1Smrg         in order for those modifications to take effect.  You can get
2453e72ca8cSmrg         Flex from any GNU archive site."
246ee3138f1Smrg    rm -f lex.yy.c
247ee3138f1Smrg    if test $# -ne 1; then
2483e72ca8cSmrg        eval LASTARG=\${$#}
249ee3138f1Smrg	case $LASTARG in
250ee3138f1Smrg	*.l)
251ee3138f1Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
252ee3138f1Smrg	    if test -f "$SRCFILE"; then
253ee3138f1Smrg	         cp "$SRCFILE" lex.yy.c
254ee3138f1Smrg	    fi
255ee3138f1Smrg	  ;;
256ee3138f1Smrg	esac
257ee3138f1Smrg    fi
258ee3138f1Smrg    if test ! -f lex.yy.c; then
259ee3138f1Smrg	echo 'main() { return 0; }' >lex.yy.c
260ee3138f1Smrg    fi
261ee3138f1Smrg    ;;
262ee3138f1Smrg
26334977a2fSmrg  help2man*)
264ee3138f1Smrg    echo 1>&2 "\
2653e72ca8cSmrgWARNING: '$1' is $msg.  You should only need it if
266ee3138f1Smrg	 you modified a dependency of a manual page.  You may need the
2673e72ca8cSmrg	 Help2man package in order for those modifications to take
2683e72ca8cSmrg	 effect.  You can get Help2man from any GNU archive site."
269ee3138f1Smrg
270ee3138f1Smrg    file=`echo "$*" | sed -n "$sed_output"`
271ee3138f1Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
272ee3138f1Smrg    if test -f "$file"; then
273ee3138f1Smrg	touch $file
274ee3138f1Smrg    else
275ee3138f1Smrg	test -z "$file" || exec >$file
276ee3138f1Smrg	echo ".ab help2man is required to generate this page"
27734977a2fSmrg	exit $?
278ee3138f1Smrg    fi
279ee3138f1Smrg    ;;
280ee3138f1Smrg
28134977a2fSmrg  makeinfo*)
282ee3138f1Smrg    echo 1>&2 "\
2833e72ca8cSmrgWARNING: '$1' is $msg.  You should only need it if
2843e72ca8cSmrg         you modified a '.texi' or '.texinfo' file, or any other file
285ee3138f1Smrg         indirectly affecting the aspect of the manual.  The spurious
2863e72ca8cSmrg         call might also be the consequence of using a buggy 'make' (AIX,
2873e72ca8cSmrg         DU, IRIX).  You might want to install the Texinfo package or
2883e72ca8cSmrg         the GNU make package.  Grab either from any GNU archive site."
289ee3138f1Smrg    # The file to touch is that specified with -o ...
290ee3138f1Smrg    file=`echo "$*" | sed -n "$sed_output"`
291ee3138f1Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
292ee3138f1Smrg    if test -z "$file"; then
293ee3138f1Smrg      # ... or it is the one specified with @setfilename ...
294ee3138f1Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
295ee3138f1Smrg      file=`sed -n '
296ee3138f1Smrg	/^@setfilename/{
297ee3138f1Smrg	  s/.* \([^ ]*\) *$/\1/
298ee3138f1Smrg	  p
299ee3138f1Smrg	  q
300ee3138f1Smrg	}' $infile`
301ee3138f1Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
302ee3138f1Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
303ee3138f1Smrg    fi
304ee3138f1Smrg    # If the file does not exist, the user really needs makeinfo;
305ee3138f1Smrg    # let's fail without touching anything.
306ee3138f1Smrg    test -f $file || exit 1
307ee3138f1Smrg    touch $file
308ee3138f1Smrg    ;;
309ee3138f1Smrg
310ee3138f1Smrg  *)
311ee3138f1Smrg    echo 1>&2 "\
3123e72ca8cSmrgWARNING: '$1' is needed, and is $msg.
313ee3138f1Smrg         You might have modified some files without having the
3143e72ca8cSmrg         proper tools for further handling them.  Check the 'README' file,
315ee3138f1Smrg         it often tells you about the needed prerequisites for installing
316ee3138f1Smrg         this package.  You may also peek at any GNU archive site, in case
3173e72ca8cSmrg         some other package would contain this missing '$1' program."
318ee3138f1Smrg    exit 1
319ee3138f1Smrg    ;;
320ee3138f1Smrgesac
321ee3138f1Smrg
322ee3138f1Smrgexit 0
323ee3138f1Smrg
324ee3138f1Smrg# Local variables:
325ee3138f1Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
326ee3138f1Smrg# time-stamp-start: "scriptversion="
327ee3138f1Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
32834977a2fSmrg# time-stamp-time-zone: "UTC"
32934977a2fSmrg# time-stamp-end: "; # UTC"
330ee3138f1Smrg# End:
331