• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2# Common stub for a few missing GNU programs while installing.
3# Copyright (C) 1996-1997, 1999-2000, 2002 Free Software Foundation,
4# Inc.
5# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
6
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2, or (at your option)
10# any later version.
11
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20# 02111-1307, USA.
21
22# As a special exception to the GNU General Public License, if you
23# distribute this file as part of a program that contains a
24# configuration script generated by Autoconf, you may include it under
25# the same distribution terms that you use for the rest of that program.
26
27if test $# -eq 0; then
28  echo 1>&2 "Try \`$0 --help' for more information"
29  exit 1
30fi
31
32run=:
33
34# In the cases where this matters, `missing' is being run in the
35# srcdir already.
36if test -f configure.ac; then
37  configure_ac=configure.ac
38else
39  configure_ac=configure.in
40fi
41
42case "$1" in
43--run)
44  # Try to run requested program, and just exit if it succeeds.
45  run=
46  shift
47  "$@" && exit 0
48  ;;
49esac
50
51# If it does not exist, or fails to run (possibly an outdated version),
52# try to emulate it.
53case "$1" in
54
55  -h|--h|--he|--hel|--help)
56    echo "\
57$0 [OPTION]... PROGRAM [ARGUMENT]...
58
59Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
60error status if there is no known handling for PROGRAM.
61
62Options:
63  -h, --help      display this help and exit
64  -v, --version   output version information and exit
65  --run           try to run the given command, and emulate it if it fails
66
67Supported PROGRAM values:
68  aclocal      touch file \`aclocal.m4'
69  autoconf     touch file \`configure'
70  autoheader   touch file \`config.h.in'
71  automake     touch all \`Makefile.in' files
72  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
73  flex         create \`lex.yy.c', if possible, from existing .c
74  help2man     touch the output file
75  lex          create \`lex.yy.c', if possible, from existing .c
76  makeinfo     touch the output file
77  tar          try tar, gnutar, gtar, then tar without non-portable flags
78  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
79    ;;
80
81  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
82    echo "missing 0.4 - GNU automake"
83    ;;
84
85  -*)
86    echo 1>&2 "$0: Unknown \`$1' option"
87    echo 1>&2 "Try \`$0 --help' for more information"
88    exit 1
89    ;;
90
91  aclocal*)
92    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
93       # We have it, but it failed.
94       exit 1
95    fi
96
97    echo 1>&2 "\
98WARNING: \`$1' is missing on your system.  You should only need it if
99         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
100         to install the \`Automake' and \`Perl' packages.  Grab them from
101         any GNU archive site."
102    touch aclocal.m4
103    ;;
104
105  autoconf)
106    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
107       # We have it, but it failed.
108       exit 1
109    fi
110
111    echo 1>&2 "\
112WARNING: \`$1' is missing on your system.  You should only need it if
113         you modified \`${configure_ac}'.  You might want to install the
114         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
115         archive site."
116    touch configure
117    ;;
118
119  autoheader)
120    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
121       # We have it, but it failed.
122       exit 1
123    fi
124
125    echo 1>&2 "\
126WARNING: \`$1' is missing on your system.  You should only need it if
127         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
128         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
129         from any GNU archive site."
130    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
131    test -z "$files" && files="config.h"
132    touch_files=
133    for f in $files; do
134      case "$f" in
135      *:*) touch_files="$touch_files "`echo "$f" |
136				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
137      *) touch_files="$touch_files $f.in";;
138      esac
139    done
140    touch $touch_files
141    ;;
142
143  automake*)
144    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
145       # We have it, but it failed.
146       exit 1
147    fi
148
149    echo 1>&2 "\
150WARNING: \`$1' is missing on your system.  You should only need it if
151         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
152         You might want to install the \`Automake' and \`Perl' packages.
153         Grab them from any GNU archive site."
154    find . -type f -name Makefile.am -print |
155	   sed 's/\.am$/.in/' |
156	   while read f; do touch "$f"; done
157    ;;
158
159  autom4te)
160    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
161       # We have it, but it failed.
162       exit 1
163    fi
164
165    echo 1>&2 "\
166WARNING: \`$1' is needed, and you do not seem to have it handy on your
167         system.  You might have modified some files without having the
168         proper tools for further handling them.
169         You can get \`$1Help2man' as part of \`Autoconf' from any GNU
170         archive site."
171
172    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
173    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
174    if test -f "$file"; then
175	touch $file
176    else
177	test -z "$file" || exec >$file
178	echo "#! /bin/sh"
179	echo "# Created by GNU Automake missing as a replacement of"
180	echo "#  $ $@"
181	echo "exit 0"
182	chmod +x $file
183	exit 1
184    fi
185    ;;
186
187  bison|yacc)
188    echo 1>&2 "\
189WARNING: \`$1' is missing on your system.  You should only need it if
190         you modified a \`.y' file.  You may need the \`Bison' package
191         in order for those modifications to take effect.  You can get
192         \`Bison' from any GNU archive site."
193    rm -f y.tab.c y.tab.h
194    if [ $# -ne 1 ]; then
195        eval LASTARG="\${$#}"
196	case "$LASTARG" in
197	*.y)
198	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
199	    if [ -f "$SRCFILE" ]; then
200	         cp "$SRCFILE" y.tab.c
201	    fi
202	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
203	    if [ -f "$SRCFILE" ]; then
204	         cp "$SRCFILE" y.tab.h
205	    fi
206	  ;;
207	esac
208    fi
209    if [ ! -f y.tab.h ]; then
210	echo >y.tab.h
211    fi
212    if [ ! -f y.tab.c ]; then
213	echo 'main() { return 0; }' >y.tab.c
214    fi
215    ;;
216
217  lex|flex)
218    echo 1>&2 "\
219WARNING: \`$1' is missing on your system.  You should only need it if
220         you modified a \`.l' file.  You may need the \`Flex' package
221         in order for those modifications to take effect.  You can get
222         \`Flex' from any GNU archive site."
223    rm -f lex.yy.c
224    if [ $# -ne 1 ]; then
225        eval LASTARG="\${$#}"
226	case "$LASTARG" in
227	*.l)
228	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
229	    if [ -f "$SRCFILE" ]; then
230	         cp "$SRCFILE" lex.yy.c
231	    fi
232	  ;;
233	esac
234    fi
235    if [ ! -f lex.yy.c ]; then
236	echo 'main() { return 0; }' >lex.yy.c
237    fi
238    ;;
239
240  help2man)
241    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
242       # We have it, but it failed.
243       exit 1
244    fi
245
246    echo 1>&2 "\
247WARNING: \`$1' is missing on your system.  You should only need it if
248	 you modified a dependency of a manual page.  You may need the
249	 \`Help2man' package in order for those modifications to take
250	 effect.  You can get \`Help2man' from any GNU archive site."
251
252    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
253    if test -z "$file"; then
254	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
255    fi
256    if [ -f "$file" ]; then
257	touch $file
258    else
259	test -z "$file" || exec >$file
260	echo ".ab help2man is required to generate this page"
261	exit 1
262    fi
263    ;;
264
265  makeinfo)
266    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
267       # We have makeinfo, but it failed.
268       exit 1
269    fi
270
271    echo 1>&2 "\
272WARNING: \`$1' is missing on your system.  You should only need it if
273         you modified a \`.texi' or \`.texinfo' file, or any other file
274         indirectly affecting the aspect of the manual.  The spurious
275         call might also be the consequence of using a buggy \`make' (AIX,
276         DU, IRIX).  You might want to install the \`Texinfo' package or
277         the \`GNU make' package.  Grab either from any GNU archive site."
278    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
279    if test -z "$file"; then
280      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
281      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
282    fi
283    touch $file
284    ;;
285
286  tar)
287    shift
288    if test -n "$run"; then
289      echo 1>&2 "ERROR: \`tar' requires --run"
290      exit 1
291    fi
292
293    # We have already tried tar in the generic part.
294    # Look for gnutar/gtar before invocation to avoid ugly error
295    # messages.
296    if (gnutar --version > /dev/null 2>&1); then
297       gnutar "$@" && exit 0
298    fi
299    if (gtar --version > /dev/null 2>&1); then
300       gtar "$@" && exit 0
301    fi
302    firstarg="$1"
303    if shift; then
304	case "$firstarg" in
305	*o*)
306	    firstarg=`echo "$firstarg" | sed s/o//`
307	    tar "$firstarg" "$@" && exit 0
308	    ;;
309	esac
310	case "$firstarg" in
311	*h*)
312	    firstarg=`echo "$firstarg" | sed s/h//`
313	    tar "$firstarg" "$@" && exit 0
314	    ;;
315	esac
316    fi
317
318    echo 1>&2 "\
319WARNING: I can't seem to be able to run \`tar' with the given arguments.
320         You may want to install GNU tar or Free paxutils, or check the
321         command line arguments."
322    exit 1
323    ;;
324
325  *)
326    echo 1>&2 "\
327WARNING: \`$1' is needed, and you do not seem to have it handy on your
328         system.  You might have modified some files without having the
329         proper tools for further handling them.  Check the \`README' file,
330         it often tells you about the needed prerequirements for installing
331         this package.  You may also peek at any GNU archive site, in case
332         some other package would contain this missing \`$1' program."
333    exit 1
334    ;;
335esac
336
337exit 0
338