Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ DIMS ?= t l h z q r
# Dependencies
DEPS = deps

# mkmf, list_paths (GFDL build toolchain)
LIST_PATHS := $(DEPS)/bin/list_paths
MKMF := $(DEPS)/bin/mkmf


#---
# Test configuration
Expand Down Expand Up @@ -295,7 +291,7 @@ build/%/MOM6: build/%/Makefile

# Use autoconf to construct the Makefile for each target
.PRECIOUS: $(foreach b,$(BUILDS),build/$(b)/Makefile)
build/%/Makefile: ../ac/configure ../ac/Makefile.in $(DEPS)/lib/libFMS.a $(MKMF) $(LIST_PATHS)
build/%/Makefile: ../ac/configure ../ac/Makefile.in $(DEPS)/lib/libFMS.a
mkdir -p $(@D)
cd $(@D) \
&& $(MOM_ENV) ../../../ac/configure $(MOM_ACFLAGS) --with-framework=$(FRAMEWORK) \
Expand All @@ -308,7 +304,7 @@ build/%/Makefile: ../ac/configure ../ac/Makefile.in $(DEPS)/lib/libFMS.a $(MKMF)

# Fetch the regression target codebase
build/target/Makefile build/opt_target/Makefile: \
$(TARGET_CODEBASE)/ac/configure $(DEPS)/lib/libFMS.a $(MKMF) $(LIST_PATHS)
$(TARGET_CODEBASE)/ac/configure $(DEPS)/lib/libFMS.a
mkdir -p $(@D)
cd $(@D) \
&& $(MOM_ENV) ../../$(TARGET_CODEBASE)/ac/configure $(MOM_ACFLAGS) \
Expand All @@ -328,7 +324,7 @@ $(TARGET_CODEBASE):
# FMS

# Set up the FMS build environment variables
FMS_ENV = PATH="${PATH}:../../bin" FCFLAGS="$(FCFLAGS_DEBUG)"
FMS_ENV = PATH="${PATH}:$(realpath ../ac)" FCFLAGS="$(FCFLAGS_DEBUG)"

# TODO: *.mod dependencies?
$(DEPS)/lib/libFMS.a: $(DEPS)/fms/build/libFMS.a
Expand All @@ -337,9 +333,8 @@ $(DEPS)/lib/libFMS.a: $(DEPS)/fms/build/libFMS.a
$(DEPS)/fms/build/libFMS.a: $(DEPS)/fms/build/Makefile
$(MAKE) -C $(DEPS) fms/build/libFMS.a

$(DEPS)/fms/build/Makefile: $(DEPS)/fms/src/configure $(DEPS)/Makefile.fms.in $(MKMF) $(LIST_PATHS)
$(DEPS)/fms/build/Makefile: $(DEPS)/fms/src/configure $(DEPS)/Makefile.fms.in
$(FMS_ENV) $(MAKE) -C $(DEPS) fms/build/Makefile
$(MAKE) -C $(DEPS) fms/build/Makefile

$(DEPS)/Makefile.fms.in: ../ac/deps/Makefile.fms.in $(DEPS)/Makefile
cp $< $(DEPS)
Expand All @@ -353,13 +348,6 @@ $(DEPS)/fms/src/configure: ../ac/deps/configure.fms.ac $(DEPS)/Makefile $(FMS_SO
$(DEPS)/fms/src: $(DEPS)/Makefile
make -C $(DEPS) fms/src

# mkmf
$(MKMF) $(LIST_PATHS): $(DEPS)/mkmf
$(MAKE) -C $(DEPS) bin/$(@F)

$(DEPS)/mkmf: $(DEPS)/Makefile
$(MAKE) -C $(DEPS) mkmf

# Dependency init
$(DEPS)/Makefile: ../ac/deps/Makefile
mkdir -p $(@D)
Expand Down Expand Up @@ -693,7 +681,7 @@ test.summary:
.PHONY: unit.cov
unit.cov: build/unit/MOM_new_unit_tests.gcov

work/unit/std.out: build/unit/MOM6
work/unit/std.out: build/unit/MOM_unit_tests
if [ $(REPORT_COVERAGE) ]; then \
find build/unit -name *.gcda -exec rm -f '{}' \; ; \
fi
Expand Down
69 changes: 21 additions & 48 deletions ac/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,33 @@
#
# Compiler flags are configured by autoconf's configure script.
#
# Source code dependencies are configured by mkmf and list_paths, specified in
# the `Makefile.mkmf` file.
#
# mkmf conventions are close, but not identical, to autoconf. We attempt to
# map the autoconf variables to the mkmf variables.
#
# The following variables are used by Makefiles generated by mkmf.
#
# CC C compiler
# CXX C++ compiler
# FC Fortran compiler (f77 and f90)
# LD Linker
# AR Archiver
#
# CPPDEFS Preprocessor macros
# CPPFLAGS C preprocessing flags
# CXXFLAGS C++ preprocessing flags
# FPPFLAGS Fortran preprocessing flags
#
# CFLAGS C compiler flags
# FFLAGS Fortran compiler flags
# LDFLAGS Linker flags + libraries
# ARFLAGS Archiver flags
#
# OTHERFLAGS Additional flags for all languages (C, C++, Fortran)
# OTHER_CFLAGS Optional C flags
# OTHER_CXXFLAGS Optional C++ flags
# OTHER_FFLAGS Optional Fortran flags
# TMPFILES Placeholder for `make clean` deletion (as `make neat`).
#
#
# NOTES:
# - FPPFLAGS and FFLAGS always appear as a pair, and autoconf does not use
# FPPFLAGS, so FPPFLAGS does not serve much purpose.
#
# - mkmf's FFLAGS does not distinguish between autoconf's fixed-format
# FFLAGS and free-format FCFLAGS.
#
# - LDFLAGS does not distinguish between autoconf's LDFLAGS and LIBS.
# It also places both after the executable rather than just LIBS.
# Source code dependencies are configured by makedep and saved to Makefile.dep.

FC = @FC@
LD = @FC@
MAKEDEP = @MAKEDEP@

CPPDEFS = @DEFS@
DEFS = @DEFS@
CPPFLAGS = @CPPFLAGS@
FFLAGS = @FCFLAGS@
LDFLAGS = @LDFLAGS@ @LIBS@
FCFLAGS = @FCFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
SRC_DIRS = @SRC_DIRS@


-include Makefile.dep


# Generate Makefile from template
Makefile: @srcdir@/ac/Makefile.in config.status
./config.status

# Gather modulefiles
TMPFILES = $(wildcard *.mod)

include Makefile.mkmf
# Generate dependencies
.PHONY: depend
depend: Makefile.dep
Makefile.dep:
$(MAKEDEP) -o Makefile.dep $(SRC_DIRS)


# Delete any files associated with configuration (including the Makefile).
Expand All @@ -64,9 +38,8 @@ distclean: clean
rm -f config.log
rm -f config.status
rm -f Makefile
# mkmf output
rm -f path_names
rm -f Makefile.mkmf
rm -f Makefile.dep


# This deletes all files generated by autoconf, including configure.
Expand Down
44 changes: 9 additions & 35 deletions ac/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -224,45 +224,19 @@ AC_COMPILE_IFELSE(
)


# Search for mkmf build tools
AC_PATH_PROG([LIST_PATHS], [list_paths])
AS_IF([test -z "$LIST_PATHS"], [
AC_PATH_PROG([LIST_PATHS], [list_paths], [], ["$PATH:${srcdir}/ac/deps/bin"])
AS_IF([test -z "$LIST_PATHS"],
[AC_MSG_ERROR([Could not find list_paths.])],
[AC_SUBST(PATH, ["$PATH:${srcdir}/ac/deps/bin"])])
]
)

AC_PATH_PROG([MKMF], [mkmf])
AS_IF([test -z "$MKMF"], [
AC_PATH_PROG([MKMF], [mkmf], [], ["$PATH:${srcdir}/ac/deps/bin"])
AS_IF([test -z "$MKMF"],
[AC_MSG_ERROR([Could not find mkmf.])],
[AC_SUBST(PATH, ["$PATH:${srcdir}/ac/deps/bin"])])
]
)
# Verify that makedep is available
AC_PATH_PROG([MAKEDEP], [makedep], [${srcdir}/ac/makedep])
AC_SUBST([MAKEDEP])


# NOTE: MEM_LAYOUT unneeded if we shift to MOM_memory.h.in template
AC_CONFIG_COMMANDS([path_names],
[list_paths -l \
${srcdir}/src \
${MODEL_FRAMEWORK} \
${srcdir}/config_src/ext* \
${DRIVER_DIR} \
${MEM_LAYOUT}],
[MODEL_FRAMEWORK=$MODEL_FRAMEWORK
MEM_LAYOUT=$MEM_LAYOUT
DRIVER_DIR=$DRIVER_DIR]
# Generate source list and configure dependency command
AC_SUBST([SRC_DIRS],
["${srcdir}/src ${MODEL_FRAMEWORK} ${srcdir}/config_src/external ${DRIVER_DIR} ${MEM_LAYOUT}"]
)


AC_CONFIG_COMMANDS([Makefile.mkmf],
[mkmf -p MOM6 -m Makefile.mkmf path_names])

AC_CONFIG_COMMANDS([Makefile.dep], [make depend])

# Prepare output
AC_SUBST(CPPFLAGS)
AC_SUBST([CPPFLAGS])
AC_CONFIG_FILES([Makefile:${srcdir}/ac/Makefile.in])
AC_OUTPUT

27 changes: 6 additions & 21 deletions ac/deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ SHELL = bash
# Disable implicit variables
MAKEFLAGS += -R


# mkmf, list_paths (GFDL build toolchain)
MKMF_URL ?= https://github.com/NOAA-GFDL/mkmf.git
MKMF_COMMIT ?= master

# FMS framework
FMS_URL ?= https://github.com/NOAA-GFDL/FMS.git
FMS_COMMIT ?= 2019.01.03
Expand All @@ -30,18 +25,7 @@ FMS_SOURCE = $(call SOURCE,fms/src)
# Rules

.PHONY: all
all: bin/mkmf bin/list_paths lib/libFMS.a

#---
# mkmf checkout

bin/mkmf bin/list_paths: mkmf
mkdir -p $(@D)
cp $^/$@ $@

mkmf:
git clone $(MKMF_URL) $@
git -C $@ checkout $(MKMF_COMMIT)
all: lib/libFMS.a


#---
Expand All @@ -54,7 +38,7 @@ mkmf:


# TODO: track *.mod copy?
lib/libFMS.a: fms/build/libFMS.a fms/build/Makefile
lib/libFMS.a: fms/build/libFMS.a
mkdir -p {lib,include}
cp fms/build/libFMS.a lib/libFMS.a
cp fms/build/*.mod include
Expand All @@ -64,7 +48,7 @@ fms/build/libFMS.a: fms/build/Makefile
make -C fms/build libFMS.a


fms/build/Makefile: Makefile.fms.in fms/src/configure bin/mkmf bin/list_paths
fms/build/Makefile: Makefile.fms.in fms/src/configure
mkdir -p fms/build
cp Makefile.fms.in fms/src/Makefile.in
cd $(@D) && ../src/configure --srcdir=../src
Expand All @@ -76,15 +60,16 @@ fms/src/configure: configure.fms.ac $(FMS_SOURCE) | fms/src
cp -r m4 $(@D)
cd $(@D) && autoreconf -i


fms/src:
git clone $(FMS_URL) $@
git -C $@ checkout $(FMS_COMMIT)


.PHONY: clean
clean:
rm -rf fms/build lib include bin
rm -rf fms/build lib include

.PHONY: distclean
distclean: clean
rm -rf fms mkmf
rm -rf fms
57 changes: 11 additions & 46 deletions ac/deps/Makefile.fms.in
Original file line number Diff line number Diff line change
@@ -1,60 +1,25 @@
# Makefile template for autoconf builds using mkmf
# Makefile template for FMS
#
# Compiler flags are configured by autoconf's configure script.
#
# Source code dependencies are configured by mkmf and list_paths, specified in
# the `Makefile.mkmf` file.
#
# mkmf conventions are close, but not identical, to autoconf. We attempt to
# map the autoconf variables to the mkmf variables.
#
# The following variables are used by Makefiles generated by mkmf.
#
# CC C compiler
# CXX C++ compiler
# FC Fortran compiler (f77 and f90)
# LD Linker
# AR Archiver
#
# CPPDEFS Preprocessor macros
# CPPFLAGS C preprocessing flags
# CXXFLAGS C++ preprocessing flags
# FPPFLAGS Fortran preprocessing flags
#
# CFLAGS C compiler flags
# FFLAGS Fortran compiler flags
# LDFLAGS Linker flags + libraries
# ARFLAGS Archiver flags
#
# OTHERFLAGS Additional flags for all languages (C, C++, Fortran)
# OTHER_CFLAGS Optional C flags
# OTHER_CXXFLAGS Optional C++ flags
# OTHER_FFLAGS Optional Fortran flags
# TMPFILES Placeholder for `make clean` deletion (as `make neat`).
#
#
# NOTES:
# - FPPFLAGS and FFLAGS always appear as a pair, and autoconf does not use
# FPPFLAGS, so FPPFLAGS does not serve much purpose.
#
# - mkmf's FFLAGS does not distinguish between autoconf's fixed-format
# FFLAGS and free-format FCFLAGS.
#
# - LDFLAGS does not distinguish between autoconf's LDFLAGS and LIBS.
# It also places both after the executable rather than just LIBS.
# Source code dependencies are configured by makedep and saved to Makefile.dep.

CC = @CC@
FC = @FC@
LD = @FC@
AR = @AR@
MAKEDEP = @MAKEDEP@

CPPDEFS = @DEFS@
DEFS = @DEFS@
CPPFLAGS = @CPPFLAGS@
FFLAGS = @FCFLAGS@
FCFLAGS = @FCFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
ARFLAGS = @ARFLAGS@

# Gather modulefiles
TMPFILES = $(wildcard *.mod)
-include Makefile.dep

include Makefile.mkmf
.PHONY: depend
depend: Makefile.dep
Makefile.dep:
$(MAKEDEP) -o Makefile.dep -x libFMS.a @srcdir@
Loading