## Makefile (G. Samsonidze Oct 2009)
##

PREFIX=../..
include $(PREFIX)/Common/common-rules.mk

SRC     = SAPO_main.f90 pw.f90 ortho.f90 hdiag.f90
OBJ     = $(SRC:.f90=.o)

# object files from Common directory
COMOBJ = norm.o write_program_header.o fft_parallel.o \
	 scalapack.o svninfo.o sort.o random.o fftw.o groupk.o \
	 wfn_rho_vxc_io.o check_inversion.o blas.o lapack.o misc.o \
	 symmetries.o
COMMONOBJS = $(addprefix $(COMMON)/,$(COMOBJ)) $(GLOBALOBJS)

LIBS = $(FFTWLIB) $(SCALAPACKLIB) $(LAPACKLIB)

default: sapo

sapo: sapo$(FLAVOR).x

sapo$(FLAVOR).x: $(COMMONOBJS) $(OBJ) $(SPGLIB)/libsymspg.a
	$(LINK) $(FOPTS) -o $@ $^ $(LIBS)
	$(INSTALL_CMD)

$(OBJ) : $(GLOBALMODS)
SAPO_main.o : $(COMMON)/random_m.mod $(COMMON)/sort_m.mod \
	      $(COMMON)/wfn_rho_vxc_io_m.mod $(COMMON)/fft_parallel_m.mod \
	      $(COMMON)/check_inversion_m.mod \
	      $(COMMON)/symmetries_m.mod $(COMMON)/groupk_m.mod \
	      pw_m.mod ortho_m.mod hdiag_m.mod
pw.o pw_m.mod : $(COMMON)/sort_m.mod $(COMMON)/groupk_m.mod \
	  $(COMMON)/lapack_m.mod $(COMMON)/random_m.mod
ortho.o ortho_m.mod : $(COMMON)/sort_m.mod $(COMMON)/blas_m.mod
hdiag.o hdiag_m.mod : $(COMMON)/blas_m.mod $(COMMON)/lapack_m.mod \
	  $(COMMON)/scalapack_m.mod $(COMMON)/fftw_m.mod \
	  $(COMMON)/fft_parallel_m.mod $(COMMON)/misc_m.mod \
	  pw_m.mod
