# This file is a component of SDPARA
# Copyright (C) 2004 SDPA Project

#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.

#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.

#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# This file is Makefile of SDPARA
# $Id: Makefile,v 1.2 2004/10/08 05:57:48 makoto Exp $

LAPACK = $(HOME)/lapack
RSDPA  = .

LAPACK_LIB =  -llapack -lcblaswr -lcblas \
              -lf77blas -lI77 -lF77 -latlas

# if you use BLAS in clapack.tgz, use next line
# and set NON_ATLAS_SDPA in rsdpa_include.h to 1.
# 
# LAPACK_LIB =  -llapack -lblas -lF77
#

SCALAPACK_LIB =  -lscalapack -lblacs -lblacsc -lblacs

RSDPA_LIB_NAME = sdpara
#RSDPA_LIB_NAME = rsdpa
RSDPA_LIB = -l$(RSDPA_LIB_NAME)

MPIBIN=
CC = $(MPIBIN)mpicxx
F77 = $(MPIBIN)mpif77
OPTION = -O3  #-g

TARGET_EXE = $(RSDPA_LIB_NAME)
#TARGET_EXE = rsdpa_main.exe

OBJS = rsdpa_tool.o rsdpa_algebra.o rsdpa_struct.o \
		rsdpa_parts.o rsdpa_io.o rsdpa_dpotrf.o \
		rsdpa_mpist.o rsdpa_mpicopy.o \
		rsdpa_rpdpotrf.o rsdpa_rpdpotf2.o \
		rsdpa_pdpotrf.o rsdpa_cg.o
BACKUP_IP_ADRRESS = 

now: $(TARGET_EXE)

all: $(TARGET_EXE)

$(TARGET_EXE): rsdpa_main.o $(OBJS)
	$(CC) $(OPTION) -o $@ $< $(OBJS) \
	  -L$(LAPACK)/lib $(SCALAPACK_LIB) $(LAPACK_LIB)

.cpp.o:
	$(CC) $(OPTION) -c -I$(RSDPA) -I$(LAPACK)/include $<
.f.o:
	$(F77) $(OPTION) -c $<

force: clean now
forceall: clean all

clean:
	/bin/rm -f *.o *~ core r r2 p PI*

exe: cleanexe $(TARGET_EXE)

cleanexe:
	/bin/rm -f $(TARGET_EXE)
cleanall: clean cleanexe

backup: clean cleanall
	(cd ..; tar czvf backupprsdpa.tar.gz prsdpa/; \
         rcp backupprsdpa.tar.gz $(BACKUP_IP_ADRRESS):tmp)
