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