2003-08-20 21:13:38 +04:00
#!/bin/sh
VERSION_FILE = $1
OUTPUT_FILE = $2
if test -z " $VERSION_FILE " ; then
VERSION_FILE = "VERSION"
fi
if test -z " $OUTPUT_FILE " ; then
OUTPUT_FILE = "include/version.h"
fi
SOURCE_DIR = $3
SAMBA_VERSION_MAJOR = ` sed -n 's/^SAMBA_VERSION_MAJOR=//p' $SOURCE_DIR $VERSION_FILE `
SAMBA_VERSION_MINOR = ` sed -n 's/^SAMBA_VERSION_MINOR=//p' $SOURCE_DIR $VERSION_FILE `
SAMBA_VERSION_RELEASE = ` sed -n 's/^SAMBA_VERSION_RELEASE=//p' $SOURCE_DIR $VERSION_FILE `
2005-08-04 06:59:19 +04:00
SAMBA_VERSION_REVISION = ` sed -n 's/^SAMBA_VERSION_REVISION=//p' $SOURCE_DIR $VERSION_FILE `
2003-08-20 21:13:38 +04:00
SAMBA_VERSION_PRE_RELEASE = ` sed -n 's/^SAMBA_VERSION_PRE_RELEASE=//p' $SOURCE_DIR $VERSION_FILE `
SAMBA_VERSION_RC_RELEASE = ` sed -n 's/^SAMBA_VERSION_RC_RELEASE=//p' $SOURCE_DIR $VERSION_FILE `
2004-04-14 12:47:53 +04:00
SAMBA_VERSION_IS_SVN_SNAPSHOT = ` sed -n 's/^SAMBA_VERSION_IS_SVN_SNAPSHOT=//p' $SOURCE_DIR $VERSION_FILE `
2003-08-20 21:13:38 +04:00
SAMBA_VERSION_VENDOR_SUFFIX = ` sed -n 's/^SAMBA_VERSION_VENDOR_SUFFIX=//p' $SOURCE_DIR $VERSION_FILE `
2006-01-24 01:02:52 +03:00
SAMBA_VENDOR_PATCH = ` sed -n 's/^SAMBA_VENDOR_PATCH=//p' $SOURCE_DIR $VERSION_FILE `
2003-08-20 21:13:38 +04:00
echo "/* Autogenerated by script/mkversion.sh */" > $OUTPUT_FILE
echo " #define SAMBA_VERSION_MAJOR ${ SAMBA_VERSION_MAJOR } " >> $OUTPUT_FILE
echo " #define SAMBA_VERSION_MINOR ${ SAMBA_VERSION_MINOR } " >> $OUTPUT_FILE
echo " #define SAMBA_VERSION_RELEASE ${ SAMBA_VERSION_RELEASE } " >> $OUTPUT_FILE
2006-01-24 01:02:52 +03:00
##
## start with "3.0.22"
##
2003-08-20 21:13:38 +04:00
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_MAJOR } . ${ SAMBA_VERSION_MINOR } . ${ SAMBA_VERSION_RELEASE } "
2006-01-24 01:02:52 +03:00
##
## maybe add "3.0.22a" or "3.0.22pre1" or "3.0.22rc1"
## We do not do pre or rc version on patch/letter releases
##
2005-08-04 06:59:19 +04:00
if test -n " ${ SAMBA_VERSION_REVISION } " ; then
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } ${ SAMBA_VERSION_REVISION } "
echo " #define SAMBA_VERSION_REVISION \" ${ SAMBA_VERSION_REVISION } \" " >> $OUTPUT_FILE
elif test -n " ${ SAMBA_VERSION_PRE_RELEASE } " ; then
2006-01-24 01:02:52 +03:00
## maybe add "3.0.22pre2"
2003-08-20 21:13:38 +04:00
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } pre ${ SAMBA_VERSION_PRE_RELEASE } "
echo " #define SAMBA_VERSION_PRE_RELEASE ${ SAMBA_VERSION_PRE_RELEASE } " >> $OUTPUT_FILE
elif test -n " ${ SAMBA_VERSION_RC_RELEASE } " ; then
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } rc ${ SAMBA_VERSION_RC_RELEASE } "
echo " #define SAMBA_VERSION_RC_RELEASE ${ SAMBA_VERSION_RC_RELEASE } " >> $OUTPUT_FILE
fi
2006-01-24 01:02:52 +03:00
##
## Add the vendor string if present
##
if test -n " ${ SAMBA_VERSION_VENDOR_SUFFIX } " ; then
echo " #define SAMBA_VERSION_VENDOR_SUFFIX ${ SAMBA_VERSION_VENDOR_SUFFIX } " >> $OUTPUT_FILE
if test -n " ${ SAMBA_VENDOR_PATCH } " ; then
echo " #define SAMBA_VENDOR_PATCH ${ SAMBA_VENDOR_PATCH } " >> $OUTPUT_FILE
fi
fi
2003-08-20 21:13:38 +04:00
2006-01-24 01:02:52 +03:00
##
## SVN revision number?
##
2004-04-14 12:47:53 +04:00
if test x" ${ SAMBA_VERSION_IS_SVN_SNAPSHOT } " = x"yes" ; then
2005-04-15 19:39:00 +04:00
_SAVE_LANG = ${ LANG }
LANG = ""
2004-04-14 19:17:34 +04:00
HAVESVN = no
svn info ${ SOURCE_DIR } >/dev/null 2>& 1 && HAVESVN = yes
2004-05-22 18:52:34 +04:00
TMP_REVISION = ` ( svn info ${ SOURCE_DIR } 2>/dev/null || svk info ${ SOURCE_DIR } 2>/dev/null) | grep 'Last Changed Rev.*:' | sed -e 's/Last Changed Rev.*: \([0-9]*\).*/\1/' `
2004-04-14 19:17:34 +04:00
if test x" ${ HAVESVN } " = x"no" ; then
HAVESVK = no
svk info ${ SOURCE_DIR } >/dev/null 2>& 1 && HAVESVK = yes
2005-05-20 18:12:28 +04:00
TMP_MIRRORED_REVISION = ` ( svk info ${ SOURCE_DIR } 2>/dev/null) | grep 'Mirrored From:.*samba\.org.*' | sed -e 's/Mirrored From: .* Rev\..* \([0-9]*\).*/\1/' `
if test -n " $TMP_MIRRORED_REVISION " ; then
TMP_SVK_REVISION_STR = " ${ TMP_REVISION } - ${ USER } @ ${ HOSTNAME } -[SVN- ${ TMP_MIRRORED_REVISION } ] "
else
TMP_SVK_REVISION_STR = " ${ TMP_REVISION } - ${ USER } @ ${ HOSTNAME } "
fi
2004-04-14 19:17:34 +04:00
fi
if test x" ${ HAVESVN } " = x"yes" ; then
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } -SVN-build- ${ TMP_REVISION } "
echo " #define SAMBA_VERSION_SVN_REVISION ${ TMP_REVISION } " >> $OUTPUT_FILE
elif test x" ${ HAVESVK } " = x"yes" ; then
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } -SVK-build- ${ TMP_SVK_REVISION_STR } "
2004-04-14 12:47:53 +04:00
else
2004-04-14 19:17:34 +04:00
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } -SVN-build-UNKNOWN "
2004-04-14 12:47:53 +04:00
fi
2005-04-15 19:39:00 +04:00
LANG = ${ _SAVE_LANG }
2003-08-20 21:13:38 +04:00
fi
echo " #define SAMBA_VERSION_OFFICIAL_STRING \" ${ SAMBA_VERSION_STRING } \" " >> $OUTPUT_FILE
echo "#define SAMBA_VERSION_STRING samba_version_string()" >> $OUTPUT_FILE
echo " $0 : 'include/version.h' created for Samba(\" ${ SAMBA_VERSION_STRING } \") "
if test -n " ${ SAMBA_VERSION_VENDOR_SUFFIX } " ; then
2006-01-30 16:32:41 +03:00
echo -n " $0 : with VENDOR_SUFFIX = \" "
echo -n ${ SAMBA_VERSION_VENDOR_SUFFIX } | sed 's/"//g'
if test -n ${ SAMBA_VENDOR_PATCH } ; then
echo -n " - ${ SAMBA_VENDOR_PATCH } "
fi
echo "\""
2003-08-20 21:13:38 +04:00
fi
exit 0