# -*-Makefile-*-  Last Modified : Fri May 15 14:18:26 2009
# 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
F77.mpich = ifort
F90.mpich = ifort
cc.mpich = $(CC.mpich)
F77LIBS.mpich=-L/export/apps/intel/fc/9.1.043/lib -lifcore -lg2c
F90LIBS.mpich=-L/export/apps/intel/fc/9.1.043/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
F77.mpicc = ifort
F90.mpicc = ifort
cc.mpicc = $(CC.mpicc)
F77LIBS.mpicc=-L/opt/intel/fc/9.0/lib -lifcore -lg2c
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
F77.mpigpp = ifort
F90.mpigpp = ifort
cc.mpigpp = $(CC.mpigpp)
F77LIBS.mpigpp=-L/opt/intel/fc/9.0/lib -lifcore -lg2c
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
TKLIBS.intel=-ltk8.4
F77.intel = ifort
F90.intel = ifort
cc.intel = icc
F77LIBS.intel=-L/opt/intel/fc/10.1.012/lib -lifcore -lg2c
F90LIBS.intel=-L/opt/intel/fc/10.1.012/lib -lifcore -lg2c

##############
# MC-CC
CC.mc-cc=icc -w1
OPT.mc-cc.D=-g3 
OPT.mc-cc.R=-O3 -xK -ipo
LOPT.mc-cc=-L/usr/X11R6/lib -lpthread
XLIBS.mc-cc=-lX11
TCLLIBS.mc-cc=-ltcl8.4
TKLIBS.mc-cc=-ltk8.4
FFTWINCLUDE.mc-cc=-I/home/caiwei/Codes/fftw-3.1.2/api
FFTWLIBS.mc-cc=-L/home/caiwei/Codes/fftw-3.1.2/.libs -lfftw3
F77.mc-cc = ifort
F90.mc-cc = ifort
cc.mc-cc = $(CC.mc-cc)
F77LIBS.mc-cc=-L/export/apps/intel/fc/9.1.043/lib -lifcore -lg2c
F90LIBS.mc-cc=-L/export/apps/intel/fc/9.1.043/lib -lifcore -lg2c

##############
# WCR
CC.wcr=icc -w
OPT.wcr.D=-g3
OPT.wcr.R=-O3 -ipo
LOPT.wcr=-L/usr/X11R6/lib64 -lpthread
XLIBS.wcr=-lX11
TCLLIBS.wcr=-ltcl8.4
TKLIBS.wcr=-ltk8.4
F77.wcr = ifort
F90.wcr = ifort
cc.wcr = $(CC.wcr)
#F77LIBS.wcr=-L/export/apps/intel/fce/9.1.039/lib -lifcore -lg2c
#F90LIBS.wcr=-L/export/apps/intel/fce/9.1.039/lib -lifcore -lg2c
F77LIBS.wcr=-L/opt/intel/fce/10.1.011/lib -lifcore -lg2c
F90LIBS.wcr=-L/opt/intel/fce/10.1.011/lib -lifcore -lg2c
OCTAVEINC.wcr=-I/usr/include/octave-2.1.57 -I/usr/include/octave-2.1.57/octave
OCTAVELIBS.wcr=-L/usr/lib64/octave-2.1.57/lib -loctave -loctinterp

##############
# 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
TKLIBS.wcr_mpich=-ltk8.4
F77.wcr_mpich = ifort
F90.wcr_mpich = ifort
cc.wcr_mpich = $(CC.wcr_mpich)
F77LIBS.wcr_mpich=-L/opt/intel/fc/9.0/lib -lifcore -lg2c
F90LIBS.wcr_mpich=-L/export/apps/intel/fce/9.1.043/lib -lifcore -lg2c

##############
# SU-AHPCRC
CC.su-ahpcrc=icc -w1
OPT.su-ahpcrc.D=-g3
OPT.su-ahpcrc.R=-O3 -ipo
LOPT.su-ahpcrc=-L/usr/X11R6/lib64 -lpthread
XLIBS.su-ahpcrc=-lX11
TCLLIBS.su-ahpcrc=-ltcl8.4
TKLIBS.su-ahpcrc=-ltk8.4
F77.su-ahpcrc = ifort
F90.su-ahpcrc = ifort
cc.su-ahpcrc = $(CC.wcr)
F77LIBS.su-ahpcrc=-L/opt/intel/fce/10.1.015/lib -lifcore
F90LIBS.su-ahpcrc=-L/opt/intel/fce/10.1.015/lib -lifcore 
OCTAVEINC.su-ahpcrc=-I/lustre/home/mpotts/octave/include/octave-3.0.3
OCTAVELIBS.su-ahpcrc=-L/lustre/home/mpotts/octave/lib/octave-3.0.3 -loctave -loctinterp

##############
# MPICH for SU-AHPCRC
CC.su-ahpcrc_mpich = mpicxx
OPT.su-ahpcrc_mpich.D=-g3 -mtune core2 -unroll -D_PARALLEL -DMPICH_IGNORE_CXX_SEEK 
OPT.su-ahpcrc_mpich.R=-O3 -mtune core2 -unroll -D_PARALLEL -DMPICH_IGNORE_CXX_SEEK -ipo
#OPT.su-ahpcrc_mpich.D=-g3 -mtune core2 -unroll -D_PARALLEL -I/usr/mpi/intel/mvapich-0.9.9/include
#OPT.su-ahpcrc_mpich.R=-O3 -mtune core2 -unroll -D_PARALLEL -I/usr/mpi/intel/mvapich-0.9.9/include -ipo
LOPT.su-ahpcrc_mpich= -lpthread -lmpich
XLIBS.su-ahpcrc_mpich=-L/usr/X11R6/lib64 -lX11
TCLLIBS.su-ahpcrc_mpich=-ltcl8.4
TKLIBS.su-ahpcrc_mpich=-ltk8.4
F77.su-ahpcrc_mpich = ifort
F90.su-ahpcrc_mpich = ifort
cc.su-ahpcrc_mpich = $(CC.su-ahpcrc_mpich)
#F77LIBS.su-ahpcrc_mpich= -lifcore -lg2c
#F90LIBS.su-ahpcrc_mpich= -lifcore -lg2c
F77LIBS.su-ahpcrc_mpich= -L/opt/intel/fce/10.1.015/lib -lifcore
F90LIBS.su-ahpcrc_mpich= -L/opt/intel/fce/10.1.015/lib -lifcore

##############
# Biox
CC.biox=icc -w1
OPT.biox.D=-g3
OPT.biox.R=-O3 -ipo
LOPT.biox=-L/usr/X11R6/lib64 -lpthread
XLIBS.biox=-lX11
F77.biox = ifort
F90.biox = ifort
cc.biox = $(CC.biox)
F77LIBS.biox=-L/opt/intel/fc/9.0/lib -lifcore -lg2c
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
F77.gcc = g77
F90.gcc = g95
cc.gcc = gcc
F77LIBS.gcc=-L/opt/intel/fc/9.0/lib -lifcore -lg2c
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
F77.gpp = g77
F90.gpp = gfortran
cc.gpp = gcc
F77LIBS.gpp=-lg2c -lstdc++
F90LIBS.gpp=-lg2c -lstdc++ -lgfortran
F90OPT.gpp.D = -g -fno-second-underscore
F90OPT.gpp.R = -O -fno-second-underscore

##############
# GNU C/C++ in cygwin
CC.cygwin=g++
OPT.cygwin.D=-Wall -g3 -D_i686 -D_NOLOCK -D_NODRAND48 -D_CYGWIN
OPT.cygwin.R=-Wall -O3 -D_i686 -D_NOLOCK -D_NODRAND48 -D_CYGWIN
LOPT.cygwin=-L/usr/X11R6/lib -lpthread
XLIBS.cygwin=-lX11
TCLLIBS.cygwin=-L/usr/local/lib -ltcl8.4
TKLIBS.cygwin=-ltk8.4
F77.cygwin = g95 -fsloppy-char
F90.cygwin = g95
cc.cygwin = gcc
F77LIBS.cygwin=-L/usr/local/lib/gcc-lib/i686-pc-cygwin/4.0.3 -lf95
F90LIBS.cygwin=-L/usr/local/lib/gcc-lib/i686-pc-cygwin/4.0.3 -lf95 
OCTAVEINC.cygwin=-I/usr/include/octave-2.1.73
OCTAVELIBS.cygwin=-L/usr/lib/octave-2.1.73 -loctave -loctinterp

##############
# GNU C/C++ in cygwin (requires gcc 4.3.2)
CC.cygwin-gcc4=g++-4
OPT.cygwin-gcc4.D=-Wall -g3 -D_i686 -D_NOLOCK -D_NODRAND48
OPT.cygwin-gcc4.R=-Wall -O3 -D_i686 -D_NOLOCK -D_NODRAND48
LOPT.cygwin-gcc4=-L/usr/X11R6/lib -lpthread
XLIBS.cygwin-gcc4=-lX11
TCLLIBS.cygwin-gcc4=-L/usr/local/lib -ltcl84
TKLIBS.cygwin-gcc4=-ltk84
F77.cygwin-gcc4 = gfortran
F90.cygwin-gcc4 = gfortran
cc.cygwin-gcc4 = gcc-4
F77LIBS.cygwin-gcc4 = -lgfortran
F90LIBS.cygwin-gcc4 = -L/usr/lib/gcc/i686-pc-cygwin/4.3.2 -lgfortran
OCTAVEINC.cygwin-gcc4 =-I/usr/include/octave-2.1.73
OCTAVELIBS.cygwin-gcc4 =-L/usr/lib/octave-2.1.73 -loctave -loctinterp

##############
# 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
F77.win = g77
F90.win = g95
cc.win = gcc
F77LIBS.win=-L/opt/intel/fc/9.0/lib -lifcore -lg2c
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
F77.mac = gfortran
F90.mac = gfortran
cc.mac = gcc
F77LIBS.mac=-L/usr/local/lib -lgfortran
F90LIBS.mac=-L/usr/local/lib -lgfortran
#F77LIBS.mac=-L/opt/intel/fc/9.0/lib -lifcore -lg2c
#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
F77.ibm = xlf
F90.ibm = xlf
cc.ibm = $(CC.ibm)
F77LIBS.ibm=-L/opt/intel/fc/9.0/lib -lifcore -lg2c
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
F77.gps = ifort
F90.gps = ifort
cc.gps = $(CC.gps)
F77LIBS.gps=-L/opt/intel/fc/9.0/lib -lifcore -lg2c
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
F77.SunOS = g77
F90.SunOS = g95
cc.SunOS = $(CC.SunOS)
F77LIBS.SunOS=-L/opt/intel/fc/9.0/lib -lifcore -lg2c
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
F77.IP22 = g77
F90.IP22 = g95
cc.IP22 = $(CC.IP22)
F77LIBS.IP22=-L/opt/intel/fc/9.0/lib -lifcore -lg2c
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
F77.i586 = g77
F90.i586 = g95
cc.i586 = $(CC.i586)
F77LIBS.i586=-L/opt/intel/fc/9.0/lib -lifcore -lg2c
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
F77.alpha = g77
F90.alpha = g95
cc.alpha = $(CC.alpha)
F77LIBS.alpha=-L/opt/intel/fc/9.0/lib -lifcore -lg2c
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
F77.IP27 = g77
F90.IP27 = g95
cc.IP27 = $(CC.IP27)
F77LIBS.IP27=-L/opt/intel/fc/9.0/lib -lifcore -lg2c
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
