104 |
CPP="cpp -traditional -P" |
CPP="cpp -traditional -P" |
105 |
fi |
fi |
106 |
|
|
107 |
|
# makedepend is not always available |
108 |
|
if test "x${MAKEDEPEND}" = x ; then |
109 |
|
which makedepend >& /dev/null |
110 |
|
RETVAL=$? |
111 |
|
if test "x${RETVAL}" = x1 ; then |
112 |
|
echo " makedepend was not found. Using xmakedpend instead." |
113 |
|
MAKEDEPEND='$(TOOLSDIR)/xmakedepend' |
114 |
|
fi |
115 |
|
fi |
116 |
|
|
117 |
# look for possible fortran compilers |
# look for possible fortran compilers |
118 |
tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95" |
tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95" |
119 |
p_FC= |
p_FC= |
274 |
exit 1 |
exit 1 |
275 |
} |
} |
276 |
|
|
277 |
#eh3 # This is the generic configuration. |
# Build a CPP macro to automate calling C routines from FORTRAN |
278 |
#eh3 set LN = ( 'ln -s' ) |
get_fortran_c_namemangling() { |
279 |
#eh3 set CPP = ( '/lib/cpp -P' ) |
default_nm="#define FC_NAMEMANGLE(X) X ## _" |
280 |
#eh3 set S64 = ( '$(TOOLSDIR)/set64bitConst.sh' ) |
|
281 |
#eh3 set KPP = ( ) |
cat > genmake_test.c <<EOF |
282 |
#eh3 set FC = ( 'f77' ) |
void tcall( char * string ) { tsub( string ); } |
283 |
#eh3 set LINK = $FC |
EOF |
284 |
#eh3 set MAKEDEPEND = ( 'makedepend' ) |
$MAKE genmake_test.o > genmake_test.log 2>&1 |
285 |
#eh3 set INCLUDES = ( -I. ) |
RETVAL=$? |
286 |
#eh3 set FFLAGS = ( ) |
if test "x$RETVAL" != x0 ; then |
287 |
#eh3 set FOPTIM = ( ) |
cat genmake_test.log >> genmake_errors |
288 |
#eh3 set CFLAGS = ( ) |
FC_NAMEMANGLE=$default_nm |
289 |
#eh3 set KFLAGS1 = ( ) |
echo |
290 |
#eh3 set KFLAGS2 = ( ) |
echo "WARNING: C test compile fails -- please see \"genmake_errors\"" |
291 |
#eh3 set LIBS = ( ) |
echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'" |
292 |
#eh3 set KPPFILES = ( ) |
echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here." |
293 |
#eh3 if (! $?NOOPTFILES ) set NOOPTFILES = ( ) |
return 1 |
294 |
#eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = ( ) |
fi |
295 |
|
c_tcall=`nm genmake_test.o | grep tcall | cut -d ' ' -f 3` |
296 |
|
RETVAL=$? |
297 |
|
if test "x$RETVAL" != x0 ; then |
298 |
|
FC_NAMEMANGLE=$default_nm |
299 |
|
echo |
300 |
|
echo "WARNING: The \"nm\" command failed." |
301 |
|
echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'" |
302 |
|
echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here." |
303 |
|
return 1 |
304 |
|
fi |
305 |
|
cat > genmake_tcomp.f <<EOF |
306 |
|
subroutine tcall( string ) |
307 |
|
character*(*) string |
308 |
|
call tsub( string ) |
309 |
|
end |
310 |
|
EOF |
311 |
|
$FC $FFLAGS $DEFINES -c genmake_tcomp.f > genmake_tcomp.log 2>&1 |
312 |
|
RETVAL=$? |
313 |
|
if test "x$RETVAL" != x0 ; then |
314 |
|
cat genmake_tcomp.log >> genmake_errors |
315 |
|
FC_NAMEMANGLE=$default_nm |
316 |
|
echo |
317 |
|
echo "WARNING: FORTRAN test compile fails -- please see \"genmake_errors\"" |
318 |
|
echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'" |
319 |
|
echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here." |
320 |
|
return 1 |
321 |
|
fi |
322 |
|
f_tcall=`nm genmake_tcomp.o | grep tcall | cut -d ' ' -f 3` |
323 |
|
RETVAL=$? |
324 |
|
if test "x$RETVAL" != x0 ; then |
325 |
|
FC_NAMEMANGLE=$default_nm |
326 |
|
echo |
327 |
|
echo "WARNING: The \"nm\" command failed." |
328 |
|
echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'" |
329 |
|
echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here." |
330 |
|
return 1 |
331 |
|
fi |
332 |
|
|
333 |
|
c_a=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'` |
334 |
|
f_a=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'` |
335 |
|
c_b=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'` |
336 |
|
f_b=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'` |
337 |
|
|
338 |
|
nmangle="X" |
339 |
|
if test "x$c_a" != "x$f_a" ; then |
340 |
|
comm="echo x$f_a | sed -e 's|x$c_a||'" |
341 |
|
a=`eval $comm` |
342 |
|
nmangle="$a ## $nmangle" |
343 |
|
fi |
344 |
|
if test "x$c_b" != "x$f_b" ; then |
345 |
|
comm="echo x$f_b | sed -e 's|x$c_b||'" |
346 |
|
b=`eval $comm` |
347 |
|
nmangle="$nmangle ## $b" |
348 |
|
fi |
349 |
|
|
350 |
|
FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) $nmangle" |
351 |
|
|
352 |
|
# cleanup the testing files |
353 |
|
rm -f genmake_tcomp.* genmake_test.* |
354 |
|
} |
355 |
|
|
356 |
# Set defaults here |
# Set defaults here |
357 |
COMMANDL="$0 $@" |
COMMANDL="$0 $@" |
362 |
KPP= |
KPP= |
363 |
FC= |
FC= |
364 |
LINK= |
LINK= |
365 |
DEFINES="-DWORDLENGTH=4" |
# DEFINES="-DWORDLENGTH=4" |
366 |
|
DEFINES= |
367 |
PACKAGES= |
PACKAGES= |
368 |
ENABLE= |
ENABLE= |
369 |
DISABLE= |
DISABLE= |
731 |
|
|
732 |
1) within the options file ("CPP=...") as specified by "-of=OPTFILE" |
1) within the options file ("CPP=...") as specified by "-of=OPTFILE" |
733 |
2) the "./genmake_local" file |
2) the "./genmake_local" file |
734 |
|
3) with the CPP environment variable |
735 |
|
|
736 |
EOF |
EOF |
737 |
exit 1 |
exit 1 |
783 |
fi |
fi |
784 |
rm -f genmake_tcomp* |
rm -f genmake_tcomp* |
785 |
|
|
786 |
echo -n " The name mangling convention for $FC is... " |
echo " The name mangling convention for $FC is... " |
787 |
|
#FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) X ## _" |
788 |
if test "x$FC_NAMEMANGLE" = x ; then |
if test "x$FC_NAMEMANGLE" = x ; then |
789 |
FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) X ## _" |
get_fortran_c_namemangling |
|
fi |
|
|
cat > genmake_tcomp.f <<EOF |
|
|
subroutine tcall( string ) |
|
|
character*(*) string |
|
|
call tsub( string ) |
|
|
end |
|
|
EOF |
|
|
$FC $FFLAGS $DEFINES -c genmake_tcomp.f > genmake_tcomp.log 2>&1 |
|
|
RETVAL=$? |
|
|
if test "x$RETVAL" != x0 ; then |
|
|
cat genmake_tcomp.log >> genmake_errors |
|
|
echo |
|
|
echo "WARNING: test compile fails -- please see \"genmake_errors\"" |
|
|
echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'" |
|
|
echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here." |
|
|
else |
|
|
tcall=`nm genmake_tcomp.o | grep tcall | cut -d ' ' -f 3` |
|
|
RETVAL=$? |
|
|
if test "x$RETVAL" != x0 ; then |
|
|
echo |
|
|
echo "WARNING: The \"nm\" command failed." |
|
|
echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'" |
|
|
echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here." |
|
|
else |
|
|
t0=`echo $tcall | sed -e 's|_tcall|_ ## X|g'` |
|
|
nmres=`echo $t0 | sed -e 's|tcall_|X ## _|g'` |
|
|
FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) $nmres" |
|
|
echo "'$FC_NAMEMANGLE'" |
|
|
fi |
|
790 |
fi |
fi |
791 |
|
echo " '$FC_NAMEMANGLE'" |
792 |
echo "$FC_NAMEMANGLE" > FC_NAMEMANGLE.h.template |
echo "$FC_NAMEMANGLE" > FC_NAMEMANGLE.h.template |
793 |
cmp FC_NAMEMANGLE.h FC_NAMEMANGLE.h.template > /dev/null 2>&1 |
cmp FC_NAMEMANGLE.h FC_NAMEMANGLE.h.template > /dev/null 2>&1 |
794 |
RETVAL=$? |
RETVAL=$? |
795 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
796 |
mv -f FC_NAMEMANGLE.h.template FC_NAMEMANGLE.h |
mv -f FC_NAMEMANGLE.h.template FC_NAMEMANGLE.h |
797 |
fi |
fi |
|
rm -f genmake_tcomp* |
|
798 |
|
|
799 |
|
|
800 |
printf "\n=== Setting defaults ===\n" |
printf "\n=== Setting defaults ===\n" |