# -*-Makefile-*-  Last Modified : Wed Aug  8 16:28:00 2007
# Creation date : Tue Sep 26 15:37:10 2000
# Last Modified : Mon Oct 20 15:49:55 2003

build=D
SPEC=
BIN=bin

##############
# MPICH (for MC-CC, login by ssh, do not use -X)
CC.mpich = icc -w1
OPT.mpich.D=-g3 -D_PARALLEL -I/opt/mpich/intel/include
OPT.mpich.R=-O3 -D_PARALLEL  -I/opt/mpich/intel/include -xK -ipo
LOPT.mpich=-L/usr/X11R6/lib -L/opt/mpich/intel/lib -lpthread -lmpich
XLIBS.mpich=-lX11
TCLLIBS.mpich=-ltcl8.4
F90LIBS.mpich=-L/opt/intel/fc/9.0/lib -lifcore -lg2c

##############
# MPICC
CC.mpicc = icc -w1
OPT.mpicc.D=-g3 -D_PARALLEL
OPT.mpicc.R=-O3 -D_PARALLEL -xK -ipo
LOPT.mpicc=-L/usr/X11R6/lib -lpthread -lmpi -llam
XLIBS.mpicc=-lX11
TCLLIBS.mpicc=-ltcl8.4
F90LIBS.mpicc=-L/opt/intel/fc/9.0/lib -lifcore -lg2c

##############
# MPIgpp
CC.mpigpp = g++ -Wall
OPT.mpigpp.D=-g3 -D_PARALLEL
OPT.mpigpp.R=-O9 -D_PARALLEL -funroll-loops -ffast-math -fomit-frame-pointer -malign-double -mcpu=pentiumpro -finline-functions -march=pentiumpro -fno-exceptions
LOPT.mpigpp=-L/usr/X11R6/lib -lpthread -llammpi++ -lmpi -llam
XLIBS.mpigpp=-lX11
TCLLIBS.mpigpp=-ltcl8.4
F90LIBS.mpigpp=-L/opt/intel/fc/9.0/lib -lifcore -lg2c

##############
# Intel
CC.intel=icc -w1
OPT.intel.D=-g3 
OPT.intel.R=-O3 -xK -ipo
LOPT.intel=-L/usr/X11R6/lib -lpthread
XLIBS.intel=-lX11
TCLLIBS.intel=-ltcl8.4
F90LIBS.intel=-L/opt/intel/fc/9.0/lib -L/export/apps/intel/fc/9.1.043/lib -lifcore -lg2c

##############
# WCR
CC.wcr=icc -w1
OPT.wcr.D=-g3
OPT.wcr.R=-O3 -ipo
LOPT.wcr=-L/usr/X11R6/lib64 -lpthread
XLIBS.wcr=-lX11
TCLLIBS.wcr=-ltcl8.4
F90LIBS.wcr=-L/opt/intel/fc/9.0/lib -lifcore -lg2c

##############
# MPICH for WCR
CC.wcr_mpich = /share/apps/mvapich/intel/bin/mpicc
OPT.wcr_mpich.D=-g3 -D_PARALLEL -I/export/apps/mvapich/intel/include
OPT.wcr_mpich.R=-O3 -D_PARALLEL -I/export/apps/mvapich/intel/include -ipo
LOPT.wcr_mpich=-L/export/apps/mvapich/intel/lib -lpthread -lmpich
XLIBS.wcr_mpich=-L/usr/X11R6/lib64 -lX11
TCLLIBS.wcr_mpich=-ltcl8.4
F90LIBS.wcr_mpich = -L/export/apps/intel/fce/9.1.043/lib -lifcore -lg2c

##############
# Biox
CC.biox=icc -w1
OPT.biox.D=-g3
OPT.biox.R=-O3 -ipo
LOPT.biox=-L/usr/X11R6/lib64 -lpthread
XLIBS.biox=-lX11
F90LIBS.biox=-L/opt/intel/fc/9.0/lib -lifcore -lg2c

##############
# GNU C/C++
CC.gcc=gcc
OPT.gcc.D=-Wall -g3 
OPT.gcc.R=-Wall -O3 
LOPT.gcc=-L/usr/X11R6/lib -lpthread
XLIBS.gcc=-lX11
TCLLIBS.gcc=-ltcl8.4
F90LIBS.gcc=-L/opt/intel/fc/9.0/lib -lifcore -lg2c

##############
# GNU C/C++
CC.gpp=g++
OPT.gpp.D=-Wall -g3 -D_i686
OPT.gpp.R=-Wall -O3 -D_i686
LOPT.gpp=-L/usr/X11R6/lib -lpthread
XLIBS.gpp=-lX11
TCLLIBS.gpp=-ltcl8.4
F90LIBS.gpp=-L/opt/intel/fc/9.0/lib -lifcore -lg2c

##############
# GNU C/C++ in cygwin
CC.cygwin=g++
OPT.cygwin.D=-Wall -g3 -D_i686 -D_NOLOCK -D_NODRAND48
OPT.cygwin.R=-Wall -O3 -D_i686 -D_NOLOCK -D_NODRAND48
LOPT.cygwin=-L/usr/X11R6/lib -lpthread
XLIBS.cygwin=-lX11
TCLLIBS.cygwin=-L/usr/local/lib -ltcl8.4
F90LIBS.cygwin=-L/opt/intel/fc/9.0/lib -lifcore -lg2c

##############
# GNU C/C++ in windows (compile in cygwin, runable in win)
CC.win=g++
OPT.win.D=-Wall -g3 -D_i686 -D_windows -D_NOLOCK -D_NODRAND48 -DNOPREPROCESS -DNO_VSNPRINTF -DNO_XPM -DDEPTH=32 -D__GNU_LIBRARY__ -D_SEM_SEMUN_UNDEFINED -I/usr/include/GL
OPT.win.R=-Wall -O3 -D_i686 -D_windows -D_NOLOCK -D_NODRAND48 -DNOPREPROCESS -DNO_VSNPRINTF -DNO_XPM -DDEPTH=32 -D__GNU_LIBRARY__ -D_SEM_SEMUN_UNDEFINED -I/usr/include/GL
LOPT.win=-L/usr/X11R6/lib -lpthread
XLIBS.win=-lglut32 -lglu32 -lopengl32
TCLLIBS.win=-ltcl84
F90LIBS.win=-L/opt/intel/fc/9.0/lib -lifcore -lg2c

##############
# Mac OS X
CC.mac=g++
OPT.mac.D=-Wall -g3 -D_mac
OPT.mac.R=-Wall -O3 -D_mac
LOPT.mac=-L/usr/X11R6/lib -lpthread
XLIBS.mac=-lX11
TCLLIBS.mac=-ltcl8.4
F90LIBS.mac=-L/opt/intel/fc/9.0/lib -lifcore -lg2c

##############
# IBM C/C++
CC.ibm=xlC
OPT.ibm.D= -g 
OPT.ibm.R= -O3 
LOPT.ibm=-lpthread
XLIBS.ibm=-lX11
TCLLIBS.ibm=-ltcl8.4
F90LIBS.ibm=-L/opt/intel/fc/9.0/lib -lifcore -lg2c

##############
# GPS
CC.gps=cxx -D__gps
OPT.gps.D= -g3 -pthread
OPT.gps.R= -O3 -pthread
GEN.gps+=-DNOPREPROCESS
LOPT.gps= -lrt
XLIBS.gps=-lX11
TCLLIBS.gps=-ltcl8.4
F90LIBS.gps=-L/opt/intel/fc/9.0/lib -lifcore -lg2c

##############
# Xolas SunOS
CC.SunOS=CC
GEN.SunOS=
OPT.SunOS.D=-xCC -g
OPT.SunOS.R=-xCC -xO5 -xdepend -xarch=v8plus -xchip=ultra -fsimple -dalign
XLIBS.SunOS=-lX11
TCLLIBS.SunOS=-ltcl8.4
F90LIBS.SunOS=-L/opt/intel/fc/9.0/lib -lifcore -lg2c

##############
# SGI IRIX
CC.IP22=CC
OPT.IP22.D=-Xcpluscomm -g
OPT.IP22.R=-Xcpluscomm -mips2 -O3 -kpicopt -non_shared 
XLIBS.IP22=-lX11
TCLLIBS.IP22=-ltcl8.4
F90LIBS.IP22=-L/opt/intel/fc/9.0/lib -lifcore -lg2c

##############
# x86 Linux
CC.i686=g++ -D_i686
OPT.i686.D=$(OPT.gcc.D)
OPT.i686.R=$(OPT.gcc.R)
LOPT.i686=-L/usr/X11R6/lib -lpthread
CC.i586=$(CC.i686)
OPT.i586.D=$(OPT.i686.D)
OPT.i586.R=$(OPT.i686.R)
LOPT.i586=$(LOPT.i686)
XLIBS.i586=-lX11
TCLLIBS.i586=-ltcl8.4
F90LIBS.i586=-L/opt/intel/fc/9.0/lib -lifcore -lg2c

##############
# alpha Linux
CC.alpha=gcc
OPT.alpha.R=$(OPT.gcc.R)
OPT.alpha.D=$(OPT.gcc.D)
LOPT.alpha=-L/usr/X11R6/lib -lpthread
XLIBS.alpha=-lX11
TCLLIBS.alpha=-ltcl8.4
F90LIBS.alpha=-L/opt/intel/fc/9.0/lib -lifcore -lg2c

##############
# SGI IRIX64
CC.IP27=CC 
#CC.IP27=gcc -fhuge-objects
FGEN.IP27=-n32
OPT.IP27.R=-Wall -O3
OPT.IP27.D=-D__BIG_ENDIAN
LOPT.IP27=-IPA -lpthread
XLIBS.IP27=-lX11
TCLLIBS.IP27=-ltcl8.4
F90LIBS.IP27=-L/opt/intel/fc/9.0/lib -lifcore -lg2c

##############
#OPT.D=-D_DEBUG
OPT.D=
OPT.R=

GEN=$(OPT.$(SYS).$(build)) $(OPT.$(build)) $(GEN.$(SYS))
FGEN=$(FGEN.$(SYS))
LINK=-lm $(GEN) $(LOPT.$(SYS))
XLIBS=$(XLIBS.$(SYS))
CC=$(CC.$(SYS)) $(SPEC)
cc=cc

##################################################
# Default rules:

define link
$(CC) $^ $(LINK) -o ../$(BIN)/$@_$(SYS)
endef

#_$(SYS)
.PHONY: all clean update

all:

%_t.o:%.cpp %.o
	$(CC) -D_TEST -c $(OPT) $< -o $@
%_t.o:%.c %.o
	$(CC) -D_TEST -c $(OPT) $< -o $@

%.to:%.cpp %.o
	$(CC) -D_TEST -c $(GEN) $< -o $@
%.o:%.cpp
	$(CC) -c $(GEN) $(basename $@).cpp
%.o:%.c
	$(CC) -c $(GEN) $(basename $@).c
clean::
	rm -f $(wildcard *.bak *.o *.to a.out *$(SYS))

%.o:%.f
	$(F77) -c $(FGEN) $^
Makefile::
	makedepend -Y *.cpp
