#  Main body of the installation makefile for the GALAHAD PROBLEM package

#  Nick Gould, for GALAHAD productions
#  This version: 2021-05-29

#  include standard GALAHAD makefile defaults before package-specifics

include $(GALAHAD)/src/makedefs/defaults

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

#  package name

package = problem
PACKAGE = PROBLEM

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

DEPENDENCIES = make_dummy make_zd11 make_smt make_userdata
               #make_norms make_tools make_nlpt

#  other packages that depend on package

DEPENDS =

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

TESTDEPS =

#  tests to be performed (preprend with test_)

TESTS =

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

#  include standard GALAHAD makefile definitions

include $(GALAHAD)/src/makedefs/definitions

#  compilation agenda for package

S$(PACKAGE) = $(DEPENDENCIES) $(PRLGS)($(package).o)
D$(PACKAGE) = $(DEPENDENCIES) $(PRLGD)($(package).o)

#  compilation and run agenda

$(PACKAGE)OBJECTSS = $(S$(PACKAGE))
$(PACKAGE)OBJECTSD = $(D$(PACKAGE))

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

#  silent package

$(package)_silent: $(package)_silent_$(PRECIS)
$(package)_silent_single: $($(PACKAGE)OBJECTSS)
$(package)_silent_double: $($(PACKAGE)OBJECTSD)

#  package

$(package): $(package)_$(PRECIS)
	@printf ' %-21s\n' "GALAHAD: $(PACKAGE) ($(PRECIS) $(SUCC)"
$(package)_single: $($(PACKAGE)OBJECTSS)
	$(RANLIB) $(PRLGS)
$(package)_double: $($(PACKAGE)OBJECTSD)
	$(RANLIB) $(PRLGD)

#  non-standard package compilation instructions

$(package).o: $(PRLG)($(package).o)

$(PRLG)($(package).o): ../$(package)/$(package).F90
	@printf ' %-9s %-15s\t\t' "Compiling" "$(package)   "
	$(CP) ../$(package)/$(package).F90 $(OBJ)/$(package).F90
	cd $(OBJ); $(FORTRAN) -o $(package).o $(FFLAGSS) $(package).F90 \
              || ( printf ' %-26s' "=> Disabling optimization " ; \
              $(FORTRAN) -o $(package).o $(FFLAGSN) $(package).F90 )
	cd $(OBJ); $(PRARR) $(package).o ; $(RM) $(package).F90 $(package).o
	$(RMARFILES) $(DEPENDS)
	@printf '[ OK ]\n'

#  book keeping

clean:
	@printf ' %-9s\t\t' "Removing $(package) files"
	$(PRRMARFILE) $(package).o
	@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
