#! /bin/sh
#
# This script derives the nx routines from the Chameleon ones.  Some editing 
# of the files may be required after this process, but the goal is to 
# fully automate this process.
#
#/bin/cp ../chameleon/*.c .
sed -e '/#define DEVICE_CHAMELEON/d' \
    -e 's/MPID_CH/MPID_N3/g' \
    -e 's/"Chameleon"/"Ncube"/g' ../chameleon/dmch.h > dmn3.h
sed -e 's/MPID_CH/MPID_N3/g' ../chameleon/mpid_bind.h > mpid_bind.h
sed -e 's/MPID_CH/MPID_N3/g' ../chameleon/packets.h > packets.h
sed -e 's/MPID_CH/MPID_N3/g' ../chameleon/channel.h > channel.h
sed -e 's/MPID_CH/MPID_N3/g' ../chameleon/mpiddebug.h > mpiddebug.h
sed -e 's/MPID_CH/MPID_N3/g' ../chameleon/mpidstat.h > mpidstat.h
../chameleon/rmhetero ../chameleon/chevent.c > n3event.c
../chameleon/rmhetero ../chameleon/chrecv.c  > n3recv.c
../chameleon/rmhetero ../chameleon/chsend.c  > n3send.c
../chameleon/rmhetero ../chameleon/chinit.c  > n3init.c
../chameleon/rmhetero ../chameleon/chprobe.c > n3probe.c
../chameleon/rmhetero ../chameleon/chsync.c  > n3sync.c
../chameleon/rmhetero ../chameleon/chrndv.c  > n3rndv.c
../chameleon/rmhetero ../chameleon/chdebug.c > n3debug.c
chmod ug+w *.[ch]
/home/gropp/tools.n/bin/inlinecomm -main -quiet -ncube n3init.c
for file in n3event.c n3recv.c n3send.c n3probe.c n3sync.c n3rndv.c \
	n3debug.c dmn3.h packets.h channel.h ; do
    /home/gropp/tools.n/bin/inlinecomm -quiet -ncube $file
done
#
# Change the names MPID_CH to MPID_N3
/bin/rm -f .tmp
for file in *.c ; do
    sed -e 's/MPID_CH/MPID_N3/g' $file > .tmp
    mv .tmp $file
done

