#===============================================================================
# Copyright 2005-2020 Intel Corporation.
#
# This software and the related documents are Intel copyrighted  materials,  and
# your use of  them is  governed by the  express license  under which  they were
# provided to you (License).  Unless the License provides otherwise, you may not
# use, modify, copy, publish, distribute,  disclose or transmit this software or
# the related documents without Intel's prior written permission.
#
# This software and the related documents  are provided as  is,  with no express
# or implied  warranties,  other  than those  that are  expressly stated  in the
# License.
#===============================================================================

arch = UNKNOWN
setup_file = setup/Make.$(arch)

include $(setup_file)

HPCG_DEPS = src/CG.o \
	    src/CG_ref.o \
	    src/ComputeResidual.o \
	    src/ExchangeHalo.o \
	    src/GenerateGeometry.o \
	    src/GenerateProblem.o \
	    src/ReadHpcgDat.o \
	    src/ReportResults.o \
	    src/TestSymmetry.o \
	    src/TestNorms.o \
	    src/WriteProblem.o \
	    src/YAML_Doc.o \
	    src/YAML_Element.o \
	    src/ComputeDotProduct.o \
	    src/ComputeDotProduct_ref.o \
	    src/mytimer.o \
	    src/ComputeSPMV_ref.o \
	    src/ComputeSYMGS_ref.o \
	    src/ComputeWAXPBY.o \
	    src/ComputeWAXPBY_ref.o \
	    src/ComputeMG_ref.o \
	    src/ComputeProlongation_ref.o \
	    src/ComputeRestriction_ref.o \
	    src/GenerateCoarseProblem.o \
	    src/ComputeOptimalShapeXYZ.o \
	    src/SparseMatrix.o \
	    src/CheckAspectRatio.o \
	    src/CheckProblem.o \
	    src/MixedBaseCounter.o \
	    src/init.o \
	    src/hpcg.o \
	    src/Vector.o \
	    src/AllReduce.o \
	    src/finalize.o

all: bin/xhpcg$(xhpcg_suff)

LINK_ARGS = $(HPCG_DEPS)

bin/xhpcg$(xhpcg_suff): src/main.o $(if $(filter -DHPCG_NO_MPI,$(HPCG_DEFS)),,src/mpi_wrappers.o) $(HPCG_DEPS)
	$(LINKER) -Wl,--start-group $(LINKFLAGS) $(if $(filter y%,$(HPCG_STATIC_IMPI)),-static-intel -static-libgcc -static-libstdc++ -static_mpi) $^ $(HPCG_LIBS) -Wl,--end-group -o $@

src/main.o: HPCG_SRC_PATH/src/main.cpp
	$(CXX) -c $(CXXFLAGS) -IHPCG_SRC_PATH/src $< -o $@

src/offload_main.o: HPCG_SRC_PATH/src/offload_main.cpp
	$(CXXMPI) -c $(CXXMPIFLAGS) -IHPCG_SRC_PATH/src $< -o $@

src/mpi_wrappers.o: HPCG_SRC_PATH/src/mpi_wrappers.cpp
	$(if $(CXXMPI),$(CXXMPI),$(CXX)) -c $(if $(CXXMPIFLAGS),$(CXXMPIFLAGS),$(CXXFLAGS)) -IHPCG_SRC_PATH/src $< -o $@

src/%.o: HPCG_SRC_PATH/src/%.cpp
	$(CXX) -c $(CXXFLAGS) -IHPCG_SRC_PATH/src $< -o $@

clean:
	rm -f src/*.o src/*.o bin/xhpcg

.PHONY: all clean


