source: trunk/Cbc/configure.ac @ 1464

Last change on this file since 1464 was 1464, checked in by stefan, 10 years ago

merge split branch into trunk; fix some examples

  • Property svn:keywords set to Author Date Id Revision
File size: 14.8 KB
Line 
1# Copyright (C) 2006, 2007 International Business Machines.
2# All Rights Reserved.
3# This file is distributed under the Common Public License.
4
5## $Id: configure.ac 1464 2010-06-07 12:27:42Z stefan $
6
7# Author:  Andreas Waechter            IBM    2006-04-13
8
9#############################################################################
10#                       Names and other basic things                        #
11#############################################################################
12
13AC_PREREQ(2.59)
14
15AC_INIT([Cbc],[trunk],[cbc@lists.coin-or.org])
16
17AC_COPYRIGHT([
18Copyright 2006 International Business Machines and others.
19All Rights Reserved.
20This file is part of the open source package Coin which is distributed
21under the Common Public License.])
22
23# List one file in the package so that the configure script can test
24# whether the package is actually there
25AC_CONFIG_SRCDIR(src/CbcTree.hpp)
26
27# Where should everything be installed by default?  Here, we want it
28# to be installed directly in 'bin', 'lib', 'include' subdirectories
29# of the directory where configure is run.  The default would be
30# /usr/local.
31AC_PREFIX_DEFAULT([`pwd`])
32
33#############################################################################
34#                         Standard build tool stuff                         #
35#############################################################################
36
37# Get the system type
38AC_CANONICAL_BUILD
39
40# If this project depends on external projects, the Externals file in
41# the source root directory contains definition of where to find those
42# externals.  The following macro ensures that those externals are
43# retrieved by svn if they are not there yet.
44AC_COIN_PROJECTDIR_INIT(Cbc)
45
46# Check if user wants to produce debugging code
47AC_COIN_DEBUG_COMPILE(Cbc)
48
49# Get the name of the C++ compiler and appropriate compiler options
50AC_COIN_PROG_CXX
51
52# Initialize automake and libtool
53AC_COIN_INIT_AUTO_TOOLS
54
55#############################################################################
56#                            COIN-OR components                             #
57#############################################################################
58
59AC_COIN_HAS_MODULE(CoinDepend, [coinutils = trunk osi cgl])
60if test $coin_has_coindepend != yes ; then
61  #if we have to use the fallback routines, then obviously it will not find CoinUtils dependencies
62  #thus, we check whether ThirdParty/Blas, ThirdParty/Lapack, and ThirdParty/Glpk have been setup and
63  #assume that if present then they are dependencies of CoinUtils
64  AC_COIN_HAS_MODULE_FALLBACK(Blas,      [coinblas],   [../ThirdParty/Blas],   [required=0 dodefine=0 doconditional=0])
65  AC_COIN_HAS_MODULE_FALLBACK(Lapack,    [coinlapack], [../ThirdParty/Lapack], [required=0 dodefine=0 doconditional=0])
66  AC_COIN_HAS_MODULE_FALLBACK(Glpk,      [coinglpk],   [../ThirdParty/Glpk],   [required=0 dodefine=0 doconditional=0])
67  AC_COIN_HAS_MODULE_FALLBACK(CoinUtils, [coinutils],  [../CoinUtils],         [dodefine=0 doconditional=0])
68  AC_COIN_HAS_MODULE_FALLBACK(Osi,       [osi],        [../Osi],               [dodefine=0 doconditional=0])
69  AC_COIN_HAS_MODULE_FALLBACK(Cgl,       [cgl],        [../Cgl],               [dodefine=0 doconditional=0])
70  COINDEPEND_LIBS="$COINUTILS_LIBS $BLAS_LIBS $LAPACK_LIBS $GLPK_LIBS $OSI_LIBS $CGL_LIBS"
71  COINDEPEND_CFLAGS="$COINUTILS_CFLAGS $GLPK_CFLAGS $OSI_CFLAGS $CGL_CFLAGS"
72  if test "${coin_has_coinutils}${coin_has_osi}${coin_has_cgl}" = yesyesyes ; then
73    coin_has_coindepend=yes
74    AC_DEFINE(m4_toupper(COIN_HAS_COINDEPEND),[1],[Define to 1 if the COINDEPEND module is available])
75    AM_CONDITIONAL(COIN_HAS_COINDEPEND, [test $coin_has_coindepend = yes])
76  fi
77fi
78if test $coin_has_coindepend != yes ; then
79  AC_MSG_ERROR([Required package CoinUtils, Osi, or Cgl not available.])
80fi
81
82AC_COIN_HAS_MODULE(Clp, [osi-clp])
83if test $coin_has_clp != yes ; then
84  # OsiClp depends on Clp
85  # so if Clp is there, then we assume that also OsiClp will be there and add the corresponding flags to the Clp flags
86  AC_COIN_HAS_MODULE_FALLBACK(Clp, [clp], [../Clp])
87  if test $coin_has_clp = yes ; then
88    AC_COIN_HAS_MODULE_FALLBACK(OsiClp, [osi-clp], [../Clp], [dodefine=0 doconditional=0])
89    CLP_CFLAGS="$CLP_CFLAGS $OSICLP_CFLAGS"
90    CLP_LIBS="$CLP_LIBS $OSICLP_LIBS"
91  fi
92fi
93if test $coin_has_clp != yes ; then
94  AC_MSG_ERROR("Required package Clp unavailable.")
95fi
96
97# we skip fallbacks for the following two
98AC_COIN_HAS_MODULE(DyLP,     [osi-dylp])
99AC_COIN_HAS_MODULE(Vol,      [osi-vol])
100AC_COIN_HAS_MODULE(OsiTests, [osi-unittests], [required=0], [../Osi])
101
102AC_COIN_HAS_MODULE(Sample,  [coindatasample],  [required=0], [../Data/Sample])
103AC_COIN_HAS_MODULE(Netlib,  [coindatanetlib],  [required=0], [../Data/Netlib])
104AC_COIN_HAS_MODULE(Miplib3, [coindatamiplib3], [required=0], [../Data/Miplib3])
105
106#############################################################################
107#                            Third party solvers                            #
108#############################################################################
109
110# Check which third party solvers are available
111AC_COIN_HAS_MODULE(Cpx,  [osi-cplex])
112AC_COIN_HAS_MODULE(Glpk, [osi-glpk])
113AC_COIN_HAS_MODULE(Grb,  [osi-gurobi])
114AC_COIN_HAS_MODULE(Msk,  [osi-mosek])
115#AC_COIN_HAS_MODULE(Spx,  [osi-soplex])
116AC_COIN_HAS_MODULE(Xpr,  [osi-xpress])
117
118#############################################################################
119#                       Other third party software                          #
120#############################################################################
121
122# Ampl Solver library
123AC_COIN_HAS_MODULE(ASL, [coinasl], [required=0], [../ThirdParty/ASL])
124
125#############################################################################
126#                       CbcGeneric configuration                            #
127#############################################################################
128
129# Are we building cbc-generic? Default is no (false).
130
131AC_ARG_WITH([cbc-generic],
132  AS_HELP_STRING([--with-cbc-generic],
133                 [specify whether to build cbc-generic (default: no)]),
134  [case $withval in
135    yes) cbc_with_cbc_generic=true ;;
136      *) cbc_with_cbc_generic=false ;;
137   esac],
138  [cbc_with_cbc_generic=false])
139if test x"$cbc_with_cbc_generic" = xyes ; then
140  AC_MSG_NOTICE([building cbc-generic])
141fi
142AM_CONDITIONAL(CBC_BUILD_CBC_GENERIC,
143               test x"$cbc_with_cbc_generic" = xtrue)
144
145# Set the default solver for cbc-generic. In theory, any OsiXXX should work.
146# In practice, only the three listed below have had any testing.
147
148AC_MSG_CHECKING(for cbc-generic default solver)
149AC_ARG_WITH([cbc-generic-solver],
150            AC_HELP_STRING([--with-cbc-generic-solver],
151                           [specify default solver for cbc-generic in lower
152                            case letters (if not given, clp is assumed)]),
153            [cbc_default_solver=$withval],
154            [cbc_default_solver=clp])
155AC_MSG_RESULT($cbc_default_solver)
156
157case $cbc_default_solver in
158   clp)
159    ;;
160  dylp)
161    ;;
162  glpk)
163    ;;
164     *)
165    AC_MSG_WARN([Unrecognised solver $cbc_default_solver chosen as cbc-generic default solver.])
166    ;;
167esac
168AC_DEFINE_UNQUOTED([CBC_DEFAULT_SOLVER],"$cbc_default_solver",
169  [Define to the name of the default solver to be used in cbc-generic in small letters])
170AC_DEFINE_UNQUOTED(CBC_VERSION, "$PACKAGE_VERSION", "Version of Cbc")
171
172
173#############################################################################
174#                       Cbc parallel configuration                          #
175#############################################################################
176
177# First we define a new option, --enable-cbc-parallel
178
179AC_ARG_ENABLE([cbc-parallel],
180[AC_HELP_STRING([--enable-cbc-parallel],
181                [enables compilation of the SMP version of Cbc])])
182
183if test "$enable_cbc_parallel" = yes; then
184  # Define the preprocessor macro
185  AC_DEFINE([CBC_THREAD],[1],[Define to 1 if the SMP version of Cbc should be compiled])
186  AC_CHECK_LIB([rt],[clock_gettime],
187               [ADDLIBS="-lrt $ADDLIBS"
188                AC_DEFINE([HAVE_CLOCK_GETTIME],[1],[Define if clock_gettime and rt library is available])],
189               [AC_MSG_WARN([--enable-cbc-parallel selected, but -lrt unavailable; using gettimeofday instead of clock_gettime])])
190  AC_CHECK_LIB([pthread],[pthread_create],
191               [ADDLIBS="-lpthread $ADDLIBS"],
192               [AC_MSG_ERROR([--enable-cbc-parallel selected, but -lpthreads unavailable])])
193fi
194
195##############################################################################
196#                            OsiCbc configuration                            #
197##############################################################################
198
199# Handles configuration of the underlying default solver in OsiCbc. The issue
200# is that OsiCbc defines a default solver, used when the client does not     
201# specify a solver in the constructor. The default solver must, therefore,   
202# be present in the build. This macro checks that this is true, and sets the
203# compile-time symbols OSICBC_DFLT_SOLVER, OSICBC_CLP_DFLT_SOLVER, and
204# OSICBC_DFLT_SOLVER_HPP that control the build. The parameter default_solver
205# should normally be clp, unless you're working on some other solver.
206
207# Ideally, this macro would not require enumeration of solvers, but the
208# effort required to avoid it is just not justified at present. One enumeration
209# is hidden in AC_OSI_CANONICAL. The other is visible, the AM_CONDITIONAL
210# list at the end.                                                             
211
212# In an ideal world this macro would do absolutely nothing if Cbc is not
213# present, but autotools is not an ideal world and we have to satisfy its
214# requirements. In particular, the AM_CONDITIONAL macros need to execute or
215# automake will complain. Really the only thing we need to suppress is the
216# check that the default solver exists. All the rest is irrelevant when Cbc
217# isn't present (hence OsiCbc will be configured but not actually compiled).
218
219# Process the with-osicbc-default-solver option.
220
221AC_ARG_WITH([osicbc-default-solver],
222  AS_HELP_STRING([--with-osicbc-default-solver],
223     [specify underlying solver for OsiCbc (default clp)]),
224     [osicbc_with_solver=$withval],
225     [osicbc_with_solver=clp])
226
227case "${osicbc_with_solver}" in
228  @<:@Cc@:>@@<:@Ll@:>@@<:@Pp@:>@*)
229    osi_lc_solver=clp ;           
230    osi_mc_solver=Clp ;           
231    osi_uc_solver=CLP ;           
232    osi_exists_solver=${coin_has_clp-"unavailable"}
233    ;;                                             
234  @<:@Dd@:>@@<:@Yy@:>@@<:@Ll@:>@@<:@Pp@:>@*)       
235    osi_lc_solver=dylp ;                           
236    osi_mc_solver=Dylp                             
237    osi_uc_solver=DYLP                             
238    osi_exists_solver=${coin_has_dylp-"unavailable"}
239    ;;                                             
240  @<:@Cc@:>@@<:@Pp@:>@@<:@Xx@:>@*)                 
241    osi_lc_solver=cpx ;                             
242    osi_mc_solver=Cpx                               
243    osi_uc_solver=CPX                               
244    osi_exists_solver=${coin_has_cpx-"unavailable"}
245    ;;
246  @<:@Gg@:>@@<:@Ll@:>@@<:@Pp@:>@@<:@Kk@:>@*)       
247    osi_lc_solver=glpk ;                           
248    osi_mc_solver=Glpk                             
249    osi_uc_solver=GLPK                             
250    osi_exists_solver=${coin_has_glpk-"unavailable"}
251    ;;
252  @<:@Gg@:>@@<:@Rr@:>@@<:@Bb@:>@*)
253    osi_lc_solver=grb ;
254    osi_mc_solver=Grb ;           
255    osi_uc_solver=GRB ;           
256    osi_exists_solver=${coin_has_grb-"unavailable"}
257    ;;                                             
258  @<:@Mm@:>@@<:@Ss@:>@@<:@Kk@:>@*)
259    osi_lc_solver=msk ;
260    osi_mc_solver=Msk
261    osi_uc_solver=MSK
262    osi_exists_solver=${coin_has_msk-"unavailable"}
263    ;;
264  @<:@Ss@:>@@<:@Yy@:>@@<:@Mm@:>@*)
265    osi_lc_solver=sym ;
266    osi_mc_solver=Sym
267    osi_uc_solver=SYM
268    osi_exists_solver=${coin_has_sym-"unavailable"}
269    ;;
270  @<:@Vv@:>@@<:@Oo@:>@@<:@Ll@:>@*)
271    osi_lc_solver=vol ;
272    osi_mc_solver=Vol
273    osi_uc_solver=VOL
274    osi_exists_solver=${coin_has_vol-"unavailable"}
275    ;;
276  @<:@Xx@:>@@<:@Pp@:>@@<:@Rr@:>@*)
277    osi_lc_solver=xpr ;
278    osi_mc_solver=Xpr
279    osi_uc_solver=XPR
280    osi_exists_solver=${coin_has_xpr-"unavailable"}
281    ;;
282  *)
283    osi_lc_solver=clp ;
284    osi_mc_solver=Clp ;
285    osi_uc_solver=CLP ;
286    osi_exists_solver=${coin_has_clp-"unavailable"}
287    AC_MSG_WARN([Unrecognised solver $1; defaulting to $osi_lc_solver.])
288    ;;
289esac
290
291# Check that the requested solver is available.
292if test $osi_exists_solver = no; then
293  AC_MSG_ERROR([selected default solver $osicbc_with_solver is unavailable.
294  Please select an available solver using the --with-osicbc-default-solver option.])
295fi
296
297# State the result.
298AC_MSG_NOTICE([OsiCbc default solver is $osi_lc_solver])
299
300# And set the configuration variables.
301AC_DEFINE_UNQUOTED([OSICBC_DFLT_SOLVER],
302  [Osi${osi_mc_solver}SolverInterface],
303  [define to the name of the default solver interface class, e.g., OsiClpSolverInterface])
304AC_DEFINE_UNQUOTED([OSICBC_DFLT_SOLVER_HPP],
305  ["Osi${osi_mc_solver}SolverInterface.hpp"],
306  [define to the name of the .hpp file for the default solver interface class, e.g., "OsiClpSolverInterface.hpp" (include quotes)])
307if test $osi_mc_solver = "Clp"; then
308  AC_DEFINE([OSICBC_DFLT_SOLVER_CLP],[1],[define this symbol if clp is the default solver])
309fi
310
311# Last but not least, we need automake conditionals.
312AM_CONDITIONAL([OSICBC_DFLT_SOLVER_CLP],[test $osi_mc_solver = Clp])
313AM_CONDITIONAL([OSICBC_DFLT_SOLVER_CPX],[test $osi_mc_solver = Cpx])
314AM_CONDITIONAL([OSICBC_DFLT_SOLVER_DYLP],[test $osi_mc_solver = Dylp])
315AM_CONDITIONAL([OSICBC_DFLT_SOLVER_GLPK],[test $osi_mc_solver = Glpk])
316AM_CONDITIONAL([OSICBC_DFLT_SOLVER_GRB],[test $osi_mc_solver = Grb])
317AM_CONDITIONAL([OSICBC_DFLT_SOLVER_MSK],[test $osi_mc_solver = Msk])
318AM_CONDITIONAL([OSICBC_DFLT_SOLVER_SYM],[test $osi_mc_solver = Sym])
319AM_CONDITIONAL([OSICBC_DFLT_SOLVER_VOL],[test $osi_mc_solver = Vol])
320AM_CONDITIONAL([OSICBC_DFLT_SOLVER_XPR],[test $osi_mc_solver = Xpr])
321
322##############################################################################
323#                   VPATH links for example input files                      #
324##############################################################################
325
326# In case this is a VPATH configuration we need to make sure that the
327# input files for the examples are available in the VPATH directory.
328
329AC_COIN_VPATH_LINK(examples/sudoku_sample.csv)
330AC_COIN_VPATH_LINK(examples/quad.mps)
331AC_COIN_VPATH_LINK(examples/quad2.mps)
332
333##############################################################################
334#                   Finishing up by writing all the output                   #
335##############################################################################
336
337# Here list all the files that configure should create (except for the
338# configuration header file)
339AC_CONFIG_FILES([Makefile
340                 examples/Makefile
341                 src/Makefile
342                 src/OsiCbc/Makefile
343                 test/Makefile
344                 cbc.pc cbc-uninstalled.pc
345                 osi-cbc.pc osi-cbc-uninstalled.pc])
346
347# Here put the location and name of the configuration header file
348AC_CONFIG_HEADER([inc/config_cbc.h])
349
350# Finally, we let configure write all the output...
351AC_COIN_FINALIZE
Note: See TracBrowser for help on using the repository browser.