# -----------------------------------------------------------------
#   Makefile for 2chi2 
#
#   
# --------------------------------------------------------------------

# Set this variable to either UNIX, MAC or WIN
SYS = UNIX

# Leave blank after "=" to disable MPI; put "= 1" to enable
MPI = 

# Put C++ compiler here. It is platform specific. If you will not use MPI, it is not necessarily to define CXX_MPI.
CXX_UNIX = g++
CXX_WIN = c:\bin\mingw\bin\mingw32-g++.exe
CXX_MPI = mpic++

# Define the place of BOOST header files on Windows
HBOOST = C:\MinGW\lib\boost2\include\boost-1_47

# Any other compiler flags here
CXXFLAGS = 

# --------------------------------------------------------------------
# Do not edit below this line
# --------------------------------------------------------------------

CXXFLAGS += -O3 -Wall
OUTPUT = 2chi2

# Define some specific flags

ifeq ($(SYS),WIN)
 CXXFLAGS += -DWIN
 CRM = del
 ifeq ($(MPI),1)
  CXX = $(CXX_MPI)
  FORCE_DYNAMIC = 1
  CXXFLAGS += -D "USEMPI=1"
 else
  CXX = $(CXX_WIN)
 endif
 ifndef FORCE_DYNAMIC
  CXXFLAGS += -static
 endif
 CXXFLAGS += -I $(HBOOST)
endif

ifeq ($(SYS),UNIX)
 CXXFLAGS += -DUNIX
 CRM = rm -f
 ifeq ($(MPI),1)
  CXX = $(CXX_MPI)
  FORCE_DYNAMIC = 1
  CXXFLAGS += -D "USEMPI=1"
 else
  CXX = $(CXX_UNIX)
 endif
 ifndef FORCE_DYNAMIC
  CXXFLAGS += -static
 endif
endif

ifeq ($(SYS),MAC)
 CXXFLAGS += -DUNIX -Dfopen64=fopen
 CRM = rm -f
 ifeq ($(MPI),1)
  CXX = $(CXX_MPI)
  FORCE_DYNAMIC = 1
  CXXFLAGS += -D "USEMPI=1"
 else
  CXX = $(CXX_UNIX)
 endif
endif

SRC = main.cpp input.cpp snp.cpp misc.cpp individu.cpp interaccio.cpp
HDR = main.h input.h snp.h misc.h individu.h interaccio.h
OBJ = $(SRC:.cpp=.o)

all : $(OUTPUT)

$(OUTPUT) :
	$(CXX) $(CXXFLAGS) -o $(OUTPUT) $(OBJ) $(LIB) 

$(OBJ) : $(HDR)

.cpp.o : 
	$(CXX) $(CXXFLAGS) -c $*.cpp
.SUFFIXES : .cpp .c .o $(SUFFIXES)

$(OUTPUT) : $(OBJ)

FORCE:

clean:
	$(CRM) *.o *~ 2chi2

