#  Main body of the installation makefile for all the GALAHAD GO packages

#  Nick Gould, for GALAHAD productions
#  This version: 2024-11-19

#  ===========================================================================
#  ====================  package-dependent parts  ============================
#  ===========================================================================

#  package section name

package = all_go
PACKAGE = ALL_GO

#  auxililiary packages that current package depends on (prepend with make_)

DEPENDENCIES = make_sls_deps make_sls make_roots make_norms \
               make_lmt make_qpt make_lms make_rand make_hash \
               make_gltr make_tools make_scu make_mi28 \
               make_mop make_ir make_trs make_userdata \
               make_nlpt make_icfs make_lancelot_psls \
               make_psls make_sha make_lhs make_sha \
               make_cauchy make_cg make_trb make_lhs \
               make_ugo make_bgo make_dgo

#  auxiliary packages that the C interface to the current package depends
#  on (prepend with make_ciface_)

CDEPENDENCIES = make_ciface_common make_ciface_trb make_ciface_hash \
                make_ciface_ugo make_ciface_lhs make_ciface_bgo \
                make_ciface_dgo

#  auxiliary packages that the python interface to the current package depends
#  on (prepend with make_pyiface_)

PYDEPENDENCIES = make_pyiface_ugo make_pyiface_trb make_pyiface_hash \
                 make_pyiface_lhs make_pyiface_bgo make_pyiface_dgo

#  auxiliary packages that are needed for tests (prepend with make_)

TESTDEPS = make_copyright

#  packages that are needed for CUTEst interfaces (prepend with make_)

CUTESTDEPS = $(CUTEST_TESTS) $(TESTDEPS) \
             make_ugo_cutest make_bgo_cutest make_dgo_cutest

#  comprehensive tests to be performed (prepend with make_)

TEST = make_ugo_test make_bgo_test make_dgo_test

#  comprehensive and CUTEst tests to be performed (prepend with make_)

TESTS = make_ugo_tests make_bgo_tests make_dgo_tests

#  all tests except CUTEst ones to be performed (prepend with make_)

TEST_FULL = make_ugo_test_full make_bgo_test_full make_dgo_test_full

#  specification documentation tests

TEST_SPEC = make_ugo_test_spec make_bgo_test_spec make_dgo_test_spec

#  tests of C interfaces to be performed (prepend with make_ciface_)

TEST_CIFACE = make_ciface_ugo_test make_ciface_bgo_test make_ciface_dgo_test

#  tests of python interfaces to be performed (prepend with make_pyiface_)

TEST_PYIFACE = make_pyiface_ugo_test make_pyiface_bgo_test \
               make_pyiface_dgo_test

#  all packages in the GO section

PACKAGES = ugo bgo dgo

#  ===========================================================================
#  =================  end of package-dependent parts  ========================
#  ===========================================================================

#  include standard GALAHAD makefile definitions

include $(GALAHAD)/src/makedefs/definitions

#  =========================================================================
#  ========================== makefile stanza ==============================
#  =========================================================================

#  main compilations and runs

all: $(package)
all_ciface: $(package) $(package)_ciface
all_pyiface: $(package) $(package)_pyiface
all_cutest: $(package)_cutest
test: all $(TEST)
tests: all $(TESTS)
test_full: all $(TEST_FULL)
test_spec: all $(TEST_SPEC)
test_ciface: all_ciface $(TEST_CIFACE)
test_pyiface: all_pyiface $(TEST_PYIFACE)

#  silent packages

$(package)_silent: $(package)_silent_$(PRECIS)
$(package)_silent_single: $(DEPENDENCIES)
$(package)_silent_double: $(DEPENDENCIES)
$(package)_silent_quadruple: $(DEPENDENCIES)
$(package)_silent_single_64: $(DEPENDENCIES)
$(package)_silent_double_64: $(DEPENDENCIES)
$(package)_silent_quadruple_64: $(DEPENDENCIES)

$(package)_ciface_silent: $(package)_ciface_silent_$(PRECIS)
$(package)_ciface_silent_single: $(CDEPENDENCIES)
$(package)_ciface_silent_double: $(CDEPENDENCIES)
$(package)_ciface_silent_quadruple: $(CDEPENDENCIES)
$(package)_ciface_silent_single_64: $(CDEPENDENCIES)
$(package)_ciface_silent_double_64: $(CDEPENDENCIES)
$(package)_ciface_silent_quadruple_64: $(CDEPENDENCIES)

$(package)_pyiface_silent: $(package)_pyiface_silent_$(PRECIS)
$(package)_pyiface_silent_single: $(PYDEPENDENCIES)
$(package)_pyiface_silent_double: $(PYDEPENDENCIES)
$(package)_pyiface_silent_quadruple: $(PYDEPENDENCIES)
$(package)_pyiface_silent_single_64: $(PYDEPENDENCIES)
$(package)_pyiface_silent_double_64: $(PYDEPENDENCIES)
$(package)_pyiface_silent_quadruple_64: $(PYDEPENDENCIES)

#  packages

$(package): $(package)_$(PRECIS)
	@printf ' %-21s\n' "GALAHAD: $(PACKAGE) ($(PRECIS) $(SUCC)"
$(package)_single: $(DEPENDENCIES)
	$(RANLIB) $(LGS)
$(package)_double: $(DEPENDENCIES)
	$(RANLIB) $(LGD)
$(package)_quadruple: $(DEPENDENCIES)
	$(RANLIB) $(LGQ)
$(package)_single_64: $(DEPENDENCIES)
	$(RANLIB) $(LGS64)
$(package)_double_64: $(DEPENDENCIES)
	$(RANLIB) $(LGD64)
$(package)_quadruple_64: $(DEPENDENCIES)
	$(RANLIB) $(LGQ64)

$(package)_ciface: $(package)_ciface_$(PRECIS)
	@printf ' %-21s\n' "GALAHAD: $(PACKAGE) ($(PRECIS) $(SUCC_C)"
$(package)_ciface_single: $(CDEPENDENCIES)
	$(RANLIB) $(CLGS)
$(package)_ciface_double: $(CDEPENDENCIES)
	$(RANLIB) $(CLGD)
$(package)_ciface_quadruple: $(CDEPENDENCIES)
	$(RANLIB) $(CLGQ)
$(package)_ciface_single_64: $(CDEPENDENCIES)
	$(RANLIB) $(CLGS64)
$(package)_ciface_double_64: $(CDEPENDENCIES)
	$(RANLIB) $(CLGD64)
$(package)_ciface_quadruple_64: $(CDEPENDENCIES)
	$(RANLIB) $(CLGQ64)

$(package)_pyiface: $(package)_pyiface_$(PRECIS)
	@printf ' %-21s\n' "GALAHAD: $(PACKAGE) ($(PRECIS) $(SUCC_PY)"
$(package)_pyiface_single: $(PYDEPENDENCIES)
	$(RANLIB) $(PYLGS)
$(package)_pyiface_double: $(PYDEPENDENCIES)
	$(RANLIB) $(PYLGD)
$(package)_pyiface_quadruple: $(PYDEPENDENCIES)
	$(RANLIB) $(PYLGQ)

#  silent CUTEst packages

$(package)_cutest_silent: $(package)_silent_$(PRECIS)
$(package)_cutest_silent_single: $(DEPENDENCIES) $(CUTESTDEPS)
$(package)_cutest_silent_double: $(DEPENDENCIES) $(CUTESTDEPS)
$(package)_cutest_silent_quadruple: $(DEPENDENCIES) $(CUTESTDEPS)
$(package)_cutest_silent_single_64: $(DEPENDENCIES) $(CUTESTDEPS)
$(package)_cutest_silent_double_64: $(DEPENDENCIES) $(CUTESTDEPS)
$(package)_cutest_silent_quadruple_64: $(DEPENDENCIES) $(CUTESTDEPS)

#  CUTEst packages

$(package)_cutest: $(package)_cutest_$(PRECIS)
	@printf ' %-21s\n' "GALAHAD: $(PACKAGE) ($(PRECIS) $(SUCC_CUTEST)"
$(package)_cutest_single: $(DEPENDENCIES) $(CUTESTDEPS)
	$(RANLIB) $(LGS)
$(package)_cutest_double: $(DEPENDENCIES) $(CUTESTDEPS)
	$(RANLIB) $(LGD)
$(package)_cutest_quadruple: $(DEPENDENCIES) $(CUTESTDEPS)
	$(RANLIB) $(LGQ)
$(package)_cutest_single_64: $(DEPENDENCIES) $(CUTESTDEPS)
	$(RANLIB) $(LGS64)
$(package)_cutest_double_64: $(DEPENDENCIES) $(CUTESTDEPS)
	$(RANLIB) $(LGD64)
$(package)_cutest_quadruple_64: $(DEPENDENCIES) $(CUTESTDEPS)
	$(RANLIB) $(LGQ64)

#  book keeping

clean:
	@printf ' %-9s\t\t' "Removing $(package) files"
	$(RMARFILES) $(PACKAGES)
	@printf '[ OK ]\n'

cleanall:
	@printf ' %-14s\t\t' \
          "Removing all $(PRECIS) precision object and module files"
	$(RM) -r $(OBJ)/* $(MOD)/*
	@printf '[ OK ]\n'

#  include required package intermediaries

include $(GALAHAD)/src/makedefs/intermediaries

#  CUTEst specific interfaces

make_ugo_cutest:
	( cd $(GALAHAD)/src/ugo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) ugo_cutest_addon \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/ugo )

make_bgo_cutest:
	( cd $(GALAHAD)/src/bgo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) bgo_cutest_addon \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/bgo )

make_dgo_cutest:
	( cd $(GALAHAD)/src/dgo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) dgo_cutest_addon \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/dgo )

#  comprehensive tests

make_bgo_test:
	( cd $(GALAHAD)/src/bgo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) test \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/bgo )

make_dgo_test:
	( cd $(GALAHAD)/src/dgo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) test \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/dgo )

make_ugo_test:
	( cd $(GALAHAD)/src/ugo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) test \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/ugo )

#  comprehensive and CUTEst tests

make_bgo_tests:
	( cd $(GALAHAD)/src/bgo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) tests \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/bgo )

make_dgo_tests:
	( cd $(GALAHAD)/src/dgo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) tests \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/dgo )

make_ugo_tests:
	( cd $(GALAHAD)/src/ugo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) tests \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/ugo )

#  all tests except CUTEst ones

make_bgo_test_full:
	( cd $(GALAHAD)/src/bgo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) test_full \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/bgo )

make_dgo_test_full:
	( cd $(GALAHAD)/src/dgo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) test_full \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/dgo )

make_ugo_test_full:
	( cd $(GALAHAD)/src/ugo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) test_full \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/ugo )

#  specification documentation tests

make_bgo_test_spec:
	( cd $(GALAHAD)/src/bgo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) test_spec \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/bgo )

make_dgo_test_spec:
	( cd $(GALAHAD)/src/dgo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) test_spec \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/dgo )

make_ugo_test_spec:
	( cd $(GALAHAD)/src/ugo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) test_spec \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/ugo )

#  comprehensive C interface tests

make_ciface_bgo_test:
	( cd $(GALAHAD)/src/bgo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) test_cifaces \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/bgo )

make_ciface_dgo_test:
	( cd $(GALAHAD)/src/dgo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) test_cifaces \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/dgo )

make_ciface_ugo_test:
	( cd $(GALAHAD)/src/ugo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) test_ciface \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/ugo )

#  comprehensive python interface tests

make_pyiface_bgo_test:
	( cd $(GALAHAD)/src/bgo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) test_pyiface \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/bgo )

make_pyiface_dgo_test:
	( cd $(GALAHAD)/src/dgo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) test_pyiface \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/dgo )

make_pyiface_ugo_test:
	( cd $(GALAHAD)/src/ugo ; \
          $(MAKE) -f $(GALAHAD)/makefiles/$(VERSION) test_pyiface \
          PRECIS=$(PRECIS) PWD=$(GALAHAD)/src/ugo )
