xref: /netbsd-src/external/gpl2/xcvs/dist/build-aux/missing (revision 75e57c5640ae4c43e46f3b9f431ed4fbffac2b5c)
1a7c91847Schristos#! /bin/sh
2a7c91847Schristos# Common stub for a few missing GNU programs while installing.
3a7c91847Schristos
4*75e57c56Schristosscriptversion=2009-04-28.21; # UTC
5a7c91847Schristos
6*75e57c56Schristos# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
7*75e57c56Schristos# 2008, 2009 Free Software Foundation, Inc.
8a7c91847Schristos# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9a7c91847Schristos
10a7c91847Schristos# This program is free software; you can redistribute it and/or modify
11a7c91847Schristos# it under the terms of the GNU General Public License as published by
12a7c91847Schristos# the Free Software Foundation; either version 2, or (at your option)
13a7c91847Schristos# any later version.
14a7c91847Schristos
15a7c91847Schristos# This program is distributed in the hope that it will be useful,
16a7c91847Schristos# but WITHOUT ANY WARRANTY; without even the implied warranty of
17a7c91847Schristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18a7c91847Schristos# GNU General Public License for more details.
19a7c91847Schristos
20a7c91847Schristos# You should have received a copy of the GNU General Public License
21*75e57c56Schristos# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22a7c91847Schristos
23a7c91847Schristos# As a special exception to the GNU General Public License, if you
24a7c91847Schristos# distribute this file as part of a program that contains a
25a7c91847Schristos# configuration script generated by Autoconf, you may include it under
26a7c91847Schristos# the same distribution terms that you use for the rest of that program.
27a7c91847Schristos
28a7c91847Schristosif test $# -eq 0; then
29a7c91847Schristos  echo 1>&2 "Try \`$0 --help' for more information"
30a7c91847Schristos  exit 1
31a7c91847Schristosfi
32a7c91847Schristos
33a7c91847Schristosrun=:
34889c434eSchristossed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
35889c434eSchristossed_minuso='s/.* -o \([^ ]*\).*/\1/p'
36a7c91847Schristos
37a7c91847Schristos# In the cases where this matters, `missing' is being run in the
38a7c91847Schristos# srcdir already.
39a7c91847Schristosif test -f configure.ac; then
40a7c91847Schristos  configure_ac=configure.ac
41a7c91847Schristoselse
42a7c91847Schristos  configure_ac=configure.in
43a7c91847Schristosfi
44a7c91847Schristos
45a7c91847Schristosmsg="missing on your system"
46a7c91847Schristos
47889c434eSchristoscase $1 in
48a7c91847Schristos--run)
49a7c91847Schristos  # Try to run requested program, and just exit if it succeeds.
50a7c91847Schristos  run=
51a7c91847Schristos  shift
52a7c91847Schristos  "$@" && exit 0
53a7c91847Schristos  # Exit code 63 means version mismatch.  This often happens
54a7c91847Schristos  # when the user try to use an ancient version of a tool on
55a7c91847Schristos  # a file that requires a minimum version.  In this case we
56a7c91847Schristos  # we should proceed has if the program had been absent, or
57a7c91847Schristos  # if --run hadn't been passed.
58a7c91847Schristos  if test $? = 63; then
59a7c91847Schristos    run=:
60a7c91847Schristos    msg="probably too old"
61a7c91847Schristos  fi
62a7c91847Schristos  ;;
63a7c91847Schristos
64a7c91847Schristos  -h|--h|--he|--hel|--help)
65a7c91847Schristos    echo "\
66a7c91847Schristos$0 [OPTION]... PROGRAM [ARGUMENT]...
67a7c91847Schristos
68a7c91847SchristosHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69a7c91847Schristoserror status if there is no known handling for PROGRAM.
70a7c91847Schristos
71a7c91847SchristosOptions:
72a7c91847Schristos  -h, --help      display this help and exit
73a7c91847Schristos  -v, --version   output version information and exit
74a7c91847Schristos  --run           try to run the given command, and emulate it if it fails
75a7c91847Schristos
76a7c91847SchristosSupported PROGRAM values:
77a7c91847Schristos  aclocal      touch file \`aclocal.m4'
78a7c91847Schristos  autoconf     touch file \`configure'
79a7c91847Schristos  autoheader   touch file \`config.h.in'
80889c434eSchristos  autom4te     touch the output file, or create a stub one
81a7c91847Schristos  automake     touch all \`Makefile.in' files
82a7c91847Schristos  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
83a7c91847Schristos  flex         create \`lex.yy.c', if possible, from existing .c
84a7c91847Schristos  help2man     touch the output file
85a7c91847Schristos  lex          create \`lex.yy.c', if possible, from existing .c
86a7c91847Schristos  makeinfo     touch the output file
87a7c91847Schristos  tar          try tar, gnutar, gtar, then tar without non-portable flags
88a7c91847Schristos  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
89a7c91847Schristos
90*75e57c56SchristosVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
91*75e57c56Schristos\`g' are ignored when checking the name.
92*75e57c56Schristos
93a7c91847SchristosSend bug reports to <bug-automake@gnu.org>."
94a7c91847Schristos    exit $?
95a7c91847Schristos    ;;
96a7c91847Schristos
97a7c91847Schristos  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
98a7c91847Schristos    echo "missing $scriptversion (GNU Automake)"
99a7c91847Schristos    exit $?
100a7c91847Schristos    ;;
101a7c91847Schristos
102a7c91847Schristos  -*)
103a7c91847Schristos    echo 1>&2 "$0: Unknown \`$1' option"
104a7c91847Schristos    echo 1>&2 "Try \`$0 --help' for more information"
105a7c91847Schristos    exit 1
106a7c91847Schristos    ;;
107a7c91847Schristos
108a7c91847Schristosesac
109a7c91847Schristos
110*75e57c56Schristos# normalize program name to check for.
111*75e57c56Schristosprogram=`echo "$1" | sed '
112*75e57c56Schristos  s/^gnu-//; t
113*75e57c56Schristos  s/^gnu//; t
114*75e57c56Schristos  s/^g//; t'`
115*75e57c56Schristos
116a7c91847Schristos# Now exit if we have it, but it failed.  Also exit now if we
117a7c91847Schristos# don't have it and --version was passed (most likely to detect
118*75e57c56Schristos# the program).  This is about non-GNU programs, so use $1 not
119*75e57c56Schristos# $program.
120889c434eSchristoscase $1 in
121*75e57c56Schristos  lex*|yacc*)
122a7c91847Schristos    # Not GNU programs, they don't have --version.
123a7c91847Schristos    ;;
124a7c91847Schristos
125*75e57c56Schristos  tar*)
126a7c91847Schristos    if test -n "$run"; then
127a7c91847Schristos       echo 1>&2 "ERROR: \`tar' requires --run"
128a7c91847Schristos       exit 1
129a7c91847Schristos    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
130a7c91847Schristos       exit 1
131a7c91847Schristos    fi
132a7c91847Schristos    ;;
133a7c91847Schristos
134a7c91847Schristos  *)
135a7c91847Schristos    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
136a7c91847Schristos       # We have it, but it failed.
137a7c91847Schristos       exit 1
138a7c91847Schristos    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
139a7c91847Schristos       # Could not run --version or --help.  This is probably someone
140a7c91847Schristos       # running `$TOOL --version' or `$TOOL --help' to check whether
141a7c91847Schristos       # $TOOL exists and not knowing $TOOL uses missing.
142a7c91847Schristos       exit 1
143a7c91847Schristos    fi
144a7c91847Schristos    ;;
145a7c91847Schristosesac
146a7c91847Schristos
147a7c91847Schristos# If it does not exist, or fails to run (possibly an outdated version),
148a7c91847Schristos# try to emulate it.
149*75e57c56Schristoscase $program in
150a7c91847Schristos  aclocal*)
151a7c91847Schristos    echo 1>&2 "\
152a7c91847SchristosWARNING: \`$1' is $msg.  You should only need it if
153a7c91847Schristos         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
154a7c91847Schristos         to install the \`Automake' and \`Perl' packages.  Grab them from
155a7c91847Schristos         any GNU archive site."
156a7c91847Schristos    touch aclocal.m4
157a7c91847Schristos    ;;
158a7c91847Schristos
159*75e57c56Schristos  autoconf*)
160a7c91847Schristos    echo 1>&2 "\
161a7c91847SchristosWARNING: \`$1' is $msg.  You should only need it if
162a7c91847Schristos         you modified \`${configure_ac}'.  You might want to install the
163a7c91847Schristos         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
164a7c91847Schristos         archive site."
165a7c91847Schristos    touch configure
166a7c91847Schristos    ;;
167a7c91847Schristos
168*75e57c56Schristos  autoheader*)
169a7c91847Schristos    echo 1>&2 "\
170a7c91847SchristosWARNING: \`$1' is $msg.  You should only need it if
171a7c91847Schristos         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
172a7c91847Schristos         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
173a7c91847Schristos         from any GNU archive site."
174a7c91847Schristos    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
175a7c91847Schristos    test -z "$files" && files="config.h"
176a7c91847Schristos    touch_files=
177a7c91847Schristos    for f in $files; do
178889c434eSchristos      case $f in
179a7c91847Schristos      *:*) touch_files="$touch_files "`echo "$f" |
180a7c91847Schristos				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
181a7c91847Schristos      *) touch_files="$touch_files $f.in";;
182a7c91847Schristos      esac
183a7c91847Schristos    done
184a7c91847Schristos    touch $touch_files
185a7c91847Schristos    ;;
186a7c91847Schristos
187a7c91847Schristos  automake*)
188a7c91847Schristos    echo 1>&2 "\
189a7c91847SchristosWARNING: \`$1' is $msg.  You should only need it if
190a7c91847Schristos         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
191a7c91847Schristos         You might want to install the \`Automake' and \`Perl' packages.
192a7c91847Schristos         Grab them from any GNU archive site."
193a7c91847Schristos    find . -type f -name Makefile.am -print |
194a7c91847Schristos	   sed 's/\.am$/.in/' |
195a7c91847Schristos	   while read f; do touch "$f"; done
196a7c91847Schristos    ;;
197a7c91847Schristos
198*75e57c56Schristos  autom4te*)
199a7c91847Schristos    echo 1>&2 "\
200a7c91847SchristosWARNING: \`$1' is needed, but is $msg.
201a7c91847Schristos         You might have modified some files without having the
202a7c91847Schristos         proper tools for further handling them.
203a7c91847Schristos         You can get \`$1' as part of \`Autoconf' from any GNU
204a7c91847Schristos         archive site."
205a7c91847Schristos
206889c434eSchristos    file=`echo "$*" | sed -n "$sed_output"`
207889c434eSchristos    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
208a7c91847Schristos    if test -f "$file"; then
209a7c91847Schristos	touch $file
210a7c91847Schristos    else
211a7c91847Schristos	test -z "$file" || exec >$file
212a7c91847Schristos	echo "#! /bin/sh"
213a7c91847Schristos	echo "# Created by GNU Automake missing as a replacement of"
214a7c91847Schristos	echo "#  $ $@"
215a7c91847Schristos	echo "exit 0"
216a7c91847Schristos	chmod +x $file
217a7c91847Schristos	exit 1
218a7c91847Schristos    fi
219a7c91847Schristos    ;;
220a7c91847Schristos
221*75e57c56Schristos  bison*|yacc*)
222a7c91847Schristos    echo 1>&2 "\
223a7c91847SchristosWARNING: \`$1' $msg.  You should only need it if
224a7c91847Schristos         you modified a \`.y' file.  You may need the \`Bison' package
225a7c91847Schristos         in order for those modifications to take effect.  You can get
226a7c91847Schristos         \`Bison' from any GNU archive site."
227a7c91847Schristos    rm -f y.tab.c y.tab.h
228889c434eSchristos    if test $# -ne 1; then
229a7c91847Schristos        eval LASTARG="\${$#}"
230889c434eSchristos	case $LASTARG in
231a7c91847Schristos	*.y)
232a7c91847Schristos	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
233889c434eSchristos	    if test -f "$SRCFILE"; then
234a7c91847Schristos	         cp "$SRCFILE" y.tab.c
235a7c91847Schristos	    fi
236a7c91847Schristos	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
237889c434eSchristos	    if test -f "$SRCFILE"; then
238a7c91847Schristos	         cp "$SRCFILE" y.tab.h
239a7c91847Schristos	    fi
240a7c91847Schristos	  ;;
241a7c91847Schristos	esac
242a7c91847Schristos    fi
243889c434eSchristos    if test ! -f y.tab.h; then
244a7c91847Schristos	echo >y.tab.h
245a7c91847Schristos    fi
246889c434eSchristos    if test ! -f y.tab.c; then
247a7c91847Schristos	echo 'main() { return 0; }' >y.tab.c
248a7c91847Schristos    fi
249a7c91847Schristos    ;;
250a7c91847Schristos
251*75e57c56Schristos  lex*|flex*)
252a7c91847Schristos    echo 1>&2 "\
253a7c91847SchristosWARNING: \`$1' is $msg.  You should only need it if
254a7c91847Schristos         you modified a \`.l' file.  You may need the \`Flex' package
255a7c91847Schristos         in order for those modifications to take effect.  You can get
256a7c91847Schristos         \`Flex' from any GNU archive site."
257a7c91847Schristos    rm -f lex.yy.c
258889c434eSchristos    if test $# -ne 1; then
259a7c91847Schristos        eval LASTARG="\${$#}"
260889c434eSchristos	case $LASTARG in
261a7c91847Schristos	*.l)
262a7c91847Schristos	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
263889c434eSchristos	    if test -f "$SRCFILE"; then
264a7c91847Schristos	         cp "$SRCFILE" lex.yy.c
265a7c91847Schristos	    fi
266a7c91847Schristos	  ;;
267a7c91847Schristos	esac
268a7c91847Schristos    fi
269889c434eSchristos    if test ! -f lex.yy.c; then
270a7c91847Schristos	echo 'main() { return 0; }' >lex.yy.c
271a7c91847Schristos    fi
272a7c91847Schristos    ;;
273a7c91847Schristos
274*75e57c56Schristos  help2man*)
275a7c91847Schristos    echo 1>&2 "\
276a7c91847SchristosWARNING: \`$1' is $msg.  You should only need it if
277a7c91847Schristos	 you modified a dependency of a manual page.  You may need the
278a7c91847Schristos	 \`Help2man' package in order for those modifications to take
279a7c91847Schristos	 effect.  You can get \`Help2man' from any GNU archive site."
280a7c91847Schristos
281889c434eSchristos    file=`echo "$*" | sed -n "$sed_output"`
282889c434eSchristos    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
283889c434eSchristos    if test -f "$file"; then
284a7c91847Schristos	touch $file
285a7c91847Schristos    else
286a7c91847Schristos	test -z "$file" || exec >$file
287a7c91847Schristos	echo ".ab help2man is required to generate this page"
288*75e57c56Schristos	exit $?
289a7c91847Schristos    fi
290a7c91847Schristos    ;;
291a7c91847Schristos
292*75e57c56Schristos  makeinfo*)
293a7c91847Schristos    echo 1>&2 "\
294a7c91847SchristosWARNING: \`$1' is $msg.  You should only need it if
295a7c91847Schristos         you modified a \`.texi' or \`.texinfo' file, or any other file
296a7c91847Schristos         indirectly affecting the aspect of the manual.  The spurious
297a7c91847Schristos         call might also be the consequence of using a buggy \`make' (AIX,
298a7c91847Schristos         DU, IRIX).  You might want to install the \`Texinfo' package or
299a7c91847Schristos         the \`GNU make' package.  Grab either from any GNU archive site."
300a7c91847Schristos    # The file to touch is that specified with -o ...
301889c434eSchristos    file=`echo "$*" | sed -n "$sed_output"`
302889c434eSchristos    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
303a7c91847Schristos    if test -z "$file"; then
304a7c91847Schristos      # ... or it is the one specified with @setfilename ...
305a7c91847Schristos      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
306889c434eSchristos      file=`sed -n '
307889c434eSchristos	/^@setfilename/{
308889c434eSchristos	  s/.* \([^ ]*\) *$/\1/
309889c434eSchristos	  p
310889c434eSchristos	  q
311889c434eSchristos	}' $infile`
312a7c91847Schristos      # ... or it is derived from the source name (dir/f.texi becomes f.info)
313a7c91847Schristos      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
314a7c91847Schristos    fi
315889c434eSchristos    # If the file does not exist, the user really needs makeinfo;
316889c434eSchristos    # let's fail without touching anything.
317889c434eSchristos    test -f $file || exit 1
318a7c91847Schristos    touch $file
319a7c91847Schristos    ;;
320a7c91847Schristos
321*75e57c56Schristos  tar*)
322a7c91847Schristos    shift
323a7c91847Schristos
324a7c91847Schristos    # We have already tried tar in the generic part.
325a7c91847Schristos    # Look for gnutar/gtar before invocation to avoid ugly error
326a7c91847Schristos    # messages.
327a7c91847Schristos    if (gnutar --version > /dev/null 2>&1); then
328a7c91847Schristos       gnutar "$@" && exit 0
329a7c91847Schristos    fi
330a7c91847Schristos    if (gtar --version > /dev/null 2>&1); then
331a7c91847Schristos       gtar "$@" && exit 0
332a7c91847Schristos    fi
333a7c91847Schristos    firstarg="$1"
334a7c91847Schristos    if shift; then
335889c434eSchristos	case $firstarg in
336a7c91847Schristos	*o*)
337a7c91847Schristos	    firstarg=`echo "$firstarg" | sed s/o//`
338a7c91847Schristos	    tar "$firstarg" "$@" && exit 0
339a7c91847Schristos	    ;;
340a7c91847Schristos	esac
341889c434eSchristos	case $firstarg in
342a7c91847Schristos	*h*)
343a7c91847Schristos	    firstarg=`echo "$firstarg" | sed s/h//`
344a7c91847Schristos	    tar "$firstarg" "$@" && exit 0
345a7c91847Schristos	    ;;
346a7c91847Schristos	esac
347a7c91847Schristos    fi
348a7c91847Schristos
349a7c91847Schristos    echo 1>&2 "\
350a7c91847SchristosWARNING: I can't seem to be able to run \`tar' with the given arguments.
351a7c91847Schristos         You may want to install GNU tar or Free paxutils, or check the
352a7c91847Schristos         command line arguments."
353a7c91847Schristos    exit 1
354a7c91847Schristos    ;;
355a7c91847Schristos
356a7c91847Schristos  *)
357a7c91847Schristos    echo 1>&2 "\
358a7c91847SchristosWARNING: \`$1' is needed, and is $msg.
359a7c91847Schristos         You might have modified some files without having the
360a7c91847Schristos         proper tools for further handling them.  Check the \`README' file,
361a7c91847Schristos         it often tells you about the needed prerequisites for installing
362a7c91847Schristos         this package.  You may also peek at any GNU archive site, in case
363a7c91847Schristos         some other package would contain this missing \`$1' program."
364a7c91847Schristos    exit 1
365a7c91847Schristos    ;;
366a7c91847Schristosesac
367a7c91847Schristos
368a7c91847Schristosexit 0
369a7c91847Schristos
370a7c91847Schristos# Local variables:
371a7c91847Schristos# eval: (add-hook 'write-file-hooks 'time-stamp)
372a7c91847Schristos# time-stamp-start: "scriptversion="
373a7c91847Schristos# time-stamp-format: "%:y-%02m-%02d.%02H"
374*75e57c56Schristos# time-stamp-time-zone: "UTC"
375*75e57c56Schristos# time-stamp-end: "; # UTC"
376a7c91847Schristos# End:
377