#!/bin/csh
#
# Queries the current working directory name for version and
# revision information, assuming that the directory goes by
# the name "magic-x.y.z".  This script determines the number
# z and returns it.
#
set pkgname=`pwd`
set pkgname=${pkgname:t}
set version=${pkgname:s/magic-//}
if ( ${version} == ${pkgname} ) then
   set pkgname=`(cd ..; pwd)`
   set pkgname=${pkgname:t}
   set version=${pkgname:s/magic-//}
   if ( ${version} == "magic" ) then
      set rootnames=`(cd ../..; ls | grep magic)`    
      foreach i ($rootnames)
         if (`(cd ../..; readlink $i)` == "magic") then
            set pkgname=$i
            set version=${pkgname:s/magic-//}
            break;
         endif
      end
   endif
endif
set revision=`echo $version | cut -d. -f3`
echo $revision
