264 |
exit 1 |
exit 1 |
265 |
} |
} |
266 |
|
|
267 |
#eh3 # This is the generic configuration. |
# Build a CPP macro to automate calling C routines from FORTRAN |
268 |
#eh3 set LN = ( 'ln -s' ) |
get_fortran_c_namemangling() { |
269 |
#eh3 set CPP = ( '/lib/cpp -P' ) |
default_nm="#define FC_NAMEMANGLE(X) X ## _" |
270 |
#eh3 set S64 = ( '$(TOOLSDIR)/set64bitConst.sh' ) |
|
271 |
#eh3 set KPP = ( ) |
cat > genmake_test.c <<EOF |
272 |
#eh3 set FC = ( 'f77' ) |
void tcall( char * string ) { tsub( string ); } |
273 |
#eh3 set LINK = $FC |
EOF |
274 |
#eh3 set MAKEDEPEND = ( 'makedepend' ) |
$MAKE genmake_test.o > genmake_test.log 2>&1 |
275 |
#eh3 set INCLUDES = ( -I. ) |
RETVAL=$? |
276 |
#eh3 set FFLAGS = ( ) |
if test "x$RETVAL" != x0 ; then |
277 |
#eh3 set FOPTIM = ( ) |
cat genmake_test.log >> genmake_errors |
278 |
#eh3 set CFLAGS = ( ) |
FC_NAMEMANGLE=$default_nm |
279 |
#eh3 set KFLAGS1 = ( ) |
echo |
280 |
#eh3 set KFLAGS2 = ( ) |
echo "WARNING: C test compile fails -- please see \"genmake_errors\"" |
281 |
#eh3 set LIBS = ( ) |
echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'" |
282 |
#eh3 set KPPFILES = ( ) |
echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here." |
283 |
#eh3 if (! $?NOOPTFILES ) set NOOPTFILES = ( ) |
return 1 |
284 |
#eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = ( ) |
fi |
285 |
|
c_tcall=`nm genmake_test.o | grep tcall | cut -d ' ' -f 3` |
286 |
|
RETVAL=$? |
287 |
|
if test "x$RETVAL" != x0 ; then |
288 |
|
FC_NAMEMANGLE=$default_nm |
289 |
|
echo |
290 |
|
echo "WARNING: The \"nm\" command failed." |
291 |
|
echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'" |
292 |
|
echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here." |
293 |
|
return 1 |
294 |
|
fi |
295 |
|
cat > genmake_tcomp.f <<EOF |
296 |
|
subroutine tcall( string ) |
297 |
|
character*(*) string |
298 |
|
call tsub( string ) |
299 |
|
end |
300 |
|
EOF |
301 |
|
$FC $FFLAGS $DEFINES -c genmake_tcomp.f > genmake_tcomp.log 2>&1 |
302 |
|
RETVAL=$? |
303 |
|
if test "x$RETVAL" != x0 ; then |
304 |
|
cat genmake_tcomp.log >> genmake_errors |
305 |
|
FC_NAMEMANGLE=$default_nm |
306 |
|
echo |
307 |
|
echo "WARNING: FORTRAN test compile fails -- please see \"genmake_errors\"" |
308 |
|
echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'" |
309 |
|
echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here." |
310 |
|
return 1 |
311 |
|
fi |
312 |
|
f_tcall=`nm genmake_tcomp.o | grep tcall | cut -d ' ' -f 3` |
313 |
|
RETVAL=$? |
314 |
|
if test "x$RETVAL" != x0 ; then |
315 |
|
FC_NAMEMANGLE=$default_nm |
316 |
|
echo |
317 |
|
echo "WARNING: The \"nm\" command failed." |
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 |
|
|
323 |
|
c_a=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'` |
324 |
|
f_a=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'` |
325 |
|
c_b=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'` |
326 |
|
f_b=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'` |
327 |
|
|
328 |
|
nmangle="X" |
329 |
|
if test "x$c_a" != "x$f_a" ; then |
330 |
|
comm="echo x$f_a | sed -e 's|x$c_a||'" |
331 |
|
a=`eval $comm` |
332 |
|
nmangle="$a ## $nmangle" |
333 |
|
fi |
334 |
|
if test "x$c_b" != "x$f_b" ; then |
335 |
|
comm="echo x$f_b | sed -e 's|x$c_b||'" |
336 |
|
b=`eval $comm` |
337 |
|
nmangle="$nmangle ## $b" |
338 |
|
fi |
339 |
|
|
340 |
|
FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) $nmangle" |
341 |
|
} |
342 |
|
|
343 |
# Set defaults here |
# Set defaults here |
344 |
COMMANDL="$0 $@" |
COMMANDL="$0 $@" |
349 |
KPP= |
KPP= |
350 |
FC= |
FC= |
351 |
LINK= |
LINK= |
352 |
DEFINES="-DWORDLENGTH=4" |
# DEFINES="-DWORDLENGTH=4" |
353 |
|
DEFINES= |
354 |
PACKAGES= |
PACKAGES= |
355 |
ENABLE= |
ENABLE= |
356 |
DISABLE= |
DISABLE= |
770 |
fi |
fi |
771 |
rm -f genmake_tcomp* |
rm -f genmake_tcomp* |
772 |
|
|
773 |
echo -n " The name mangling convention for $FC is... " |
echo " The name mangling convention for $FC is... " |
774 |
|
#FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) X ## _" |
775 |
if test "x$FC_NAMEMANGLE" = x ; then |
if test "x$FC_NAMEMANGLE" = x ; then |
776 |
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 |
|
777 |
fi |
fi |
778 |
|
echo " '$FC_NAMEMANGLE'" |
779 |
echo "$FC_NAMEMANGLE" > FC_NAMEMANGLE.h.template |
echo "$FC_NAMEMANGLE" > FC_NAMEMANGLE.h.template |
780 |
cmp FC_NAMEMANGLE.h FC_NAMEMANGLE.h.template > /dev/null 2>&1 |
cmp FC_NAMEMANGLE.h FC_NAMEMANGLE.h.template > /dev/null 2>&1 |
781 |
RETVAL=$? |
RETVAL=$? |
782 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
783 |
mv -f FC_NAMEMANGLE.h.template FC_NAMEMANGLE.h |
mv -f FC_NAMEMANGLE.h.template FC_NAMEMANGLE.h |
784 |
fi |
fi |
|
rm -f genmake_tcomp* |
|
785 |
|
|
786 |
|
|
787 |
printf "\n=== Setting defaults ===\n" |
printf "\n=== Setting defaults ===\n" |