# ---
#  This file is distributed under the terms of the
#  Modified BSD License: see the BSD_LICENSE file
# ---
#
.SUFFIXES:
.SUFFIXES: .o .F90 .f90 .F .f .a 
#
default: module_built 
VPATH=.
#
# This makefile can also be used "remotely", so we allow
# for an external specification of the (relative) location 
# of the arch.make file.
#
ARCH_MAKE_DEFAULT=../lib-arch.make
ARCH_MAKE?=$(ARCH_MAKE_DEFAULT)
include $(ARCH_MAKE)
#
#
TEMPLATES= mpi__type_s.f90 mpi__type_sv.f90 mpi__type_v.f90 mpi__type_vs.f90
#
INCFLAGS=-I$(MPI_INCLUDE)
#
Interfaces.f90 V_S.uses VS.uses: $(TEMPLATES)
	if [ -z "$(KINDS)" ] ; then  $(MAKE) kind_explorer ; fi
	@echo "The kind numbers for single and double precision reals follow"
	sh ${<D}/generate.sh "$(KINDS)"
#
kind_explorer: kind_explorer.o
	$(FC) -o kind_explorer $(LDFLAGS) kind_explorer.o
#
mpi.o: mpi__include.o Interfaces.o V_S.uses VS.uses
mpi_siesta.o: timer_mpi.o
Interfaces.o: timer_mpi.o
#
# Note: The copy operation below is only a possible way to
#       make the module files accessible.
#
module_built: libmpi_f90.a
	@touch module_built
	@cp *.mod ..
#
libmpi_f90.a: mpi.o mpi__include.o Interfaces.o timer_mpi.o mpi_siesta.o
	@ar $(ARFLAGS_EXTRA) cru libmpi_f90.a mpi.o mpi__include.o \
                                 Interfaces.o timer_mpi.o mpi_siesta.o
	-$(RANLIB) libmpi_f90.a
#
clean:
	@rm -f Interfaces.f90 *.o *.mod
	@rm -f module_built *.uses kind_explorer




