#
# Makefile for MD++ simulation package
# by Wei Cai  caiwei@stanford.edu
# Creation Date : Mon Oct 20 15:47:55 2003 
# Last Modified : Wed Aug 22 17:24:02 2007

SYS = gpp
MAKE = make
TCL = yes
TOB = no

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

include Makefile.base

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

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

ifeq ($(TCL),yes)
  GEN += -D_USETCL -ITcl_include
  XLIBS+= $(TCLLIBS.$(SYS))
endif

ifeq ($(TOB),yes)
  GEN += -D_TORSION_OR_BENDING
  FORTRAN_SPEC += -D_TORSION_OR_BENDING
endif

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
#IFORTLIBS = -L/opt/intel/fc/9.0/lib -lifcore -lg2c
#F77LIBS  = -lg2c

MEAM-LAMMPS-DIR  = ../Fortran/MEAM-Lammps
#MEAM-LAMMPS-LIBS = -L$(MEAM-LAMMPS-DIR) -lmeam
MEAM-LAMMPS-LIBS = $(MEAM-LAMMPS-DIR)/meam_data.o $(MEAM-LAMMPS-DIR)/meam_setup_done.o $(MEAM-LAMMPS-DIR)/meam_setup_global.o $(MEAM-LAMMPS-DIR)/meam_setup_param.o $(MEAM-LAMMPS-DIR)/meam_dens_init.o $(MEAM-LAMMPS-DIR)/meam_dens_final.o $(MEAM-LAMMPS-DIR)/meam_force.o
#IFORTLIBS = -L/export/apps/intel/fce/9.1.043/lib -lifcore -lg2c
#IFORTLIBS = -L/opt/intel/fc/9.0/lib -lifcore -lg2c
#F77LIBS  = -lg2c

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

.PHONY: clean backup sys

all: md alglue eam fs lj meam sw swge swsige vaspbox xgeo
#	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)

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

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

sworig: sw.cpp mdparallel.o mdparallel.o md.o $(LIBS)
	$(link) -D_SW_Si -D_SW_ORIG -D_TEST  $(XLIBS)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

meam-baskes: meam-baskes.cpp mdparallel.o md.o $(LIBS)
	cd $(MEAM-BASKES-DIR) ; make SPEC=$(FORTRAN_SPEC) compiler_options="$(OPT.$(SYS).$(build))" cc_compiler_options="$(OPT.$(SYS).$(build))"
	$(link) -D_TEST  $(XLIBS) $(MEAM-BASKES-LIBS) $(F90LIBS.$(SYS))

meam-lammps: meam-lammps.cpp mdparallel.o md.o $(LIBS)
	cd $(MEAM-LAMMPS-DIR) ; make SPEC=$(FORTRAN_SPEC) F90FLAGS="$(OPT.$(SYS).$(build))"
	$(link) -D_TEST  $(XLIBS) $(MEAM-LAMMPS-LIBS) $(F90LIBS.$(SYS))

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

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

sing: ising.cpp $(LIBS)
	$(link) -D_TEST $(XLIBS)

testsum: testsum.cpp
	$(link)

# 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

alglue.o: alglue.h mdparallel.h md.h general.h organizer.h scparser.h
alglue.o: filecls.h display.h linalg3.h relax.h
cn2pdb.o: general.h linalg3.h filecls.h
display.o: display.h general.h
display_win.o: display_win.h general.h
eam.o: eam.h mdparallel.h md.h general.h organizer.h scparser.h filecls.h
eam.o: display.h linalg3.h relax.h
filecls.o: filecls.h general.h
fs.o: fs.h mdparallel.h md.h general.h organizer.h scparser.h filecls.h
fs.o: display.h linalg3.h relax.h
general.o: general.h
ising.o: ising.h general.h organizer.h scparser.h filecls.h display.h
lj2.o: lj2.h mdparallel.h md.h general.h organizer.h scparser.h filecls.h
lj2.o: display.h linalg3.h relax.h
ljbond.o: ljbond.h mdparallel.h md.h general.h organizer.h scparser.h
ljbond.o: filecls.h display.h linalg3.h relax.h
lj.o: lj.h mdparallel.h md.h general.h organizer.h scparser.h filecls.h
lj.o: display.h linalg3.h relax.h
ljdimer.o: ljdimer.h mdparallel.h md.h general.h organizer.h scparser.h
ljdimer.o: filecls.h display.h linalg3.h relax.h
md.o: md.h general.h organizer.h scparser.h filecls.h display.h linalg3.h
md.o: relax.h
mdparallel.o: mdparallel.h md.h general.h organizer.h scparser.h filecls.h
mdparallel.o: display.h linalg3.h relax.h
meam-baskes.o: meam-baskes.h mdparallel.h md.h general.h organizer.h
meam-baskes.o: scparser.h filecls.h display.h linalg3.h relax.h
meam.o: meam.h mdparallel.h md.h general.h organizer.h scparser.h filecls.h
meam.o: display.h linalg3.h relax.h
meam-lammps.o: meam-lammps.h mdparallel.h md.h general.h organizer.h
meam-lammps.o: scparser.h filecls.h display.h linalg3.h relax.h
meam-lenosky.o: meam-lenosky.h mdparallel.h md.h general.h organizer.h
meam-lenosky.o: scparser.h filecls.h display.h linalg3.h relax.h
meam-marian.o: meam-marian.h mdparallel.h md.h general.h organizer.h
meam-marian.o: scparser.h filecls.h display.h linalg3.h relax.h
meam.wei.o: meam.h mdparallel.h md.h general.h organizer.h scparser.h
meam.wei.o: filecls.h display.h linalg3.h relax.h
organizer.o: organizer.h scparser.h filecls.h general.h
relax.o: general.h scparser.h
rods.o: rods.h mdparallel.h md.h general.h organizer.h scparser.h filecls.h
rods.o: display.h linalg3.h relax.h
scparser.o: general.h scparser.h
siedip.o: siedip.h mdparallel.h md.h general.h organizer.h scparser.h
siedip.o: filecls.h display.h linalg3.h relax.h
sw.o: sw.h mdparallel.h md.h general.h organizer.h scparser.h filecls.h
sw.o: display.h linalg3.h relax.h
swlj.o: swlj.h mdparallel.h md.h general.h organizer.h scparser.h filecls.h
swlj.o: display.h linalg3.h relax.h
swsiau.o: swsiau.h mdparallel.h md.h general.h organizer.h scparser.h
swsiau.o: filecls.h display.h linalg3.h relax.h
swsige.o: swsige.h mdparallel.h md.h general.h organizer.h scparser.h
swsige.o: filecls.h display.h linalg3.h relax.h
tersoff.o: tersoff.h mdparallel.h md.h general.h organizer.h scparser.h
tersoff.o: filecls.h display.h linalg3.h relax.h
vaspbox.o: mdparallel.h md.h general.h organizer.h scparser.h filecls.h
vaspbox.o: display.h linalg3.h relax.h main.cpp
xgeo.o: xgeo.h mdparallel.h md.h general.h organizer.h scparser.h filecls.h
xgeo.o: display.h linalg3.h relax.h namecolor.c main.cpp
