--- MITgcm/tools/genmake2 2004/06/30 01:19:29 1.82 +++ MITgcm/tools/genmake2 2005/01/06 15:09:54 1.115 @@ -1,6 +1,6 @@ -#! /usr/bin/env sh +#! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.82 2004/06/30 01:19:29 cnh Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.115 2005/01/06 15:09:54 edhill Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -122,16 +122,16 @@ stop end EOF - test -e Makefile && mv -f Makefile Makefile.bak + test -f Makefile && mv -f Makefile Makefile.bak cat <> Makefile -%.$tfs : %.F .SUFFIXES: -genmake_hello.$tfs: genmake_hello.F - $LN genmake_hello.F genmake_hello.$tfs +.SUFFIXES: .$tfs .F +.F.$tfs: + $LN \$< \$@ EOF $MAKE "genmake_hello."$tfs > /dev/null 2>&1 RETVAL=$? - if test "x$RETVAL" != x0 -o ! -e "genmake_hello."$tfs ; then + if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then if test "x$FS" = x ; then FS='for' FS90='fr9' @@ -149,7 +149,7 @@ fi fi rm -f genmake_hello.* Makefile - test -e Makefile && mv -f Makefile.bak Makefile + test -f Makefile && mv -f Makefile.bak Makefile # If we make it here, use the extensions FS=$tfs @@ -158,6 +158,85 @@ } +look_for_makedepend() { + + # The "original" makedepend is part of the Imake system that is + # most often distributed with XFree86 or with an XFree86 source + # package. As a result, many machines (eg. generic Linux) do not + # have a system-default "makedepend" available. For those + # systems, we have two fall-back options: + # + # 1) a makedepend implementation shipped with the cyrus-imapd + # package: ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/ + # + # 2) a known-buggy xmakedpend shell script + # + # So the choices are, in order: + # + # 1) use the user-specified program + # 2) use a system-wide default + # 3) locally build and use the cyrus implementation + # 4) fall back to the buggy local xmakedpend script + # + if test "x${MAKEDEPEND}" = x ; then + which makedepend > /dev/null 2>&1 + RV0=$? + cat <> genmake_tc.f + program test + write(*,*) 'test' + stop + end +EOF + makedepend genmake_tc.f > /dev/null 2>&1 + RV1=$? + if test "x${RV0}${RV1}" = x00 ; then + MAKEDEPEND=makedepend + else + echo " a system-default makedepend was not found." + + # Try to build the cyrus implementation + build_cyrus_makedepend + RETVAL=$? + if test "x$RETVAL" != x0 ; then + MAKEDEPEND='$(TOOLSDIR)/xmakedepend' + 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() { + rm -f ./genmake_cy_md + ( + cd $ROOTDIR/tools/cyrus-imapd-makedepend \ + && ./configure > /dev/null 2>&1 \ + && make > /dev/null 2>&1 + if test -x ./makedepend.exe ; then + $LN ./makedepend.exe ./makedepend + fi + ./makedepend ifparser.c > /dev/null 2>&1 \ + && echo "true" + ) > ./genmake_cy_md + grep true ./genmake_cy_md > /dev/null 2>&1 + RETVAL=$? + rm -f ./genmake_cy_md + if test "x$RETVAL" = x0 ; then + MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend' + return 0 + else + echo "WARNING: unable to build cyrus-imapd-makedepend" + return 1 + fi +} + # Guess possible config options for this host find_possible_configs() { @@ -188,62 +267,49 @@ CPP="cpp -traditional -P" fi - # The "original" makedepend is part of the Imake system that is - # most often distributed with XFree86 or with an XFree86 source - # package. As a result, many machines (eg. generic Linux) do not - # have a system-default "makedepend" available. For those - # systems, we have two fall-back options: - # - # 1) a makedepend implementation shipped with the cyrus-imapd - # package: ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/ - # - # 2) a known-buggy xmakedpend shell script - # - # So the choices are, in order: - # - # 1) use the user-specified program - # 2) use a system-wide default - # 3) locally build and use the cyrus implementation - # 4) fall back to the buggy local xmakedpend script - # - if test "x${MAKEDEPEND}" = x ; then - which makedepend > /dev/null 2>&1 - RV0=$? - cat <> genmake_tc.f - program test - write(*,*) 'test' - stop - end + look_for_makedepend + + #================================================================ + # look for possible C compilers + tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc" + p_CC= + for c in $tmp ; do + 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 + RETVAL=$? + if test "x${RETVAL}" = x0 ; then + p_CC="$p_CC $c" + fi + done + rm -f ./genmake_hello.c ./genmake_hello + if test "x${p_CC}" = x ; then + cat 1>&2 < /dev/null 2>&1 - RV1=$? - if test ! "x${RV0}${RV1}" = x00 ; then - echo " a system-default makedepend was not found." - - # Try to build the cyrus impl - rm -f ./genmake_cy_md - ( - cd $ROOTDIR/tools/cyrus-imapd-makedepend \ - && ./configure > /dev/null 2>&1 \ - && make > /dev/null 2>&1 - if test -x ./makedepend.exe ; then - $LN ./makedepend.exe ./makedepend - fi - ./makedepend ifparser.c > /dev/null 2>&1 \ - && echo "true" - ) > ./genmake_cy_md - grep true ./genmake_cy_md > /dev/null 2>&1 - RETVAL=$? - if test "x$RETVAL" = x0 ; then - MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend' - else - MAKEDEPEND='$(TOOLSDIR)/xmakedepend' - fi - rm -f ./genmake_cy_md - fi + exit 1 + else + echo " The possible C compilers found in your path are:" + echo " "$p_CC + if test "x$CC" = x ; then + CC=`echo $p_CC | $AWK '{print $1}'` + echo " Setting C compiler to: "$CC + fi fi - # look for possible fortran compilers + #================================================================ + # look for possible FORTRAN compilers tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95" p_FC= for c in $tmp ; do @@ -269,7 +335,7 @@ 1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"), 2) a command-line option (eg. "-fc NAME"), or - 3) the MITGCM_FC environment variable. + 3) the FC or MITGCM_FC environment variables. EOF exit 1 @@ -440,6 +506,11 @@ will search for a working compiler by trying a list of "usual suspects" such as g77, f77, etc. + -cc NAME | --cc NAME | -cc=NAME | --cc=NAME + Use "NAME" as the C compiler. By default, genmake + will search for a working compiler by trying a list of + "usual suspects" such as gcc, c89, cc, etc. + -[no]ieee | --[no]ieee Do or don't use IEEE numerics. Note that this option *only* works if it is supported by the OPTFILE that @@ -449,8 +520,8 @@ Include MPI header files and link to MPI libraries -mpi=PATH | --mpi=PATH Include MPI header files and link to MPI libraries using MPI_ROOT - set to PATH. i.e. Include files from $PATH/include, link to libraries - from $PATH/lib and use binaries from $PATH/bin. + set to PATH. i.e. Include files from \$PATH/include, link to libraries + from \$PATH/lib and use binaries from \$PATH/bin. -bash NAME Explicitly specify the Bourne or BASH shell to use @@ -475,6 +546,12 @@ # Build a CPP macro to automate calling C routines from FORTRAN get_fortran_c_namemangling() { + + #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\"" + if test ! "x$FC_NAMEMANGLE" = x ; then + return 0 + fi + default_nm="#define FC_NAMEMANGLE(X) X ## _" cat > genmake_test.c </dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3` RETVAL=$? if test "x$RETVAL" != x0 ; then FC_NAMEMANGLE=$default_nm @@ -522,7 +599,7 @@ EOF return 1 fi - f_tcall=`nm genmake_tcomp.o | grep 'T ' | grep tcall | cut -d ' ' -f 3` + f_tcall=`nm genmake_tcomp.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3` RETVAL=$? if test "x$RETVAL" != x0 ; then FC_NAMEMANGLE=$default_nm @@ -598,10 +675,61 @@ } +check_HAVE_STAT() { + get_fortran_c_namemangling + cat < genmake_tc_1.c +$FC_NAMEMANGLE +#include +#include +#include +#include +#include +void FC_NAMEMANGLE(tfsize) ( int *nbyte ) +{ + char name[512]; + struct stat astat; + + name[0] = 'a'; name[1] = '\0'; + if (! stat(name, &astat)) + *nbyte = (int)(astat.st_size); + else + *nbyte = -1; +} +EOF + make genmake_tc_1.o >> genmake_tc.log 2>&1 + RET_C=$? + cat < genmake_tc_2.f + program hello + integer nbyte + call tfsize(nbyte) + print *," HELLO WORLD", nbyte + end program hello +EOF + $FC $FFLAGS -o genmake_tc genmake_tc_2.f genmake_tc_1.o >> genmake_tc.log 2>&1 + RET_F=$? + test -x ./genmake_tc && ./genmake_tc >> genmake_tc.log 2>&1 + RETVAL=$? + if test "x$RETVAL" = x0 ; then + HAVE_STAT=t + DEFINES="$DEFINES -DHAVE_STAT" + fi + rm -f genmake_tc* +} + + check_netcdf_libs() { + if test ! "x$SKIP_NETCDF_CHECK" = x ; then + return + fi + echo "" > genmake_tnc.log cat < genmake_tnc.for program fgennc #include "netcdf.inc" +EOF + if test ! "x$MPI" = x ; then + echo '#include "mpif.h"' >> genmake_tnc.for + fi + cat <> genmake_tnc.for integer iret, ncid, xid iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid) IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret) @@ -611,22 +739,41 @@ IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret) end EOF - $CPP genmake_tnc.for > genmake_tnc.f \ - && $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1 + echo "Executing:" > genmake_tnc.log + echo " $CPP $DEFINES $INCLUDES genmake_tnc.for > genmake_tnc.f" \ + > genmake_tnc.log + RET_CPP=f + $CPP $DEFINES $INCLUDES genmake_tnc.for > genmake_tnc.f 2>/dev/null \ + && RET_CPP=t + if test "x$RET_CPP" = xf ; then + echo " WARNING: CPP failed to pre-process the netcdf test." \ + > genmake_tnc.log + echo " Please check that \$INCLUDES is properly set." \ + > genmake_tnc.log + fi + echo "Executing:" > genmake_tnc.log + echo " $FC $FFLAGS $FOPTIM -c genmake_tnc.f" > genmake_tnc.log + echo " $LINK -o genmake_tnc.o $LIBS" > genmake_tnc.log + $FC $FFLAGS $FOPTIM -c genmake_tnc.f >> genmake_tnc.log 2>&1 \ + && $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1 RET_COMPILE=$? - test -x ./genmake_tnc && ./genmake_tnc >> genmake_tnc.log 2>&1 - RETVAL=$? - if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then + + #EH3 Remove test program execution for machines that either disallow + #EH3 execution or cannot support it (eg. cross-compilers) + #EH3 + #EH3 test -x ./genmake_tnc && ./genmake_tnc >> genmake_tnc.log 2>&1 + #EH3 RETVAL=$? + #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then + + if test "x$RET_COMPILE" = x0 ; then HAVE_NETCDF=t else # try again with "-lnetcdf" added to the libs - $CPP genmake_tnc.for > genmake_tnc.f \ - && $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \ - $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1 + $CPP $DEFINES $INCLUDES genmake_tnc.for > genmake_tnc.f 2>/dev/null \ + && $FC $FFLAGS $FOPTIM -c genmake_tnc.f >> genmake_tnc.log 2>&1 \ + && $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1 RET_COMPILE=$? - test -x ./genmake_tnc && ./genmake_tnc >> genmake_tnc.log 2>&1 - RETVAL=$? - if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then + if test "x$RET_COMPILE" = x0 ; then LIBS="$LIBS -lnetcdf" HAVE_NETCDF=t else @@ -649,20 +796,21 @@ LN= S64= KPP= -FC= -CPP= +#FC= +#CC=gcc +#CPP= LINK= DEFINES= PACKAGES= ENABLE= DISABLE= MAKEFILE= -MAKEDEPEND= +#MAKEDEPEND= PDEPEND= DUMPSTATE=t PDEFAULT= OPTFILE= -INCLUDES="-I." +INCLUDES="-I. $INCLUDES" FFLAGS= FOPTIM= CFLAGS= @@ -681,6 +829,7 @@ HAVE_FDATE= FC_NAMEMANGLE= HAVE_CLOC= +HAVE_STAT= HAVE_NETCDF= HAVE_ETIME= @@ -693,11 +842,13 @@ G2ARGS= BASH= PWD=`pwd` -MAKE=make -AWK=awk -THISHOSTNAME=`hostname` +test "x$MAKE" = x && MAKE=make +test "x$AWK" = x && AWK=awk +THISHOST=`hostname` THISCWD=`pwd` THISDATE=`date` +THISUSER=`echo $USER` +THISVER= MACHINE=`uname -a` EXECUTABLE= EXEHOOK= @@ -731,7 +882,7 @@ # The following state is not directly set by command-line switches gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM " gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS" -gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE" +gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE" gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF" gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME" @@ -763,7 +914,7 @@ fi done printf " getting local config information: " -if test -e $gm_local ; then +if test -f $gm_local ; then echo "using $gm_local" . $gm_local # echo "DISABLE=$DISABLE" @@ -772,7 +923,7 @@ echo "none found" fi -# echo "$0::$1:$2:$3:$4:$5:$6:$7:" +#echo "$0::$1:$2:$3:$4:$5:$6:$7:" #OPTIONS= #n=0 #for i ; do @@ -784,7 +935,7 @@ #done #parse_options ac_prev= -for ac_option ; do +for ac_option in "$@" ; do G2ARGS="$G2ARGS \"$ac_option\"" @@ -880,7 +1031,12 @@ # ac_prev=cpp ;; # -cpp=* | --cpp=*) # CPP=$ac_optarg ;; - + + -cc | --cc) + ac_prev=CC ;; + -cc=* | --cc=*) + CC=$ac_optarg ;; + -fortran | --fortran | -fc | --fc) ac_prev=FC ;; -fc=* | --fc=*) @@ -951,8 +1107,10 @@ echo fi +# Find the MITgcm ${ROOTDIR} if test "x${ROOTDIR}" = x ; then - if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then + tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'` + if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then ROOTDIR=".." else for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do @@ -976,6 +1134,11 @@ exit 1 fi +# Find the MITgcm ${THISVER} +if test -f "${ROOTDIR}/doc/tag-index" ; then + THISVER=`grep checkpoint ${ROOTDIR}/doc/tag-index | head -1` +fi + echo " getting OPTFILE information: " if test "x${OPTFILE}" = x ; then if test "x$MITGCM_OF" = x ; then @@ -1035,7 +1198,7 @@ fi fi -# Check that FC, LINK, CPP, S64, LN, and MAKE are defined. If not, +# Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined. If not, # either set defaults or complain and abort! if test ! "x$BASH" = x ; then # add a trailing space so that it works within the Makefile syntax (see below) @@ -1051,6 +1214,16 @@ EOF exit 1 fi +if test "x$CC" = x ; then + 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 LINK=$FC fi @@ -1085,9 +1258,7 @@ else rm -f test_cpp fi -if test "x$MAKEDEPEND" = x ; then - MAKEDEPEND=makedepend -fi +look_for_makedepend if test "x$LN" = x ; then LN="ln -s" fi @@ -1184,6 +1355,15 @@ fi rm -f genmake_t* +printf " Can we use stat() through C calls... " +check_HAVE_STAT +if test "x$HAVE_STAT" != x ; then + echo "yes" +else + echo "no" +fi +rm -f genmake_t* + printf " Can we create NetCDF-enabled binaries... " check_netcdf_libs if test "x$HAVE_NETCDF" != x ; then @@ -1216,7 +1396,8 @@ fi if test "x${EXEDIR}" = x ; then - if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then + tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'` + if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then EXEDIR=../exe else EXEDIR=. @@ -1235,7 +1416,30 @@ exit 1 fi if test "x$S64" = x ; then - S64='$(TOOLSDIR)/set64bitConst.sh' + echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1 + RETVAL=$? + if test "x${RETVAL}" = x0 ; then + S64='$(TOOLSDIR)/set64bitConst.sh' + else + echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1 + RETVAL=$? + if test "x${RETVAL}" = x0 ; then + S64='$(TOOLSDIR)/set64bitConst.csh' + else + cat < /dev/null; done + RET=1 + while test $RET = 1 ; do expand_pkg_groups; RET=$?; done echo " after group expansion packages are: $PACKAGES" fi fi @@ -1379,6 +1584,41 @@ rm -f ./.tmp_pack echo " packages are: $PACKAGES" +# Check availability of NetCDF and then either build the MNC template +# files or delete mnc from the list of available packages. +echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1 +RETVAL=$? +if test "x$RETVAL" = x0 ; then + if test "x$HAVE_NETCDF" != xt ; then + cat < make_mnc.errors 2>&1 + RETVAL=$? + if test "x${RETVAL}" = x0 ; then + rm -f make_mnc.errors + else + echo "Error: problem encountered while building source files in pkg/mnc:" + cat make_mnc.errors 1>&2 + exit 1 + fi + fi +fi + echo " applying package dependency rules" ck= while test "x$ck" != xtt ; do @@ -1443,7 +1683,8 @@ echo " the dependency rules for \"$dname\"" exit 1 fi - i=$(( $i + 1 )) + i=`echo "$i + 1" | bc -l` + #i=$(( $i + 1 )) done ck=$ck"t" done @@ -1462,33 +1703,6 @@ fi done -# Build MNC templates and check for ability to build and use NetCDF -echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1 -RETVAL=$? -if test "x$RETVAL" = x0 ; then - ( cd $ROOTDIR"/pkg/mnc" && $MAKE templates ) > make_mnc.errors 2>&1 - RETVAL=$? - if test "x${RETVAL}" = x0 ; then - rm -f make_mnc.errors - else - echo "Error: problem encountered while building source files in pkg/mnc:" - cat make_mnc.errors 1>&2 - exit 1 - fi - if test "x$HAVE_NETCDF" != xt ; then - cat <> srclist.inc @@ -1682,7 +1896,7 @@ echo "" >> hlist.inc echo "" >> ad_flow_files.inc -if test -e $MAKEFILE ; then +if test -f $MAKEFILE ; then mv -f $MAKEFILE "$MAKEFILE.bak" fi echo " Writing makefile: $MAKEFILE" @@ -1693,7 +1907,7 @@ echo "# by the command:" >> $MAKEFILE echo "# $0 $G2ARGS" >> $MAKEFILE echo "# executed by:" >> $MAKEFILE -echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE +echo "# ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE EXE_AD=$EXECUTABLE"_ad" EXE_FTL=$EXECUTABLE"_ftl" @@ -1739,7 +1953,7 @@ DISABLED_PACKAGES = ${DISABLED_PACKAGES} # These files are created by Makefile -SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h +SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h BUILD_INFO.h EOF @@ -1758,6 +1972,8 @@ FC = ${FC} # Fortran compiler F90C = ${F90C} +# C compiler +CC = ${CC} # Link editor LINK = ${LINK} ${LDADD} @@ -1780,7 +1996,7 @@ NOOPTFILES = ${NOOPTFILES} NOOPTFLAGS = ${NOOPTFLAGS} # Flags and libraries needed for linking -LIBS = ${LIBS} \$(XLIBS) +LIBS = ${LIBS} # Name of the Mekfile MAKEFILE=${MAKEFILE} @@ -1797,7 +2013,7 @@ echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE echo >> $MAKEFILE echo '.SUFFIXES:' >> $MAKEFILE -echo '.SUFFIXES: .o .F .p .'$FS' .c .F90 .'$FS90 >> $MAKEFILE +echo '.SUFFIXES: .o .'$FS' .p .F .c .'$FS90' .F90' >> $MAKEFILE rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc rm -f ad_flow_files.inc @@ -1841,7 +2057,7 @@ cleanlinks: -find . -type l -exec rm {} \; -# Special targets ($SPECIAL_FILES) which are create by make +# Special targets (SPECIAL_FILES) which are create by make ${PACKAGES_DOT_H}: @echo Creating \$@ ... @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@ @@ -1852,9 +2068,21 @@ @echo Creating \$@ ... echo "$FC_NAMEMANGLE" > \$@ +BUILD_INFO.h: + @echo Creating \$@ ... +EOF + +test ! "x$THISVER" = x && echo " -echo \"#define THISVER '$THISVER'\" > \$@" >> $MAKEFILE +test ! "x$THISUSER" = x && echo " -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE +test ! "x$THISDATE" = x && echo " -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE +test ! "x$THISHOST" = x && echo " -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE + +cat >>$MAKEFILE < \$@ @@ -1939,6 +2167,11 @@ ad_tamc: ad_tamc_output.o \$(OBJFILES) \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) +adonlyfwd: + patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff + +adtrick: + patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff # ... FTL ... ftlall: ftl_taf @@ -1974,11 +2207,27 @@ # ... SVD ... svdtaf: ad_taf_output.f ftl_taf_output.f -svdall: svd_taf + @echo "--->>> Only ran TAF to generate SVD code! <<<---" + @echo "--->>> Do make svdall afterwards to compile. <<<---" +svdall: svd_touch svd_taf -svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES) +svd_taf: \$(OBJFILES) \$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS) + @echo "--->>> Only COMPILE svd code! <<<---" + @echo "--->>> Assumes you previously <<<---" + @echo "--->>> did make svdtaf <<<---" + +svd_touch: + @echo "--->>> Only COMPILE svd code! <<<---" + @echo "--->>> Assumes you previously <<<---" + @echo "--->>> did make svdtaf <<<---" + touch ad_taf_output.f ftl_taf_output.f + \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.f + \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.f + @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template + cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h + -rm -f ftl_config.template #=========================================