--- MITgcm/tools/genmake2 2010/11/04 18:01:22 1.212 +++ MITgcm/tools/genmake2 2010/12/26 01:04:45 1.218 @@ -1,6 +1,7 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.212 2010/11/04 18:01:22 jmc Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.218 2010/12/26 01:04:45 jmc Exp $ +# $Name: $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -8,6 +9,167 @@ # modified by aja 01/00 # rewritten in bash by eh3 08/03 +# Explain usage +usage() { +cat <> $LOGFILE + echo "running: look_for_makedepend()" >> $LOGFILE + if test "x${MAKEDEPEND}" != x ; then + echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1 + RETVAL=$? + if test x"$RETVAL" = x0 ; then + build_cyrus_makedepend + RETVAL=$? + if test "x$RETVAL" != x0 ; then + echo "WARNING: unable to build cyrus-makedepend. Try 'makedepend'" + MAKEDEPEND= + fi + else + echo " --> MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE + fi + fi if test "x${MAKEDEPEND}" = x ; then which makedepend > /dev/null 2>&1 RV0=$? @@ -209,29 +386,24 @@ test -f $MAKEFILE".tst" && mv -f $MAKEFILE".tst" $MAKEFILE if test "x${RV0}${RV1}" = x00 ; then MAKEDEPEND=makedepend + echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE else - echo " a system-default makedepend was not found." - + echo " system-default makedepend not found. Try to build cyrus-makedepend" # Try to build the cyrus implementation build_cyrus_makedepend RETVAL=$? if test "x$RETVAL" != x0 ; then + echo "WARNING: unable to build cyrus-makedepend. Use local xmakedepend" MAKEDEPEND='$(TOOLSDIR)/xmakedepend' + echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE 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() { + echo >> $LOGFILE + echo "running: build_cyrus_makedepend()" >> $LOGFILE rm -f ./genmake_cy_md ( cd $ROOTDIR/tools/cyrus-imapd-makedepend \ @@ -248,14 +420,14 @@ rm -f ./genmake_cy_md if test "x$RETVAL" = x0 ; then MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend' + echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE return 0 else - echo "WARNING: unable to build cyrus-imapd-makedepend" + echo "WARNING: fail to build cyrus-imapd-makedepend" >> $LOGFILE return 1 fi } - build_embed_encode() { printf " building the embed-encode utility... " @@ -289,23 +461,27 @@ DEFINES="$DEFINES -DHAVE_EMBED_SRC" } - # look for possible C compilers look_for_C_compilers() { - tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc icc" - p_CC= - for c in $tmp ; do - rm -f ./genmake_hello.c ./genmake_hello - cat >> genmake_hello.c << EOF + echo >> $LOGFILE + echo "running: look_for_C_compilers()" >> $LOGFILE + 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 + tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc icc" + p_CC= + for c in $tmp ; do + COMM="$c $CFLAGS -o genmake_hello genmake_hello.c" + echo $COMM >> $LOGFILE + $COMM >> $LOGFILE 2>&1 RETVAL=$? if test "x${RETVAL}" = x0 ; then + echo " $c test successful" >> $LOGFILE p_CC="$p_CC $c" fi done @@ -321,18 +497,20 @@ EOF exit 1 else - echo " The possible C compilers found in your path are:" - echo " "$p_CC + echo " The possible C compilers found in your path are: $p_CC" | tee -a $LOGFILE if test "x$CC" = x ; then CC=`echo $p_CC | $AWK '{print $1}'` echo " Setting C compiler to: "$CC fi fi + echo " --> set CC='$CC'" >> $LOGFILE } # Guess possible config options for this host find_possible_optfile() { + echo >> $LOGFILE + echo "running: find_possible_optfile()" >> $LOGFILE tmp1=`uname`"_"`uname -m` tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'` @@ -342,48 +520,32 @@ 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_C_compilers + echo " The platform appears to be: $PLATFORM" | tee -a $LOGFILE #================================================================ # look for possible FORTRAN compilers - tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc ifort f90 f95 mpif77 mpf77 mpxlf95 gfortran g95" + echo " look for possible FORTRAN compilers" >> $LOGFILE + tmp="$MITGCM_FC $FC efc gfortran g77 f77 pgf77 pgf95 ifc ifort f90 f95 mpif77 mpf77 mpxlf95 g95" p_FC= - for c in $tmp ; do - rm -f ./hello.f ./hello - cat >> hello.f <> genmake_hello.f < /dev/null 2>&1 + for f in $tmp ; do + COMM="$f -o genmake_hello genmake_hello.f" + echo $COMM >> $LOGFILE + $COMM >> $LOGFILE 2>&1 RETVAL=$? if test "x${RETVAL}" = x0 ; then - p_FC="$p_FC $c" + echo " $f test successful" >> $LOGFILE + p_FC="$p_FC $f" fi done - rm -f ./hello.f ./hello + rm -f ./genmake_hello.f ./genmake_hello if test "x${p_FC}" = x ; then cat 1>&2 < genmake_test.c <> $LOGFILE 2>&1 COMM="$CC $CFLAGS -c genmake_test.c" echo ' '$COMM >> $LOGFILE $COMM >> $LOGFILE 2>&1 @@ -741,7 +741,6 @@ echo " --> set FC_NAMEMANGLE='$FC_NAMEMANGLE'" >> $LOGFILE } - check_HAVE_CLOC() { echo >> $LOGFILE echo "running: check_HAVE_CLOC()" >> $LOGFILE @@ -787,7 +786,6 @@ echo " --> set HAVE_CLOC='$HAVE_CLOC'" >> $LOGFILE } - check_HAVE_SIGREG() { if test ! "x$HAVE_SIGREG" = x ; then return @@ -850,7 +848,6 @@ echo " --> set HAVE_SIGREG='$HAVE_SIGREG'" >> $LOGFILE } - check_HAVE_SETRLSTK() { if test "x$HAVE_SETRLSTK" = xt ; then DEFINES="$DEFINES -DHAVE_SETRLSTK" @@ -899,7 +896,6 @@ echo " --> set HAVE_SETRLSTK='$HAVE_SETRLSTK'" >> $LOGFILE } - check_HAVE_STAT() { echo >> $LOGFILE echo "running: check_HAVE_STAT()" >> $LOGFILE @@ -947,7 +943,6 @@ echo " --> set HAVE_STAT='$HAVE_STAT'" >> $LOGFILE } - check_netcdf_libs() { if test ! "x$SKIP_NETCDF_CHECK" = x ; then return @@ -1041,7 +1036,6 @@ } - ############################################################################### # Sequential part of script starts here ############################################################################### @@ -1073,6 +1067,7 @@ FEXTRAFLAGS= USE_EXTENDED_SRC= EXTENDED_SRC_FLAG= +GET_FC_VERSION= CFLAGS= KFLAGS1= KFLAGS2= @@ -1152,7 +1147,7 @@ # The following state can be set directly by command-line switches gm_s1="OPTFILE PKG_DEPEND PKG_GROUPS MAKEFILE MAKEDEPEND PLATFORM ROOTDIR MODS DISABLE ENABLE" -gm_s2="FC IEEE USE_R4 TS PAPIS PCLS PAPI PCL HPMT GSL DEVEL MPI OMP DUMPSTATE STANDARDDIRS" +gm_s2="FC CC IEEE USE_R4 TS PAPIS PCLS PAPI PCL HPMT GSL DEVEL MPI OMP DUMPSTATE STANDARDDIRS" # The following state is not directly set by command-line switches gm_s3="LN S64 LINK MAKE PACKAGES INCLUDES FFLAGS FOPTIM FEXTRAFLAGS" @@ -1390,7 +1385,6 @@ done - if test -f ./.genmakerc ; then echo echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\"" @@ -1411,8 +1405,8 @@ for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then ROOTDIR=$d - printf "Warning: ROOTDIR was not specified but there appears to be" - echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it." + printf "Warning: ROOTDIR was not specified ;" + echo " try using a local copy of MITgcm found at \"$ROOTDIR\"" break fi done @@ -1519,17 +1513,14 @@ EOF exit 1 fi +if test "x$GET_FC_VERSION" != x ; then + echo "Get compiler version using: $FC $GET_FC_VERSION" >> $LOGFILE + $FC $GET_FC_VERSION >> $LOGFILE 2>&1 + echo "<-- compiler version ----" >> $LOGFILE +fi if test "x$CC" = x ; then look_for_C_compilers -# CC=cc -# cat <&2 -# Error: no C compiler: please specify using one of the following: -# 1) within the options file ("CC=...") as specified by "-of=OPTFILE" -# 2) the "-cc=XXX" command-line option -# 3) the "./genmake_local" file -# EOF -# exit 1 fi if test "x$LINK" = x ; then @@ -1816,7 +1807,6 @@ ENABLE="$ENABLE embed_files" fi - printf "\n=== Setting defaults ===\n" printf " Adding MODS directories: " for d in $MODS ; do @@ -2720,7 +2710,7 @@ Clean: @make clean @make cleanlinks - -rm -f \$(SPECIAL_FILES) f90mkdepend.log + -rm -f \$(SPECIAL_FILES) f90mkdepend.log $MAKEFILE.old -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log -rm -f genmake_warnings genmake_errors make.log @@ -2728,7 +2718,7 @@ # and output from a run (plus log files from testreport) CLEAN: @make Clean - -rm -f \$(EXECUTABLE) \$(EXE_AD) *.bak $MAKEFILE.old + -rm -f \$(EXECUTABLE) \$(EXE_AD) *.bak -rm -f $LOGFILE genmake_state genmake_*optfile genmake.tr_log make.tr_log -find \$(EXEDIR) -name "*.meta" -exec rm {} \; -find \$(EXEDIR) -name "*.data" -exec rm {} \; @@ -2792,6 +2782,8 @@ \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ .$FS.o: \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< +.F.o: + \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< .F90.$FS90: \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ .FF90.f$FS90: @@ -2926,7 +2918,6 @@ ftl_tamc: ftl_tamc_output.o \$(OBJFILES) \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS) - # ... SVD ... svdtaf: ad_taf_output.$FS ftl_taf_output.$FS @echo "--->>> Only ran TAF to generate SVD code! <<<---" @@ -3250,7 +3241,6 @@ $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > AD_CONFIG.h fi - # Write the "state" for future records if test "x$DUMPSTATE" = xt ; then printf "" > genmake_state