# Defines how to build the NEMS executables, and the full dependency # list (all components' *.mk files). This is the equivalent to # component_NEMS.mk for the NEMS itself. # Make sure the source directory exists and is non-empty. $(call require_dir,$(NEMSDIR)/src,NEMS source directory) # Ensure that Make knows these rules do not correspond to files to be built: .PHONY: build_NEMS clean_NEMS COMMA_COMPONENT_LIST=,$(subst $(space),$(comma),$(COMPONENTS)), COMMA_COMPONENT_LIST_LOWER=$(call lc,$(COMMA_COMPONENT_LIST)) COMPONENT_DIR_LIST=$(foreach COMP,$(COMPONENTS),$(COMP)_DIR=$(call $(COMP)_BINDIR)) ######################################################################## # Rule for building NEMS: build_NEMS: $(NEMS_EXE) component_mk_fragment=echo $(call lc,$(1))_mk="$($(call lc,$(1))_mk)" $(semicolon) $(CONFDIR)/configure.nems.NUOPC: $(CONFDIR)/configure.nems.NUOPC.in FORCE ( \ echo "# Do not edit this file. It is automatically generated." ; \ echo "# Edit the component list or $<" ; \ echo ; cat "$<" ; \ $(foreach COMP,$(COMPONENTS),$(call component_mk_fragment,$(COMP))) ) > "$@" $(NEMS_EXE): $(all_component_mk_files) configure \ $(CONFDIR)/configure.nems.NUOPC $(MODULE_LOGIC) ; \ set -e ; \ for m in $(all_component_mk_files) ; do \ test -s $$m ; \ done ; \ echo build NEMS after $(all_component_mk_files) ; \ cd $(NEMSDIR)/src ; \ $(MAKE) nems $(NEMS_BUILDOPT) \ COMPONENTS="$(COMPONENTS)" \ $(COMPONENT_DIR_LIST) TARGET="$(NEMS_EXE)" ; \ test -x $(NEMS_EXE) ######################################################################## # Rules for cleaning NEMS: clean_NEMS: if ! test -f $(CONFDIR)/configure.nems.NUOPC ; then \ cat /dev/null > $(CONFDIR)/configure.nems.NUOPC ; \ delete_nuopc=yes ; \ fi ; \ cd $(NEMSDIR)/src ; $(MAKE) "COMPONENTS=$(COMPONENTS)" \ INCLUDES_ARE_OPTIONAL=YES clean ; \ if [ "$$delete_nuopc" = yes ] ; then \ rm -f $(CONFDIR)/configure.nems.NUOPC ; \ fi distclean_NEMS: clean_NEMS rm -f $(NEMS_EXE) $(CONFDIR)/configure.nems.NUOPC