s4:heimdal_build: predefine GSSAPI_DEPRECATED depending on the compiler version
[Samba/aatanasov.git] / source4 / script / mkversion.sh
blobda912ac0927cae20e8a8a7c7a8768ba760e43230
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="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`
20 SAMBA_VERSION_REVISION=`sed -n 's/^SAMBA_VERSION_REVISION=//p' $SOURCE_DIR$VERSION_FILE`
22 SAMBA_VERSION_TP_RELEASE=`sed -n 's/^SAMBA_VERSION_TP_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
23 SAMBA_VERSION_ALPHA_RELEASE=`sed -n 's/^SAMBA_VERSION_ALPHA_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
24 SAMBA_VERSION_PRE_RELEASE=`sed -n 's/^SAMBA_VERSION_PRE_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
25 SAMBA_VERSION_RC_RELEASE=`sed -n 's/^SAMBA_VERSION_RC_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
27 SAMBA_VERSION_IS_GIT_SNAPSHOT=`sed -n 's/^SAMBA_VERSION_IS_GIT_SNAPSHOT=//p' $SOURCE_DIR$VERSION_FILE`
29 SAMBA_VERSION_RELEASE_NICKNAME=`sed -n 's/^SAMBA_VERSION_RELEASE_NICKNAME=//p' $SOURCE_DIR$VERSION_FILE`
31 SAMBA_VERSION_VENDOR_SUFFIX=`sed -n 's/^SAMBA_VERSION_VENDOR_SUFFIX=//p' $SOURCE_DIR$VERSION_FILE`
32 SAMBA_VERSION_VENDOR_PATCH=`sed -n 's/^SAMBA_VERSION_VENDOR_PATCH=//p' $SOURCE_DIR$VERSION_FILE`
34 echo "/* Autogenerated by script/mkversion.sh */" > $OUTPUT_FILE
36 echo "#define SAMBA_VERSION_MAJOR ${SAMBA_VERSION_MAJOR}" >> $OUTPUT_FILE
37 echo "#define SAMBA_VERSION_MINOR ${SAMBA_VERSION_MINOR}" >> $OUTPUT_FILE
38 echo "#define SAMBA_VERSION_RELEASE ${SAMBA_VERSION_RELEASE}" >> $OUTPUT_FILE
42 ## start with "3.0.22"
44 SAMBA_VERSION_STRING="${SAMBA_VERSION_MAJOR}.${SAMBA_VERSION_MINOR}.${SAMBA_VERSION_RELEASE}"
48 ## maybe add "3.0.22a" or "4.0.0tp11" or "4.0.0alpha1" or "3.0.22pre1" or "3.0.22rc1"
49 ## We do not do pre or rc version on patch/letter releases
51 if test -n "${SAMBA_VERSION_REVISION}";then
52 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}${SAMBA_VERSION_REVISION}"
53 echo "#define SAMBA_VERSION_REVISION \"${SAMBA_VERSION_REVISION}\"" >> $OUTPUT_FILE
54 elif test -n "${SAMBA_VERSION_TP_RELEASE}";then
55 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}tp${SAMBA_VERSION_TP_RELEASE}"
56 echo "#define SAMBA_VERSION_TP_RELEASE ${SAMBA_VERSION_TP_RELEASE}" >> $OUTPUT_FILE
57 elif test -n "${SAMBA_VERSION_ALPHA_RELEASE}";then
58 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}alpha${SAMBA_VERSION_ALPHA_RELEASE}"
59 echo "#define SAMBA_VERSION_ALPHA_RELEASE ${SAMBA_VERSION_ALPHA_RELEASE}" >> $OUTPUT_FILE
60 elif test -n "${SAMBA_VERSION_PRE_RELEASE}";then
61 ## maybe add "3.0.22pre2"
62 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}pre${SAMBA_VERSION_PRE_RELEASE}"
63 echo "#define SAMBA_VERSION_PRE_RELEASE ${SAMBA_VERSION_PRE_RELEASE}" >> $OUTPUT_FILE
64 elif test -n "${SAMBA_VERSION_RC_RELEASE}";then
65 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}rc${SAMBA_VERSION_RC_RELEASE}"
66 echo "#define SAMBA_VERSION_RC_RELEASE ${SAMBA_VERSION_RC_RELEASE}" >> $OUTPUT_FILE
70 ## GIT commit details
72 if test x"${SAMBA_VERSION_IS_GIT_SNAPSHOT}" = x"yes";then
73 _SAVE_LANG=${LANG}
74 LANG="C"
75 HAVEVER="no"
77 if test x"${HAVEVER}" != x"yes" -a -d "${SOURCE_DIR}../.git";then
78 HAVEGIT=no
79 GIT_INFO=`git show --pretty=format:"%h%n%ct%n%H%n%cd" --stat HEAD 2>/dev/null`
80 GIT_COMMIT_ABBREV=`printf %s "${GIT_INFO}" | sed -n 1p`
81 GIT_COMMIT_TIME=`printf %s "${GIT_INFO}" | sed -n 2p`
82 GIT_COMMIT_FULLREV=`printf %s "${GIT_INFO}" | sed -n 3p`
83 GIT_COMMIT_DATE=`printf %s "${GIT_INFO}" | sed -n 4p`
84 if test -n "${GIT_COMMIT_ABBREV}";then
85 HAVEGIT=yes
86 HAVEVER=yes
90 if test x"${HAVEGIT}" = x"yes";then
91 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-GIT-${GIT_COMMIT_ABBREV}"
93 echo "#define SAMBA_VERSION_GIT_COMMIT_ABBREV \"${GIT_COMMIT_ABBREV}\"" >> $OUTPUT_FILE
94 echo "#define SAMBA_VERSION_GIT_COMMIT_TIME ${GIT_COMMIT_TIME}" >> $OUTPUT_FILE
95 echo "#define SAMBA_VERSION_GIT_COMMIT_FULLREV \"${GIT_COMMIT_FULLREV}\"" >> $OUTPUT_FILE
96 echo "#define SAMBA_VERSION_GIT_COMMIT_DATE \"${GIT_COMMIT_DATE}\"" >> $OUTPUT_FILE
97 else
98 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-GIT-UNKNOWN"
100 LANG=${_SAVE_LANG}
103 echo "#define SAMBA_VERSION_OFFICIAL_STRING \"${SAMBA_VERSION_STRING}\"" >> $OUTPUT_FILE
106 ## Add the vendor string if present
108 if test -n "${SAMBA_VERSION_VENDOR_SUFFIX}";then
109 echo "#define SAMBA_VERSION_VENDOR_SUFFIX ${SAMBA_VERSION_VENDOR_SUFFIX}" >> $OUTPUT_FILE
110 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-${SAMBA_VERSION_VENDOR_SUFFIX}"
111 if test -n "${SAMBA_VERSION_VENDOR_PATCH}";then
112 echo "#define SAMBA_VERSION_VENDOR_PATCH ${SAMBA_VERSION_VENDOR_PATCH}" >> $OUTPUT_FILE
113 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-${SAMBA_VERSION_VENDOR_PATCH}"
117 echo "/* Version for mkrelease.sh: " >> $OUTPUT_FILE
118 echo "SAMBA_VERSION_STRING=$SAMBA_VERSION_STRING" >> $OUTPUT_FILE
119 echo "*/" >> $OUTPUT_FILE
122 ## Add a release nickname
124 if test -n "${SAMBA_VERSION_RELEASE_NICKNAME}";then
125 echo "#define SAMBA_VERSION_RELEASE_NICKNAME ${SAMBA_VERSION_RELEASE_NICKNAME}" >> $OUTPUT_FILE
126 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING} (${SAMBA_VERSION_RELEASE_NICKNAME})"
129 echo "#define SAMBA_VERSION_STRING \"${SAMBA_VERSION_STRING}\"" >> $OUTPUT_FILE
131 echo "$0: '$OUTPUT_FILE' created for Samba(\"${SAMBA_VERSION_STRING}\")"
133 exit 0