diff --git a/CMakeLists.txt b/CMakeLists.txt
index 93961dbe94ec533a8bf132f5362afb9222529577..4392c8a0d4fd0903c6aad2af2af0ae0107a281d6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -434,8 +434,7 @@ add_custom_target(version COMMAND ${CMAKE_SOURCE_DIR}/build/unix/makeversion.sh
 endif()
 
 #---distribution commands------------------------------------------------------------------------
-add_custom_target(distsrc COMMAND ${CMAKE_SOURCE_DIR}/build/unix/makedistsrc.sh ${CMAKE_SOURCE_DIR}
-                  DEPENDS ${CMAKE_BINARY_DIR}/include/RGitCommit.h)
+add_custom_target(distsrc COMMAND ${CMAKE_SOURCE_DIR}/build/unix/makedistsrc.sh "${ROOT_VERSION}" "${GIT_DESCRIBE_ALWAYS}" "${CMAKE_SOURCE_DIR}")
 add_custom_target(dist COMMAND cpack --config CPackConfig.cmake)
 
 #---Configure and install various files neded later and for clients -----------------------------
diff --git a/build/unix/makedistsrc.sh b/build/unix/makedistsrc.sh
index 1fcba34ddb2df71233dc0842530193d0114090e9..ad443dc5bb59464ace735ed3d9b8e8b1c018e0d2 100755
--- a/build/unix/makedistsrc.sh
+++ b/build/unix/makedistsrc.sh
@@ -1,24 +1,19 @@
 #! /bin/sh
 
-ROOTSRCDIR=$1
+FILEVERS=$1
+GITTAG=$2
+ROOTSRCDIR=$3
 
-CURVERS=`cat $ROOTSRCDIR/build/version_number | sed -e "s/^/v/" -e "s/\./-/" -e "s/\//-/"`
-ROOTVERS=`cat $ROOTSRCDIR/build/version_number | sed -e 's/\//\./'`
-TYPE=source
-TARFILE=root_v$ROOTVERS.$TYPE.tar
+TARFILE=root_v$FILEVERS.source.tar
 
-( cd $ROOTSRCDIR; git checkout $CURVERS )
-# generate etc/gitinfo.txt
-$ROOTSRCDIR/build/unix/gitinfo.sh $ROOTSRCDIR
+( cd $ROOTSRCDIR; git archive -v -o ../$TARFILE --prefix=root-$FILEVERS/ $GITTAG )
 
-( cd $ROOTSRCDIR; git archive -v -o ../$TARFILE --prefix=root-$ROOTVERS/ $CURVERS )
-
-mkdir -p etc/root-$ROOTVERS/etc
-cp etc/gitinfo.txt etc/root-$ROOTVERS/etc/
+mkdir -p etc/root-$FILEVERS/etc
+cp etc/gitinfo.txt etc/root-$FILEVERS/etc/
 cd etc
-tar -r -vf ../../$TARFILE root-$ROOTVERS/etc/gitinfo.txt
+tar -r -vf ../../$TARFILE root-$FILEVERS/etc/gitinfo.txt
 cd ..
-rm -rf etc/root-$ROOTVERS
+rm -rf etc/root-$FILEVERS
 cd ..
 gzip $TARFILE