--- MITgcm/tools/genmake2 2003/12/04 15:00:01 1.52 +++ MITgcm/tools/genmake2 2004/04/08 21:32:11 1.76 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.52 2003/12/04 15:00:01 adcroft Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.76 2004/04/08 21:32:11 edhill Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -37,7 +37,7 @@ grep -i "$strng" $file > /dev/null 2>&1 RETVAL=$? if test "x${RETVAL}" = x0 ; then - echo -n "Error: In $file there is an illegal line: " + printf "Error: In $file there is an illegal line: " grep -i "$strng" $file return 1 fi @@ -67,18 +67,106 @@ done PACKAGES=$new_packages rm -f ./p[1,2].tmp + return $matched else echo "Warning: can't read package groups definition file: $PKG_GROUPS" fi } +# Check for broken environments (eg. cygwin, MacOSX w/HFS+) that +# cannot distinguish [*.F/*.F90] from [*.f/*.f90] files. +check_for_broken_Ff() { + # Do we have defaults for $FS and/or $FS90 ? + tfs=f + tfs9=f90 + if test "x$FS" != x ; then + tfs="$FS" + fi + if test "x$FS90" != x ; then + tfs9="$FS90" + fi + + # First check the ability to create a *.F/.f pair. + cat <> genmake_hello.F + program hello + write(*,*) 'hi' + stop + end +EOF + cp genmake_hello.F "genmake_hello."$tfs > /dev/null 2>&1 + RETVAL=$? + if test "x$RETVAL" != x0 ; then + if test "x$FS" = x ; then + FS='fs' + FS90='fs90' + check_for_broken_Ff + else + cat <&1 +ERROR: Your file system cannot distinguish between *.F and *.f files + (fails the "cp" test) and this program cannot find a suitable + replacement extension. Please try a different build environment or + contact the list for help. + +EOF + exit -1 + fi + return + fi + rm -f genmake_hello.* + + # Check the ability of ${MAKE} and ${LN} to use the current set + # of extensions. + cat <> genmake_hello.F + program hello + write(*,*) 'hi' + stop + end +EOF + test -e Makefile && mv -f Makefile Makefile.bak + cat <> Makefile +.SUFFIXES: +genmake_hello.$tfs: genmake_hello.F + $LN genmake_hello.F genmake_hello.$tfs +EOF + $MAKE "genmake_hello."$tfs > /dev/null 2>&1 + RETVAL=$? + if test "x$RETVAL" != x0 -o ! -e "genmake_hello."$tfs ; then + if test "x$FS" = x ; then + FS='fs' + FS90='fs9' + check_for_broken_Ff + else + cat <&1 +ERROR: Your file system cannot distinguish between *.F and *.f files + (fails the "make/ln" test) and this program cannot find a suitable + replacement extension. Please try a different build environment or + contact the list for help. + +EOF + exit -1 + return + fi + fi + rm -f genmake_hello.* Makefile + test -e Makefile && mv -f Makefile.bak Makefile + + # If we make it here, use the extensions + FS=$tfs + FS90=$tfs9 + return +} + + # Guess possible config options for this host find_possible_configs() { tmp1=`uname`"_"`uname -m` tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'` - PLATFORM=`echo $tmp3 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'` + tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'` + tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'` + tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'` + PLATFORM=$tmp3 OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")` echo " The platform appears to be: $PLATFORM" @@ -98,13 +186,47 @@ CPP="cpp -traditional -P" fi - # makedepend is not always available + # 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 + which makedepend > /dev/null 2>&1 RETVAL=$? - if test "x${RETVAL}" = x1 ; then - echo " makedepend was not found. Using xmakedpend instead." - MAKEDEPEND='$(TOOLSDIR)/xmakedepend' + if test ! "x${RETVAL}" = x0 ; 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 \ + && ./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 fi @@ -143,18 +265,27 @@ echo " "$p_FC if test "x$FC" = x ; then FC=`echo $p_FC | $AWK '{print $1}'` + echo " Setting FORTRAN compiler to: "$FC fi fi - for i in $p_FC ; do - p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i - if test -r $p_OF ; then - OPTFILE=$p_OF - echo " The options file: $p_OF" - echo " appears to match so we'll use it." - break - fi - done + if test "x$OPTFILE" = x ; then + OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC + if test ! -r $OPTFILE ; then + echo " I looked for the file "$OPTFILE" but did not find it" + fi + fi +# echo " The options file: $p_OF" +# echo " appears to match so we'll use it." +# for i in $p_FC ; do +#p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i +#if test -r $p_OF ; then +# OPTFILE=$p_OF +# echo " The options file: $p_OF" +# echo " appears to match so we'll use it." +# break +#fi +# done if test "x$OPTFILE" = x ; then cat 1>&2 < genmake_tnc.for + program fgennc +#include "netcdf.inc" + integer iret, ncid, xid + iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid) + IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret) + iret = nf_def_dim(ncid, 'X', 11, xid) + IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret) + iret = nf_close(ncid) + 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 + 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 + 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 + 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 + LIBS="$LIBS -lnetcdf" + HAVE_NETCDF=t + else + cat genmake_tnc.log >> genmake_warnings + fi + fi + rm -f genmake_tnc* +} + + + +############################################################################### +# Sequential part of script starts here +############################################################################### + # Set defaults here COMMANDL="$0 $@" @@ -443,8 +632,8 @@ S64= KPP= FC= +CPP= LINK= -# DEFINES="-DWORDLENGTH=4" DEFINES= PACKAGES= ENABLE= @@ -461,23 +650,29 @@ CFLAGS= KFLAGS1= KFLAGS2= +#LDADD= LIBS= KPPFILES= NOOPTFILES= NOOPTFLAGS= +MPI= +MPIPATH= # DEFINES checked by test compilation HAVE_SYSTEM= HAVE_FDATE= FC_NAMEMANGLE= HAVE_CLOC= +HAVE_NETCDF= MODS= TOOLSDIR= SOURCEDIRS= INCLUDEDIRS= -STANDARDDIRS= +STANDARDDIRS="USE_THE_DEFAULT" +G2ARGS= +BASH= PWD=`pwd` MAKE=make AWK=awk @@ -493,6 +688,8 @@ if test "x$MITGCM_IEEE" != x ; then IEEE=$MITGCM_IEEE fi +FS= +FS90= AUTODIFF_PKG_USED=f AD_OPTFILE= @@ -510,7 +707,7 @@ # The following state can be set directly by command-line switches gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE" -gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS" +gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STANDARDDIRS" # The following state is not directly set by command-line switches gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM " @@ -546,7 +743,7 @@ break fi done -echo -n " getting local config information: " +printf " getting local config information: " if test -e $gm_local ; then echo "using $gm_local" . $gm_local @@ -570,6 +767,8 @@ ac_prev= for ac_option ; do + G2ARGS="$G2ARGS \"$ac_option\"" + # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" @@ -611,6 +810,16 @@ -make=* | --make=* | -m=* | --m=*) MAKE=$ac_optarg ;; + -bash | --bash) + ac_prev=BASH ;; + -bash=* | --bash=*) + BASH=$ac_optarg ;; + + -makedepend | --makedepend | -md | --md) + ac_prev=MAKEDEPEND ;; + -makedepend=* | --makedepend=* | -md=* | --md=*) + MAKEDEPEND=$ac_optarg ;; + -makefile | --makefile | -ma | --ma) ac_prev=MAKEFILE ;; -makefile=* | --makefile=* | -ma=* | --ma=*) @@ -658,10 +867,26 @@ -fc=* | --fc=*) FC=$ac_optarg ;; + -fs | --fs) + ac_prev=FS ;; + -fs=* | --fs=*) + FS=$ac_optarg ;; + + -fs90 | --fs90) + ac_prev=FS90 ;; + -fs90=* | --fs90=*) + FS90=$ac_optarg ;; + -ieee | --ieee) IEEE=true ;; -noieee | --noieee) IEEE= ;; + + -mpi | --mpi) + MPI=true ;; + -mpi=* | --mpi=*) + MPIPATH=$ac_optarg + MPI=true ;; # -jam | --jam) # JAM=1 ;; @@ -714,7 +939,7 @@ for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then ROOTDIR=$d - echo -n "Warning: ROOTDIR was not specified but there appears to be" + printf "Warning: ROOTDIR was not specified but there appears to be" echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it." break fi @@ -748,7 +973,7 @@ . "$OPTFILE" RETVAL=$? if test "x$RETVAL" != x0 ; then - echo -n "Error: failed to source OPTFILE \"$OPTFILE\"" + printf "Error: failed to source OPTFILE \"$OPTFILE\"" echo "--please check that variable syntax is bash-compatible" exit 1 fi @@ -761,6 +986,9 @@ fi fi +# Check for broken systems that cannot correctly distinguish *.F and *.f files +check_for_broken_Ff + echo " getting AD_OPTFILE information: " if test "x${AD_OPTFILE}" = x ; then if test "x$MITGCM_AD_OF" = x ; then @@ -775,7 +1003,7 @@ . "$AD_OPTFILE" RETVAL=$? if test "x$RETVAL" != x0 ; then - echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\"" + printf "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\"" echo "--please check that variable syntax is bash-compatible" exit 1 fi @@ -790,6 +1018,10 @@ # Check that FC, 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) + BASH="$BASH " +fi if test "x$FC" = x ; then cat <&2 @@ -803,12 +1035,21 @@ if test "x$LINK" = x ; then LINK=$FC fi -if test "x$CPP" = x ; then - CPP="cpp" -fi if test "x$MAKE" = x ; then MAKE="make" fi +if test "x$CPP" = x ; then + CPP=cpp +fi +#EH3 === UGLY === +# The following is an ugly little hack to check for $CPP in /lib/ and +# it should eventually be replaced with a more general function that +# searches a combo of the user's path and a list of "usual suspects" +# to find the correct location for binaries such as $CPP. +for i in " " "/lib/" ; do + echo "#define A a" | $i$CPP > test_cpp 2>&1 && CPP=$i$CPP +done +#EH3 === UGLY === echo "#define A a" | $CPP > test_cpp 2>&1 RETVAL=$? if test "x$RETVAL" != x0 ; then @@ -845,9 +1086,13 @@ fi rm -f genmake_test_ln genmake_tlink +if test ! "x$MPI" = x ; then + echo " Turning on MPI cpp macros" + DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI" +fi printf "\n=== Checking system libraries ===\n" -echo -n " Do we have the system() command using $FC... " +printf " Do we have the system() command using $FC... " cat > genmake_tcomp.f < genmake_tcomp.f <&2 exit 1 fi fi +#same for exch2 +if test -r $ROOTDIR"/pkg/exch2/Makefile" ; then + echo " Making source files in exch2 from templates" + ( cd $ROOTDIR"/pkg/exch2/" && $MAKE ) > make_exch2.errors 2>&1 + RETVAL=$? + if test "x${RETVAL}" = x0 ; then + rm -f make_exch2.errors + else + echo "Error: problem encountered while building source files in exch2:" + cat make_exch2.errors 1>&2 + exit 1 + fi +fi + printf "\n=== Determining package settings ===\n" if test "x${PDEPEND}" = x ; then tmp=$ROOTDIR"/pkg/pkg_depend" @@ -1015,7 +1282,7 @@ def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'` RETVAL=$? if test "x${RETVAL}" != x0 ; then - echo -n "Error: can't parse default package list " + printf "Error: can't parse default package list " echo "-- please check PDEFAULT=\"$PDEFAULT\"" exit 1 fi @@ -1023,12 +1290,19 @@ PACKAGES="$PACKAGES $i" done echo " before group expansion packages are: $PACKAGES" - expand_pkg_groups + while ! expand_pkg_groups; do echo > /dev/null; done echo " after group expansion packages are: $PACKAGES" fi fi echo " applying DISABLE settings" +for i in $PACKAGES ; do + echo $i >> ./.tmp_pack +done +for i in `grep "-" ./.tmp_pack` ; do + j=`echo $i | sed 's/[-]//'` + DISABLE="$DISABLE $j" +done pack= for p in $PACKAGES ; do addit="t" @@ -1045,19 +1319,20 @@ echo " applying ENABLE settings" echo "" > ./.tmp_pack PACKAGES="$PACKAGES $ENABLE" +# Test if each explicitly referenced package exists for i in $PACKAGES ; do - if test ! -d "$ROOTDIR/pkg/$i" ; then + j=`echo $i | sed 's/[-+]//'` + if test ! -d "$ROOTDIR/pkg/$j" ; then echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\"" - exit 1 + exit 1 fi echo $i >> ./.tmp_pack done -pack=`cat ./.tmp_pack | sort | uniq` -rm -f ./.tmp_pack PACKAGES= -for i in $pack ; do +for i in `grep -v "-" ./.tmp_pack | sort | uniq` ; do PACKAGES="$PACKAGES $i" done +rm -f ./.tmp_pack echo " packages are: $PACKAGES" echo " applying package dependency rules" @@ -1143,6 +1418,32 @@ 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 < srclinks.tmp echo "" >> srclinks.tmp -echo -n 'SRCFILES = ' > srclist.inc -echo -n 'CSRCFILES = ' > csrclist.inc -echo -n 'F90SRCFILES = ' > f90srclist.inc -echo -n 'HEADERFILES = ' > hlist.inc -echo -n 'AD_FLOW_FILES = ' > ad_flow_files.inc +printf 'SRCFILES = ' > srclist.inc +printf 'CSRCFILES = ' > csrclist.inc +printf 'F90SRCFILES = ' > f90srclist.inc +printf 'HEADERFILES = ' > hlist.inc +printf 'AD_FLOW_FILES = ' > ad_flow_files.inc alldirs="$SOURCEDIRS $INCLUDEDIRS ." for d in $alldirs ; do deplist= @@ -1299,23 +1602,23 @@ case $extn in F) echo " \\" >> srclist.inc - echo -n " $sf" >> srclist.inc + printf " $sf" >> srclist.inc ;; F90) echo " \\" >> f90srclist.inc - echo -n " $sf" >> f90srclist.inc + printf " $sf" >> f90srclist.inc ;; c) echo " \\" >> csrclist.inc - echo -n " $sf" >> csrclist.inc + printf " $sf" >> csrclist.inc ;; h) echo " \\" >> hlist.inc - echo -n " $sf" >> hlist.inc + printf " $sf" >> hlist.inc ;; flow) echo " \\" >> ad_flow_files.inc - echo -n " $sf" >> ad_flow_files.inc + printf " $sf" >> ad_flow_files.inc ;; esac fi @@ -1344,7 +1647,7 @@ echo "# This makefile was generated automatically on" >> $MAKEFILE echo "# $THISDATE" >> $MAKEFILE echo "# by the command:" >> $MAKEFILE -echo "# $0 $@" >> $MAKEFILE +echo "# $0 $G2ARGS" >> $MAKEFILE echo "# executed by:" >> $MAKEFILE echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE @@ -1353,6 +1656,8 @@ EXE_SVD=$EXECUTABLE"_svd" cat >>$MAKEFILE <> $MAKEFILE cat hlist.inc >> $MAKEFILE cat ad_flow_files.inc >> $MAKEFILE -echo >> $MAKEFILE -echo 'F77FILES = $(SRCFILES:.F=.f)' >> $MAKEFILE -echo 'F90FILES = $(F90SRCFILES:.F90=.f90)' >> $MAKEFILE +echo >> $MAKEFILE +echo 'F77FILES = $(SRCFILES:.F=.'$FS')' >> $MAKEFILE +echo 'F90FILES = $(F90SRCFILES:.F=.'$FS90')' >> $MAKEFILE 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 rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc rm -f ad_flow_files.inc cat >>$MAKEFILE <> \$(MAKEFILE) + -rm -f makedepend.out links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES) @@ -1473,7 +1778,7 @@ @\$(EXECUTABLE) > \$@ clean: - -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} *.template + -rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template Clean: @make clean @make cleanlinks @@ -1488,37 +1793,40 @@ #eh3 Makefile: makefile makefile: - $THIS_SCRIPT $@ + $THIS_SCRIPT $G2ARGS cleanlinks: -find . -type l -exec rm {} \; # Special targets ($SPECIAL_FILES) which are create by make ${PACKAGES_DOT_H}: @echo Creating \$@ ... - @\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@ + @$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) > \$@ AD_CONFIG.h: @echo Creating \$@ ... - @\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > \$@ + @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > \$@ FC_NAMEMANGLE.h: @echo Creating \$@ ... echo "$FC_NAMEMANGLE" > \$@ -# The normal chain of rules is ( .F - .f - .o ) -.F.f: +# The normal chain of rules is ( .F - .$FS - .o ) + +%.o : %.F + +.F.$FS: \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ -.f.o: +.$FS.o: \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< -.F90.f90: +.F90.$FS90: \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ -.f90.o: +.$FS90.o: \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$< .c.o: \$(CC) \$(CFLAGS) -c \$< -# Special exceptions that use the ( .F - .p - .f - .o ) rule-chain +# Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain .F.p: \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ -.p.f: +.p.$FS: \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$< #========================================= @@ -1545,11 +1853,11 @@ echo " Add the source list for AD code generation" echo >> $MAKEFILE -echo -n "AD_FILES = " >> $MAKEFILE +printf "AD_FILES = " >> $MAKEFILE AD_FILES=`cat ad_files` for i in $AD_FILES ; do echo " \\" >> $MAKEFILE - echo -n " $i" >> $MAKEFILE + printf " $i" >> $MAKEFILE done echo >> $MAKEFILE rm -f ad_files @@ -1562,7 +1870,7 @@ adtamc: ad_tamc_output.f ad_input_code.f: \$(AD_FILES) \$(HEADERFILES) - @\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template + @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h -rm -f ad_config.template @make \$(F77FILES) @@ -1594,7 +1902,7 @@ ftltamc: ftl_tamc_output.f ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES) - @\$(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 + @$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 @make \$(F77FILES) @@ -1643,7 +1951,7 @@ if test "x$RETVAL" != x0 ; then echo "Error: unable to add file \"$i\" to the exceptions list" fi - echo "$base.f: $base.p" >> $MAKEFILE + echo "$base.$FS: $base.p" >> $MAKEFILE done echo " Making list of NOOPTFILES" @@ -1653,7 +1961,7 @@ if test "x$RETVAL" != x0 ; then echo "Error: unable to add file \"$i\" to the exceptions list" fi - echo "$base.o: $base.f" >> $MAKEFILE + echo "$base.o: $base.$FS" >> $MAKEFILE printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE done @@ -1667,11 +1975,11 @@ printf "\n=== Done ===\n" # Create special header files -$TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" $DISABLED_PACKAGES " " "Enabled packages:" $ENABLED_PACKAGES > $PACKAGES_DOT_H".tmp" +$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 > $PACKAGES_DOT_H".tmp" if test ! -f $PACKAGES_DOT_H ; then mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H else - cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H + cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H > /dev/null 2>&1 RETVAL=$? if test "x$RETVAL" = x0 ; then rm -f $PACKAGES_DOT_H".tmp" @@ -1681,13 +1989,13 @@ fi fi if test ! -f AD_CONFIG.h ; then - $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 + $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" != xf ; then - echo -n "" > genmake_state + printf "" > genmake_state for i in $gm_state ; do t1="t2=\$$i" eval $t1