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