# Copyright (C) 2006 International Business Machines and others.
# All Rights Reserved.
# This file is distributed under the Common Public License.

# $Id$

##########################################################################
#    You can modify this example makefile to fit for your own program.   #
#    Usually, you only need to change the five CHANGEME entries below.   #
##########################################################################

# CHANGEME: add extra definitions here
USER_DEFINES =

# Possibilities: 
#                -DHEUR_SOL :      generate heuristic solutions
#                -DCUSTOM_BRANCH : branch on first non integer variable
#                -DUSER_DATA :     define data associated with each node
#

# CHANGEME: This should be the name of your executable
EXE = bac

# Add access to Cplex if available (see bac.pdf for installation)
ifneq ($(ENV_CPLEX_LIB),)
  LIB_CPLEX = -L$(ENV_CPLEX_LIB) -lcplex -lm -lpthread
  CPLEX_H = $(ENV_CPLEX_H)
  LIB_OsiCpx = -lOsiCpx
endif

# CHANGEME: Here is the name of all object files corresponding to the source
#           code that you wrote in order to define the problem statement
OBJS = \
	./LP/BB_lp.o \
	./TM/BB_tm.o \
	./Member/BB_user_data.o \
	./Member/BB_packer.o \
	./Member/BB_init.o \
	./Member/BB.o \
	./Member/BB_cut.o

# CHANGEME: Additional include directories for compilation. Note that no
# include directory needs to be listed here for headers from COIN.
USER_OSI_LIBS = $(LIB_OsiCpx)
USER_SOLVER_LIBS = $(LIB_CPLEX)
USER_INCDIRS = include

##########################################################################
#  Usually, you don't have to change anything below.  Note that if you   #
#  change certain compiler options, you might have to recompile the      #
#  BCP package.                                                          #
##########################################################################

COIN_HAS_PKGCONFIG = TRUE
COIN_CXX_IS_CL = #TRUE

# C++ Compiler command
CXX = mpiCC

# C++ Compiler options
CXXFLAGS = $(CYGFLAG) -g -O2 -pipe -Wall -DBCP_BUILD $(USER_DEFINES)

# additional C++ Compiler options for linking
CXXLINKFLAGS = 

# Include directories (we use the CYGPATH_W variables to allow compilation with Windows compilers)
ifeq ($(COIN_HAS_PKGCONFIG), TRUE)
  INCL = `PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/share/pkgconfig: /usr/bin/pkg-config --cflags bcp cgl`
else
  INCL =  
endif
INCL += $(ADDINCFLAGS)

# Linker flags
ifeq ($(COIN_HAS_PKGCONFIG), TRUE)
  LIBS = `PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/share/pkgconfig: /usr/bin/pkg-config --libs bcp cgl`
else
  ifeq ($(COIN_CXX_IS_CL), TRUE)
    LIBS = -link -libpath:`$(CYGPATH_W) /usr/lib` libBcp.lib  -L/usr/lib/openmpi/lib -Wl,-rpath,/usr/lib/openmpi/lib -lmpi 
  else
    LIBS = -L/usr/lib -lBcp  -L/usr/lib/openmpi/lib -Wl,-rpath,/usr/lib/openmpi/lib -lmpi 
  endif
endif

LIBS += $(USER_OSI_LIBS) $(USER_SOLVER_LIBS) 

# The following is necessary under cygwin, if native compilers are used
CYGPATH_W = echo

# Necessary Include dirs (we use the CYGPATH_W variables to allow
# compilation with Windows compilers)
INCL += `for i in $(USER_INCDIRS); do $(CYGPATH_W) $$i | sed -e 's/^/-I/'; done`

all: $(EXE)

.SUFFIXES: .cpp .c .o .obj

$(EXE): $(OBJS)
	bla=;\
	for file in $(OBJS); do bla="$$bla `$(CYGPATH_W) $$file`"; done; \
	$(CXX) $(CXXLINKFLAGS) $(CXXFLAGS) -o $@ $$bla $(ADDLIBS) $(LIBS)

clean:
	rm -rf $(EXE) $(OBJS)

.cpp.o:
	$(CXX) $(CXXFLAGS) $(INCL) -c -o $@ `test -f '$<' || echo '$(SRCDIR)/'`$<


.cpp.obj:
	$(CXX) $(CXXFLAGS) $(INCL) -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(SRCDIR)/$<'; fi`
