#!/bin/sh
# @(#)$Mu: tools/mkver,v 1.25 $
##
## mkver
##	A script for building an object file with various build defined
##	values.
##
## Copyright (C) 1996  Eric A. Howe
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
##   Authors:	Matthew D. Francey
##		Eric A. Howe (mu@echo-on.net)
##
prefix=$1;	shift
version=$1;	shift
status=$1;	shift
sysname=$1;	shift
make=$1;	shift
defs=$1;	shift
libs=$1;	shift
ldflags=$1;	shift
warn=$1;	shift
opt=$1;		shift
cc=$1;		shift
incl=$1;	shift
date=`date -u +'%Y/%m/%d %H:%M UTC'`

rcsid="\"\$MuVer: \
	version='${version}'\
	sysname='${sysname}'\
	defs='${defs}'\
	libs='${libs}'\
	ldflags='${ldflags}'\
	warn='${warn}'\
	opt='${opt}'\
	cc='${cc}'\
	incl='${incl}'\
	date='${date}'\
	status='${status}'\
 \$\""

cat > _${prefix}.c <<_STOP_DAMMIT_STOP_
#if defined(NORCS)
#	undef	NORCS
#endif
#include	<wlib/rcs.h>
MU_ID(${rcsid})
char *${prefix}verstring = "${version}";
char *${prefix}sysname   = "${sysname}";
char *${prefix}defs      = "${defs}";
char *${prefix}libs      = "${libs}";
char *${prefix}ldflags   = "${ldflags}";
char *${prefix}warn      = "${warn}";
char *${prefix}opt       = "${opt}";
char *${prefix}cc        = "${cc}";
char *${prefix}incl      = "${incl}";
char *${prefix}date      = "${date}";
char *${prefix}verstatus = "${status}";
_STOP_DAMMIT_STOP_

${make} _${prefix}.o
if [ $? = 0 ]; then
	rm -f _${prefix}.c
	exit 0
else
	echo 'mkver is busted!'
	exit 1
fi
