#! /bin/sh
# Note that we must REMOVE links that are not writable, since the SYSV version
# of ln will otherwise ask for a y/no response.  The -f option means different
# things in the SYSV and non-SYSV systems, so we can't use that.
if [ ! -s ./examples/basic/upshot ] ; then (cd ./examples/basic/ ; rm -f upshot ; ln -s ../../bin/upshot  upshot >/dev/null 2>&1 ; ) ; fi
if [ ! -s ./examples/perftest/aclocal.m4 ] ; then (cd ./examples/perftest/ ; rm -f aclocal.m4 ; ln -s ../../aclocal.m4  aclocal.m4 >/dev/null 2>&1 ; ) ; fi
if [ ! -s ./examples/test/aclocal.m4 ] ; then (cd ./examples/test/ ; rm -f aclocal.m4 ; ln -s ../../aclocal.m4  aclocal.m4 >/dev/null 2>&1 ; ) ; fi
if [ ! -s ./include/mpeexten.h ] ; then (cd ./include/ ; rm -f mpeexten.h ; ln -s ../mpe/mpeexten.h  mpeexten.h >/dev/null 2>&1 ; ) ; fi
if [ -d mpe ] ; then
if [ ! -s ./mpe/point.h ] ; then (cd ./mpe/ ; rm -f point.h ; ln -s profiling/lib/point.h  point.h >/dev/null 2>&1 ; ) ; fi
if [ ! -s ./mpe/profiling/examples/upshot ] ; then (cd ./mpe/profiling/examples/ ; rm -f upshot ; ln -s ../../../bin/upshot  upshot >/dev/null 2>&1 ; ) ; fi
if [ ! -s ./mpe/profiling/nupshot/aclocal.m4 ] ; then (cd ./mpe/profiling/nupshot/ ; rm -f aclocal.m4 ; ln -s ../../aclocal.m4  aclocal.m4 >/dev/null 2>&1 ; ) ; fi
if [ ! -s ./mpe/profiling/nupshot/logfiles ] ; then (cd ./mpe/profiling/nupshot/ ; rm -f logfiles ; ln -s ../upshot/logfiles  logfiles >/dev/null 2>&1 ; ) ; fi
if [ ! -s ./mpe/profiling/nupshot/protofix.h ] ; then (cd ./mpe/profiling/nupshot/ ; rm -f protofix.h ; ln -s ../../../include/protofix.h  protofix.h >/dev/null 2>&1 ; ) ; fi
if [ ! -s ./mpe/profiling/upshot/bin/aclocal.m4 ] ; then (cd ./mpe/profiling/upshot/bin/ ; rm -f aclocal.m4 ; ln -s ../../../aclocal.m4  aclocal.m4 >/dev/null 2>&1 ; ) ; fi
if [ ! -s ./mpe/profiling/wrappergen/aclocal.m4 ] ; then (cd ./mpe/profiling/wrappergen/ ; rm -f aclocal.m4 ; ln -s ../../aclocal.m4  aclocal.m4 >/dev/null 2>&1 ; ) ; fi
if [ ! -s ./mpe/requests.h ] ; then (cd ./mpe/ ; rm -f requests.h ; ln -s profiling/lib/requests.h  requests.h >/dev/null 2>&1 ; ) ; fi
if [ ! -s ./mpe/aclocal.m4 ] ; then (cd ./mpe/ ; rm -f aclocal.m4 ; ln -s ../aclocal.m4  aclocal.m4 >/dev/null 2>&1 ; ) ; fi
fi

if [ -d mpid/ch2 ] ; then 
if [ ! -s ./mpid/ch2/tr2.h ] ; then (cd ./mpid/ch2/ ; rm -f tr2.h ; ln -s ../util/tr2.h  tr2.h >/dev/null 2>&1 ; ) ; fi
if [ ! -s ./mpid/ch2/sbcnst2.h ] ; then (cd ./mpid/ch2/ ; rm -f sbcnst2.h ; ln -s ../util/sbcnst2.h  sbcnst2.h >/dev/null 2>&1 ; ) ; fi
fi

if [ -d ./mpid/ch_meiko ] ; then
if [ ! -s ./mpid/ch_meiko/dm.h ] ; then (cd ./mpid/ch_meiko/ ; rm -f dm.h ; ln -s dmmeiko.h  dm.h >/dev/null 2>&1 ; ) ; fi
fi

#if [ ! -s ./mpid/ch_nc/dm.h ] ; then (cd ./mpid/ch_nc/ ; rm -f dm.h ; ln -s dmn3.h  dm.h >/dev/null 2>&1 ; ) ; fi

if [ -d ./mpid/ch_p4 ] ; then
if [ ! -s ./mpid/ch_p4/p4/aclocal.m4 ] ; then (cd ./mpid/ch_p4/p4/ ; rm -f aclocal.m4 ; ln -s ../../../aclocal.m4  aclocal.m4 >/dev/null 2>&1 ; ) ; fi
if [ ! -s ./mpid/ch_p4/p4/alog/protofix.h ] ; then (cd ./mpid/ch_p4/p4/alog/ ; rm -f protofix.h ; ln -s ../../../../include/protofix.h  protofix.h >/dev/null 2>&1 ; ) ; fi
fi

if [ ! -s ./src/env/dbxerr.c ] ; then (cd ./src/env/ ; rm -f dbxerr.c ; ln -s ../../mpe/dbxerr.c  dbxerr.c >/dev/null 2>&1 ; ) ; fi
if [ ! -s ./src/env/mpehname.c ] ; then (cd ./src/env/ ; rm -f mpehname.c ; ln -s ../../mpe/mpehname.c  mpehname.c >/dev/null 2>&1 ; ) ; fi

# Two-level deep
for dir in examples/perftest examples/test ; do
    if [ ! -s $dir/aclocal_tcl.m4 ] ; then
        rm -f $dir/aclocal_tcl.m4
	(cd $dir ; ln -s ../../aclocal_tcl.m4 aclocal_tcl.m4 >/dev/null 2>&1 )
    fi
done

if [ ! -s ./mpe/profiling/nupshot/aclocal_tcl.m4 ] ; then (cd ./mpe/profiling/nupshot/ ; rm -f aclocal_tcl.m4 ; ln -s ../../aclocal_tcl.m4  aclocal_tcl.m4 >/dev/null 2>&1 ; ) ; fi
if [ ! -s ./mpe/profiling/upshot/bin/aclocal_tcl.m4 ] ; then (cd ./mpe/profiling/upshot/bin/ ; rm -f aclocal_tcl.m4 ; ln -s ../../../aclocal_tcl.m4  aclocal_tcl.m4 >/dev/null 2>&1 ; ) ; fi
if [ ! -s ./mpe/profiling/wrappergen/aclocal_tcl.m4 ] ; then (cd ./mpe/profiling/wrappergen/ ; rm -f aclocal_tcl.m4 ; ln -s ../../aclocal_tcl.m4  aclocal_tcl.m4 >/dev/null 2>&1 ; ) ; fi
if [ ! -s ./mpe/aclocal_tcl.m4 ] ; then (cd ./mpe/ ; rm -f aclocal_tcl.m4 ; ln -s ../aclocal_tcl.m4  aclocal_tcl.m4 >/dev/null 2>&1 ; ) ; fi
