make-ver.sh

This is a simple script used by most of the modules to generate a header file defining version information for the module. It reads the VERSION file used by all modules to create this header. Its usage is as follows:

make-ver.sh [[-b branch] | [-d date] | [-f version file] | [-i source template file] | [-n release name] | [-o output file] | [-s threading subsystem] | [-v version]]

The following shows a typical usage in a makefile:

PARAM_HEADER=	proj/projParam.h
BRANCH=		HEAD
CANON_NAME=	Chef
VER_ARGS=	-f $(PROJROOT_ABS)/VERSION -s @VPR_SUBSYSTEM@	\
		-b $(BRANCH) -o $(PARAM_HEADER) -n "$(CANON_NAME)"	\
		-i $(PROJROOT_ABS)/proj/projParam.h.in		\
		-d "`date '+%b %e, %Y %H:%M:%S'`"

BEFOREBUILD=	beforebuild

beforebuild:
	@$(MAKE) $(PARAM_HEADER)

$(PARAM_HEADER): $(PROJROOT_ABS)/proj/projParam.h.in $(PROJROOT_ABS)/VERSION
	@$(SHELL) $(scriptdir)/make-ver.sh $(VER_ARGS)

The above would normally occur in a module's top-level Makefile.inc.in file. It only generates the header proj/projParam.h when the source template changes or the module's VERSION file changes. Because it is generated during 'beforebuild', it is guaranteed to exist when any C/C++ code would need to include it for proper compiling.

This script basically serves as a way to generate the version information at build time rather than at configuration time using the configure script. Clearly, the use of a .in template file would be suited well to life as a configure-generated file, but the needs of the Juggler Project dictate that version information be up to date for builds since they are done more frequently than configurations.