xref: /netbsd-src/external/gpl3/autoconf/dist/build-aux/missing (revision d874e91932377fc40d53f102e48fc3ee6f4fe9de)
1*d874e919Schristos#! /bin/sh
2*d874e919Schristos# Common stub for a few missing GNU programs while installing.
3*d874e919Schristos
4*d874e919Schristosscriptversion=2012-01-06.18; # UTC
5*d874e919Schristos
6*d874e919Schristos# Copyright (C) 1996-2012 Free Software Foundation, Inc.
7*d874e919Schristos# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8*d874e919Schristos
9*d874e919Schristos# This program is free software; you can redistribute it and/or modify
10*d874e919Schristos# it under the terms of the GNU General Public License as published by
11*d874e919Schristos# the Free Software Foundation; either version 2, or (at your option)
12*d874e919Schristos# any later version.
13*d874e919Schristos
14*d874e919Schristos# This program is distributed in the hope that it will be useful,
15*d874e919Schristos# but WITHOUT ANY WARRANTY; without even the implied warranty of
16*d874e919Schristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17*d874e919Schristos# GNU General Public License for more details.
18*d874e919Schristos
19*d874e919Schristos# You should have received a copy of the GNU General Public License
20*d874e919Schristos# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21*d874e919Schristos
22*d874e919Schristos# As a special exception to the GNU General Public License, if you
23*d874e919Schristos# distribute this file as part of a program that contains a
24*d874e919Schristos# configuration script generated by Autoconf, you may include it under
25*d874e919Schristos# the same distribution terms that you use for the rest of that program.
26*d874e919Schristos
27*d874e919Schristosif test $# -eq 0; then
28*d874e919Schristos  echo 1>&2 "Try '$0 --help' for more information"
29*d874e919Schristos  exit 1
30*d874e919Schristosfi
31*d874e919Schristos
32*d874e919Schristosrun=:
33*d874e919Schristossed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
34*d874e919Schristossed_minuso='s/.* -o \([^ ]*\).*/\1/p'
35*d874e919Schristos
36*d874e919Schristos# In the cases where this matters, 'missing' is being run in the
37*d874e919Schristos# srcdir already.
38*d874e919Schristosif test -f configure.ac; then
39*d874e919Schristos  configure_ac=configure.ac
40*d874e919Schristoselse
41*d874e919Schristos  configure_ac=configure.in
42*d874e919Schristosfi
43*d874e919Schristos
44*d874e919Schristosmsg="missing on your system"
45*d874e919Schristos
46*d874e919Schristoscase $1 in
47*d874e919Schristos--run)
48*d874e919Schristos  # Try to run requested program, and just exit if it succeeds.
49*d874e919Schristos  run=
50*d874e919Schristos  shift
51*d874e919Schristos  "$@" && exit 0
52*d874e919Schristos  # Exit code 63 means version mismatch.  This often happens
53*d874e919Schristos  # when the user try to use an ancient version of a tool on
54*d874e919Schristos  # a file that requires a minimum version.  In this case we
55*d874e919Schristos  # we should proceed has if the program had been absent, or
56*d874e919Schristos  # if --run hadn't been passed.
57*d874e919Schristos  if test $? = 63; then
58*d874e919Schristos    run=:
59*d874e919Schristos    msg="probably too old"
60*d874e919Schristos  fi
61*d874e919Schristos  ;;
62*d874e919Schristos
63*d874e919Schristos  -h|--h|--he|--hel|--help)
64*d874e919Schristos    echo "\
65*d874e919Schristos$0 [OPTION]... PROGRAM [ARGUMENT]...
66*d874e919Schristos
67*d874e919SchristosHandle 'PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
68*d874e919Schristoserror status if there is no known handling for PROGRAM.
69*d874e919Schristos
70*d874e919SchristosOptions:
71*d874e919Schristos  -h, --help      display this help and exit
72*d874e919Schristos  -v, --version   output version information and exit
73*d874e919Schristos  --run           try to run the given command, and emulate it if it fails
74*d874e919Schristos
75*d874e919SchristosSupported PROGRAM values:
76*d874e919Schristos  aclocal      touch file 'aclocal.m4'
77*d874e919Schristos  autoconf     touch file 'configure'
78*d874e919Schristos  autoheader   touch file 'config.h.in'
79*d874e919Schristos  autom4te     touch the output file, or create a stub one
80*d874e919Schristos  automake     touch all 'Makefile.in' files
81*d874e919Schristos  bison        create 'y.tab.[ch]', if possible, from existing .[ch]
82*d874e919Schristos  flex         create 'lex.yy.c', if possible, from existing .c
83*d874e919Schristos  help2man     touch the output file
84*d874e919Schristos  lex          create 'lex.yy.c', if possible, from existing .c
85*d874e919Schristos  makeinfo     touch the output file
86*d874e919Schristos  yacc         create 'y.tab.[ch]', if possible, from existing .[ch]
87*d874e919Schristos
88*d874e919SchristosVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
89*d874e919Schristos'g' are ignored when checking the name.
90*d874e919Schristos
91*d874e919SchristosSend bug reports to <bug-automake@gnu.org>."
92*d874e919Schristos    exit $?
93*d874e919Schristos    ;;
94*d874e919Schristos
95*d874e919Schristos  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
96*d874e919Schristos    echo "missing $scriptversion (GNU Automake)"
97*d874e919Schristos    exit $?
98*d874e919Schristos    ;;
99*d874e919Schristos
100*d874e919Schristos  -*)
101*d874e919Schristos    echo 1>&2 "$0: Unknown '$1' option"
102*d874e919Schristos    echo 1>&2 "Try '$0 --help' for more information"
103*d874e919Schristos    exit 1
104*d874e919Schristos    ;;
105*d874e919Schristos
106*d874e919Schristosesac
107*d874e919Schristos
108*d874e919Schristos# normalize program name to check for.
109*d874e919Schristosprogram=`echo "$1" | sed '
110*d874e919Schristos  s/^gnu-//; t
111*d874e919Schristos  s/^gnu//; t
112*d874e919Schristos  s/^g//; t'`
113*d874e919Schristos
114*d874e919Schristos# Now exit if we have it, but it failed.  Also exit now if we
115*d874e919Schristos# don't have it and --version was passed (most likely to detect
116*d874e919Schristos# the program).  This is about non-GNU programs, so use $1 not
117*d874e919Schristos# $program.
118*d874e919Schristoscase $1 in
119*d874e919Schristos  lex*|yacc*)
120*d874e919Schristos    # Not GNU programs, they don't have --version.
121*d874e919Schristos    ;;
122*d874e919Schristos
123*d874e919Schristos  *)
124*d874e919Schristos    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
125*d874e919Schristos       # We have it, but it failed.
126*d874e919Schristos       exit 1
127*d874e919Schristos    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
128*d874e919Schristos       # Could not run --version or --help.  This is probably someone
129*d874e919Schristos       # running '$TOOL --version' or '$TOOL --help' to check whether
130*d874e919Schristos       # $TOOL exists and not knowing $TOOL uses missing.
131*d874e919Schristos       exit 1
132*d874e919Schristos    fi
133*d874e919Schristos    ;;
134*d874e919Schristosesac
135*d874e919Schristos
136*d874e919Schristos# If it does not exist, or fails to run (possibly an outdated version),
137*d874e919Schristos# try to emulate it.
138*d874e919Schristoscase $program in
139*d874e919Schristos  aclocal*)
140*d874e919Schristos    echo 1>&2 "\
141*d874e919SchristosWARNING: '$1' is $msg.  You should only need it if
142*d874e919Schristos         you modified 'acinclude.m4' or '${configure_ac}'.  You might want
143*d874e919Schristos         to install the Automake and Perl packages.  Grab them from
144*d874e919Schristos         any GNU archive site."
145*d874e919Schristos    touch aclocal.m4
146*d874e919Schristos    ;;
147*d874e919Schristos
148*d874e919Schristos  autoconf*)
149*d874e919Schristos    echo 1>&2 "\
150*d874e919SchristosWARNING: '$1' is $msg.  You should only need it if
151*d874e919Schristos         you modified '${configure_ac}'.  You might want to install the
152*d874e919Schristos         Autoconf and GNU m4 packages.  Grab them from any GNU
153*d874e919Schristos         archive site."
154*d874e919Schristos    touch configure
155*d874e919Schristos    ;;
156*d874e919Schristos
157*d874e919Schristos  autoheader*)
158*d874e919Schristos    echo 1>&2 "\
159*d874e919SchristosWARNING: '$1' is $msg.  You should only need it if
160*d874e919Schristos         you modified 'acconfig.h' or '${configure_ac}'.  You might want
161*d874e919Schristos         to install the Autoconf and GNU m4 packages.  Grab them
162*d874e919Schristos         from any GNU archive site."
163*d874e919Schristos    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
164*d874e919Schristos    test -z "$files" && files="config.h"
165*d874e919Schristos    touch_files=
166*d874e919Schristos    for f in $files; do
167*d874e919Schristos      case $f in
168*d874e919Schristos      *:*) touch_files="$touch_files "`echo "$f" |
169*d874e919Schristos				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
170*d874e919Schristos      *) touch_files="$touch_files $f.in";;
171*d874e919Schristos      esac
172*d874e919Schristos    done
173*d874e919Schristos    touch $touch_files
174*d874e919Schristos    ;;
175*d874e919Schristos
176*d874e919Schristos  automake*)
177*d874e919Schristos    echo 1>&2 "\
178*d874e919SchristosWARNING: '$1' is $msg.  You should only need it if
179*d874e919Schristos         you modified 'Makefile.am', 'acinclude.m4' or '${configure_ac}'.
180*d874e919Schristos         You might want to install the Automake and Perl packages.
181*d874e919Schristos         Grab them from any GNU archive site."
182*d874e919Schristos    find . -type f -name Makefile.am -print |
183*d874e919Schristos	   sed 's/\.am$/.in/' |
184*d874e919Schristos	   while read f; do touch "$f"; done
185*d874e919Schristos    ;;
186*d874e919Schristos
187*d874e919Schristos  autom4te*)
188*d874e919Schristos    echo 1>&2 "\
189*d874e919SchristosWARNING: '$1' is needed, but is $msg.
190*d874e919Schristos         You might have modified some files without having the
191*d874e919Schristos         proper tools for further handling them.
192*d874e919Schristos         You can get '$1' as part of Autoconf from any GNU
193*d874e919Schristos         archive site."
194*d874e919Schristos
195*d874e919Schristos    file=`echo "$*" | sed -n "$sed_output"`
196*d874e919Schristos    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
197*d874e919Schristos    if test -f "$file"; then
198*d874e919Schristos	touch $file
199*d874e919Schristos    else
200*d874e919Schristos	test -z "$file" || exec >$file
201*d874e919Schristos	echo "#! /bin/sh"
202*d874e919Schristos	echo "# Created by GNU Automake missing as a replacement of"
203*d874e919Schristos	echo "#  $ $@"
204*d874e919Schristos	echo "exit 0"
205*d874e919Schristos	chmod +x $file
206*d874e919Schristos	exit 1
207*d874e919Schristos    fi
208*d874e919Schristos    ;;
209*d874e919Schristos
210*d874e919Schristos  bison*|yacc*)
211*d874e919Schristos    echo 1>&2 "\
212*d874e919SchristosWARNING: '$1' $msg.  You should only need it if
213*d874e919Schristos         you modified a '.y' file.  You may need the Bison package
214*d874e919Schristos         in order for those modifications to take effect.  You can get
215*d874e919Schristos         Bison from any GNU archive site."
216*d874e919Schristos    rm -f y.tab.c y.tab.h
217*d874e919Schristos    if test $# -ne 1; then
218*d874e919Schristos        eval LASTARG=\${$#}
219*d874e919Schristos	case $LASTARG in
220*d874e919Schristos	*.y)
221*d874e919Schristos	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
222*d874e919Schristos	    if test -f "$SRCFILE"; then
223*d874e919Schristos	         cp "$SRCFILE" y.tab.c
224*d874e919Schristos	    fi
225*d874e919Schristos	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
226*d874e919Schristos	    if test -f "$SRCFILE"; then
227*d874e919Schristos	         cp "$SRCFILE" y.tab.h
228*d874e919Schristos	    fi
229*d874e919Schristos	  ;;
230*d874e919Schristos	esac
231*d874e919Schristos    fi
232*d874e919Schristos    if test ! -f y.tab.h; then
233*d874e919Schristos	echo >y.tab.h
234*d874e919Schristos    fi
235*d874e919Schristos    if test ! -f y.tab.c; then
236*d874e919Schristos	echo 'main() { return 0; }' >y.tab.c
237*d874e919Schristos    fi
238*d874e919Schristos    ;;
239*d874e919Schristos
240*d874e919Schristos  lex*|flex*)
241*d874e919Schristos    echo 1>&2 "\
242*d874e919SchristosWARNING: '$1' is $msg.  You should only need it if
243*d874e919Schristos         you modified a '.l' file.  You may need the Flex package
244*d874e919Schristos         in order for those modifications to take effect.  You can get
245*d874e919Schristos         Flex from any GNU archive site."
246*d874e919Schristos    rm -f lex.yy.c
247*d874e919Schristos    if test $# -ne 1; then
248*d874e919Schristos        eval LASTARG=\${$#}
249*d874e919Schristos	case $LASTARG in
250*d874e919Schristos	*.l)
251*d874e919Schristos	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
252*d874e919Schristos	    if test -f "$SRCFILE"; then
253*d874e919Schristos	         cp "$SRCFILE" lex.yy.c
254*d874e919Schristos	    fi
255*d874e919Schristos	  ;;
256*d874e919Schristos	esac
257*d874e919Schristos    fi
258*d874e919Schristos    if test ! -f lex.yy.c; then
259*d874e919Schristos	echo 'main() { return 0; }' >lex.yy.c
260*d874e919Schristos    fi
261*d874e919Schristos    ;;
262*d874e919Schristos
263*d874e919Schristos  help2man*)
264*d874e919Schristos    echo 1>&2 "\
265*d874e919SchristosWARNING: '$1' is $msg.  You should only need it if
266*d874e919Schristos	 you modified a dependency of a manual page.  You may need the
267*d874e919Schristos	 Help2man package in order for those modifications to take
268*d874e919Schristos	 effect.  You can get Help2man from any GNU archive site."
269*d874e919Schristos
270*d874e919Schristos    file=`echo "$*" | sed -n "$sed_output"`
271*d874e919Schristos    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
272*d874e919Schristos    if test -f "$file"; then
273*d874e919Schristos	touch $file
274*d874e919Schristos    else
275*d874e919Schristos	test -z "$file" || exec >$file
276*d874e919Schristos	echo ".ab help2man is required to generate this page"
277*d874e919Schristos	exit $?
278*d874e919Schristos    fi
279*d874e919Schristos    ;;
280*d874e919Schristos
281*d874e919Schristos  makeinfo*)
282*d874e919Schristos    echo 1>&2 "\
283*d874e919SchristosWARNING: '$1' is $msg.  You should only need it if
284*d874e919Schristos         you modified a '.texi' or '.texinfo' file, or any other file
285*d874e919Schristos         indirectly affecting the aspect of the manual.  The spurious
286*d874e919Schristos         call might also be the consequence of using a buggy 'make' (AIX,
287*d874e919Schristos         DU, IRIX).  You might want to install the Texinfo package or
288*d874e919Schristos         the GNU make package.  Grab either from any GNU archive site."
289*d874e919Schristos    # The file to touch is that specified with -o ...
290*d874e919Schristos    file=`echo "$*" | sed -n "$sed_output"`
291*d874e919Schristos    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
292*d874e919Schristos    if test -z "$file"; then
293*d874e919Schristos      # ... or it is the one specified with @setfilename ...
294*d874e919Schristos      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
295*d874e919Schristos      file=`sed -n '
296*d874e919Schristos	/^@setfilename/{
297*d874e919Schristos	  s/.* \([^ ]*\) *$/\1/
298*d874e919Schristos	  p
299*d874e919Schristos	  q
300*d874e919Schristos	}' $infile`
301*d874e919Schristos      # ... or it is derived from the source name (dir/f.texi becomes f.info)
302*d874e919Schristos      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
303*d874e919Schristos    fi
304*d874e919Schristos    # If the file does not exist, the user really needs makeinfo;
305*d874e919Schristos    # let's fail without touching anything.
306*d874e919Schristos    test -f $file || exit 1
307*d874e919Schristos    touch $file
308*d874e919Schristos    ;;
309*d874e919Schristos
310*d874e919Schristos  *)
311*d874e919Schristos    echo 1>&2 "\
312*d874e919SchristosWARNING: '$1' is needed, and is $msg.
313*d874e919Schristos         You might have modified some files without having the
314*d874e919Schristos         proper tools for further handling them.  Check the 'README' file,
315*d874e919Schristos         it often tells you about the needed prerequisites for installing
316*d874e919Schristos         this package.  You may also peek at any GNU archive site, in case
317*d874e919Schristos         some other package would contain this missing '$1' program."
318*d874e919Schristos    exit 1
319*d874e919Schristos    ;;
320*d874e919Schristosesac
321*d874e919Schristos
322*d874e919Schristosexit 0
323*d874e919Schristos
324*d874e919Schristos# Local variables:
325*d874e919Schristos# eval: (add-hook 'write-file-hooks 'time-stamp)
326*d874e919Schristos# time-stamp-start: "scriptversion="
327*d874e919Schristos# time-stamp-format: "%:y-%02m-%02d.%02H"
328*d874e919Schristos# time-stamp-time-zone: "UTC"
329*d874e919Schristos# time-stamp-end: "; # UTC"
330*d874e919Schristos# End:
331