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# Copyright (C) 1996-2002 Free Software Foundation, Inc.
17#
18# This program is free software; you can redistribute it and/or modify
19# it under the terms of the GNU General Public License as published by
20# the Free Software Foundation; either version 2, or (at your option)
21# any later version.
22#
23# This program is distributed in the hope that it will be useful,
24# but WITHOUT ANY WARRANTY; without even the implied warranty of
25# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26# GNU General Public License for more details.
27#
28# You should have received a copy of the GNU General Public License
29# along with this program; if not, write to the Free Software
30# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
31
32PROG=`basename $0`
33
34# defaults
35srcdir=.
36
37distname="_distribution"
38patchname="_patchlevel"
39
40while [ $# -gt 0 ]; do
41	case "$1" in
42	-s)	shift; srcdir="$1"; shift;;
43	-d)	shift; outdir="$1"; shift;;
44	-v)	shift; verbose=yes ;;
45	-n)	shift; nocreate=yes;;
46	--)	shift; break;;
47	*)	echo "${PROG}: usage: ${PROG} [-s srcdir] [-d outdir] [-nv]" >&2; exit 2;;
48	esac
49done
50
51if [ ! -f ${srcdir}/configure ]; then
52	echo "${PROG}: ${srcdir}/configure not found" >&2
53	exit 1
54fi
55
56# default output directory to source directory
57if [ -z "$outdir" ]; then
58	outdir=${srcdir}
59fi
60
61DISTRIB=`grep '^BASHVERS' ${srcdir}/configure | sed 's:.*=::'`
62PATCH=`grep '^BASHPATCH' ${srcdir}/configure | sed 's:.*=::'`
63
64if [ -n "$verbose" ]; then
65	echo "${PROG}: creating new distribution files for bash-${DISTRIB}.${PATCH} in ${outdir}"
66fi
67
68distout=${outdir}/${distname}
69patchout=${outdir}/${patchname}
70
71if [ -z "$nocreate" ]; then
72	echo "$DISTRIB" > $distout
73	echo "$PATCH"   > $patchout
74fi
75
76if [ -n "$verbose" ]; then
77	echo "${PROG}: created $distout and $patchout"
78fi
79
80exit 0
81