r13676: have to return a value from a non-void function
[Samba.git] / source / script / mkversion.sh
blob578405492135e1172b83cf5e5f48e410faa3a4f9
1 #!/bin/sh
3 VERSION_FILE=$1
4 OUTPUT_FILE=$2
6 if test -z "$VERSION_FILE";then
7 VERSION_FILE="VERSION"
8 fi
10 if test -z "$OUTPUT_FILE";then
11 OUTPUT_FILE="include/version.h"
14 SOURCE_DIR=$3
16 SAMBA_VERSION_MAJOR=`sed -n 's/^SAMBA_VERSION_MAJOR=//p' $SOURCE_DIR$VERSION_FILE`
17 SAMBA_VERSION_MINOR=`sed -n 's/^SAMBA_VERSION_MINOR=//p' $SOURCE_DIR$VERSION_FILE`
18 SAMBA_VERSION_RELEASE=`sed -n 's/^SAMBA_VERSION_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
19 SAMBA_VERSION_REVISION=`sed -n 's/^SAMBA_VERSION_REVISION=//p' $SOURCE_DIR$VERSION_FILE`
20 SAMBA_VERSION_PRE_RELEASE=`sed -n 's/^SAMBA_VERSION_PRE_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
21 SAMBA_VERSION_RC_RELEASE=`sed -n 's/^SAMBA_VERSION_RC_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
22 SAMBA_VERSION_IS_SVN_SNAPSHOT=`sed -n 's/^SAMBA_VERSION_IS_SVN_SNAPSHOT=//p' $SOURCE_DIR$VERSION_FILE`
23 SAMBA_VERSION_VENDOR_SUFFIX=`sed -n 's/^SAMBA_VERSION_VENDOR_SUFFIX=//p' $SOURCE_DIR$VERSION_FILE`
24 SAMBA_VENDOR_PATCH=`sed -n 's/^SAMBA_VENDOR_PATCH=//p' $SOURCE_DIR$VERSION_FILE`
26 echo "/* Autogenerated by script/mkversion.sh */" > $OUTPUT_FILE
28 echo "#define SAMBA_VERSION_MAJOR ${SAMBA_VERSION_MAJOR}" >> $OUTPUT_FILE
29 echo "#define SAMBA_VERSION_MINOR ${SAMBA_VERSION_MINOR}" >> $OUTPUT_FILE
30 echo "#define SAMBA_VERSION_RELEASE ${SAMBA_VERSION_RELEASE}" >> $OUTPUT_FILE
34 ## start with "3.0.22"
36 SAMBA_VERSION_STRING="${SAMBA_VERSION_MAJOR}.${SAMBA_VERSION_MINOR}.${SAMBA_VERSION_RELEASE}"
40 ## maybe add "3.0.22a" or "3.0.22pre1" or "3.0.22rc1"
41 ## We do not do pre or rc version on patch/letter releases
43 if test -n "${SAMBA_VERSION_REVISION}";then
44 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}${SAMBA_VERSION_REVISION}"
45 echo "#define SAMBA_VERSION_REVISION \"${SAMBA_VERSION_REVISION}\"" >> $OUTPUT_FILE
46 elif test -n "${SAMBA_VERSION_PRE_RELEASE}";then
47 ## maybe add "3.0.22pre2"
48 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}pre${SAMBA_VERSION_PRE_RELEASE}"
49 echo "#define SAMBA_VERSION_PRE_RELEASE ${SAMBA_VERSION_PRE_RELEASE}" >> $OUTPUT_FILE
50 elif test -n "${SAMBA_VERSION_RC_RELEASE}";then
51 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}rc${SAMBA_VERSION_RC_RELEASE}"
52 echo "#define SAMBA_VERSION_RC_RELEASE ${SAMBA_VERSION_RC_RELEASE}" >> $OUTPUT_FILE
56 ## Add the vendor string if present
58 if test -n "${SAMBA_VERSION_VENDOR_SUFFIX}";then
59 echo "#define SAMBA_VERSION_VENDOR_SUFFIX ${SAMBA_VERSION_VENDOR_SUFFIX}" >> $OUTPUT_FILE
60 if test -n "${SAMBA_VENDOR_PATCH}";then
61 echo "#define SAMBA_VENDOR_PATCH ${SAMBA_VENDOR_PATCH}" >> $OUTPUT_FILE
68 ## SVN revision number?
70 if test x"${SAMBA_VERSION_IS_SVN_SNAPSHOT}" = x"yes";then
71 _SAVE_LANG=${LANG}
72 LANG=""
73 HAVESVN=no
74 svn info ${SOURCE_DIR} >/dev/null 2>&1 && HAVESVN=yes
75 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/'`
76 if test x"${HAVESVN}" = x"no";then
77 HAVESVK=no
78 svk info ${SOURCE_DIR} >/dev/null 2>&1 && HAVESVK=yes
79 TMP_MIRRORED_REVISION=`(svk info ${SOURCE_DIR} 2>/dev/null) |grep 'Mirrored From:.*samba\.org.*' |sed -e 's/Mirrored From: .* Rev\..* \([0-9]*\).*/\1/'`
80 if test -n "$TMP_MIRRORED_REVISION"; then
81 TMP_SVK_REVISION_STR="${TMP_REVISION}-${USER}@${HOSTNAME}-[SVN-${TMP_MIRRORED_REVISION}]"
82 else
83 TMP_SVK_REVISION_STR="${TMP_REVISION}-${USER}@${HOSTNAME}"
87 if test x"${HAVESVN}" = x"yes";then
88 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-SVN-build-${TMP_REVISION}"
89 echo "#define SAMBA_VERSION_SVN_REVISION ${TMP_REVISION}" >> $OUTPUT_FILE
90 elif test x"${HAVESVK}" = x"yes";then
91 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-SVK-build-${TMP_SVK_REVISION_STR}"
92 else
93 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-SVN-build-UNKNOWN"
95 LANG=${_SAVE_LANG}
98 echo "#define SAMBA_VERSION_OFFICIAL_STRING \"${SAMBA_VERSION_STRING}\"" >> $OUTPUT_FILE
100 echo "#define SAMBA_VERSION_STRING samba_version_string()" >> $OUTPUT_FILE
102 echo "$0: 'include/version.h' created for Samba(\"${SAMBA_VERSION_STRING}\")"
104 if test -n "${SAMBA_VERSION_VENDOR_SUFFIX}";then
105 echo -n "$0: with VENDOR_SUFFIX = \""
106 echo -n ${SAMBA_VERSION_VENDOR_SUFFIX} | sed 's/"//g'
107 if test -n ${SAMBA_VENDOR_PATCH}; then
108 echo -n "-${SAMBA_VENDOR_PATCH}"
110 echo "\""
113 exit 0