missing revision 335e815a
1335e815aSmrg#! /bin/sh
2335e815aSmrg# Common stub for a few missing GNU programs while installing.
3335e815aSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
4335e815aSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
5335e815aSmrg
6335e815aSmrg# This program is free software; you can redistribute it and/or modify
7335e815aSmrg# it under the terms of the GNU General Public License as published by
8335e815aSmrg# the Free Software Foundation; either version 2, or (at your option)
9335e815aSmrg# any later version.
10335e815aSmrg
11335e815aSmrg# This program is distributed in the hope that it will be useful,
12335e815aSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
13335e815aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14335e815aSmrg# GNU General Public License for more details.
15335e815aSmrg
16335e815aSmrg# You should have received a copy of the GNU General Public License
17335e815aSmrg# along with this program; if not, write to the Free Software
18335e815aSmrg# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19335e815aSmrg# 02111-1307, USA.
20335e815aSmrg
21335e815aSmrg# As a special exception to the GNU General Public License, if you
22335e815aSmrg# distribute this file as part of a program that contains a
23335e815aSmrg# configuration script generated by Autoconf, you may include it under
24335e815aSmrg# the same distribution terms that you use for the rest of that program.
25335e815aSmrg
26335e815aSmrgif test $# -eq 0; then
27335e815aSmrg  echo 1>&2 "Try \`$0 --help' for more information"
28335e815aSmrg  exit 1
29335e815aSmrgfi
30335e815aSmrg
31335e815aSmrgrun=:
32335e815aSmrg
33335e815aSmrg# In the cases where this matters, `missing' is being run in the
34335e815aSmrg# srcdir already.
35335e815aSmrgif test -f configure.ac; then
36335e815aSmrg  configure_ac=configure.ac
37335e815aSmrgelse
38335e815aSmrg  configure_ac=configure.in
39335e815aSmrgfi
40335e815aSmrg
41335e815aSmrgcase "$1" in
42335e815aSmrg--run)
43335e815aSmrg  # Try to run requested program, and just exit if it succeeds.
44335e815aSmrg  run=
45335e815aSmrg  shift
46335e815aSmrg  "$@" && exit 0
47335e815aSmrg  ;;
48335e815aSmrgesac
49335e815aSmrg
50335e815aSmrg# If it does not exist, or fails to run (possibly an outdated version),
51335e815aSmrg# try to emulate it.
52335e815aSmrgcase "$1" in
53335e815aSmrg
54335e815aSmrg  -h|--h|--he|--hel|--help)
55335e815aSmrg    echo "\
56335e815aSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
57335e815aSmrg
58335e815aSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
59335e815aSmrgerror status if there is no known handling for PROGRAM.
60335e815aSmrg
61335e815aSmrgOptions:
62335e815aSmrg  -h, --help      display this help and exit
63335e815aSmrg  -v, --version   output version information and exit
64335e815aSmrg  --run           try to run the given command, and emulate it if it fails
65335e815aSmrg
66335e815aSmrgSupported PROGRAM values:
67335e815aSmrg  aclocal      touch file \`aclocal.m4'
68335e815aSmrg  autoconf     touch file \`configure'
69335e815aSmrg  autoheader   touch file \`config.h.in'
70335e815aSmrg  automake     touch all \`Makefile.in' files
71335e815aSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
72335e815aSmrg  flex         create \`lex.yy.c', if possible, from existing .c
73335e815aSmrg  help2man     touch the output file
74335e815aSmrg  lex          create \`lex.yy.c', if possible, from existing .c
75335e815aSmrg  makeinfo     touch the output file
76335e815aSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
77335e815aSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
78335e815aSmrg    ;;
79335e815aSmrg
80335e815aSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
81335e815aSmrg    echo "missing 0.4 - GNU automake"
82335e815aSmrg    ;;
83335e815aSmrg
84335e815aSmrg  -*)
85335e815aSmrg    echo 1>&2 "$0: Unknown \`$1' option"
86335e815aSmrg    echo 1>&2 "Try \`$0 --help' for more information"
87335e815aSmrg    exit 1
88335e815aSmrg    ;;
89335e815aSmrg
90335e815aSmrg  aclocal*)
91335e815aSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
92335e815aSmrg       # We have it, but it failed.
93335e815aSmrg       exit 1
94335e815aSmrg    fi
95335e815aSmrg
96335e815aSmrg    echo 1>&2 "\
97335e815aSmrgWARNING: \`$1' is missing on your system.  You should only need it if
98335e815aSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
99335e815aSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
100335e815aSmrg         any GNU archive site."
101335e815aSmrg    touch aclocal.m4
102335e815aSmrg    ;;
103335e815aSmrg
104335e815aSmrg  autoconf)
105335e815aSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
106335e815aSmrg       # We have it, but it failed.
107335e815aSmrg       exit 1
108335e815aSmrg    fi
109335e815aSmrg
110335e815aSmrg    echo 1>&2 "\
111335e815aSmrgWARNING: \`$1' is missing on your system.  You should only need it if
112335e815aSmrg         you modified \`${configure_ac}'.  You might want to install the
113335e815aSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
114335e815aSmrg         archive site."
115335e815aSmrg    touch configure
116335e815aSmrg    ;;
117335e815aSmrg
118335e815aSmrg  autoheader)
119335e815aSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
120335e815aSmrg       # We have it, but it failed.
121335e815aSmrg       exit 1
122335e815aSmrg    fi
123335e815aSmrg
124335e815aSmrg    echo 1>&2 "\
125335e815aSmrgWARNING: \`$1' is missing on your system.  You should only need it if
126335e815aSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
127335e815aSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
128335e815aSmrg         from any GNU archive site."
129335e815aSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
130335e815aSmrg    test -z "$files" && files="config.h"
131335e815aSmrg    touch_files=
132335e815aSmrg    for f in $files; do
133335e815aSmrg      case "$f" in
134335e815aSmrg      *:*) touch_files="$touch_files "`echo "$f" |
135335e815aSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
136335e815aSmrg      *) touch_files="$touch_files $f.in";;
137335e815aSmrg      esac
138335e815aSmrg    done
139335e815aSmrg    touch $touch_files
140335e815aSmrg    ;;
141335e815aSmrg
142335e815aSmrg  automake*)
143335e815aSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
144335e815aSmrg       # We have it, but it failed.
145335e815aSmrg       exit 1
146335e815aSmrg    fi
147335e815aSmrg
148335e815aSmrg    echo 1>&2 "\
149335e815aSmrgWARNING: \`$1' is missing on your system.  You should only need it if
150335e815aSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
151335e815aSmrg         You might want to install the \`Automake' and \`Perl' packages.
152335e815aSmrg         Grab them from any GNU archive site."
153335e815aSmrg    find . -type f -name Makefile.am -print |
154335e815aSmrg	   sed 's/\.am$/.in/' |
155335e815aSmrg	   while read f; do touch "$f"; done
156335e815aSmrg    ;;
157335e815aSmrg
158335e815aSmrg  autom4te)
159335e815aSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
160335e815aSmrg       # We have it, but it failed.
161335e815aSmrg       exit 1
162335e815aSmrg    fi
163335e815aSmrg
164335e815aSmrg    echo 1>&2 "\
165335e815aSmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
166335e815aSmrg         system.  You might have modified some files without having the
167335e815aSmrg         proper tools for further handling them.
168335e815aSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
169335e815aSmrg         archive site."
170335e815aSmrg
171335e815aSmrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
172335e815aSmrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
173335e815aSmrg    if test -f "$file"; then
174335e815aSmrg	touch $file
175335e815aSmrg    else
176335e815aSmrg	test -z "$file" || exec >$file
177335e815aSmrg	echo "#! /bin/sh"
178335e815aSmrg	echo "# Created by GNU Automake missing as a replacement of"
179335e815aSmrg	echo "#  $ $@"
180335e815aSmrg	echo "exit 0"
181335e815aSmrg	chmod +x $file
182335e815aSmrg	exit 1
183335e815aSmrg    fi
184335e815aSmrg    ;;
185335e815aSmrg
186335e815aSmrg  bison|yacc)
187335e815aSmrg    echo 1>&2 "\
188335e815aSmrgWARNING: \`$1' is missing on your system.  You should only need it if
189335e815aSmrg         you modified a \`.y' file.  You may need the \`Bison' package
190335e815aSmrg         in order for those modifications to take effect.  You can get
191335e815aSmrg         \`Bison' from any GNU archive site."
192335e815aSmrg    rm -f y.tab.c y.tab.h
193335e815aSmrg    if [ $# -ne 1 ]; then
194335e815aSmrg        eval LASTARG="\${$#}"
195335e815aSmrg	case "$LASTARG" in
196335e815aSmrg	*.y)
197335e815aSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
198335e815aSmrg	    if [ -f "$SRCFILE" ]; then
199335e815aSmrg	         cp "$SRCFILE" y.tab.c
200335e815aSmrg	    fi
201335e815aSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
202335e815aSmrg	    if [ -f "$SRCFILE" ]; then
203335e815aSmrg	         cp "$SRCFILE" y.tab.h
204335e815aSmrg	    fi
205335e815aSmrg	  ;;
206335e815aSmrg	esac
207335e815aSmrg    fi
208335e815aSmrg    if [ ! -f y.tab.h ]; then
209335e815aSmrg	echo >y.tab.h
210335e815aSmrg    fi
211335e815aSmrg    if [ ! -f y.tab.c ]; then
212335e815aSmrg	echo 'main() { return 0; }' >y.tab.c
213335e815aSmrg    fi
214335e815aSmrg    ;;
215335e815aSmrg
216335e815aSmrg  lex|flex)
217335e815aSmrg    echo 1>&2 "\
218335e815aSmrgWARNING: \`$1' is missing on your system.  You should only need it if
219335e815aSmrg         you modified a \`.l' file.  You may need the \`Flex' package
220335e815aSmrg         in order for those modifications to take effect.  You can get
221335e815aSmrg         \`Flex' from any GNU archive site."
222335e815aSmrg    rm -f lex.yy.c
223335e815aSmrg    if [ $# -ne 1 ]; then
224335e815aSmrg        eval LASTARG="\${$#}"
225335e815aSmrg	case "$LASTARG" in
226335e815aSmrg	*.l)
227335e815aSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
228335e815aSmrg	    if [ -f "$SRCFILE" ]; then
229335e815aSmrg	         cp "$SRCFILE" lex.yy.c
230335e815aSmrg	    fi
231335e815aSmrg	  ;;
232335e815aSmrg	esac
233335e815aSmrg    fi
234335e815aSmrg    if [ ! -f lex.yy.c ]; then
235335e815aSmrg	echo 'main() { return 0; }' >lex.yy.c
236335e815aSmrg    fi
237335e815aSmrg    ;;
238335e815aSmrg
239335e815aSmrg  help2man)
240335e815aSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
241335e815aSmrg       # We have it, but it failed.
242335e815aSmrg       exit 1
243335e815aSmrg    fi
244335e815aSmrg
245335e815aSmrg    echo 1>&2 "\
246335e815aSmrgWARNING: \`$1' is missing on your system.  You should only need it if
247335e815aSmrg	 you modified a dependency of a manual page.  You may need the
248335e815aSmrg	 \`Help2man' package in order for those modifications to take
249335e815aSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
250335e815aSmrg
251335e815aSmrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
252335e815aSmrg    if test -z "$file"; then
253335e815aSmrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
254335e815aSmrg    fi
255335e815aSmrg    if [ -f "$file" ]; then
256335e815aSmrg	touch $file
257335e815aSmrg    else
258335e815aSmrg	test -z "$file" || exec >$file
259335e815aSmrg	echo ".ab help2man is required to generate this page"
260335e815aSmrg	exit 1
261335e815aSmrg    fi
262335e815aSmrg    ;;
263335e815aSmrg
264335e815aSmrg  makeinfo)
265335e815aSmrg    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
266335e815aSmrg       # We have makeinfo, but it failed.
267335e815aSmrg       exit 1
268335e815aSmrg    fi
269335e815aSmrg
270335e815aSmrg    echo 1>&2 "\
271335e815aSmrgWARNING: \`$1' is missing on your system.  You should only need it if
272335e815aSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
273335e815aSmrg         indirectly affecting the aspect of the manual.  The spurious
274335e815aSmrg         call might also be the consequence of using a buggy \`make' (AIX,
275335e815aSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
276335e815aSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
277335e815aSmrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
278335e815aSmrg    if test -z "$file"; then
279335e815aSmrg      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
280335e815aSmrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
281335e815aSmrg    fi
282335e815aSmrg    touch $file
283335e815aSmrg    ;;
284335e815aSmrg
285335e815aSmrg  tar)
286335e815aSmrg    shift
287335e815aSmrg    if test -n "$run"; then
288335e815aSmrg      echo 1>&2 "ERROR: \`tar' requires --run"
289335e815aSmrg      exit 1
290335e815aSmrg    fi
291335e815aSmrg
292335e815aSmrg    # We have already tried tar in the generic part.
293335e815aSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
294335e815aSmrg    # messages.
295335e815aSmrg    if (gnutar --version > /dev/null 2>&1); then
296335e815aSmrg       gnutar "$@" && exit 0
297335e815aSmrg    fi
298335e815aSmrg    if (gtar --version > /dev/null 2>&1); then
299335e815aSmrg       gtar "$@" && exit 0
300335e815aSmrg    fi
301335e815aSmrg    firstarg="$1"
302335e815aSmrg    if shift; then
303335e815aSmrg	case "$firstarg" in
304335e815aSmrg	*o*)
305335e815aSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
306335e815aSmrg	    tar "$firstarg" "$@" && exit 0
307335e815aSmrg	    ;;
308335e815aSmrg	esac
309335e815aSmrg	case "$firstarg" in
310335e815aSmrg	*h*)
311335e815aSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
312335e815aSmrg	    tar "$firstarg" "$@" && exit 0
313335e815aSmrg	    ;;
314335e815aSmrg	esac
315335e815aSmrg    fi
316335e815aSmrg
317335e815aSmrg    echo 1>&2 "\
318335e815aSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
319335e815aSmrg         You may want to install GNU tar or Free paxutils, or check the
320335e815aSmrg         command line arguments."
321335e815aSmrg    exit 1
322335e815aSmrg    ;;
323335e815aSmrg
324335e815aSmrg  *)
325335e815aSmrg    echo 1>&2 "\
326335e815aSmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
327335e815aSmrg         system.  You might have modified some files without having the
328335e815aSmrg         proper tools for further handling them.  Check the \`README' file,
329335e815aSmrg         it often tells you about the needed prerequisites for installing
330335e815aSmrg         this package.  You may also peek at any GNU archive site, in case
331335e815aSmrg         some other package would contain this missing \`$1' program."
332335e815aSmrg    exit 1
333335e815aSmrg    ;;
334335e815aSmrgesac
335335e815aSmrg
336335e815aSmrgexit 0
337