Skip to content

Commit

Permalink
Restructure .testing/build/deps/fms
Browse files Browse the repository at this point in the history
- Replaced rules that built in side build/deps/fms with rules
  that work in either build/deps/fms1 or build/deps/fms2
- ac/deps/Makefile not installs deps/fms1 and deps/fms2 with
  appropriate commits
- macro FRAMEWORK defaults to "fms2" so there is not change
  in change in the edfault libaries or executables being built
- adding FRAMEWORK=fms1 to the command line, or config.mk
  will install fms1 alongside or instead of fms2
- moved deps/lib and deps/include downward to deps/fms1/lib, etc.

Gotchas:
- fms1 and fms2 libraries can be built side-by-side. However, the
  version of FMS referred to in build/symmetric/Makefile is configured
  when it is first created, so you need to wipe the build/% directories
  to switch versions of FMS.
- bottom line: provides a path to have two built copies of FMS but
  only support one version of the execitables
  • Loading branch information
adcroft committed May 18, 2024
1 parent 6272bbc commit 9f0424c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 33 deletions.
17 changes: 9 additions & 8 deletions .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ build.prof: $(foreach b,opt opt_target,$(BUILD)/$(b)/MOM6)
# .testing dependencies
# TODO: We should probably build TARGET with the FMS that it was configured
# to use. But for now we use the same FMS over all builds.
FCFLAGS_DEPS = -I$(abspath $(DEPS)/include)
LDFLAGS_DEPS = -L$(abspath $(DEPS)/lib)
FCFLAGS_DEPS = -I$(abspath $(DEPS)/$(FRAMEWORK)/include)
LDFLAGS_DEPS = -L$(abspath $(DEPS)/$(FRAMEWORK)/lib)
PATH_DEPS = PATH="${PATH}:$(abspath $(DEPS)/bin)"


Expand Down Expand Up @@ -318,7 +318,7 @@ FORCE:
$(BUILD)/%/Makefile: $(BUILD)/%/Makefile.in $(BUILD)/%/config.status
cd $(@D) && ./config.status

$(BUILD)/%/config.status: $(BUILD)/%/configure $(DEPS)/lib/libFMS.a
$(BUILD)/%/config.status: $(BUILD)/%/configure $(DEPS)/$(FRAMEWORK)/lib/libFMS.a
cd $(@D) && $(MOM_ENV) ./configure -n --srcdir=$(AC_SRCDIR) $(MOM_ACFLAGS) \
|| (cat config.log && false)

Expand All @@ -341,7 +341,7 @@ $(foreach b,$(ALL_EXECS),$(BUILD)/$(b)/):

# Fetch the regression target codebase

$(BUILD)/target/config.status: $(BUILD)/target/configure $(DEPS)/lib/libFMS.a
$(BUILD)/target/config.status: $(BUILD)/target/configure $(DEPS)/$(FRAMEWORK)/lib/libFMS.a
cd $(@D) && $(MOM_ENV) ./configure -n \
--srcdir=$(abspath $(BUILD))/target_codebase/ac $(MOM_ACFLAGS) \
|| (cat config.log && false)
Expand All @@ -368,8 +368,8 @@ FMS_ENV = \
FCFLAGS="$(FCFLAGS_FMS)" \
REPORT_ERROR_LOGS="$(REPORT_ERROR_LOGS)"

$(DEPS)/lib/libFMS.a: $(DEPS)/Makefile $(DEPS)/Makefile.fms.in $(DEPS)/configure.fms.ac $(DEPS)/m4
$(FMS_ENV) $(MAKE) -C $(DEPS) lib/libFMS.a
$(DEPS)/$(FRAMEWORK)/lib/libFMS.a: $(DEPS)/Makefile $(DEPS)/Makefile.fms.in $(DEPS)/configure.fms.ac $(DEPS)/m4
$(FMS_ENV) $(MAKE) -C $(DEPS) $(FRAMEWORK)/lib/libFMS.a

$(DEPS)/Makefile: ../ac/deps/Makefile | $(DEPS)
cp ../ac/deps/Makefile $(DEPS)/Makefile
Expand Down Expand Up @@ -840,8 +840,6 @@ $(WORK)/p0/%/perf.data:

.PHONY: clean
clean: clean.build clean.stats
rm -rf $(BUILD)


.PHONY: clean.build
clean.build:
Expand All @@ -850,6 +848,9 @@ clean.build:
rm -rf $(BUILD)/$${b}; \
done

.PHONY: clean.deps
clean.deps:
make -C build/deps clean

.PHONY: clean.stats
clean.stats:
Expand Down
59 changes: 34 additions & 25 deletions ac/deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ SHELL = bash
MAKEFLAGS += -R

# FMS framework
FMS_URL ?= https://github.com/NOAA-GFDL/FMS.git
FMS_COMMIT ?= 2023.03
FMS2_URL ?= https://github.com/NOAA-GFDL/FMS.git
FMS2_COMMIT ?= 2023.03
FMS1_URL ?= https://github.com/NOAA-GFDL/FMS.git
FMS1_COMMIT ?= 2019.01.03


# List of source files to link this Makefile's dependencies to model Makefiles
Expand All @@ -17,7 +19,8 @@ FMS_COMMIT ?= 2023.03
SOURCE = \
$(foreach ext,F90 inc c h,$(wildcard $(1)/*/*.$(ext) $(1)/*/*/*.$(ext)))

FMS_SOURCE = $(call SOURCE,fms/src)
FMS1_SOURCE = $(call SOURCE,fms1/src)
FMS2_SOURCE = $(call SOURCE,fms2/src)


# If `true`, print logs if an error is encountered.
Expand All @@ -28,23 +31,25 @@ REPORT_ERROR_LOGS ?=
# Rules

.PHONY: all
all: lib/libFMS.a
all: lib/libfms1.a lib/libfms2.a

.SECONDARY:

#---
# FMS build

# NOTE: We emulate the automake `make install` stage by storing libFMS.a to
# ${srcdir}/deps/lib and copying module files to ${srcdir}/deps/include.
lib/libFMS.a: fms/build/libFMS.a
mkdir -p lib include
cp fms/build/libFMS.a lib/libFMS.a
cp fms/build/*.mod include
# The % pattern will be either fms1 or fms2
%/lib/libFMS.a: %/build/libFMS.a
mkdir -p $(@D) $(@D)/../include
cp $^ $@
cp $(<D)/*.mod $(@D)/../include

fms/build/libFMS.a: fms/build/Makefile
$(MAKE) -C fms/build libFMS.a
%/build/libFMS.a: %/build/Makefile
$(MAKE) -C $(^D) libFMS.a

fms/build/Makefile: fms/build/Makefile.in fms/build/configure
%/build/Makefile: %/build/Makefile.in %/build/configure
cd $(@D) && { \
./configure --srcdir=../src \
|| { \
Expand All @@ -53,29 +58,33 @@ fms/build/Makefile: fms/build/Makefile.in fms/build/configure
} \
}

fms/build/Makefile.in: Makefile.fms.in | fms/build
cp Makefile.fms.in fms/build/Makefile.in
%/build/Makefile.in: Makefile.fms.in | %/build
cp Makefile.fms.in $(@D)/Makefile.in

fms/build/configure: fms/build/configure.ac $(FMS_SOURCE) | fms/src
autoreconf fms/build
%/build/configure: %/build/configure.ac $(FMS_SOURCE) | %/src
autoreconf $(@D)

fms/build/configure.ac: configure.fms.ac m4 | fms/build
cp configure.fms.ac fms/build/configure.ac
cp -r m4 fms/build
%/build/configure.ac: configure.fms.ac m4 | %/build
cp configure.fms.ac $(@D)/configure.ac
cp -r m4 $(@D)

fms/build:
mkdir -p fms/build
%/build:
mkdir -p $@

fms/src:
git clone $(FMS_URL) $@
git -C $@ checkout $(FMS_COMMIT)
fms2/src:
git clone $(FMS2_URL) $@
git -C $@ checkout $(FMS2_COMMIT)
fms1/src:
git clone $(FMS1_URL) $@
git -C $@ checkout $(FMS1_COMMIT)

# Cleanup

.PHONY: clean
clean:
rm -rf fms/build lib include
rm -rf fms1/{build,lib,include} fms2/{build,lib,include}

# Keeping "fms" to clean up earlier version of this install process
.PHONY: distclean
distclean: clean
rm -rf fms
rm -rf fms fms1 fms2

0 comments on commit 9f0424c

Please sign in to comment.