#===========================================================================#
# This file is part of a solver for the Vehicle Routing Problem             #
# developed using the BiCePS Linear Integer Solver (BLIS).                  #
#                                                                           #
# This solver is distributed under the Eclipse Public License as part of    # 
# the COIN-OR repository (http://www.coin-or.org).                          #
#                                                                           #
# Authors: Yan Xu, Lehigh University                                        #
#          Ted Ralphs, Lehigh University                                    #
#                                                                           #
# Copyright (C) 2007 Yan Xu and Ted Ralphs.                                 #
# All Rights Reserved.                                                      #
#===========================================================================#

## $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: This should be the name of your executable
EXE = vrp

# 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 =  VrpMain.o \
	VrpCutGenerator.o \
	VrpHeurTSP.o \
	VrpParams.o \
	VrpModel.o \
	VrpNetwork.o \
	VrpSolution.o 

# CHANGEME: Additional libraries
ADDLIBS =

# CHANGEME: Additional flags for compilation (e.g., include flags)
ADDINCFLAGS =

# CHANGEME: Directory to the sources for the (example) problem definition
# files
SRCDIR = .


##############################################################################
# This section is for CONCORDE
##############################################################################

##############################################################################
# This solver can use separation routines from CONCORDE, the
# TSP solver of Applegate, Bixby, Chvatal, and Cook. To enable this option:
# 1. set the variables DO_CONCORDE_CUTS to TRUE. 
# 2. Download the source code for CONCORDE and the qsopt LP solver from 
#    http://www.tsp.gatech.edu.
# 3. Put qsopt.a and qsopt.h in ~/lib (make the directory if it doesn't exist).
# 4. Put a copy of qsopt.h in ~/include (make this directory if it doesn't 
#    exist).
#.5. Rename qsopt.a libqsopt.a (so it is detected as a library).
# 6. Build concorde with qsopt as the LP solver (configure --with-qsopt=~/lib).
# 7. Move the resulting library concorde.a to ~/lib and rename it 
#    libconcorde.a (or create a soft link).
# 8. Put a copy of concorde.h in ~/include (or create a soft link).
# 9. Make the CNRP application as usual.
##############################################################################

DO_TSP_CUTS = FALSE

ifeq ($(DO_TSP_CUTS),TRUE)
ADDLIBS += -L${HOME}/lib -lconcorde -lqsopt
ADDINCFLAGS += -I${HOME}/include -DDO_TSP_CUTS 
endif

ADDFLAGS += $(ADDINCFLAGS) @SYMDEFS@

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

COIN_HAS_PKGCONFIG = TRUE
COIN_CXX_IS_CL = #TRUE

# C++ Compiler command
CXX = mpiCC

# C++ Compiler options
CXXFLAGS = -g -O2 -pipe -Wall -DBLIS_BUILD

# additional C++ Compiler options for linking
CXXLINKFLAGS = 

ifeq ($(COIN_HAS_PKGCONFIG), TRUE)
  INCL = `PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/share/pkgconfig: pkg-config --cflags blis`
else
  INCL = 
endif
INCL += $(ADDINCFLAGS)

# Linker flags
ifeq ($(COIN_HAS_PKGCONFIG), TRUE)
  LIBS = `PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/share/pkgconfig: pkg-config --libs blis`
else
  ifeq ($(COIN_CXX_IS_CL), TRUE)
    LIBS = -link -libpath:`$(CYGPATH_W) /usr/lib` libBlis.lib 
  else
    LIBS = -L/usr/lib -lBlis 
  endif
endif

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

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`
