#TODO copyright
# $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
EXEDECOMP = decomp_mad
EXEALPS   = alps_mad

# 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         = MAD_DecompApp.o
OBJS        += MAD_Heuristic.o
OBJS        += MAD_DecompDebug.o
OBJS_DECOMP  = $(OBJS) MAD_DecompMain.o
OBJS_ALPS    = $(OBJS) MAD_Main.o

# CLIQUER 
CLIQUER_LIB  = cliquer.a
CLIQUER_DIR  = ./cliquer_msvs
CLIQUER_OBJ  = $(CLIQUER_DIR)/cliquer.o 
CLIQUER_OBJ += $(CLIQUER_DIR)/graph.o 
CLIQUER_OBJ += $(CLIQUER_DIR)/reorder.o

# QUALEX (for now, assume its been built)
QUALEX_LIB  = Qualex
QUALEX_DIR  = ./../ExternalSolvers/MaxClique/Qualex

# CHANGEME: Additional libraries
ADDLIBS  = $(CLIQUER_LIB) 
ADDLIBS += -L$(QUALEX_DIR) -l$(QUALEX_LIB)
ADDLIBS += ../../../../Decomp/examples/ExternalSolvers/lapack-3.1.1/lapack_LINUX.a
ADDLIBS += ../../../../Decomp/examples/ExternalSolvers/lapack-3.1.1/blas_LINUX.a
ADDLIBS += -lg2c


# CHANGEME: Additional flags for compilation (e.g., include flags)
ADDINCFLAGS =-I$(CLIQUER_DIR) -I$(QUALEX_DIR)

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


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

# additional C++ Compiler options for linking
CXXLINKFLAGS = 

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

# Directory with COIN libraries
COINLIBDIR = /usr/lib

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

#TODO
include ../Makefile.Examples

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

#TODO: needs to be conditional on alps or not
#all: $(EXEDECOMP) $(EXEALPS)
all: $(EXEALPS)

.SUFFIXES: .cpp .c .o .obj

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

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

$(CLIQUER_LIB):
	bla=;\
	for file in $(CLIQUER_OBJ); do bla="$$bla `$(CYGPATH_W) $$file`"; done; \
   $(AR) -q $@ $$bla

clean:
	rm -rf $(EXE) $(OBJS_DECOMP) $(OBJS_ALPS) $(CLIQUER_LIB)

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