Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / tools / move-if-changed.sh
CommitLineData
920dae64
AT
1#!/bin/sh
2#
3# move-if-changed <file1> <file2>
4#
5# if (file2 != file1) then copy file2 to file1.
6#
7src=$1
8dest=$2
9tmp1=$src.tmp
10tmp2=$dest.tmp
11
12RM="/usr/bin/rm -f"
13GREP="/usr/bin/grep"
14SCCS="/usr/ccs/bin/sccs"
15CP="/usr/bin/cp -p"
16TOUCH="/usr/bin/touch"
17CMP="/usr/bin/cmp -s"
18CHMOD="/usr/bin/chmod"
19
20$RM $tmp1 $tmp2
21$GREP -v '#' $src > $tmp1
22$GREP -v '#' $dest > $tmp2
23$TOUCH $tmp1 $tmp2
24if $CMP $tmp1 $tmp2; then
25 /bin/true
26else
27 dir=`dirname $src`;
28 fname=`basename $src`;
29 here=`pwd`;
30 cd $dir
31 $CHMOD -w $fname
32 $RM SCCS/p.$fname
33 $SCCS edit $fname > /dev/null
34 cd $here
35 $CP -f $dest $src
36fi
37$RM $tmp1 $tmp2 $dest
38exit 0