#
# Makefile for MD++ simulation package
# by Wei Cai  caiwei@stanford.edu
# Creation Date : Mon Oct 20 15:47:55 2003 
# Last Modified : Tue Dec 13 22:50:41 2005

SYS = gpp
MAKE = make

#Other system options (see Makfile.base) 
#SYS = gcc/gps/ibm/SunOS/IP22/IP27/i686/i586

include Makefile.base

#OPT+=-I/usr/X11R6/include (defunct)

GEN+= -DNO_VSNPRINTF -DNO_XPM -DDEPTH=32
GEN+= -D__GNU_LIBRARY__ -D_SEM_SEMUN_UNDEFINED
GEN+= -I/usr/include/GL
#GEN+= -DNOPREPROCESS

LIBS=general.o filecls.o organizer.o scparser.o display.o relax.o

MEAM-MARIAN-DIR  = ../Fortran/MEAM-Marian
MEAM-MARIAN-LIBS = $(MEAM-MARIAN-DIR)/dscreen.o $(MEAM-MARIAN-DIR)/dscrfor.o $(MEAM-MARIAN-DIR)/forces.o $(MEAM-MARIAN-DIR)/input.o $(MEAM-MARIAN-DIR)/krameam.o $(MEAM-MARIAN-DIR)/linvlc.o $(MEAM-MARIAN-DIR)/meamfunctions.o $(MEAM-MARIAN-DIR)/rhomeam.o $(MEAM-MARIAN-DIR)/screen.o
F90LIBS  = -L/opt/intel/fc/9.0/lib -lifcore

MEAM-BASKES-DIR  = ../Fortran/MEAM-Baskes/meam/linux
MEAM-BASKES-LIBS = $(MEAM-BASKES-DIR)/acfs.o $(MEAM-BASKES-DIR)/cutils.o $(MEAM-BASKES-DIR)/forces.o $(MEAM-BASKES-DIR)/utils.o $(MEAM-BASKES-DIR)/dyn88a.o
F77LIBS  = -lg2c

MEAM-LENOSKY-DIR  = ../Fortran/MEAM-Lenosky
MEAM-LENOSKY-LIBS = $(MEAM-LENOSKY-DIR)/lenosky_lib.o

.PHONY: clean backup sys

all: md
	echo "Fortran codes can be compiled manually by"
	echo "make FMGPT EAM FS FS2 SW CR ALGLUE"

md: md.cpp $(LIBS)
	$(link) -D_TEST  $(XLIBS)

sw: sw.cpp md.o $(LIBS)
	$(link) -D_TEST  $(XLIBS)

swge: swge.cpp md.o $(LIBS)
	$(link) -D_TEST  $(XLIBS)

swsige: swsige.cpp md.o $(LIBS)
	$(link) -D_TEST  $(XLIBS)

fs: fs.cpp md.o $(LIBS)
	$(link) -D_TEST  $(XLIBS)

lj: lj.cpp md.o $(LIBS)
	$(link) -D_TEST  $(XLIBS)

eam: eam.cpp md.o $(LIBS)
	$(link) -D_TEST  $(XLIBS)

meam-marian: meam-marian.cpp md.o $(LIBS)
	cd $(MEAM-MARIAN-DIR); make
	$(link) -D_TEST  $(XLIBS) $(MEAM-MARIAN-LIBS) $(F90LIBS)

meam-baskes: meam-baskes.cpp md.o $(LIBS)
	cd $(MEAM-BASKES-DIR) ; make
	$(link) -D_TEST  $(XLIBS) $(MEAM-BASKES-LIBS) $(F77LIBS)

meam-lenosky: meam-lenosky.cpp md.o $(LIBS)
	cd $(MEAM-LENOSKY-DIR) ; make
	$(link) -D_TEST  $(XLIBS) $(MEAM-LENOSKY-LIBS) $(F90LIBS)

alglue: alglue.cpp aluminum.o md.o $(LIBS)
	$(link) -D_TEST  $(XLIBS)

# Fortran codes
FMGPT:
	cd F90MGPT; $(MAKE)
EAM:
	cd F90EAM; $(MAKE)
FS:
	cd F90FS; $(MAKE)
FS2:
	cd F90FS2; $(MAKE)
SW:
	clsd F90SW; $(MAKE)
CR:
	cd F90CR; $(MAKE)
ALGLUE:
	cd F90ALGLUE; $(MAKE)



# Utilities and tests
disp: display.cpp general.o
	$(link) -D_TEST $(XLIBS)

scparser: scparser.cpp general.o
	$(link) -D_TEST

organizer: organizer.cpp filecls.o scparser.o general.o
	$(link) -D_TEST

cn2pdb:cn2pdb.cpp filecls.o general.o
	$(link) -D_CN2PDB 

xgeo: xgeo.o $(LIBS)
	$(link)  $(XLIBS)

vaspbox: vaspbox.o md.o $(LIBS)
	$(link)  $(XLIBS)

sys:
	SYS=`uname`; export SYS

backup:
	cp -f *.f *.h *.cpp Makefile backup

clean::


Makefile::
	makedepend -Y *.cpp
# DO NOT DELETE

display.o: display.h general.h
general.o: general.h
md.o: md.h general.h organizer.h display.h linalg3.h relax.h
organizer.o: organizer.h

