File indexing completed on 2024-12-01 12:45:48
0001 ########################################################################## 0002 ## ## 0003 ## This script is part of Kooka, a KDE scanning/OCR application. ## 0004 ## ## 0005 ## This file may be distributed and/or modified under the terms of ## 0006 ## the GNU General Public License version 2, as published by the ## 0007 ## Free Software Foundation and appearing in the file COPYING ## 0008 ## included in the packaging of this file. ## 0009 ## ## 0010 ## Author: Jonathan Marten <jjm AT keelhaul DOT me DOT uk> ## 0011 ## ## 0012 ########################################################################## 0013 0014 SRC=$1 # CMAKE_CURRENT_SOURCE_DIR 0015 BIN=$2 # CMAKE_CURRENT_BINARY_DIR 0016 VER=$3 # application version 0017 0018 SVNCMD=`PATH=$PATH:$KDEDIR/bin type -p svn 2>/dev/null` 0019 GITCMD=`PATH=$PATH:$KDEDIR/bin type -p git 2>/dev/null` 0020 0021 VCS= # version control found 0022 REV= # version from that 0023 0024 if [ -d "$SRC/.svn" ] # source is under SVN 0025 then 0026 VCS="SVN" 0027 if [ -n "$SVNCMD" ] # SVN command available 0028 then 0029 REV=`$SVNCMD info $SRC 2>/dev/null | sed -n -e'/^Revision:/ { s/^[^:]*: *//;p;q }'` 0030 else # SVN command not found 0031 REV="Unknown" 0032 fi 0033 elif [ -d "$SRC/.git" ] # source is under GIT 0034 then 0035 VCS="GIT" 0036 if [ -n "$GITCMD" ] # GIT command available 0037 then # first try formatted version 0038 REV=`cd $1 && $GITCMD describe 2>/dev/null` 0039 if [ ! -n "$REV" ] # if not available then 0040 then # hash of last commit 0041 REV=`cd $1 && $GITCMD log -1 --abbrev-commit | sed -e 's/commit *//;q'` 0042 fi 0043 else # GIT command not found 0044 REV="Unknown" 0045 fi 0046 fi 0047 0048 TMPFILE="$BIN/vcsversion.h.tmp" # temporary header file 0049 { 0050 echo "#ifndef VERSION" 0051 echo "#define VERSION \"${VER}\"" 0052 echo "#endif" 0053 echo 0054 echo "#define VCS_TYPE \"${VCS}\"" 0055 echo "#define VCS_REVISION \"${REV}\"" 0056 if [ -n "$VCS" ] 0057 then 0058 echo "#define VCS_AVAILABLE 1" 0059 else 0060 echo "#define VCS_AVAILABLE 0" 0061 fi 0062 echo 0063 } >$TMPFILE 0064 0065 0066 OUTFILE="$BIN/vcsversion.h" # the real header file 0067 if [ ! -f $OUTFILE ] # does not exist yet 0068 then 0069 echo "Creating $OUTFILE..." 0070 else # already exists 0071 if cmp -s $TMPFILE $OUTFILE # is it still current? 0072 then 0073 rm $TMPFILE # yes, nothing to do 0074 exit 0 0075 else 0076 echo "Updating $OUTFILE..." 0077 fi 0078 fi 0079 0080 0081 mv $TMPFILE $OUTFILE # update the header file 0082 test -n "$VCS" && echo "Current $VCS revision: $REV" 0083 exit 0