Warning, /tools/suggest_optfile_names is written in an unsupported language. File is not indexed.
view on githubraw file Latest commit 51a1c301 on 2018-03-27 14:32:52 UTC
8baeb68a7a Ed H*0001 #! /usr/bin/env bash
0002
0003 look_for_makedepend() {
0004
0005 # The "original" makedepend is part of the Imake system that is
0006 # most often distributed with XFree86 or with an XFree86 source
0007 # package. As a result, many machines (eg. generic Linux) do not
0008 # have a system-default "makedepend" available. For those
0009 # systems, we have two fall-back options:
0010 #
0011 # 1) a makedepend implementation shipped with the cyrus-imapd
0012 # package: ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
0013 #
0014 # 2) a known-buggy xmakedpend shell script
0015 #
0016 # So the choices are, in order:
0017 #
0018 # 1) use the user-specified program
0019 # 2) use a system-wide default
0020 # 3) locally build and use the cyrus implementation
0021 # 4) fall back to the buggy local xmakedpend script
0022 #
0023 if test "x${MAKEDEPEND}" = x ; then
0024 which makedepend > /dev/null 2>&1
0025 RV0=$?
0026 cat <<EOF >> genmake_tc.f
0027 program test
0028 write(*,*) 'test'
0029 stop
0030 end
0031 EOF
0032 makedepend genmake_tc.f > /dev/null 2>&1
0033 RV1=$?
0034 if test "x${RV0}${RV1}" = x00 ; then
0035 MAKEDEPEND=makedepend
0036 else
0037 echo " a system-default makedepend was not found."
309b5c610e Jean*0038
8baeb68a7a Ed H*0039 # Try to build the cyrus implementation
0040 build_cyrus_makedepend
0041 RETVAL=$?
0042 if test "x$RETVAL" != x0 ; then
0043 MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
0044 fi
0045 rm -f ./genmake_cy_md
0046 fi
0047 else
0048 # echo "MAKEDEPEND=${MAKEDEPEND}"
0049 echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1
0050 RETVAL=$?
0051 if test x"$RETVAL" = x0 ; then
0052 build_cyrus_makedepend
0053 fi
0054 fi
2555311bc3 Ed H*0055 rm -f genmake_tc*
8baeb68a7a Ed H*0056 }
0057
0058 build_cyrus_makedepend() {
0059 rm -f ./genmake_cy_md
0060 (
0061 cd $ROOTDIR/tools/cyrus-imapd-makedepend \
0062 && ./configure > /dev/null 2>&1 \
0063 && make > /dev/null 2>&1
0064 if test -x ./makedepend.exe ; then
0065 $LN ./makedepend.exe ./makedepend
0066 fi
0067 ./makedepend ifparser.c > /dev/null 2>&1 \
0068 && echo "true"
0069 ) > ./genmake_cy_md
0070 grep true ./genmake_cy_md > /dev/null 2>&1
0071 RETVAL=$?
0072 rm -f ./genmake_cy_md
0073 if test "x$RETVAL" = x0 ; then
0074 MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
0075 return 0
0076 else
0077 echo "WARNING: unable to build cyrus-imapd-makedepend"
0078 return 1
0079 fi
0080 }
0081
0082 find_possible_configs() {
0083
0084 tmp1=`uname`"_"`uname -m`
0085 tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
0086 tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
0087 tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
0088 tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
0089 tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
0090 PLATFORM=$tmp3
0091 echo $PLATFORM | grep cygwin > /dev/null 2>&1 && PLATFORM=cygwin_ia32
0092 OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
0093 echo " The platform appears to be: $PLATFORM"
309b5c610e Jean*0094
8baeb68a7a Ed H*0095 echo "test" > test
0096 ln -s ./test link
0097 RETVAL=$?
0098 if test "x${RETVAL}" = x0 ; then
0099 LN="ln -s"
0100 else
0101 echo "Error: \"ln -s\" does not appear to work on this system!"
0102 echo " For help, please contact <MITgcm-support@mitgcm.org>."
0103 exit 1
0104 fi
0105 rm -f test link
0106
0107 if test "x$CPP" = x ; then
0108 CPP="cpp -traditional -P"
0109 fi
0110
0111 look_for_makedepend
0112
0113 #================================================================
0114 # look for possible C compilers
0115 tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc"
0116 p_CC=
0117 for c in $tmp ; do
0118 rm -f ./genmake_hello.c ./genmake_hello
0119 cat >> genmake_hello.c << EOF
0120 #include <stdio.h>
0121 int main(int argc, char **argv) {
0122 printf("Hello!\n");
0123 return 0;
0124 }
0125 EOF
0126 $c -o genmake_hello genmake_hello.c > /dev/null 2>&1
0127 RETVAL=$?
0128 if test "x${RETVAL}" = x0 ; then
0129 p_CC="$p_CC $c"
0130 fi
0131 done
0132 rm -f ./genmake_hello.c ./genmake_hello
0133 if test "x${p_CC}" = x ; then
0134 cat 1>&2 <<EOF
0135
0136 Error: No C compilers were found in your path. Please specify one using:
0137
0138 1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
0139 2) the CC or MITGCM_CC environment variables.
0140
0141 EOF
0142 exit 1
0143 else
0144 echo " The possible C compilers found in your path are:"
0145 echo " "$p_CC
0146 if test "x$CC" = x ; then
0147 CC=`echo $p_CC | $AWK '{print $1}'`
0148 echo " Setting C compiler to: "$CC
0149 fi
0150 fi
0151
0152 #================================================================
0153 # look for possible FORTRAN compilers
0154 tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"
0155 p_FC=
0156 for c in $tmp ; do
0157 rm -f ./hello.f ./hello
0158 cat >> hello.f <<EOF
0159 program hello
0160 do i=1,3
0161 print *, 'hello world : ', i
0162 enddo
0163 end
0164 EOF
0165 $c -o hello hello.f > /dev/null 2>&1
0166 RETVAL=$?
0167 if test "x${RETVAL}" = x0 ; then
0168 p_FC="$p_FC $c"
0169 fi
0170 done
0171 rm -f ./hello.f ./hello
0172 if test "x${p_FC}" = x ; then
0173 cat 1>&2 <<EOF
0174
0175 Error: No Fortran compilers were found in your path. Please specify one using:
0176
0177 1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
0178 2) a command-line option (eg. "-fc NAME"), or
0179 3) the FC or MITGCM_FC environment variables.
0180
0181 EOF
0182 exit 1
0183 else
0184 echo " The possible FORTRAN compilers found in your path are:"
0185 echo " "$p_FC
0186 if test "x$FC" = x ; then
0187 FC=`echo $p_FC | $AWK '{print $1}'`
0188 echo " Setting FORTRAN compiler to: "$FC
0189 fi
0190 fi
0191
0192 if test "x$OPTFILE" = x ; then
0193 OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
0194 if test ! -r $OPTFILE ; then
0195 echo " I looked for the file "$OPTFILE" but did not find it"
0196 fi
0197 fi
0198 if test "x$OPTFILE" = x ; then
0199 cat 1>&2 <<EOF
0200
0201 Error: No options file was found in: $ROOTDIR/tools/build_options/
0202 that matches this platform ("$PLATFORM") and the compilers found in
0203 your path. Please specify an "optfile" using:
0204
0205 1) the command line (eg. "-optfile=path/to/OPTFILE"), or
0206 2) the MITGCM_OF environment variable.
0207
0208 If you need help, please contact the developers at <MITgcm-support@mitgcm.org>.
0209
0210 EOF
0211 exit 1
0212 fi
309b5c610e Jean*0213
8baeb68a7a Ed H*0214 }
0215
309b5c610e Jean*0216 #-- Sequential part of script starts here --------------------------------------
0217 if test "x$MITGCM_ROOTDIR" = x ; then
0218 if test "x$ROOTDIR" != x ; then
51a1c30199 Jean*0219 echo "WARNING: Environment Variable 'ROOTDIR' no longer recognized"
309b5c610e Jean*0220 echo "WARNING: use instead 'MITGCM_ROOTDIR'" ; ROOTDIR=
0221 fi
0222 else
0223 ROOTDIR=$MITGCM_ROOTDIR
0224 fi
8baeb68a7a Ed H*0225
0226 AWK=awk
0227
0228 if test "x${ROOTDIR}" = x ; then
0229 tmp=`echo $PWD | sed -e 's/\// /g' | awk '{print $NR}'`
0230 if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
0231 ROOTDIR=".."
0232 else
0233 for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
0234 if test -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ; then
0235 ROOTDIR=$d
0236 printf "Warning: ROOTDIR unspecified but there appears to be"
0237 echo " a copy of MITgcm at \"$ROOTDIR\""
0238 break
0239 fi
0240 done
0241 fi
0242 fi
0243
0244 tmp1=`uname`"_"`uname -m`
0245 tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
0246 tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
0247 tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
0248 tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
0249 tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
0250 PLATFORM=$tmp3
0251 echo $PLATFORM | grep cygwin > /dev/null 2>&1 && PLATFORM=cygwin_ia32
0252 echo " The platform appears to be: $PLATFORM"
0253 echo " And possible optfiles are: "
0254 OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
0255 for i in $OFLIST ; do
0256 echo " $i"
0257 done
0258
0259 find_possible_configs
0260
0261 echo
0262 echo " The default optfile is: "$PLATFORM"_"$FC
0263