1240a9a23Smbalmer#! /bin/sh
2240a9a23Smbalmer# Common stub for a few missing GNU programs while installing.
3240a9a23Smbalmer
4240a9a23Smbalmerscriptversion=2005-06-08.21
5240a9a23Smbalmer
6240a9a23Smbalmer# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
7240a9a23Smbalmer#   Free Software Foundation, Inc.
8240a9a23Smbalmer# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9240a9a23Smbalmer
10240a9a23Smbalmer# This program is free software; you can redistribute it and/or modify
11240a9a23Smbalmer# it under the terms of the GNU General Public License as published by
12240a9a23Smbalmer# the Free Software Foundation; either version 2, or (at your option)
13240a9a23Smbalmer# any later version.
14240a9a23Smbalmer
15240a9a23Smbalmer# This program is distributed in the hope that it will be useful,
16240a9a23Smbalmer# but WITHOUT ANY WARRANTY; without even the implied warranty of
17240a9a23Smbalmer# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18240a9a23Smbalmer# GNU General Public License for more details.
19240a9a23Smbalmer
20240a9a23Smbalmer# You should have received a copy of the GNU General Public License
21240a9a23Smbalmer# along with this program; if not, write to the Free Software
22240a9a23Smbalmer# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23240a9a23Smbalmer# 02110-1301, USA.
24240a9a23Smbalmer
25240a9a23Smbalmer# As a special exception to the GNU General Public License, if you
26240a9a23Smbalmer# distribute this file as part of a program that contains a
27240a9a23Smbalmer# configuration script generated by Autoconf, you may include it under
28240a9a23Smbalmer# the same distribution terms that you use for the rest of that program.
29240a9a23Smbalmer
30240a9a23Smbalmerif test $# -eq 0; then
31240a9a23Smbalmer  echo 1>&2 "Try \`$0 --help' for more information"
32240a9a23Smbalmer  exit 1
33240a9a23Smbalmerfi
34240a9a23Smbalmer
35240a9a23Smbalmerrun=:
36240a9a23Smbalmer
37240a9a23Smbalmer# In the cases where this matters, `missing' is being run in the
38240a9a23Smbalmer# srcdir already.
39240a9a23Smbalmerif test -f configure.ac; then
40240a9a23Smbalmer  configure_ac=configure.ac
41240a9a23Smbalmerelse
42240a9a23Smbalmer  configure_ac=configure.in
43240a9a23Smbalmerfi
44240a9a23Smbalmer
45240a9a23Smbalmermsg="missing on your system"
46240a9a23Smbalmer
47240a9a23Smbalmercase "$1" in
48240a9a23Smbalmer--run)
49240a9a23Smbalmer  # Try to run requested program, and just exit if it succeeds.
50240a9a23Smbalmer  run=
51240a9a23Smbalmer  shift
52240a9a23Smbalmer  "$@" && exit 0
53240a9a23Smbalmer  # Exit code 63 means version mismatch.  This often happens
54240a9a23Smbalmer  # when the user try to use an ancient version of a tool on
55240a9a23Smbalmer  # a file that requires a minimum version.  In this case we
56240a9a23Smbalmer  # we should proceed has if the program had been absent, or
57240a9a23Smbalmer  # if --run hadn't been passed.
58240a9a23Smbalmer  if test $? = 63; then
59240a9a23Smbalmer    run=:
60240a9a23Smbalmer    msg="probably too old"
61240a9a23Smbalmer  fi
62240a9a23Smbalmer  ;;
63240a9a23Smbalmer
64240a9a23Smbalmer  -h|--h|--he|--hel|--help)
65240a9a23Smbalmer    echo "\
66240a9a23Smbalmer$0 [OPTION]... PROGRAM [ARGUMENT]...
67240a9a23Smbalmer
68240a9a23SmbalmerHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69240a9a23Smbalmererror status if there is no known handling for PROGRAM.
70240a9a23Smbalmer
71240a9a23SmbalmerOptions:
72240a9a23Smbalmer  -h, --help      display this help and exit
73240a9a23Smbalmer  -v, --version   output version information and exit
74240a9a23Smbalmer  --run           try to run the given command, and emulate it if it fails
75240a9a23Smbalmer
76240a9a23SmbalmerSupported PROGRAM values:
77240a9a23Smbalmer  aclocal      touch file \`aclocal.m4'
78240a9a23Smbalmer  autoconf     touch file \`configure'
79240a9a23Smbalmer  autoheader   touch file \`config.h.in'
80240a9a23Smbalmer  automake     touch all \`Makefile.in' files
81240a9a23Smbalmer  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
82240a9a23Smbalmer  flex         create \`lex.yy.c', if possible, from existing .c
83240a9a23Smbalmer  help2man     touch the output file
84240a9a23Smbalmer  lex          create \`lex.yy.c', if possible, from existing .c
85240a9a23Smbalmer  makeinfo     touch the output file
86240a9a23Smbalmer  tar          try tar, gnutar, gtar, then tar without non-portable flags
87240a9a23Smbalmer  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
88240a9a23Smbalmer
89240a9a23SmbalmerSend bug reports to <bug-automake@gnu.org>."
90240a9a23Smbalmer    exit $?
91240a9a23Smbalmer    ;;
92240a9a23Smbalmer
93240a9a23Smbalmer  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
94240a9a23Smbalmer    echo "missing $scriptversion (GNU Automake)"
95240a9a23Smbalmer    exit $?
96240a9a23Smbalmer    ;;
97240a9a23Smbalmer
98240a9a23Smbalmer  -*)
99240a9a23Smbalmer    echo 1>&2 "$0: Unknown \`$1' option"
100240a9a23Smbalmer    echo 1>&2 "Try \`$0 --help' for more information"
101240a9a23Smbalmer    exit 1
102240a9a23Smbalmer    ;;
103240a9a23Smbalmer
104240a9a23Smbalmeresac
105240a9a23Smbalmer
106240a9a23Smbalmer# Now exit if we have it, but it failed.  Also exit now if we
107240a9a23Smbalmer# don't have it and --version was passed (most likely to detect
108240a9a23Smbalmer# the program).
109240a9a23Smbalmercase "$1" in
110240a9a23Smbalmer  lex|yacc)
111240a9a23Smbalmer    # Not GNU programs, they don't have --version.
112240a9a23Smbalmer    ;;
113240a9a23Smbalmer
114240a9a23Smbalmer  tar)
115240a9a23Smbalmer    if test -n "$run"; then
116240a9a23Smbalmer       echo 1>&2 "ERROR: \`tar' requires --run"
117240a9a23Smbalmer       exit 1
118240a9a23Smbalmer    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
119240a9a23Smbalmer       exit 1
120240a9a23Smbalmer    fi
121240a9a23Smbalmer    ;;
122240a9a23Smbalmer
123240a9a23Smbalmer  *)
124240a9a23Smbalmer    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
125240a9a23Smbalmer       # We have it, but it failed.
126240a9a23Smbalmer       exit 1
127240a9a23Smbalmer    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
128240a9a23Smbalmer       # Could not run --version or --help.  This is probably someone
129240a9a23Smbalmer       # running `$TOOL --version' or `$TOOL --help' to check whether
130240a9a23Smbalmer       # $TOOL exists and not knowing $TOOL uses missing.
131240a9a23Smbalmer       exit 1
132240a9a23Smbalmer    fi
133240a9a23Smbalmer    ;;
134240a9a23Smbalmeresac
135240a9a23Smbalmer
136240a9a23Smbalmer# If it does not exist, or fails to run (possibly an outdated version),
137240a9a23Smbalmer# try to emulate it.
138240a9a23Smbalmercase "$1" in
139240a9a23Smbalmer  aclocal*)
140240a9a23Smbalmer    echo 1>&2 "\
141240a9a23SmbalmerWARNING: \`$1' is $msg.  You should only need it if
142240a9a23Smbalmer         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
143240a9a23Smbalmer         to install the \`Automake' and \`Perl' packages.  Grab them from
144240a9a23Smbalmer         any GNU archive site."
145240a9a23Smbalmer    touch aclocal.m4
146240a9a23Smbalmer    ;;
147240a9a23Smbalmer
148240a9a23Smbalmer  autoconf)
149240a9a23Smbalmer    echo 1>&2 "\
150240a9a23SmbalmerWARNING: \`$1' is $msg.  You should only need it if
151240a9a23Smbalmer         you modified \`${configure_ac}'.  You might want to install the
152240a9a23Smbalmer         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
153240a9a23Smbalmer         archive site."
154240a9a23Smbalmer    touch configure
155240a9a23Smbalmer    ;;
156240a9a23Smbalmer
157240a9a23Smbalmer  autoheader)
158240a9a23Smbalmer    echo 1>&2 "\
159240a9a23SmbalmerWARNING: \`$1' is $msg.  You should only need it if
160240a9a23Smbalmer         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
161240a9a23Smbalmer         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
162240a9a23Smbalmer         from any GNU archive site."
163240a9a23Smbalmer    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
164240a9a23Smbalmer    test -z "$files" && files="config.h"
165240a9a23Smbalmer    touch_files=
166240a9a23Smbalmer    for f in $files; do
167240a9a23Smbalmer      case "$f" in
168240a9a23Smbalmer      *:*) touch_files="$touch_files "`echo "$f" |
169240a9a23Smbalmer				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
170240a9a23Smbalmer      *) touch_files="$touch_files $f.in";;
171240a9a23Smbalmer      esac
172240a9a23Smbalmer    done
173240a9a23Smbalmer    touch $touch_files
174240a9a23Smbalmer    ;;
175240a9a23Smbalmer
176240a9a23Smbalmer  automake*)
177240a9a23Smbalmer    echo 1>&2 "\
178240a9a23SmbalmerWARNING: \`$1' is $msg.  You should only need it if
179240a9a23Smbalmer         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
180240a9a23Smbalmer         You might want to install the \`Automake' and \`Perl' packages.
181240a9a23Smbalmer         Grab them from any GNU archive site."
182240a9a23Smbalmer    find . -type f -name Makefile.am -print |
183240a9a23Smbalmer	   sed 's/\.am$/.in/' |
184240a9a23Smbalmer	   while read f; do touch "$f"; done
185240a9a23Smbalmer    ;;
186240a9a23Smbalmer
187240a9a23Smbalmer  autom4te)
188240a9a23Smbalmer    echo 1>&2 "\
189240a9a23SmbalmerWARNING: \`$1' is needed, but is $msg.
190240a9a23Smbalmer         You might have modified some files without having the
191240a9a23Smbalmer         proper tools for further handling them.
192240a9a23Smbalmer         You can get \`$1' as part of \`Autoconf' from any GNU
193240a9a23Smbalmer         archive site."
194240a9a23Smbalmer
195240a9a23Smbalmer    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
196240a9a23Smbalmer    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
197240a9a23Smbalmer    if test -f "$file"; then
198240a9a23Smbalmer	touch $file
199240a9a23Smbalmer    else
200240a9a23Smbalmer	test -z "$file" || exec >$file
201240a9a23Smbalmer	echo "#! /bin/sh"
202240a9a23Smbalmer	echo "# Created by GNU Automake missing as a replacement of"
203240a9a23Smbalmer	echo "#  $ $@"
204240a9a23Smbalmer	echo "exit 0"
205240a9a23Smbalmer	chmod +x $file
206240a9a23Smbalmer	exit 1
207240a9a23Smbalmer    fi
208240a9a23Smbalmer    ;;
209240a9a23Smbalmer
210240a9a23Smbalmer  bison|yacc)
211240a9a23Smbalmer    echo 1>&2 "\
212240a9a23SmbalmerWARNING: \`$1' $msg.  You should only need it if
213240a9a23Smbalmer         you modified a \`.y' file.  You may need the \`Bison' package
214240a9a23Smbalmer         in order for those modifications to take effect.  You can get
215240a9a23Smbalmer         \`Bison' from any GNU archive site."
216240a9a23Smbalmer    rm -f y.tab.c y.tab.h
217240a9a23Smbalmer    if [ $# -ne 1 ]; then
218240a9a23Smbalmer        eval LASTARG="\${$#}"
219240a9a23Smbalmer	case "$LASTARG" in
220240a9a23Smbalmer	*.y)
221240a9a23Smbalmer	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
222240a9a23Smbalmer	    if [ -f "$SRCFILE" ]; then
223240a9a23Smbalmer	         cp "$SRCFILE" y.tab.c
224240a9a23Smbalmer	    fi
225240a9a23Smbalmer	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
226240a9a23Smbalmer	    if [ -f "$SRCFILE" ]; then
227240a9a23Smbalmer	         cp "$SRCFILE" y.tab.h
228240a9a23Smbalmer	    fi
229240a9a23Smbalmer	  ;;
230240a9a23Smbalmer	esac
231240a9a23Smbalmer    fi
232240a9a23Smbalmer    if [ ! -f y.tab.h ]; then
233240a9a23Smbalmer	echo >y.tab.h
234240a9a23Smbalmer    fi
235240a9a23Smbalmer    if [ ! -f y.tab.c ]; then
236240a9a23Smbalmer	echo 'main() { return 0; }' >y.tab.c
237240a9a23Smbalmer    fi
238240a9a23Smbalmer    ;;
239240a9a23Smbalmer
240240a9a23Smbalmer  lex|flex)
241240a9a23Smbalmer    echo 1>&2 "\
242240a9a23SmbalmerWARNING: \`$1' is $msg.  You should only need it if
243240a9a23Smbalmer         you modified a \`.l' file.  You may need the \`Flex' package
244240a9a23Smbalmer         in order for those modifications to take effect.  You can get
245240a9a23Smbalmer         \`Flex' from any GNU archive site."
246240a9a23Smbalmer    rm -f lex.yy.c
247240a9a23Smbalmer    if [ $# -ne 1 ]; then
248240a9a23Smbalmer        eval LASTARG="\${$#}"
249240a9a23Smbalmer	case "$LASTARG" in
250240a9a23Smbalmer	*.l)
251240a9a23Smbalmer	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
252240a9a23Smbalmer	    if [ -f "$SRCFILE" ]; then
253240a9a23Smbalmer	         cp "$SRCFILE" lex.yy.c
254240a9a23Smbalmer	    fi
255240a9a23Smbalmer	  ;;
256240a9a23Smbalmer	esac
257240a9a23Smbalmer    fi
258240a9a23Smbalmer    if [ ! -f lex.yy.c ]; then
259240a9a23Smbalmer	echo 'main() { return 0; }' >lex.yy.c
260240a9a23Smbalmer    fi
261240a9a23Smbalmer    ;;
262240a9a23Smbalmer
263240a9a23Smbalmer  help2man)
264240a9a23Smbalmer    echo 1>&2 "\
265240a9a23SmbalmerWARNING: \`$1' is $msg.  You should only need it if
266240a9a23Smbalmer	 you modified a dependency of a manual page.  You may need the
267240a9a23Smbalmer	 \`Help2man' package in order for those modifications to take
268240a9a23Smbalmer	 effect.  You can get \`Help2man' from any GNU archive site."
269240a9a23Smbalmer
270240a9a23Smbalmer    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
271240a9a23Smbalmer    if test -z "$file"; then
272240a9a23Smbalmer	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
273240a9a23Smbalmer    fi
274240a9a23Smbalmer    if [ -f "$file" ]; then
275240a9a23Smbalmer	touch $file
276240a9a23Smbalmer    else
277240a9a23Smbalmer	test -z "$file" || exec >$file
278240a9a23Smbalmer	echo ".ab help2man is required to generate this page"
279240a9a23Smbalmer	exit 1
280240a9a23Smbalmer    fi
281240a9a23Smbalmer    ;;
282240a9a23Smbalmer
283240a9a23Smbalmer  makeinfo)
284240a9a23Smbalmer    echo 1>&2 "\
285240a9a23SmbalmerWARNING: \`$1' is $msg.  You should only need it if
286240a9a23Smbalmer         you modified a \`.texi' or \`.texinfo' file, or any other file
287240a9a23Smbalmer         indirectly affecting the aspect of the manual.  The spurious
288240a9a23Smbalmer         call might also be the consequence of using a buggy \`make' (AIX,
289240a9a23Smbalmer         DU, IRIX).  You might want to install the \`Texinfo' package or
290240a9a23Smbalmer         the \`GNU make' package.  Grab either from any GNU archive site."
291240a9a23Smbalmer    # The file to touch is that specified with -o ...
292240a9a23Smbalmer    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
293240a9a23Smbalmer    if test -z "$file"; then
294240a9a23Smbalmer      # ... or it is the one specified with @setfilename ...
295240a9a23Smbalmer      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
296240a9a23Smbalmer      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
297240a9a23Smbalmer      # ... or it is derived from the source name (dir/f.texi becomes f.info)
298240a9a23Smbalmer      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
299240a9a23Smbalmer    fi
300240a9a23Smbalmer    # If the file does not exist, the user really needs makeinfo;
301240a9a23Smbalmer    # let's fail without touching anything.
302240a9a23Smbalmer    test -f $file || exit 1
303240a9a23Smbalmer    touch $file
304240a9a23Smbalmer    ;;
305240a9a23Smbalmer
306240a9a23Smbalmer  tar)
307240a9a23Smbalmer    shift
308240a9a23Smbalmer
309240a9a23Smbalmer    # We have already tried tar in the generic part.
310240a9a23Smbalmer    # Look for gnutar/gtar before invocation to avoid ugly error
311240a9a23Smbalmer    # messages.
312240a9a23Smbalmer    if (gnutar --version > /dev/null 2>&1); then
313240a9a23Smbalmer       gnutar "$@" && exit 0
314240a9a23Smbalmer    fi
315240a9a23Smbalmer    if (gtar --version > /dev/null 2>&1); then
316240a9a23Smbalmer       gtar "$@" && exit 0
317240a9a23Smbalmer    fi
318240a9a23Smbalmer    firstarg="$1"
319240a9a23Smbalmer    if shift; then
320240a9a23Smbalmer	case "$firstarg" in
321240a9a23Smbalmer	*o*)
322240a9a23Smbalmer	    firstarg=`echo "$firstarg" | sed s/o//`
323240a9a23Smbalmer	    tar "$firstarg" "$@" && exit 0
324240a9a23Smbalmer	    ;;
325240a9a23Smbalmer	esac
326240a9a23Smbalmer	case "$firstarg" in
327240a9a23Smbalmer	*h*)
328240a9a23Smbalmer	    firstarg=`echo "$firstarg" | sed s/h//`
329240a9a23Smbalmer	    tar "$firstarg" "$@" && exit 0
330240a9a23Smbalmer	    ;;
331240a9a23Smbalmer	esac
332240a9a23Smbalmer    fi
333240a9a23Smbalmer
334240a9a23Smbalmer    echo 1>&2 "\
335240a9a23SmbalmerWARNING: I can't seem to be able to run \`tar' with the given arguments.
336240a9a23Smbalmer         You may want to install GNU tar or Free paxutils, or check the
337240a9a23Smbalmer         command line arguments."
338240a9a23Smbalmer    exit 1
339240a9a23Smbalmer    ;;
340240a9a23Smbalmer
341240a9a23Smbalmer  *)
342240a9a23Smbalmer    echo 1>&2 "\
343240a9a23SmbalmerWARNING: \`$1' is needed, and is $msg.
344240a9a23Smbalmer         You might have modified some files without having the
345240a9a23Smbalmer         proper tools for further handling them.  Check the \`README' file,
346240a9a23Smbalmer         it often tells you about the needed prerequisites for installing
347240a9a23Smbalmer         this package.  You may also peek at any GNU archive site, in case
348240a9a23Smbalmer         some other package would contain this missing \`$1' program."
349240a9a23Smbalmer    exit 1
350240a9a23Smbalmer    ;;
351240a9a23Smbalmeresac
352240a9a23Smbalmer
353240a9a23Smbalmerexit 0
354240a9a23Smbalmer
355240a9a23Smbalmer# Local variables:
356240a9a23Smbalmer# eval: (add-hook 'write-file-hooks 'time-stamp)
357240a9a23Smbalmer# time-stamp-start: "scriptversion="
358240a9a23Smbalmer# time-stamp-format: "%:y-%02m-%02d.%02H"
359240a9a23Smbalmer# time-stamp-end: "$"
360240a9a23Smbalmer# End:
361