From f79ba37af18d4dd89edd01735aa63c0d22aeb17e Mon Sep 17 00:00:00 2001 From: Martin Losch <30285667+mjlosch@users.noreply.github.com> Date: Thu, 26 Sep 2024 18:30:15 +0200 Subject: [PATCH] Detect include-dependencies also in files with F90-suffix (#865) * detect include-dependencies also in files with F90-suffix * no saved Makefile.bak when just appending (-a) * document improving dependencies for F90 src files --------- Co-authored-by: Jean-Michel Campin --- doc/tag-index | 3 +++ tools/genmake2 | 1 + tools/xmakedepend | 14 +++++++++----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/doc/tag-index b/doc/tag-index index 6d2a46479c..7d60787ea0 100644 --- a/doc/tag-index +++ b/doc/tag-index @@ -1,6 +1,9 @@ Notes on tags used in MITgcmUV ============================== +o tools/xmakedepend: + - fix xmakedepend to accept suffix longer than 1.c and add dependencies to + Makefile from included headers in F90 src files. o model/src: - Add new param "cg3dTargetResWunit" to skip the normalization of cg3d RHS by specifying the CG3D target residual in term of vertical-velocity units ; diff --git a/tools/genmake2 b/tools/genmake2 index a54f6dcd82..7058a1b37b 100755 --- a/tools/genmake2 +++ b/tools/genmake2 @@ -3263,6 +3263,7 @@ fwd_exe_target: depend: @\$(MAKE) -f \$(MAKEFILE) links \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(CPPINCLUDES) \$(F77_SRC_FILES) + \$(MAKEDEPEND) -f \$(MAKEFILE) -a -o .$FS90 \$(DEFINES) \$(INCLUDES) \$(CPPINCLUDES) \$(F90_SRC_FILES) \$(TOOLSDIR)/f90mkdepend -fs $FS -fs90 $FS90 >> \$(MAKEFILE) -rm -f makedepend.out diff --git a/tools/xmakedepend b/tools/xmakedepend index 99347a933c..b56aa49000 100755 --- a/tools/xmakedepend +++ b/tools/xmakedepend @@ -92,7 +92,7 @@ do *) if [ "$endmarker"x = x ]; then - case "$1" in + case "$1" in -w) width="$2" shift @@ -113,7 +113,7 @@ do objsuffix="$2" shift ;; - + --*) echo "$1" | sed 's/^\-\-//' >${TMP}end endmarker="`cat ${TMP}end`" @@ -191,7 +191,8 @@ done | sed -e 's|/[^/.][^/]*/\.\.||g' -e 's|/\.[^.][^/]*/\.\.||g' -e 's|"| if ($1 != $4 && $2 != "#ident" && $2 != "#pragma") { - ofile = substr ($1, 1, length ($1) - 2) "'"$objsuffix"'" + ofile = $1 + sub(/\.[^.]*$/, "'"$objsuffix"'", ofile) print ofile, $4 } }' | sort -u | awk ' @@ -224,8 +225,11 @@ case "$makefile" in $TMPMAKEFILE) ;; *) - rm -f $makefile.bak - cp $makefile $makefile.bak + if [ "$append" = "n" ] + then + rm -f $makefile.bak + cp $makefile $makefile.bak + fi echo "Appending dependencies to $makefile" ;; esac