#! /usr/bin/env bash # # look_for_makedepend() { # The "original" makedepend is part of the Imake system that is # most often distributed with XFree86 or with an XFree86 source # package. As a result, many machines (eg. generic Linux) do not # have a system-default "makedepend" available. For those # systems, we have two fall-back options: # # 1) a makedepend implementation shipped with the cyrus-imapd # package: ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/ # # 2) a known-buggy xmakedpend shell script # # So the choices are, in order: # # 1) use the user-specified program # 2) use a system-wide default # 3) locally build and use the cyrus implementation # 4) fall back to the buggy local xmakedpend script # if test "x${MAKEDEPEND}" = x ; then which makedepend > /dev/null 2>&1 RV0=$? cat <> genmake_tc.f program test write(*,*) 'test' stop end EOF makedepend genmake_tc.f > /dev/null 2>&1 RV1=$? if test "x${RV0}${RV1}" = x00 ; then MAKEDEPEND=makedepend else echo " a system-default makedepend was not found." # Try to build the cyrus implementation build_cyrus_makedepend RETVAL=$? if test "x$RETVAL" != x0 ; then MAKEDEPEND='$(TOOLSDIR)/xmakedepend' fi rm -f ./genmake_cy_md fi else # echo "MAKEDEPEND=${MAKEDEPEND}" echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1 RETVAL=$? if test x"$RETVAL" = x0 ; then build_cyrus_makedepend fi fi } build_cyrus_makedepend() { rm -f ./genmake_cy_md ( cd $ROOTDIR/tools/cyrus-imapd-makedepend \ && ./configure > /dev/null 2>&1 \ && make > /dev/null 2>&1 if test -x ./makedepend.exe ; then $LN ./makedepend.exe ./makedepend fi ./makedepend ifparser.c > /dev/null 2>&1 \ && echo "true" ) > ./genmake_cy_md grep true ./genmake_cy_md > /dev/null 2>&1 RETVAL=$? rm -f ./genmake_cy_md if test "x$RETVAL" = x0 ; then MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend' return 0 else echo "WARNING: unable to build cyrus-imapd-makedepend" return 1 fi } find_possible_configs() { tmp1=`uname`"_"`uname -m` tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'` tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'` tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'` tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'` PLATFORM=$tmp3 echo $PLATFORM | grep cygwin > /dev/null 2>&1 && PLATFORM=cygwin_ia32 OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")` echo " The platform appears to be: $PLATFORM" echo "test" > test ln -s ./test link RETVAL=$? if test "x${RETVAL}" = x0 ; then LN="ln -s" else echo "Error: \"ln -s\" does not appear to work on this system!" echo " For help, please contact ." exit 1 fi rm -f test link if test "x$CPP" = x ; then CPP="cpp -traditional -P" fi look_for_makedepend #================================================================ # look for possible C compilers tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc" p_CC= for c in $tmp ; do rm -f ./genmake_hello.c ./genmake_hello cat >> genmake_hello.c << EOF #include int main(int argc, char **argv) { printf("Hello!\n"); return 0; } EOF $c -o genmake_hello genmake_hello.c > /dev/null 2>&1 RETVAL=$? if test "x${RETVAL}" = x0 ; then p_CC="$p_CC $c" fi done rm -f ./genmake_hello.c ./genmake_hello if test "x${p_CC}" = x ; then cat 1>&2 <> hello.f < /dev/null 2>&1 RETVAL=$? if test "x${RETVAL}" = x0 ; then p_FC="$p_FC $c" fi done rm -f ./hello.f ./hello if test "x${p_FC}" = x ; then cat 1>&2 <&2 <. EOF exit 1 fi } AWK=awk if test "x${ROOTDIR}" = x ; then tmp=`echo $PWD | sed -e 's/\// /g' | awk '{print $NR}'` if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then ROOTDIR=".." else for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do if test -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ; then ROOTDIR=$d printf "Warning: ROOTDIR unspecified but there appears to be" echo " a copy of MITgcm at \"$ROOTDIR\"" break fi done fi fi tmp1=`uname`"_"`uname -m` tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'` tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'` tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'` tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'` PLATFORM=$tmp3 echo $PLATFORM | grep cygwin > /dev/null 2>&1 && PLATFORM=cygwin_ia32 echo " The platform appears to be: $PLATFORM" echo " And possible optfiles are: " OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")` for i in $OFLIST ; do echo " $i" done find_possible_configs echo echo " The default optfile is: "$PLATFORM"_"$FC