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 `
2007-06-26 13:10:30 +04:00
2005-08-04 06:59:19 +04:00
SAMBA_VERSION_REVISION = ` sed -n 's/^SAMBA_VERSION_REVISION=//p' $SOURCE_DIR $VERSION_FILE `
2007-06-26 13:10:30 +04:00
SAMBA_VERSION_TP_RELEASE = ` sed -n 's/^SAMBA_VERSION_TP_RELEASE=//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 `
2007-06-26 13:10:30 +04:00
2007-10-11 14:27:38 +04:00
SAMBA_VERSION_IS_GIT_SNAPSHOT = ` sed -n 's/^SAMBA_VERSION_IS_GIT_SNAPSHOT=//p' $SOURCE_DIR $VERSION_FILE `
2007-06-26 13:10:30 +04:00
SAMBA_VERSION_RELEASE_NICKNAME = ` sed -n 's/^SAMBA_VERSION_RELEASE_NICKNAME=//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 `
2007-06-26 13:10:30 +04:00
SAMBA_VERSION_VENDOR_PATCH = ` sed -n 's/^SAMBA_VERSION_VENDOR_PATCH=//p' $SOURCE_DIR $VERSION_FILE `
2003-08-20 21:13:38 +04:00
2008-07-17 14:25:31 +04:00
SAMBA_VERSION_VENDOR_FUNCTION = ` sed -n 's/^SAMBA_VERSION_VENDOR_FUNCTION=//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
##
2007-06-26 13:10:30 +04:00
## maybe add "3.0.22a" or "4.0.0tp11" or "3.0.22pre1" or "3.0.22rc1"
2006-01-24 01:02:52 +03:00
## 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
2007-06-26 13:10:30 +04:00
elif test -n " ${ SAMBA_VERSION_TP_RELEASE } " ; then
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } tp ${ SAMBA_VERSION_TP_RELEASE } "
echo " #define SAMBA_VERSION_TP_RELEASE ${ SAMBA_VERSION_TP_RELEASE } " >> $OUTPUT_FILE
2005-08-04 06:59:19 +04:00
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
##
2007-10-11 14:27:38 +04:00
## GIT commit details
2006-01-24 01:02:52 +03:00
##
2007-10-11 14:27:38 +04:00
if test x" ${ SAMBA_VERSION_IS_GIT_SNAPSHOT } " = x"yes" ; then
2005-04-15 19:39:00 +04:00
_SAVE_LANG = ${ LANG }
2007-10-11 14:27:38 +04:00
LANG = "C"
2007-06-26 13:10:30 +04:00
HAVEVER = "no"
2007-07-03 18:46:06 +04:00
if test x" ${ HAVEVER } " != x"yes" -a -d " ${ SOURCE_DIR } ../.git " ; then
2007-06-26 13:10:30 +04:00
HAVEGIT = no
2007-10-11 14:27:38 +04:00
GIT_INFO = ` git show --pretty= format:"%h%n%ct%n%H%n%cd" --stat HEAD 2>/dev/null`
2008-04-01 17:54:34 +04:00
GIT_COMMIT_ABBREV = ` printf "%s" " ${ GIT_INFO } " | sed -n 1p`
2010-11-12 20:06:20 +03:00
COMMIT_TIME = ` printf "%s" " ${ GIT_INFO } " | sed -n 2p`
2008-04-01 17:54:34 +04:00
GIT_COMMIT_FULLREV = ` printf "%s" " ${ GIT_INFO } " | sed -n 3p`
2010-11-12 20:06:20 +03:00
COMMIT_DATE = ` printf "%s" " ${ GIT_INFO } " | sed -n 4p`
2007-10-11 14:27:38 +04:00
if test -n " ${ GIT_COMMIT_ABBREV } " ; then
2007-06-26 13:10:30 +04:00
HAVEGIT = yes
HAVEVER = yes
2007-04-20 14:27:33 +04:00
fi
2004-04-14 19:17:34 +04:00
fi
2007-06-26 13:10:30 +04:00
2007-10-11 14:27:38 +04:00
if test x" ${ HAVEGIT } " = x"yes" ; then
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } -GIT- ${ GIT_COMMIT_ABBREV } "
2007-06-26 13:10:30 +04:00
2007-10-11 14:27:38 +04:00
echo " #define SAMBA_VERSION_GIT_COMMIT_ABBREV \" ${ GIT_COMMIT_ABBREV } \" " >> $OUTPUT_FILE
2010-11-12 20:06:20 +03:00
echo " #define SAMBA_VERSION_COMMIT_TIME ${ COMMIT_TIME } " >> $OUTPUT_FILE
2007-10-11 14:27:38 +04:00
echo " #define SAMBA_VERSION_GIT_COMMIT_FULLREV \" ${ GIT_COMMIT_FULLREV } \" " >> $OUTPUT_FILE
2010-11-12 20:06:20 +03:00
echo " #define SAMBA_VERSION_COMMIT_DATE \" ${ COMMIT_DATE } \" " >> $OUTPUT_FILE
2004-04-14 12:47:53 +04:00
else
2007-10-11 14:27:38 +04:00
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } -GIT-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
2007-06-26 13:10:30 +04:00
##
## Add the vendor string if present
##
2008-07-17 14:25:31 +04:00
if test -n " ${ SAMBA_VERSION_VENDOR_FUNCTION } " ; then
echo " #define SAMBA_VERSION_VENDOR_FUNCTION ${ SAMBA_VERSION_VENDOR_FUNCTION } " >> $OUTPUT_FILE
fi
2003-08-20 21:13:38 +04:00
if test -n " ${ SAMBA_VERSION_VENDOR_SUFFIX } " ; then
2007-06-26 13:10:30 +04:00
echo " #define SAMBA_VERSION_VENDOR_SUFFIX ${ SAMBA_VERSION_VENDOR_SUFFIX } " >> $OUTPUT_FILE
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } - ${ SAMBA_VERSION_VENDOR_SUFFIX } "
if test -n " ${ SAMBA_VERSION_VENDOR_PATCH } " ; then
echo " #define SAMBA_VERSION_VENDOR_PATCH ${ SAMBA_VERSION_VENDOR_PATCH } " >> $OUTPUT_FILE
2009-03-20 01:55:21 +03:00
echo " #define SAMBA_VERSION_VENDOR_PATCH_STRING \" ${ SAMBA_VERSION_VENDOR_PATCH } \" " >> $OUTPUT_FILE
2007-06-26 13:10:30 +04:00
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } - ${ SAMBA_VERSION_VENDOR_PATCH } "
fi
2003-08-20 21:13:38 +04:00
fi
2007-06-26 13:10:30 +04:00
##
## Add a release nickname
##
if test -n " ${ SAMBA_VERSION_RELEASE_NICKNAME } " ; then
echo " #define SAMBA_VERSION_RELEASE_NICKNAME ${ SAMBA_VERSION_RELEASE_NICKNAME } " >> $OUTPUT_FILE
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } ( ${ SAMBA_VERSION_RELEASE_NICKNAME } ) "
fi
2008-09-12 14:38:54 +04:00
cat >>$OUTPUT_FILE <<CEOF
#ifdef SAMBA_VERSION_VENDOR_FUNCTION
# define SAMBA_VERSION_STRING SAMBA_VERSION_VENDOR_FUNCTION
#else /* SAMBA_VERSION_VENDOR_FUNCTION */
# ifdef SAMBA_VERSION_VENDOR_SUFFIX
# ifdef SAMBA_VERSION_VENDOR_PATCH
2009-03-20 01:55:21 +03:00
# define SAMBA_VERSION_STRING SAMBA_VERSION_OFFICIAL_STRING "-" SAMBA_VERSION_VENDOR_SUFFIX "-" SAMBA_VERSION_VENDOR_PATCH_STRING
2008-09-12 14:38:54 +04:00
# else /* SAMBA_VERSION_VENDOR_PATCH */
# define SAMBA_VERSION_STRING SAMBA_VERSION_OFFICIAL_STRING "-" SAMBA_VERSION_VENDOR_SUFFIX
# endif /* SAMBA_VERSION_VENDOR_SUFFIX */
# else /* SAMBA_VERSION_VENDOR_FUNCTION */
# define SAMBA_VERSION_STRING SAMBA_VERSION_OFFICIAL_STRING
# endif
#endif
CEOF
2007-06-26 13:10:30 +04:00
echo " $0 : ' $OUTPUT_FILE ' created for Samba(\" ${ SAMBA_VERSION_STRING } \") "
2003-08-20 21:13:38 +04:00
exit 0