missing revision d17cd367
1266e564dSmrg#! /bin/sh
2266e564dSmrg# Common stub for a few missing GNU programs while installing.
3266e564dSmrg
4d17cd367Smrgscriptversion=2009-04-28.21; # UTC
5266e564dSmrg
6d17cd367Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
7d17cd367Smrg# 2008, 2009 Free Software Foundation, Inc.
8266e564dSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9266e564dSmrg
10266e564dSmrg# This program is free software; you can redistribute it and/or modify
11266e564dSmrg# it under the terms of the GNU General Public License as published by
12266e564dSmrg# the Free Software Foundation; either version 2, or (at your option)
13266e564dSmrg# any later version.
14266e564dSmrg
15266e564dSmrg# This program is distributed in the hope that it will be useful,
16266e564dSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17266e564dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18266e564dSmrg# GNU General Public License for more details.
19266e564dSmrg
20266e564dSmrg# You should have received a copy of the GNU General Public License
21d17cd367Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22266e564dSmrg
23266e564dSmrg# As a special exception to the GNU General Public License, if you
24266e564dSmrg# distribute this file as part of a program that contains a
25266e564dSmrg# configuration script generated by Autoconf, you may include it under
26266e564dSmrg# the same distribution terms that you use for the rest of that program.
27266e564dSmrg
28266e564dSmrgif test $# -eq 0; then
29266e564dSmrg  echo 1>&2 "Try \`$0 --help' for more information"
30266e564dSmrg  exit 1
31266e564dSmrgfi
32266e564dSmrg
33266e564dSmrgrun=:
34266e564dSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
35266e564dSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
36266e564dSmrg
37266e564dSmrg# In the cases where this matters, `missing' is being run in the
38266e564dSmrg# srcdir already.
39266e564dSmrgif test -f configure.ac; then
40266e564dSmrg  configure_ac=configure.ac
41266e564dSmrgelse
42266e564dSmrg  configure_ac=configure.in
43266e564dSmrgfi
44266e564dSmrg
45266e564dSmrgmsg="missing on your system"
46266e564dSmrg
47266e564dSmrgcase $1 in
48266e564dSmrg--run)
49266e564dSmrg  # Try to run requested program, and just exit if it succeeds.
50266e564dSmrg  run=
51266e564dSmrg  shift
52266e564dSmrg  "$@" && exit 0
53266e564dSmrg  # Exit code 63 means version mismatch.  This often happens
54266e564dSmrg  # when the user try to use an ancient version of a tool on
55266e564dSmrg  # a file that requires a minimum version.  In this case we
56266e564dSmrg  # we should proceed has if the program had been absent, or
57266e564dSmrg  # if --run hadn't been passed.
58266e564dSmrg  if test $? = 63; then
59266e564dSmrg    run=:
60266e564dSmrg    msg="probably too old"
61266e564dSmrg  fi
62266e564dSmrg  ;;
63266e564dSmrg
64266e564dSmrg  -h|--h|--he|--hel|--help)
65266e564dSmrg    echo "\
66266e564dSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
67266e564dSmrg
68266e564dSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69266e564dSmrgerror status if there is no known handling for PROGRAM.
70266e564dSmrg
71266e564dSmrgOptions:
72266e564dSmrg  -h, --help      display this help and exit
73266e564dSmrg  -v, --version   output version information and exit
74266e564dSmrg  --run           try to run the given command, and emulate it if it fails
75266e564dSmrg
76266e564dSmrgSupported PROGRAM values:
77266e564dSmrg  aclocal      touch file \`aclocal.m4'
78266e564dSmrg  autoconf     touch file \`configure'
79266e564dSmrg  autoheader   touch file \`config.h.in'
80266e564dSmrg  autom4te     touch the output file, or create a stub one
81266e564dSmrg  automake     touch all \`Makefile.in' files
82266e564dSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
83266e564dSmrg  flex         create \`lex.yy.c', if possible, from existing .c
84266e564dSmrg  help2man     touch the output file
85266e564dSmrg  lex          create \`lex.yy.c', if possible, from existing .c
86266e564dSmrg  makeinfo     touch the output file
87266e564dSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
88266e564dSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
89266e564dSmrg
90d17cd367SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
91d17cd367Smrg\`g' are ignored when checking the name.
92d17cd367Smrg
93266e564dSmrgSend bug reports to <bug-automake@gnu.org>."
94266e564dSmrg    exit $?
95266e564dSmrg    ;;
96266e564dSmrg
97266e564dSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
98266e564dSmrg    echo "missing $scriptversion (GNU Automake)"
99266e564dSmrg    exit $?
100266e564dSmrg    ;;
101266e564dSmrg
102266e564dSmrg  -*)
103266e564dSmrg    echo 1>&2 "$0: Unknown \`$1' option"
104266e564dSmrg    echo 1>&2 "Try \`$0 --help' for more information"
105266e564dSmrg    exit 1
106266e564dSmrg    ;;
107266e564dSmrg
108266e564dSmrgesac
109266e564dSmrg
110d17cd367Smrg# normalize program name to check for.
111d17cd367Smrgprogram=`echo "$1" | sed '
112d17cd367Smrg  s/^gnu-//; t
113d17cd367Smrg  s/^gnu//; t
114d17cd367Smrg  s/^g//; t'`
115d17cd367Smrg
116266e564dSmrg# Now exit if we have it, but it failed.  Also exit now if we
117266e564dSmrg# don't have it and --version was passed (most likely to detect
118d17cd367Smrg# the program).  This is about non-GNU programs, so use $1 not
119d17cd367Smrg# $program.
120266e564dSmrgcase $1 in
121d17cd367Smrg  lex*|yacc*)
122266e564dSmrg    # Not GNU programs, they don't have --version.
123266e564dSmrg    ;;
124266e564dSmrg
125d17cd367Smrg  tar*)
126266e564dSmrg    if test -n "$run"; then
127266e564dSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
128266e564dSmrg       exit 1
129266e564dSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
130266e564dSmrg       exit 1
131266e564dSmrg    fi
132266e564dSmrg    ;;
133266e564dSmrg
134266e564dSmrg  *)
135266e564dSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
136266e564dSmrg       # We have it, but it failed.
137266e564dSmrg       exit 1
138266e564dSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
139266e564dSmrg       # Could not run --version or --help.  This is probably someone
140266e564dSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
141266e564dSmrg       # $TOOL exists and not knowing $TOOL uses missing.
142266e564dSmrg       exit 1
143266e564dSmrg    fi
144266e564dSmrg    ;;
145266e564dSmrgesac
146266e564dSmrg
147266e564dSmrg# If it does not exist, or fails to run (possibly an outdated version),
148266e564dSmrg# try to emulate it.
149d17cd367Smrgcase $program in
150266e564dSmrg  aclocal*)
151266e564dSmrg    echo 1>&2 "\
152266e564dSmrgWARNING: \`$1' is $msg.  You should only need it if
153266e564dSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
154266e564dSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
155266e564dSmrg         any GNU archive site."
156266e564dSmrg    touch aclocal.m4
157266e564dSmrg    ;;
158266e564dSmrg
159d17cd367Smrg  autoconf*)
160266e564dSmrg    echo 1>&2 "\
161266e564dSmrgWARNING: \`$1' is $msg.  You should only need it if
162266e564dSmrg         you modified \`${configure_ac}'.  You might want to install the
163266e564dSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
164266e564dSmrg         archive site."
165266e564dSmrg    touch configure
166266e564dSmrg    ;;
167266e564dSmrg
168d17cd367Smrg  autoheader*)
169266e564dSmrg    echo 1>&2 "\
170266e564dSmrgWARNING: \`$1' is $msg.  You should only need it if
171266e564dSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
172266e564dSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
173266e564dSmrg         from any GNU archive site."
174266e564dSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
175266e564dSmrg    test -z "$files" && files="config.h"
176266e564dSmrg    touch_files=
177266e564dSmrg    for f in $files; do
178266e564dSmrg      case $f in
179266e564dSmrg      *:*) touch_files="$touch_files "`echo "$f" |
180266e564dSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
181266e564dSmrg      *) touch_files="$touch_files $f.in";;
182266e564dSmrg      esac
183266e564dSmrg    done
184266e564dSmrg    touch $touch_files
185266e564dSmrg    ;;
186266e564dSmrg
187266e564dSmrg  automake*)
188266e564dSmrg    echo 1>&2 "\
189266e564dSmrgWARNING: \`$1' is $msg.  You should only need it if
190266e564dSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
191266e564dSmrg         You might want to install the \`Automake' and \`Perl' packages.
192266e564dSmrg         Grab them from any GNU archive site."
193266e564dSmrg    find . -type f -name Makefile.am -print |
194266e564dSmrg	   sed 's/\.am$/.in/' |
195266e564dSmrg	   while read f; do touch "$f"; done
196266e564dSmrg    ;;
197266e564dSmrg
198d17cd367Smrg  autom4te*)
199266e564dSmrg    echo 1>&2 "\
200266e564dSmrgWARNING: \`$1' is needed, but is $msg.
201266e564dSmrg         You might have modified some files without having the
202266e564dSmrg         proper tools for further handling them.
203266e564dSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
204266e564dSmrg         archive site."
205266e564dSmrg
206266e564dSmrg    file=`echo "$*" | sed -n "$sed_output"`
207266e564dSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
208266e564dSmrg    if test -f "$file"; then
209266e564dSmrg	touch $file
210266e564dSmrg    else
211266e564dSmrg	test -z "$file" || exec >$file
212266e564dSmrg	echo "#! /bin/sh"
213266e564dSmrg	echo "# Created by GNU Automake missing as a replacement of"
214266e564dSmrg	echo "#  $ $@"
215266e564dSmrg	echo "exit 0"
216266e564dSmrg	chmod +x $file
217266e564dSmrg	exit 1
218266e564dSmrg    fi
219266e564dSmrg    ;;
220266e564dSmrg
221d17cd367Smrg  bison*|yacc*)
222266e564dSmrg    echo 1>&2 "\
223266e564dSmrgWARNING: \`$1' $msg.  You should only need it if
224266e564dSmrg         you modified a \`.y' file.  You may need the \`Bison' package
225266e564dSmrg         in order for those modifications to take effect.  You can get
226266e564dSmrg         \`Bison' from any GNU archive site."
227266e564dSmrg    rm -f y.tab.c y.tab.h
228266e564dSmrg    if test $# -ne 1; then
229266e564dSmrg        eval LASTARG="\${$#}"
230266e564dSmrg	case $LASTARG in
231266e564dSmrg	*.y)
232266e564dSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
233266e564dSmrg	    if test -f "$SRCFILE"; then
234266e564dSmrg	         cp "$SRCFILE" y.tab.c
235266e564dSmrg	    fi
236266e564dSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
237266e564dSmrg	    if test -f "$SRCFILE"; then
238266e564dSmrg	         cp "$SRCFILE" y.tab.h
239266e564dSmrg	    fi
240266e564dSmrg	  ;;
241266e564dSmrg	esac
242266e564dSmrg    fi
243266e564dSmrg    if test ! -f y.tab.h; then
244266e564dSmrg	echo >y.tab.h
245266e564dSmrg    fi
246266e564dSmrg    if test ! -f y.tab.c; then
247266e564dSmrg	echo 'main() { return 0; }' >y.tab.c
248266e564dSmrg    fi
249266e564dSmrg    ;;
250266e564dSmrg
251d17cd367Smrg  lex*|flex*)
252266e564dSmrg    echo 1>&2 "\
253266e564dSmrgWARNING: \`$1' is $msg.  You should only need it if
254266e564dSmrg         you modified a \`.l' file.  You may need the \`Flex' package
255266e564dSmrg         in order for those modifications to take effect.  You can get
256266e564dSmrg         \`Flex' from any GNU archive site."
257266e564dSmrg    rm -f lex.yy.c
258266e564dSmrg    if test $# -ne 1; then
259266e564dSmrg        eval LASTARG="\${$#}"
260266e564dSmrg	case $LASTARG in
261266e564dSmrg	*.l)
262266e564dSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
263266e564dSmrg	    if test -f "$SRCFILE"; then
264266e564dSmrg	         cp "$SRCFILE" lex.yy.c
265266e564dSmrg	    fi
266266e564dSmrg	  ;;
267266e564dSmrg	esac
268266e564dSmrg    fi
269266e564dSmrg    if test ! -f lex.yy.c; then
270266e564dSmrg	echo 'main() { return 0; }' >lex.yy.c
271266e564dSmrg    fi
272266e564dSmrg    ;;
273266e564dSmrg
274d17cd367Smrg  help2man*)
275266e564dSmrg    echo 1>&2 "\
276266e564dSmrgWARNING: \`$1' is $msg.  You should only need it if
277266e564dSmrg	 you modified a dependency of a manual page.  You may need the
278266e564dSmrg	 \`Help2man' package in order for those modifications to take
279266e564dSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
280266e564dSmrg
281266e564dSmrg    file=`echo "$*" | sed -n "$sed_output"`
282266e564dSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
283266e564dSmrg    if test -f "$file"; then
284266e564dSmrg	touch $file
285266e564dSmrg    else
286266e564dSmrg	test -z "$file" || exec >$file
287266e564dSmrg	echo ".ab help2man is required to generate this page"
288d17cd367Smrg	exit $?
289266e564dSmrg    fi
290266e564dSmrg    ;;
291266e564dSmrg
292d17cd367Smrg  makeinfo*)
293266e564dSmrg    echo 1>&2 "\
294266e564dSmrgWARNING: \`$1' is $msg.  You should only need it if
295266e564dSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
296266e564dSmrg         indirectly affecting the aspect of the manual.  The spurious
297266e564dSmrg         call might also be the consequence of using a buggy \`make' (AIX,
298266e564dSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
299266e564dSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
300266e564dSmrg    # The file to touch is that specified with -o ...
301266e564dSmrg    file=`echo "$*" | sed -n "$sed_output"`
302266e564dSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
303266e564dSmrg    if test -z "$file"; then
304266e564dSmrg      # ... or it is the one specified with @setfilename ...
305266e564dSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
306266e564dSmrg      file=`sed -n '
307266e564dSmrg	/^@setfilename/{
308266e564dSmrg	  s/.* \([^ ]*\) *$/\1/
309266e564dSmrg	  p
310266e564dSmrg	  q
311266e564dSmrg	}' $infile`
312266e564dSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
313266e564dSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
314266e564dSmrg    fi
315266e564dSmrg    # If the file does not exist, the user really needs makeinfo;
316266e564dSmrg    # let's fail without touching anything.
317266e564dSmrg    test -f $file || exit 1
318266e564dSmrg    touch $file
319266e564dSmrg    ;;
320266e564dSmrg
321d17cd367Smrg  tar*)
322266e564dSmrg    shift
323266e564dSmrg
324266e564dSmrg    # We have already tried tar in the generic part.
325266e564dSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
326266e564dSmrg    # messages.
327266e564dSmrg    if (gnutar --version > /dev/null 2>&1); then
328266e564dSmrg       gnutar "$@" && exit 0
329266e564dSmrg    fi
330266e564dSmrg    if (gtar --version > /dev/null 2>&1); then
331266e564dSmrg       gtar "$@" && exit 0
332266e564dSmrg    fi
333266e564dSmrg    firstarg="$1"
334266e564dSmrg    if shift; then
335266e564dSmrg	case $firstarg in
336266e564dSmrg	*o*)
337266e564dSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
338266e564dSmrg	    tar "$firstarg" "$@" && exit 0
339266e564dSmrg	    ;;
340266e564dSmrg	esac
341266e564dSmrg	case $firstarg in
342266e564dSmrg	*h*)
343266e564dSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
344266e564dSmrg	    tar "$firstarg" "$@" && exit 0
345266e564dSmrg	    ;;
346266e564dSmrg	esac
347266e564dSmrg    fi
348266e564dSmrg
349266e564dSmrg    echo 1>&2 "\
350266e564dSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
351266e564dSmrg         You may want to install GNU tar or Free paxutils, or check the
352266e564dSmrg         command line arguments."
353266e564dSmrg    exit 1
354266e564dSmrg    ;;
355266e564dSmrg
356266e564dSmrg  *)
357266e564dSmrg    echo 1>&2 "\
358266e564dSmrgWARNING: \`$1' is needed, and is $msg.
359266e564dSmrg         You might have modified some files without having the
360266e564dSmrg         proper tools for further handling them.  Check the \`README' file,
361266e564dSmrg         it often tells you about the needed prerequisites for installing
362266e564dSmrg         this package.  You may also peek at any GNU archive site, in case
363266e564dSmrg         some other package would contain this missing \`$1' program."
364266e564dSmrg    exit 1
365266e564dSmrg    ;;
366266e564dSmrgesac
367266e564dSmrg
368266e564dSmrgexit 0
369266e564dSmrg
370266e564dSmrg# Local variables:
371266e564dSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
372266e564dSmrg# time-stamp-start: "scriptversion="
373266e564dSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
374d17cd367Smrg# time-stamp-time-zone: "UTC"
375d17cd367Smrg# time-stamp-end: "; # UTC"
376266e564dSmrg# End:
377