`mkmf` is an external dependency that that uses a multi-stage
approach to building a Makefile with dependencies but fails to yield
an optimal link stage (it links everything, including unused modules).
`makedep` is a bash script that constructs the link stage for as many
programs as found, links only the necessary object files*, and is coded
solely in bash thus removing an external dependency. The addition of this
script is the bulk of this commit.
Code changes:
- when more than one program is encountered the executable is given
the name following "program". Since all the programs were named
"MOM_main" I have had to change them to provide unique names:
- MOM_sum_driver.F90, "program MOM_main" has been changed to
"MOM_sum_driver"
- solo_driver/MOM_driver.F90, "program MOM_main" has been
changed to "MOM6"
Script changes:
- Makefile.in now has a target "depend" to generate dependencies
using makedep
- configure.ac no longer checks for list_paths and mkmf
- configure.ac now invokes "make depend" in place of mkmf
- Added target "unit" to .testing/Makefile to build all programs
in config_src/drivers/unit_drivers
Ugliness:
- I had to add a -f option to makedep to handle FMS non-standard macros
- To compile FMS, the dependencies Makefile is passed CPPDEFS in addition
to CPPFLAGS.
- The first version of makedep was consistent with the standard gmake
rules which were sufficient to build MOM6. Adding -f "rule command"
allows FMS to be built:
makemake -f '$(FC) $(FFLAGS) $(CPPFLAGS) $(CPPDEFS) -c $<' -x libFMS.a ../src
- .inc suffix is included when searching for include directories
- FMS has includes of .inc files which modify the search path passed
to /lib/cpp .
- Handling of badly formatted comments when searching for modules
- FMS fm_util.F90, that generates fm_util_mod.mod, has some odd strings
in a comment on the module declaration line. This was causing wierdness
in the script.
- Not just Fortran dependencies
- makedep needs to also generate rules for C files in order to
build FMS
Todo:
[ ] *A work around is used for TEOS10 (gsw_*) functions that are in separate
object files even though accessed via a module (WTFortran!!!)