/[MITgcm]/MITgcm/tools/suggest_optfile_names
ViewVC logotype

Contents of /MITgcm/tools/suggest_optfile_names

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Fri Jul 30 19:59:45 2004 UTC (19 years, 8 months ago) by edhill
Branch: MAIN
 o initial check-in of convenience script to help find/name optfiles

1 #! /usr/bin/env bash
2 #
3 #
4
5 look_for_makedepend() {
6
7 # The "original" makedepend is part of the Imake system that is
8 # most often distributed with XFree86 or with an XFree86 source
9 # package. As a result, many machines (eg. generic Linux) do not
10 # have a system-default "makedepend" available. For those
11 # systems, we have two fall-back options:
12 #
13 # 1) a makedepend implementation shipped with the cyrus-imapd
14 # package: ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
15 #
16 # 2) a known-buggy xmakedpend shell script
17 #
18 # So the choices are, in order:
19 #
20 # 1) use the user-specified program
21 # 2) use a system-wide default
22 # 3) locally build and use the cyrus implementation
23 # 4) fall back to the buggy local xmakedpend script
24 #
25 if test "x${MAKEDEPEND}" = x ; then
26 which makedepend > /dev/null 2>&1
27 RV0=$?
28 cat <<EOF >> genmake_tc.f
29 program test
30 write(*,*) 'test'
31 stop
32 end
33 EOF
34 makedepend genmake_tc.f > /dev/null 2>&1
35 RV1=$?
36 if test "x${RV0}${RV1}" = x00 ; then
37 MAKEDEPEND=makedepend
38 else
39 echo " a system-default makedepend was not found."
40
41 # Try to build the cyrus implementation
42 build_cyrus_makedepend
43 RETVAL=$?
44 if test "x$RETVAL" != x0 ; then
45 MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
46 fi
47 rm -f ./genmake_cy_md
48 fi
49 else
50 # echo "MAKEDEPEND=${MAKEDEPEND}"
51 echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1
52 RETVAL=$?
53 if test x"$RETVAL" = x0 ; then
54 build_cyrus_makedepend
55 fi
56 fi
57 }
58
59
60 build_cyrus_makedepend() {
61 rm -f ./genmake_cy_md
62 (
63 cd $ROOTDIR/tools/cyrus-imapd-makedepend \
64 && ./configure > /dev/null 2>&1 \
65 && make > /dev/null 2>&1
66 if test -x ./makedepend.exe ; then
67 $LN ./makedepend.exe ./makedepend
68 fi
69 ./makedepend ifparser.c > /dev/null 2>&1 \
70 && echo "true"
71 ) > ./genmake_cy_md
72 grep true ./genmake_cy_md > /dev/null 2>&1
73 RETVAL=$?
74 rm -f ./genmake_cy_md
75 if test "x$RETVAL" = x0 ; then
76 MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
77 return 0
78 else
79 echo "WARNING: unable to build cyrus-imapd-makedepend"
80 return 1
81 fi
82 }
83
84
85 find_possible_configs() {
86
87 tmp1=`uname`"_"`uname -m`
88 tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
89 tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
90 tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
91 tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
92 tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
93 PLATFORM=$tmp3
94 echo $PLATFORM | grep cygwin > /dev/null 2>&1 && PLATFORM=cygwin_ia32
95 OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
96 echo " The platform appears to be: $PLATFORM"
97
98 echo "test" > test
99 ln -s ./test link
100 RETVAL=$?
101 if test "x${RETVAL}" = x0 ; then
102 LN="ln -s"
103 else
104 echo "Error: \"ln -s\" does not appear to work on this system!"
105 echo " For help, please contact <MITgcm-support@mitgcm.org>."
106 exit 1
107 fi
108 rm -f test link
109
110 if test "x$CPP" = x ; then
111 CPP="cpp -traditional -P"
112 fi
113
114 look_for_makedepend
115
116 #================================================================
117 # look for possible C compilers
118 tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc"
119 p_CC=
120 for c in $tmp ; do
121 rm -f ./genmake_hello.c ./genmake_hello
122 cat >> genmake_hello.c << EOF
123 #include <stdio.h>
124 int main(int argc, char **argv) {
125 printf("Hello!\n");
126 return 0;
127 }
128 EOF
129 $c -o genmake_hello genmake_hello.c > /dev/null 2>&1
130 RETVAL=$?
131 if test "x${RETVAL}" = x0 ; then
132 p_CC="$p_CC $c"
133 fi
134 done
135 rm -f ./genmake_hello.c ./genmake_hello
136 if test "x${p_CC}" = x ; then
137 cat 1>&2 <<EOF
138
139 Error: No C compilers were found in your path. Please specify one using:
140
141 1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
142 2) the CC or MITGCM_CC environment variables.
143
144 EOF
145 exit 1
146 else
147 echo " The possible C compilers found in your path are:"
148 echo " "$p_CC
149 if test "x$CC" = x ; then
150 CC=`echo $p_CC | $AWK '{print $1}'`
151 echo " Setting C compiler to: "$CC
152 fi
153 fi
154
155 #================================================================
156 # look for possible FORTRAN compilers
157 tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"
158 p_FC=
159 for c in $tmp ; do
160 rm -f ./hello.f ./hello
161 cat >> hello.f <<EOF
162 program hello
163 do i=1,3
164 print *, 'hello world : ', i
165 enddo
166 end
167 EOF
168 $c -o hello hello.f > /dev/null 2>&1
169 RETVAL=$?
170 if test "x${RETVAL}" = x0 ; then
171 p_FC="$p_FC $c"
172 fi
173 done
174 rm -f ./hello.f ./hello
175 if test "x${p_FC}" = x ; then
176 cat 1>&2 <<EOF
177
178 Error: No Fortran compilers were found in your path. Please specify one using:
179
180 1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
181 2) a command-line option (eg. "-fc NAME"), or
182 3) the FC or MITGCM_FC environment variables.
183
184 EOF
185 exit 1
186 else
187 echo " The possible FORTRAN compilers found in your path are:"
188 echo " "$p_FC
189 if test "x$FC" = x ; then
190 FC=`echo $p_FC | $AWK '{print $1}'`
191 echo " Setting FORTRAN compiler to: "$FC
192 fi
193 fi
194
195 if test "x$OPTFILE" = x ; then
196 OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
197 if test ! -r $OPTFILE ; then
198 echo " I looked for the file "$OPTFILE" but did not find it"
199 fi
200 fi
201 if test "x$OPTFILE" = x ; then
202 cat 1>&2 <<EOF
203
204 Error: No options file was found in: $ROOTDIR/tools/build_options/
205 that matches this platform ("$PLATFORM") and the compilers found in
206 your path. Please specify an "optfile" using:
207
208 1) the command line (eg. "-optfile=path/to/OPTFILE"), or
209 2) the MITGCM_OF environment variable.
210
211 If you need help, please contact the developers at <MITgcm-support@mitgcm.org>.
212
213 EOF
214 exit 1
215 fi
216
217 }
218
219
220 AWK=awk
221
222 if test "x${ROOTDIR}" = x ; then
223 tmp=`echo $PWD | sed -e 's/\// /g' | awk '{print $NR}'`
224 if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
225 ROOTDIR=".."
226 else
227 for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
228 if test -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ; then
229 ROOTDIR=$d
230 printf "Warning: ROOTDIR unspecified but there appears to be"
231 echo " a copy of MITgcm at \"$ROOTDIR\""
232 break
233 fi
234 done
235 fi
236 fi
237
238 tmp1=`uname`"_"`uname -m`
239 tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
240 tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
241 tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
242 tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
243 tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
244 PLATFORM=$tmp3
245 echo $PLATFORM | grep cygwin > /dev/null 2>&1 && PLATFORM=cygwin_ia32
246 echo " The platform appears to be: $PLATFORM"
247 echo " And possible optfiles are: "
248 OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
249 for i in $OFLIST ; do
250 echo " $i"
251 done
252
253 find_possible_configs
254
255 echo
256 echo " The default optfile is: "$PLATFORM"_"$FC

  ViewVC Help
Powered by ViewVC 1.1.22