s3-spoolss: cleanup _spoolss_EnumPrinterDrivers().
[Samba/bb.git] / source3 / script / mkversion.sh
blobce9d2af4c0d17d1cd1143649a91cc7cf61d5ea24
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`
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_PRE_RELEASE=`sed -n 's/^SAMBA_VERSION_PRE_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
24 SAMBA_VERSION_RC_RELEASE=`sed -n 's/^SAMBA_VERSION_RC_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
26 SAMBA_VERSION_IS_GIT_SNAPSHOT=`sed -n 's/^SAMBA_VERSION_IS_GIT_SNAPSHOT=//p' $SOURCE_DIR$VERSION_FILE`
28 SAMBA_VERSION_RELEASE_NICKNAME=`sed -n 's/^SAMBA_VERSION_RELEASE_NICKNAME=//p' $SOURCE_DIR$VERSION_FILE`
30 SAMBA_VERSION_VENDOR_SUFFIX=`sed -n 's/^SAMBA_VERSION_VENDOR_SUFFIX=//p' $SOURCE_DIR$VERSION_FILE`
31 SAMBA_VERSION_VENDOR_PATCH=`sed -n 's/^SAMBA_VERSION_VENDOR_PATCH=//p' $SOURCE_DIR$VERSION_FILE`
33 SAMBA_VERSION_VENDOR_FUNCTION=`sed -n 's/^SAMBA_VERSION_VENDOR_FUNCTION=//p' $SOURCE_DIR$VERSION_FILE`
35 echo "/* Autogenerated by script/mkversion.sh */" > $OUTPUT_FILE
37 echo "#define SAMBA_VERSION_MAJOR ${SAMBA_VERSION_MAJOR}" >> $OUTPUT_FILE
38 echo "#define SAMBA_VERSION_MINOR ${SAMBA_VERSION_MINOR}" >> $OUTPUT_FILE
39 echo "#define SAMBA_VERSION_RELEASE ${SAMBA_VERSION_RELEASE}" >> $OUTPUT_FILE
43 ## start with "3.0.22"
45 SAMBA_VERSION_STRING="${SAMBA_VERSION_MAJOR}.${SAMBA_VERSION_MINOR}.${SAMBA_VERSION_RELEASE}"
49 ## maybe add "3.0.22a" or "4.0.0tp11" or "3.0.22pre1" or "3.0.22rc1"
50 ## We do not do pre or rc version on patch/letter releases
52 if test -n "${SAMBA_VERSION_REVISION}";then
53 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}${SAMBA_VERSION_REVISION}"
54 echo "#define SAMBA_VERSION_REVISION \"${SAMBA_VERSION_REVISION}\"" >> $OUTPUT_FILE
55 elif test -n "${SAMBA_VERSION_TP_RELEASE}";then
56 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}tp${SAMBA_VERSION_TP_RELEASE}"
57 echo "#define SAMBA_VERSION_TP_RELEASE ${SAMBA_VERSION_TP_RELEASE}" >> $OUTPUT_FILE
58 elif test -n "${SAMBA_VERSION_PRE_RELEASE}";then
59 ## maybe add "3.0.22pre2"
60 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}pre${SAMBA_VERSION_PRE_RELEASE}"
61 echo "#define SAMBA_VERSION_PRE_RELEASE ${SAMBA_VERSION_PRE_RELEASE}" >> $OUTPUT_FILE
62 elif test -n "${SAMBA_VERSION_RC_RELEASE}";then
63 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}rc${SAMBA_VERSION_RC_RELEASE}"
64 echo "#define SAMBA_VERSION_RC_RELEASE ${SAMBA_VERSION_RC_RELEASE}" >> $OUTPUT_FILE
68 ## GIT commit details
70 if test x"${SAMBA_VERSION_IS_GIT_SNAPSHOT}" = x"yes";then
71 _SAVE_LANG=${LANG}
72 LANG="C"
73 HAVEVER="no"
75 if test x"${HAVEVER}" != x"yes" -a -d "${SOURCE_DIR}../.git";then
76 HAVEGIT=no
77 GIT_INFO=`git show --pretty=format:"%h%n%ct%n%H%n%cd" --stat HEAD 2>/dev/null`
78 GIT_COMMIT_ABBREV=`printf "%s" "${GIT_INFO}" | sed -n 1p`
79 GIT_COMMIT_TIME=`printf "%s" "${GIT_INFO}" | sed -n 2p`
80 GIT_COMMIT_FULLREV=`printf "%s" "${GIT_INFO}" | sed -n 3p`
81 GIT_COMMIT_DATE=`printf "%s" "${GIT_INFO}" | sed -n 4p`
82 if test -n "${GIT_COMMIT_ABBREV}";then
83 HAVEGIT=yes
84 HAVEVER=yes
88 if test x"${HAVEGIT}" = x"yes";then
89 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-GIT-${GIT_COMMIT_ABBREV}"
91 echo "#define SAMBA_VERSION_GIT_COMMIT_ABBREV \"${GIT_COMMIT_ABBREV}\"" >> $OUTPUT_FILE
92 echo "#define SAMBA_VERSION_GIT_COMMIT_TIME ${GIT_COMMIT_TIME}" >> $OUTPUT_FILE
93 echo "#define SAMBA_VERSION_GIT_COMMIT_FULLREV \"${GIT_COMMIT_FULLREV}\"" >> $OUTPUT_FILE
94 echo "#define SAMBA_VERSION_GIT_COMMIT_DATE \"${GIT_COMMIT_DATE}\"" >> $OUTPUT_FILE
95 else
96 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-GIT-UNKNOWN"
98 LANG=${_SAVE_LANG}
101 echo "#define SAMBA_VERSION_OFFICIAL_STRING \"${SAMBA_VERSION_STRING}\"" >> $OUTPUT_FILE
104 ## Add the vendor string if present
106 if test -n "${SAMBA_VERSION_VENDOR_FUNCTION}"; then
107 echo "#define SAMBA_VERSION_VENDOR_FUNCTION ${SAMBA_VERSION_VENDOR_FUNCTION}" >> $OUTPUT_FILE
110 if test -n "${SAMBA_VERSION_VENDOR_SUFFIX}";then
111 echo "#define SAMBA_VERSION_VENDOR_SUFFIX ${SAMBA_VERSION_VENDOR_SUFFIX}" >> $OUTPUT_FILE
112 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-${SAMBA_VERSION_VENDOR_SUFFIX}"
113 if test -n "${SAMBA_VERSION_VENDOR_PATCH}";then
114 echo "#define SAMBA_VERSION_VENDOR_PATCH ${SAMBA_VERSION_VENDOR_PATCH}" >> $OUTPUT_FILE
115 echo "#define SAMBA_VERSION_VENDOR_PATCH_STRING \"${SAMBA_VERSION_VENDOR_PATCH}\"" >> $OUTPUT_FILE
116 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-${SAMBA_VERSION_VENDOR_PATCH}"
121 ## Add a release nickname
123 if test -n "${SAMBA_VERSION_RELEASE_NICKNAME}";then
124 echo "#define SAMBA_VERSION_RELEASE_NICKNAME ${SAMBA_VERSION_RELEASE_NICKNAME}" >> $OUTPUT_FILE
125 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING} (${SAMBA_VERSION_RELEASE_NICKNAME})"
128 cat >>$OUTPUT_FILE<<CEOF
129 #ifdef SAMBA_VERSION_VENDOR_FUNCTION
130 # define SAMBA_VERSION_STRING SAMBA_VERSION_VENDOR_FUNCTION
131 #else /* SAMBA_VERSION_VENDOR_FUNCTION */
132 # ifdef SAMBA_VERSION_VENDOR_SUFFIX
133 # ifdef SAMBA_VERSION_VENDOR_PATCH
134 # define SAMBA_VERSION_STRING SAMBA_VERSION_OFFICIAL_STRING "-" SAMBA_VERSION_VENDOR_SUFFIX "-" SAMBA_VERSION_VENDOR_PATCH_STRING
135 # else /* SAMBA_VERSION_VENDOR_PATCH */
136 # define SAMBA_VERSION_STRING SAMBA_VERSION_OFFICIAL_STRING "-" SAMBA_VERSION_VENDOR_SUFFIX
137 # endif /* SAMBA_VERSION_VENDOR_SUFFIX */
138 # else /* SAMBA_VERSION_VENDOR_FUNCTION */
139 # define SAMBA_VERSION_STRING SAMBA_VERSION_OFFICIAL_STRING
140 # endif
141 #endif
142 CEOF
144 echo "$0: '$OUTPUT_FILE' created for Samba(\"${SAMBA_VERSION_STRING}\")"
146 exit 0