# openmpi-single = Fedora 12, gcc-4.4.3, OpenMPI-1.4.1, FFTW-2.1.5 (single precision)
# to select openmpi (over mpich) do: module load openmpi-x86_64
SHELL = /bin/sh

# ---------------------------------------------------------------------
# compiler/linker settings
# specify flags and libraries needed for your compiler

CC =		mpic++
CCFLAGS =	-O3 -march=native -mpc64 -fno-exceptions -fno-rtti -ffast-math -funroll-loops -fstrict-aliasing -Wall -W -Wno-uninitialized
DEPFLAGS =	-MM
LINK =		mpic++
LINKFLAGS =	-O 
LIB =           -Wl,-rpath,/usr/lib64/openmpi/lib -lstdc++
ARCHIVE =	ar
ARFLAGS =	-rcsv
SIZE =		size

# ---------------------------------------------------------------------
# LAMMPS-specific settings
# specify settings for LAMMPS features you will use

# LAMMPS ifdef options, see doc/Section_start.html

LMP_INC =	-DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64

# MPI library, can be src/STUBS dummy lib
# INC = path for mpi.h, MPI compiler settings
# PATH = path for MPI library
# LIB = name of MPI library

MPI_INC =       
MPI_PATH = 
MPI_LIB =	

# FFT library, can be -DFFT_NONE if not using PPPM from KSPACE package
# INC = -DFFT_FFTW, -DFFT_INTEL, -DFFT_NONE, etc, FFT compiler settings
# PATH = path for FFT library
# LIB = name of FFT library

FFT_INC =       -DFFT_FFTW -DFFT_SIZE -DFFT_SINGLE
FFT_PATH = 
FFT_LIB =	-lsfftw

# additional system libraries needed by LAMMPS package libraries
# these settings are IGNORED if the corresponding LAMMPS package
#   (e.g. gpu, meam) is NOT included in the LAMMPS build
# SYSLIB = names of libraries
# SYSPATH = paths of libraries

gpu_SYSLIB =       -lcudart
meam_SYSLIB =      -lgfortran
reax_SYSLIB =      -lgfortran
user-atc_SYSLIB =  -lblas -llapack

gpu_SYSPATH =      -L$(HOME)/cuda/lib64 -Wl,-rpath,$(HOME)/cuda/lib64
meam_SYSPATH =     -L/opt/intel/fce/10.0.023/lib
reax_SYSPATH =     -L/opt/intel/fce/10.0.023/lib
user-atc_SYSPATH = 	

# ---------------------------------------------------------------------
# build rules and dependencies
# no need to edit this section

include	Makefile.package

EXTRA_INC = $(LMP_INC) $(PKG_INC) $(MPI_INC) $(FFT_INC)
EXTRA_PATH = $(PKG_PATH) $(MPI_PATH) $(FFT_PATH) $(PKG_SYSPATH)
EXTRA_LIB = $(PKG_LIB) $(MPI_LIB) $(FFT_LIB) $(PKG_SYSLIB)

# Path to src files

vpath %.cpp ..
vpath %.h ..

# Link target

$(EXE):	$(OBJ)
	$(LINK) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(EXTRA_LIB) $(LIB) -o $(EXE)
	$(SIZE) $(EXE)

# Library target

lib:	$(OBJ)
	$(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)

# Compilation rules

%.o:%.cpp
	$(CC) $(CCFLAGS) $(EXTRA_INC) -c $<

%.d:%.cpp
	$(CC) $(CCFLAGS) $(EXTRA_INC) $(DEPFLAGS) $< > $@

# Individual dependencies

DEPENDS = $(OBJ:.o=.d)
sinclude $(DEPENDS)