Imported from ../bash-2.01.tar.gz.
[platform/upstream/bash.git] / support / mkconffiles
1 #! /bin/sh
2 #
3 # mkconffiles - create _distribution and _patchlevel files in preparation
4 #               for recreating `configure' from `configure.in'
5 #
6 # options:
7 #       -s srcdir       directory where `configure' resides (defaults to `.')
8 #       -d outdir       directory where the files should be written (defaults
9 #                       to "$srcdir")
10 #       -v              verbose
11 #       -n              nocreate - don't create the output files
12 #
13 # Chet Ramey
14 # chet@po.cwru.edu
15
16 PROG=`basename $0`
17
18 # defaults
19 srcdir=.
20
21 distname="_distribution"
22 patchname="_patchlevel"
23
24 while [ $# -gt 0 ]; do
25         case "$1" in
26         -s)     shift; srcdir="$1"; shift;;
27         -d)     shift; outdir="$1"; shift;;
28         -v)     shift; verbose=yes ;;
29         -n)     shift; nocreate=yes;;
30         --)     shift; break;;
31         *)      echo "${PROG}: usage: ${PROG} [-s srcdir] [-d outdir] [-nv]" >&2; exit 2;;
32         esac
33 done
34
35 if [ ! -f ${srcdir}/configure ]; then
36         echo "${PROG}: ${srcdir}/configure not found" >&2
37         exit 1
38 fi
39
40 # default output directory to source directory
41 if [ -z "$outdir" ]; then
42         outdir=${srcdir}
43 fi
44
45 DISTRIB=`grep '^BASHVERS' ${srcdir}/configure | sed 's:.*=::'`
46 PATCH=`grep '^BASHPATCH' ${srcdir}/configure | sed 's:.*=::'`
47
48 if [ -n "$verbose" ]; then
49         echo "${PROG}: creating new distribution files for bash-${DISTRIB}.${PATCH} in ${outdir}"
50 fi
51
52 distout=${outdir}/${distname}
53 patchout=${outdir}/${patchname}
54
55 if [ -z "$nocreate" ]; then
56         echo "$DISTRIB" > $distout
57         echo "$PATCH"   > $patchout
58 fi
59
60 if [ -n "$verbose" ]; then
61         echo "${PROG}: created $distout and $patchout"
62 fi
63
64 exit 0
65