#!/bin/sh
#
# madiff test.c
#
# Compares a file to its counterpart in the "version/current" directory.
# change: Allow -diff, -srcroot

DIFFOPTS=""

ALDHOME=${ALDHOME:-${HOME}/aldor}
SysRoot=$ALDORSERV/../..
OwnRoot=`(cd $ALDHOME/@version@; pwd)`
current=@version@/current

while [ $# -gt 1 ]
do
	case "$1" in
	-diff)
		DIFFOPTS="$2"
		shift
		;;
	-sysroot)
	  	SysRoot="$2"
		shift
		;;   	
	-version)
		current=$2
		shift
		;;
	-*)
		echo ignoring unknown option $1
		;;
	esac
	shift
done


file="$1"
dir=.`pwd | sed -e "s:$OwnRoot/[^/]*::"`
ver=`pwd | sed -e "s:$OwnRoot/::"`
ver=`echo "$ver" | sed -e "s:/.*::"`

echo ============================== DIFF ===================================
echo ======== '<' $SysRoot/$current/$dir/$file
echo ======== '>' $OwnRoot/$ver/$dir/$file
diff $DIFFOPTS -rb $SysRoot/$current/$dir/$file $OwnRoot/$ver/$dir/$file
echo ========================================================================
