--- MITgcm/tools/genmake2 2016/01/15 22:08:17 1.278 +++ MITgcm/tools/genmake2 2017/02/08 22:31:33 1.280 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.278 2016/01/15 22:08:17 jmc Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.280 2017/02/08 22:31:33 jmc Exp $ # $Name: $ # # Makefile generator for MITgcm UV codes @@ -697,6 +697,7 @@ echo "Error: unable to parse package dependencies -- please check PKG_DEPEND=\"$1\"" exit 1 fi + #echo "---- content of tmp file '.pd_tmp' :" ; cat .pd_tmp ; echo "---- end of file" . ./.pd_tmp rm -f ./.pd_tmp } @@ -1717,6 +1718,12 @@ fi #==================================================================== +# Initialize INCLUDEDIRSMK from and optfile INCLUDEDIRS +if test "x${INCLUDEDIRS}" != "x" ; then + INCLUDEDIRSMK=${INCLUDEDIRS} +fi + +#==================================================================== # Set default values if not set by the optfile # # Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined. If not, @@ -2105,6 +2112,8 @@ printf "$d " SOURCEDIRS="$SOURCEDIRS $d" INCLUDEDIRS="$INCLUDEDIRS $d" + SOURCEDIRSMK="$SOURCEDIRSMK $d" + INCLUDEDIRSMK="$INCLUDEDIRSMK $d" fi done echo @@ -2128,6 +2137,9 @@ if test "x${TOOLSDIR}" = x ; then TOOLSDIR="$ROOTDIR/tools" + TOOLSDIRMK='$(ROOTDIR)'"/tools" +else + TOOLSDIRMK=${TOOLSDIR} fi if test ! -d ${TOOLSDIR} ; then echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!" @@ -2438,18 +2450,19 @@ if test "x$p" = "x$pname" ; then pin="t" ; fi done - # Is the DNAME entry a (+) or (-) rule ? + # Is the DNAME entry a (=), (+) or (-) rule ? tmp="dname=\"\$DNAME_$i\"" eval $tmp - plus="-" + plus="a" echo $dname | grep '^+' > /dev/null 2>&1 RETVAL=$? - if test "x$RETVAL" = x0 ; then - plus="+" - fi + if test "x$RETVAL" = x0 ; then plus="+" ; fi + echo $dname | grep '^-' > /dev/null 2>&1 + RETVAL=$? + if test "x$RETVAL" = x0 ; then plus="-" ; fi # Is $dname in the current $PACKAGES list? - dname=`echo $dname | sed -e 's/^[+-]//'` + dname=`echo $dname | sed -e 's/^[=+-]//'` din="f" for p in $PACKAGES ; do if test "x$p" = "x$dname" ; then @@ -2458,7 +2471,7 @@ done # Do we need to add $dname according to the dependency rules? - if test "x$pin" = xt -a "x$plus" = "x+" -a "x$din" = xf ; then + if test "x$pin" = xt -a "x$plus" != "x-" -a "x$din" = xf ; then #echo " " $pname ": need to add :" $dname in_dis="f" for dis in $DISABLE ; do @@ -2467,10 +2480,17 @@ fi done if test "x$in_dis" = xt ; then - echo "Error: can't satisfy package dependencies:" - echo " \"$dname\" is required by the dependency rules" - echo " but is disallowed by the DISABLE settings" - exit 1 + if test "x$plus" = "x+" ; then + echo "Error: can't satisfy package dependencies:" + echo " \"$dname\" is required with pkg \"$pname\" (dependency rules)" + echo " but is disallowed by the DISABLE settings" + exit 1 + elif test "x$ck" = xt ; then + #- (=) is a weaker dependency rule: warning but no stop + echo "Warning: pkg \"$dname\" is set DISABLE (from: \"$PKG_LIST\")" + echo -n " but is recommended with pkg \"$pname\" (dependency rules)" + echo " <- ignores recommendation" + fi else PACKAGES="$PACKAGES $dname" ck= @@ -2480,8 +2500,8 @@ # Do we need to get rid of $dname according to the dependency rules? if test "x$pin" = xt -a "x$plus" = "x-" -a "x$din" = xt; then echo "Error: can't satisfy package dependencies:" - echo " \"$pname\" was requested but is disallowed by" - echo " the dependency rules for \"$dname\"" + echo " \"$dname\" was requested but is disallowed by" + echo " the dependency rules for \"$pname\"" exit 1 fi i=`echo "$i + 1" | bc -l` @@ -2493,9 +2513,12 @@ fi for i in $PACKAGES ; do adr="$ROOTDIR/pkg/$i" + adrmk='$(ROOTDIR)'"/pkg/$i" if test -d $adr ; then SOURCEDIRS="$SOURCEDIRS $adr" INCLUDEDIRS="$INCLUDEDIRS $adr" + SOURCEDIRSMK="$SOURCEDIRSMK $adrmk" + INCLUDEDIRSMK="$INCLUDEDIRSMK $adrmk" if test "x$i" = xautodiff ; then AUTODIFF_PKG_USED=t fi @@ -2551,20 +2574,24 @@ if test "x$STANDARDDIRS" != x ; then for d in $STANDARDDIRS ; do adr="$ROOTDIR/$d/src" + adrmk='$(ROOTDIR)/'"$d/src" if test ! -d $adr ; then echo "Error: directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\"" echo " is correct and that you correctly specified the STANDARDDIRS option" exit 1 else SOURCEDIRS="$SOURCEDIRS $adr" + SOURCEDIRSMK="$SOURCEDIRSMK $adrmk" fi adr="$ROOTDIR/$d/inc" + adrmk='$(ROOTDIR)/'"$d/inc" if test ! -d $adr ; then echo "Error: directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\"" echo " is correct and that you correctly specified the STANDARDDIRS option" exit 1 else INCLUDEDIRS="$INCLUDEDIRS $adr" + INCLUDEDIRSMK="$INCLUDEDIRSMK $adrmk" fi done fi @@ -2664,6 +2691,7 @@ OAD_KEEP_ORIGINAL="/dev/null" OAD_CB2M_FILES="/dev/null" OADTOOLS="$TOOLSDIR/OAD_support" + OADTOOLSMK='$(TOOLSDIR)/OAD_support' echo " looking for dontCompile file: " for i in "." $MODS $OADTOOLS ; do if test -r $i"/dontCompile" ; then @@ -2708,7 +2736,11 @@ printf 'H_SRC_FILES = ' > $TMP.hsrclist printf 'AD_FLOW_FILES = ' > $TMP.ad_flow_files alldirs="$SOURCEDIRS $INCLUDEDIRS ." +alldirsmk=(${SOURCEDIRSMK} ${INCLUDEDIRSMK} ".") +nd=0 for d in $alldirs ; do + dmk=${alldirsmk[${nd}]} + nd=$((${nd}+1)) deplist= sfiles=`( cd $d; echo *.[h,c,F] *.flow )` sfiles=`( echo $sfiles; cd $d; echo *.F90 )` @@ -2811,12 +2843,12 @@ if test "x$deplist" != x ; then if test "$d" != "." ; then echo "" >> $TMP.srclinks - echo "# These files are linked from $d" >> $TMP.srclinks + echo "# These files are linked from $dmk ( aka $d )" >> $TMP.srclinks echo "$deplist :" >> $TMP.srclinks # We need to make sure that the link isn't already there. # This may happen when make thinks that a header file has to be "remade" # because a module it depends on has changed. In this case we do nothing. - printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> $TMP.srclinks + printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $dmk >> $TMP.srclinks fi fi done @@ -2873,15 +2905,15 @@ ROOTDIR = ${ROOTDIR} BUILDDIR = ${BUILDDIR} -SOURCEDIRS = ${SOURCEDIRS} -INCLUDEDIRS = ${INCLUDEDIRS} +SOURCEDIRS = ${SOURCEDIRSMK} +INCLUDEDIRS = ${INCLUDEDIRSMK} EXEDIR = ${EXEDIR} EXECUTABLE = \$(EXEDIR)/${EXECUTABLE} -TOOLSDIR = ${TOOLSDIR} -OADTOOLS = ${OADTOOLS} +TOOLSDIR = ${TOOLSDIRMK} +OADTOOLS = ${OADTOOLSMK} #eh3 new defines for the adjoint work -AUTODIFF = ${ROOTDIR}/pkg/autodiff +AUTODIFF = \$(ROOTDIR)/pkg/autodiff EXE_AD = ${EXE_AD} EXE_FTL = ${EXE_FTL} EXE_SVD = ${EXE_SVD} @@ -2995,7 +3027,7 @@ lib: libmitgcmuv.a -libmitgcmuv.a: \$(OBJFILES) +libmitgcmuv.a: \$(SPECIAL_FILES) \$(OBJFILES) ar rcv libmitgcmuv.a \$(OBJFILES) ar d libmitgcmuv.a main.o @@ -3471,16 +3503,16 @@ \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS) # create sources files modules from header files containing common blocks -%_mod.FF90 : %.h \${OADTOOLS}/cb2mGetModules.csh \${OADTOOLS}/cb2mGetModules.awk - \${OADTOOLS}/cb2mGetModules.csh $< \${OADTOOLS}/cb2mGetModules.awk +%_mod.FF90 : %.h \$(OADTOOLS)/cb2mGetModules.csh \$(OADTOOLS)/cb2mGetModules.awk + \$(OADTOOLS)/cb2mGetModules.csh $< \$(OADTOOLS)/cb2mGetModules.awk # create new header files with USE statements for the new modules made above -%_mod.h : %.h \${OADTOOLS}/cb2mGetHeaders.csh \${OADTOOLS}/cb2mGetHeaders.awk - \${OADTOOLS}/cb2mGetHeaders.csh $< \${OADTOOLS}/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES) +%_mod.h : %.h \$(OADTOOLS)/cb2mGetHeaders.csh \$(OADTOOLS)/cb2mGetHeaders.awk + \$(OADTOOLS)/cb2mGetHeaders.csh $< \$(OADTOOLS)/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES) # change the include directives of everybody to refer to the new header files with the USE statements -%_cb2m.FF90 : %.F \${OADTOOLS}/cb2mUseModules.bash - \${OADTOOLS}/cb2mUseModules.bash $< ${MPI} +%_cb2m.FF90 : %.F \$(OADTOOLS)/cb2mUseModules.bash + \$(OADTOOLS)/cb2mUseModules.bash $< ${MPI} # makefile debug rule small_f: \$(CB2M_F90_PP_SRC_FILES) @@ -3495,7 +3527,7 @@ # replace stop statements (to avoid the implied unstructured control flow) with print statements ad_input_code_sf.pre.s2p.f90 : ad_input_code_sf.pre.f90 - cat \$< | sed -f \${OADTOOLS}/stop2print.sed > ad_input_code_sf.pre.s2p.f90 + cat \$< | sed -f \$(OADTOOLS)/stop2print.sed > ad_input_code_sf.pre.s2p.f90 # F -> WHIRL ad_input_code_sf.pre.s2p.B: ad_input_code_sf.pre.s2p.f90 @@ -3518,10 +3550,10 @@ \${OPEN64ROOT}/whirl2f/whirl2f -FLIST:ftn_file=\$@ -openad \$< # insert template directives -ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90 \${OADTOOLS}/insertTemplateDir.bash - \${OADTOOLS}/insertTemplateDir.bash \$< \$@ +ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90 \$(OADTOOLS)/insertTemplateDir.bash + \$(OADTOOLS)/insertTemplateDir.bash \$< \$@ -PPEXTRAS=\$(notdir \$(wildcard \${OADTOOLS}/ad_template.*.F)) ad_inline.F +PPEXTRAS=\$(notdir \$(wildcard \$(OADTOOLS)/ad_template.*.F)) ad_inline.F # postprocess F' postProcess.tag: ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90 \$(PPEXTRAS:.F=.f) | w2f__types.f90 \${OPENADFORTTK_BASE}/tools/SourceProcessing/postProcess.py --progress --timing --infoUnitFile w2f__types.f90 --outputFormat=fixed --separateOutput --pathSuffix "" --filenameSuffix "_oad" -m r -i ad_inline.f \$< @@ -3536,7 +3568,7 @@ # link the support files: \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES) \$(PPEXTRAS): - \$(LN) \${OADTOOLS}/\$@ . + \$(LN) \$(OADTOOLS)/\$@ . AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.tag