#===========================================================================#
# 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 Common 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.                                                         #
##########################################################################

# C++ Compiler command
CXX = mpiCC

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

# additional C++ Compiler options for linking
CXXLINKFLAGS =  -Wl,--rpath -Wl,/usr/lib

# Directory with COIN header files
COININCDIR = /usr/include/coin

# Directory with COIN libraries
COINLIBDIR = /usr/lib

# Libraries necessary to link with Clp
LIBS = -L$(COINLIBDIR) -lBlis -lBcps -lAlps -lCgl -lOsiClp -lOsi -lClp -lCoinUtils \
	-L/usr/lib/openmpi/lib -lmpi -lm  \
	`cat /usr/lib/../share/doc/coin/Blis/blis_addlibs.txt` \
	`cat /bcps_addlibs.txt` \
	`cat /alps_addlibs.txt` \
	`cat /cgl_addlibs.txt` \
	`cat /osi_addlibs.txt` \
	`cat /clp_addlibs.txt` \
	`cat /coinutils_addlibs.txt` \
	$(ADDLIBS)

# Necessary Include dirs (we use the CYGPATH_W variables to allow
# compilation with Windows compilers)
INCL =  -I`$(CYGPATH_W) $(COININCDIR)` $(ADDINCFLAGS)

# 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`
