xref: /openbsd-src/gnu/usr.bin/texinfo/missing (revision a1acfa9b69ad64eb720639240c8438f11107dc85)
1840175f0Skstailey#! /bin/sh
2840175f0Skstailey# Common stub for a few missing GNU programs while installing.
3*a1acfa9bSespie
4*a1acfa9bSespiescriptversion=2004-09-07.08
5*a1acfa9bSespie
6*a1acfa9bSespie# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004
7*a1acfa9bSespie#   Free Software Foundation, Inc.
83fb98d4aSespie# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9840175f0Skstailey
10840175f0Skstailey# This program is free software; you can redistribute it and/or modify
11840175f0Skstailey# it under the terms of the GNU General Public License as published by
12840175f0Skstailey# the Free Software Foundation; either version 2, or (at your option)
13840175f0Skstailey# any later version.
14840175f0Skstailey
15840175f0Skstailey# This program is distributed in the hope that it will be useful,
16840175f0Skstailey# but WITHOUT ANY WARRANTY; without even the implied warranty of
17840175f0Skstailey# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18840175f0Skstailey# GNU General Public License for more details.
19840175f0Skstailey
20840175f0Skstailey# You should have received a copy of the GNU General Public License
21840175f0Skstailey# along with this program; if not, write to the Free Software
22840175f0Skstailey# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23840175f0Skstailey# 02111-1307, USA.
24840175f0Skstailey
253fb98d4aSespie# As a special exception to the GNU General Public License, if you
263fb98d4aSespie# distribute this file as part of a program that contains a
273fb98d4aSespie# configuration script generated by Autoconf, you may include it under
283fb98d4aSespie# the same distribution terms that you use for the rest of that program.
293fb98d4aSespie
30840175f0Skstaileyif test $# -eq 0; then
31840175f0Skstailey  echo 1>&2 "Try \`$0 --help' for more information"
32840175f0Skstailey  exit 1
33840175f0Skstaileyfi
34840175f0Skstailey
353fb98d4aSespierun=:
363fb98d4aSespie
373fb98d4aSespie# In the cases where this matters, `missing' is being run in the
383fb98d4aSespie# srcdir already.
393fb98d4aSespieif test -f configure.ac; then
403fb98d4aSespie  configure_ac=configure.ac
413fb98d4aSespieelse
423fb98d4aSespie  configure_ac=configure.in
433fb98d4aSespiefi
443fb98d4aSespie
45*a1acfa9bSespiemsg="missing on your system"
46*a1acfa9bSespie
473fb98d4aSespiecase "$1" in
483fb98d4aSespie--run)
493fb98d4aSespie  # Try to run requested program, and just exit if it succeeds.
503fb98d4aSespie  run=
513fb98d4aSespie  shift
523fb98d4aSespie  "$@" && exit 0
53*a1acfa9bSespie  # Exit code 63 means version mismatch.  This often happens
54*a1acfa9bSespie  # when the user try to use an ancient version of a tool on
55*a1acfa9bSespie  # a file that requires a minimum version.  In this case we
56*a1acfa9bSespie  # we should proceed has if the program had been absent, or
57*a1acfa9bSespie  # if --run hadn't been passed.
58*a1acfa9bSespie  if test $? = 63; then
59*a1acfa9bSespie    run=:
60*a1acfa9bSespie    msg="probably too old"
61*a1acfa9bSespie  fi
623fb98d4aSespie  ;;
63840175f0Skstailey
64840175f0Skstailey  -h|--h|--he|--hel|--help)
65840175f0Skstailey    echo "\
66840175f0Skstailey$0 [OPTION]... PROGRAM [ARGUMENT]...
67840175f0Skstailey
68840175f0SkstaileyHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69840175f0Skstaileyerror status if there is no known handling for PROGRAM.
70840175f0Skstailey
71840175f0SkstaileyOptions:
72840175f0Skstailey  -h, --help      display this help and exit
73840175f0Skstailey  -v, --version   output version information and exit
743fb98d4aSespie  --run           try to run the given command, and emulate it if it fails
75840175f0Skstailey
76840175f0SkstaileySupported PROGRAM values:
77840175f0Skstailey  aclocal      touch file \`aclocal.m4'
78840175f0Skstailey  autoconf     touch file \`configure'
79840175f0Skstailey  autoheader   touch file \`config.h.in'
80840175f0Skstailey  automake     touch all \`Makefile.in' files
811cc83814Sespie  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
821cc83814Sespie  flex         create \`lex.yy.c', if possible, from existing .c
833fb98d4aSespie  help2man     touch the output file
841cc83814Sespie  lex          create \`lex.yy.c', if possible, from existing .c
85840175f0Skstailey  makeinfo     touch the output file
863fb98d4aSespie  tar          try tar, gnutar, gtar, then tar without non-portable flags
87*a1acfa9bSespie  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
88*a1acfa9bSespie
89*a1acfa9bSespieSend bug reports to <bug-automake@gnu.org>."
90*a1acfa9bSespie    exit 0
91840175f0Skstailey    ;;
92840175f0Skstailey
93840175f0Skstailey  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
94*a1acfa9bSespie    echo "missing $scriptversion (GNU Automake)"
95*a1acfa9bSespie    exit 0
96840175f0Skstailey    ;;
97840175f0Skstailey
98840175f0Skstailey  -*)
99840175f0Skstailey    echo 1>&2 "$0: Unknown \`$1' option"
100840175f0Skstailey    echo 1>&2 "Try \`$0 --help' for more information"
101840175f0Skstailey    exit 1
102840175f0Skstailey    ;;
103840175f0Skstailey
104*a1acfa9bSespieesac
105*a1acfa9bSespie
106*a1acfa9bSespie# Now exit if we have it, but it failed.  Also exit now if we
107*a1acfa9bSespie# don't have it and --version was passed (most likely to detect
108*a1acfa9bSespie# the program).
109*a1acfa9bSespiecase "$1" in
110*a1acfa9bSespie  lex|yacc)
111*a1acfa9bSespie    # Not GNU programs, they don't have --version.
112*a1acfa9bSespie    ;;
113*a1acfa9bSespie
114*a1acfa9bSespie  tar)
115*a1acfa9bSespie    if test -n "$run"; then
116*a1acfa9bSespie       echo 1>&2 "ERROR: \`tar' requires --run"
117*a1acfa9bSespie       exit 1
118*a1acfa9bSespie    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
119*a1acfa9bSespie       exit 1
120*a1acfa9bSespie    fi
121*a1acfa9bSespie    ;;
122*a1acfa9bSespie
123*a1acfa9bSespie  *)
124*a1acfa9bSespie    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
125*a1acfa9bSespie       # We have it, but it failed.
126*a1acfa9bSespie       exit 1
127*a1acfa9bSespie    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
128*a1acfa9bSespie       # Could not run --version or --help.  This is probably someone
129*a1acfa9bSespie       # running `$TOOL --version' or `$TOOL --help' to check whether
130*a1acfa9bSespie       # $TOOL exists and not knowing $TOOL uses missing.
131*a1acfa9bSespie       exit 1
132*a1acfa9bSespie    fi
133*a1acfa9bSespie    ;;
134*a1acfa9bSespieesac
135*a1acfa9bSespie
136*a1acfa9bSespie# If it does not exist, or fails to run (possibly an outdated version),
137*a1acfa9bSespie# try to emulate it.
138*a1acfa9bSespiecase "$1" in
139*a1acfa9bSespie  aclocal*)
140840175f0Skstailey    echo 1>&2 "\
141*a1acfa9bSespieWARNING: \`$1' is $msg.  You should only need it if
1423fb98d4aSespie         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
143840175f0Skstailey         to install the \`Automake' and \`Perl' packages.  Grab them from
144840175f0Skstailey         any GNU archive site."
145840175f0Skstailey    touch aclocal.m4
146840175f0Skstailey    ;;
147840175f0Skstailey
148840175f0Skstailey  autoconf)
149840175f0Skstailey    echo 1>&2 "\
150*a1acfa9bSespieWARNING: \`$1' is $msg.  You should only need it if
1513fb98d4aSespie         you modified \`${configure_ac}'.  You might want to install the
152840175f0Skstailey         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
153840175f0Skstailey         archive site."
154840175f0Skstailey    touch configure
155840175f0Skstailey    ;;
156840175f0Skstailey
157840175f0Skstailey  autoheader)
158840175f0Skstailey    echo 1>&2 "\
159*a1acfa9bSespieWARNING: \`$1' is $msg.  You should only need it if
1603fb98d4aSespie         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
161840175f0Skstailey         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
162840175f0Skstailey         from any GNU archive site."
1633fb98d4aSespie    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1641cc83814Sespie    test -z "$files" && files="config.h"
1651cc83814Sespie    touch_files=
1661cc83814Sespie    for f in $files; do
1671cc83814Sespie      case "$f" in
1681cc83814Sespie      *:*) touch_files="$touch_files "`echo "$f" |
1691cc83814Sespie				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1701cc83814Sespie      *) touch_files="$touch_files $f.in";;
1711cc83814Sespie      esac
1721cc83814Sespie    done
1731cc83814Sespie    touch $touch_files
174840175f0Skstailey    ;;
175840175f0Skstailey
176*a1acfa9bSespie  automake*)
177840175f0Skstailey    echo 1>&2 "\
178*a1acfa9bSespieWARNING: \`$1' is $msg.  You should only need it if
1793fb98d4aSespie         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
180840175f0Skstailey         You might want to install the \`Automake' and \`Perl' packages.
181840175f0Skstailey         Grab them from any GNU archive site."
1821cc83814Sespie    find . -type f -name Makefile.am -print |
1831cc83814Sespie	   sed 's/\.am$/.in/' |
1841cc83814Sespie	   while read f; do touch "$f"; done
185840175f0Skstailey    ;;
186840175f0Skstailey
187*a1acfa9bSespie  autom4te)
188*a1acfa9bSespie    echo 1>&2 "\
189*a1acfa9bSespieWARNING: \`$1' is needed, but is $msg.
190*a1acfa9bSespie         You might have modified some files without having the
191*a1acfa9bSespie         proper tools for further handling them.
192*a1acfa9bSespie         You can get \`$1' as part of \`Autoconf' from any GNU
193*a1acfa9bSespie         archive site."
194*a1acfa9bSespie
195*a1acfa9bSespie    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
196*a1acfa9bSespie    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
197*a1acfa9bSespie    if test -f "$file"; then
198*a1acfa9bSespie	touch $file
199*a1acfa9bSespie    else
200*a1acfa9bSespie	test -z "$file" || exec >$file
201*a1acfa9bSespie	echo "#! /bin/sh"
202*a1acfa9bSespie	echo "# Created by GNU Automake missing as a replacement of"
203*a1acfa9bSespie	echo "#  $ $@"
204*a1acfa9bSespie	echo "exit 0"
205*a1acfa9bSespie	chmod +x $file
206*a1acfa9bSespie	exit 1
207*a1acfa9bSespie    fi
208*a1acfa9bSespie    ;;
209*a1acfa9bSespie
210840175f0Skstailey  bison|yacc)
211840175f0Skstailey    echo 1>&2 "\
212*a1acfa9bSespieWARNING: \`$1' $msg.  You should only need it if
213840175f0Skstailey         you modified a \`.y' file.  You may need the \`Bison' package
214840175f0Skstailey         in order for those modifications to take effect.  You can get
215840175f0Skstailey         \`Bison' from any GNU archive site."
2161cc83814Sespie    rm -f y.tab.c y.tab.h
2171cc83814Sespie    if [ $# -ne 1 ]; then
2181cc83814Sespie        eval LASTARG="\${$#}"
2191cc83814Sespie	case "$LASTARG" in
2201cc83814Sespie	*.y)
2211cc83814Sespie	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2221cc83814Sespie	    if [ -f "$SRCFILE" ]; then
2231cc83814Sespie	         cp "$SRCFILE" y.tab.c
2241cc83814Sespie	    fi
2251cc83814Sespie	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2261cc83814Sespie	    if [ -f "$SRCFILE" ]; then
2271cc83814Sespie	         cp "$SRCFILE" y.tab.h
2281cc83814Sespie	    fi
2291cc83814Sespie	  ;;
2301cc83814Sespie	esac
2311cc83814Sespie    fi
2321cc83814Sespie    if [ ! -f y.tab.h ]; then
2331cc83814Sespie	echo >y.tab.h
2341cc83814Sespie    fi
2351cc83814Sespie    if [ ! -f y.tab.c ]; then
2361cc83814Sespie	echo 'main() { return 0; }' >y.tab.c
2371cc83814Sespie    fi
2381cc83814Sespie    ;;
2391cc83814Sespie
2401cc83814Sespie  lex|flex)
2411cc83814Sespie    echo 1>&2 "\
242*a1acfa9bSespieWARNING: \`$1' is $msg.  You should only need it if
2431cc83814Sespie         you modified a \`.l' file.  You may need the \`Flex' package
2441cc83814Sespie         in order for those modifications to take effect.  You can get
2451cc83814Sespie         \`Flex' from any GNU archive site."
2461cc83814Sespie    rm -f lex.yy.c
2471cc83814Sespie    if [ $# -ne 1 ]; then
2481cc83814Sespie        eval LASTARG="\${$#}"
2491cc83814Sespie	case "$LASTARG" in
2501cc83814Sespie	*.l)
2511cc83814Sespie	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2521cc83814Sespie	    if [ -f "$SRCFILE" ]; then
2531cc83814Sespie	         cp "$SRCFILE" lex.yy.c
2541cc83814Sespie	    fi
2551cc83814Sespie	  ;;
2561cc83814Sespie	esac
2571cc83814Sespie    fi
2581cc83814Sespie    if [ ! -f lex.yy.c ]; then
2591cc83814Sespie	echo 'main() { return 0; }' >lex.yy.c
2601cc83814Sespie    fi
261840175f0Skstailey    ;;
262840175f0Skstailey
2633fb98d4aSespie  help2man)
2643fb98d4aSespie    echo 1>&2 "\
265*a1acfa9bSespieWARNING: \`$1' is $msg.  You should only need it if
2663fb98d4aSespie	 you modified a dependency of a manual page.  You may need the
2673fb98d4aSespie	 \`Help2man' package in order for those modifications to take
2683fb98d4aSespie	 effect.  You can get \`Help2man' from any GNU archive site."
2693fb98d4aSespie
2703fb98d4aSespie    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2713fb98d4aSespie    if test -z "$file"; then
2723fb98d4aSespie	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
2733fb98d4aSespie    fi
2743fb98d4aSespie    if [ -f "$file" ]; then
2753fb98d4aSespie	touch $file
2763fb98d4aSespie    else
2773fb98d4aSespie	test -z "$file" || exec >$file
2783fb98d4aSespie	echo ".ab help2man is required to generate this page"
2793fb98d4aSespie	exit 1
2803fb98d4aSespie    fi
2813fb98d4aSespie    ;;
2823fb98d4aSespie
283840175f0Skstailey  makeinfo)
284840175f0Skstailey    echo 1>&2 "\
285*a1acfa9bSespieWARNING: \`$1' is $msg.  You should only need it if
286840175f0Skstailey         you modified a \`.texi' or \`.texinfo' file, or any other file
287840175f0Skstailey         indirectly affecting the aspect of the manual.  The spurious
288840175f0Skstailey         call might also be the consequence of using a buggy \`make' (AIX,
289840175f0Skstailey         DU, IRIX).  You might want to install the \`Texinfo' package or
290840175f0Skstailey         the \`GNU make' package.  Grab either from any GNU archive site."
291840175f0Skstailey    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
292840175f0Skstailey    if test -z "$file"; then
293840175f0Skstailey      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
294840175f0Skstailey      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
295840175f0Skstailey    fi
296840175f0Skstailey    touch $file
297840175f0Skstailey    ;;
298840175f0Skstailey
2993fb98d4aSespie  tar)
3003fb98d4aSespie    shift
3013fb98d4aSespie
3023fb98d4aSespie    # We have already tried tar in the generic part.
3033fb98d4aSespie    # Look for gnutar/gtar before invocation to avoid ugly error
3043fb98d4aSespie    # messages.
3053fb98d4aSespie    if (gnutar --version > /dev/null 2>&1); then
306*a1acfa9bSespie       gnutar "$@" && exit 0
3073fb98d4aSespie    fi
3083fb98d4aSespie    if (gtar --version > /dev/null 2>&1); then
309*a1acfa9bSespie       gtar "$@" && exit 0
3103fb98d4aSespie    fi
3113fb98d4aSespie    firstarg="$1"
3123fb98d4aSespie    if shift; then
3133fb98d4aSespie	case "$firstarg" in
3143fb98d4aSespie	*o*)
3153fb98d4aSespie	    firstarg=`echo "$firstarg" | sed s/o//`
316*a1acfa9bSespie	    tar "$firstarg" "$@" && exit 0
3173fb98d4aSespie	    ;;
3183fb98d4aSespie	esac
3193fb98d4aSespie	case "$firstarg" in
3203fb98d4aSespie	*h*)
3213fb98d4aSespie	    firstarg=`echo "$firstarg" | sed s/h//`
322*a1acfa9bSespie	    tar "$firstarg" "$@" && exit 0
3233fb98d4aSespie	    ;;
3243fb98d4aSespie	esac
3253fb98d4aSespie    fi
3263fb98d4aSespie
3273fb98d4aSespie    echo 1>&2 "\
3283fb98d4aSespieWARNING: I can't seem to be able to run \`tar' with the given arguments.
3293fb98d4aSespie         You may want to install GNU tar or Free paxutils, or check the
3303fb98d4aSespie         command line arguments."
3313fb98d4aSespie    exit 1
3323fb98d4aSespie    ;;
3333fb98d4aSespie
334840175f0Skstailey  *)
335840175f0Skstailey    echo 1>&2 "\
336*a1acfa9bSespieWARNING: \`$1' is needed, and is $msg.
337*a1acfa9bSespie         You might have modified some files without having the
338840175f0Skstailey         proper tools for further handling them.  Check the \`README' file,
339*a1acfa9bSespie         it often tells you about the needed prerequisites for installing
340840175f0Skstailey         this package.  You may also peek at any GNU archive site, in case
341840175f0Skstailey         some other package would contain this missing \`$1' program."
342840175f0Skstailey    exit 1
343840175f0Skstailey    ;;
344840175f0Skstaileyesac
345840175f0Skstailey
346840175f0Skstaileyexit 0
347*a1acfa9bSespie
348*a1acfa9bSespie# Local variables:
349*a1acfa9bSespie# eval: (add-hook 'write-file-hooks 'time-stamp)
350*a1acfa9bSespie# time-stamp-start: "scriptversion="
351*a1acfa9bSespie# time-stamp-format: "%:y-%02m-%02d.%02H"
352*a1acfa9bSespie# time-stamp-end: "$"
353*a1acfa9bSespie# End:
354