#!/bin/csh -f
#
# Queries the current working directory name for version and
# revision information, assuming that the directory goes by
# the name "xcircuit-x.y.z".  This script determines the number
# x.y and returns it.
#
# Note that we need a fallback version in case of an
# unexpected directory structure. . .
#
set pkgname=`pwd`
set pkgname=${pkgname:t}
set version=${pkgname:s/xcircuit-//}
if ( ${version} == ${pkgname} ) then
   set pkgname=`(cd ..; pwd)`
   set pkgname=${pkgname:t}
   set version=${pkgname:s/xcircuit-//}
   # Handle condition where the directory is a symbolic link.
   if ( ${version} == "xcircuit" ) then
      set rootnames=`(cd ../..; ls | grep xcircuit)`
      foreach i ($rootnames)
	 if (`(cd ../..; readlink $i)` == "xcircuit") then
	    set pkgname=$i
	    set version=${pkgname:s/xcircuit-//}
	    break;
	 endif
      end
   endif
endif
set version=`echo $version | cut -d. -f1-2`
echo $version
