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

## $Id: Makefile.am 1800 2011-08-14 10:37:34Z stefan $

# Author:  Andreas Waechter           IBM    2006-04-13

AUTOMAKE_OPTIONS = foreign

########################################################################
#                         unitTest for Coin                            #
########################################################################

noinst_PROGRAMS = unitTest

unitTest_SOURCES = unitTest.cpp \
  OsiTestSolver.cpp \
  OsiTestSolverInterface.cpp \
  OsiTestSolverInterfaceIO.cpp \
  OsiTestSolverInterfaceTest.cpp

# List libraries of COIN projects
unitTest_LDADD        = ../src/OsiCommonTest/libOsiCommonTests.la
unitTest_DEPENDENCIES = ../src/OsiCommonTest/libOsiCommonTests.la

# Here list all include flags, relative to this "srcdir" directory.  This
# "cygpath" stuff is necessary to compile with native compilers on Windows
AM_CPPFLAGS = \
	-I`$(CYGPATH_W) $(srcdir)/../src/Osi` \
	-I`$(CYGPATH_W) $(srcdir)/../src/OsiCommonTest` \
	$(COINUTILS_CFLAGS)

# This line is necessary to allow VPATH compilation
DEFAULT_INCLUDES = -I. -I`$(CYGPATH_W) $(srcdir)` -I$(top_builddir)/src/Osi

# Depending of what solvers are available, we add the corresponding files,
# libraries and include dirs

if COIN_HAS_CPX
  unitTest_SOURCES += OsiCpxSolverInterfaceTest.cpp
  AM_CPPFLAGS += -I`$(CYGPATH_W) $(CPXINCDIR)` \
	-I`$(CYGPATH_W) $(srcdir)/../src/OsiCpx`
  unitTest_LDADD += ../src/OsiCpx/libOsiCpx.la
  unitTest_DEPENDENCIES += ../src/OsiCpx/libOsiCpx.la
  LIBS += $(CPXLIB)
endif

if COIN_HAS_GLPK
  unitTest_SOURCES += OsiGlpkSolverInterfaceTest.cpp
  AM_CPPFLAGS += $(GLPK_CFLAGS) \
	-I`$(CYGPATH_W) $(srcdir)/../src/OsiGlpk`
  unitTest_LDADD += ../src/OsiGlpk/libOsiGlpk.la
  unitTest_DEPENDENCIES += ../src/OsiGlpk/libOsiGlpk.la
  LIBS += $(GLPK_LIBS)
endif

if COIN_HAS_MSK
  unitTest_SOURCES += OsiMskSolverInterfaceTest.cpp
  AM_CPPFLAGS += -I`$(CYGPATH_W) $(MSKINCDIR)` \
	-I`$(CYGPATH_W) $(srcdir)/../src/OsiMsk`
  unitTest_LDADD += ../src/OsiMsk/libOsiMsk.la
  unitTest_DEPENDENCIES += ../src/OsiMsk/libOsiMsk.la
  LIBS += $(MSKLIB)
endif

if COIN_HAS_XPR
  unitTest_SOURCES += OsiXprSolverInterfaceTest.cpp
  AM_CPPFLAGS += -I`$(CYGPATH_W) $(XPRINCDIR)` \
	-I`$(CYGPATH_W) $(srcdir)/../src/OsiXpr`
  unitTest_LDADD += ../src/OsiXpr/libOsiXpr.la
  unitTest_DEPENDENCIES += ../src/OsiXpr/libOsiXpr.la
  LIBS += $(XPRLIB)
endif

if COIN_HAS_GRB
  unitTest_SOURCES += OsiGrbSolverInterfaceTest.cpp
  AM_CPPFLAGS += -I`$(CYGPATH_W) $(GRBINCDIR)` \
	-I`$(CYGPATH_W) $(srcdir)/../src/OsiGrb`
  unitTest_LDADD += ../src/OsiGrb/libOsiGrb.la
  unitTest_DEPENDENCIES += ../src/OsiGrb/libOsiGrb.la
  LIBS += $(GRBLIB)
endif

if COIN_HAS_SOPLEX
  unitTest_SOURCES += OsiSpxSolverInterfaceTest.cpp
  AM_CPPFLAGS += $(SOPLEX_CFLAGS) \
	-I`$(CYGPATH_W) $(srcdir)/../src/OsiSpx`
  unitTest_LDADD += ../src/OsiSpx/libOsiSpx.la
  unitTest_DEPENDENCIES += ../src/OsiSpx/libOsiSpx.la
  LIBS += $(SOPLEX_LIBS)
endif

unitTest_LDADD        += ../src/Osi/libOsi.la $(OSILIB_LIBS)
unitTest_DEPENDENCIES += ../src/Osi/libOsi.la $(OSILIB_DEPENDENCIES)

unittestflags =
if COIN_HAS_SAMPLE
  unittestflags += -mpsDir=`$(CYGPATH_W) $(SAMPLE_DATA)`
endif
if COIN_HAS_NETLIB
  unittestflags += -netlibDir=`$(CYGPATH_W) $(NETLIB_DATA)` -testOsiSolverInterface
endif

test: unitTest$(EXEEXT)
	./unitTest$(EXEEXT) $(unittestflags)

.PHONY: test

########################################################################
#                          Cleaning stuff                              #
########################################################################

# Here we list everything that is not generated by the compiler, e.g.,
# output files of a program

DISTCLEANFILES = *.mps *.mps.gz *.lp test2out *.out.gz *.out
