source: trunk/Cbc/configure.ac @ 1472

Last change on this file since 1472 was 1472, checked in by lou, 10 years ago

Tweaks to use PROJECTDIR_INIT to define CBC_VERSION.

  • Property svn:keywords set to Author Date Id Revision
File size: 15.0 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 1472 2010-06-15 17:43:50Z lou $
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="$CGL_LIBS $OSI_LIBS $COINUTILS_LIBS $LAPACK_LIBS $BLAS_LIBS $GLPK_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])
115AC_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 soplex)
165      ;;
166      *)
167      AC_MSG_WARN([Unrecognised solver $cbc_default_solver chosen as cbc-generic default solver.])
168      ;;
169esac
170AC_DEFINE_UNQUOTED([CBC_DEFAULT_SOLVER],"$cbc_default_solver",
171  [Define to the name of the default solver to be used in cbc-generic in small letters])
172
173
174#############################################################################
175#                       Cbc parallel configuration                          #
176#############################################################################
177
178# First we define a new option, --enable-cbc-parallel
179
180AC_ARG_ENABLE([cbc-parallel],
181[AC_HELP_STRING([--enable-cbc-parallel],
182                [enables compilation of the SMP version of Cbc])])
183
184if test "$enable_cbc_parallel" = yes; then
185  # Define the preprocessor macro
186  AC_DEFINE([CBC_THREAD],[1],[Define to 1 if the SMP version of Cbc should be compiled])
187  AC_CHECK_LIB([rt],[clock_gettime],
188               [ADDLIBS="-lrt $ADDLIBS"
189                AC_DEFINE([HAVE_CLOCK_GETTIME],[1],[Define if clock_gettime and rt library is available])],
190               [AC_MSG_WARN([--enable-cbc-parallel selected, but -lrt unavailable; using gettimeofday instead of clock_gettime])])
191  AC_CHECK_LIB([pthread],[pthread_create],
192               [ADDLIBS="-lpthread $ADDLIBS"],
193               [AC_MSG_ERROR([--enable-cbc-parallel selected, but -lpthreads unavailable])])
194fi
195
196##############################################################################
197#                            OsiCbc configuration                            #
198##############################################################################
199
200# Handles configuration of the underlying default solver in OsiCbc. The issue
201# is that OsiCbc defines a default solver, used when the client does not     
202# specify a solver in the constructor. The default solver must, therefore,   
203# be present in the build. This macro checks that this is true, and sets the
204# compile-time symbols OSICBC_DFLT_SOLVER, OSICBC_CLP_DFLT_SOLVER, and
205# OSICBC_DFLT_SOLVER_HPP that control the build. The parameter default_solver
206# should normally be clp, unless you're working on some other solver.
207
208# Ideally, this macro would not require enumeration of solvers, but the
209# effort required to avoid it is just not justified at present. One enumeration
210# is hidden in AC_OSI_CANONICAL. The other is visible, the AM_CONDITIONAL
211# list at the end.                                                             
212
213# In an ideal world this macro would do absolutely nothing if Cbc is not
214# present, but autotools is not an ideal world and we have to satisfy its
215# requirements. In particular, the AM_CONDITIONAL macros need to execute or
216# automake will complain. Really the only thing we need to suppress is the
217# check that the default solver exists. All the rest is irrelevant when Cbc
218# isn't present (hence OsiCbc will be configured but not actually compiled).
219
220# Process the with-osicbc-default-solver option.
221
222AC_ARG_WITH([osicbc-default-solver],
223  AS_HELP_STRING([--with-osicbc-default-solver],
224     [specify underlying solver for OsiCbc (default clp)]),
225     [osicbc_with_solver=$withval],
226     [osicbc_with_solver=clp])
227
228case "${osicbc_with_solver}" in
229  @<:@Cc@:>@@<:@Ll@:>@@<:@Pp@:>@*)
230    osi_lc_solver=clp ;           
231    osi_mc_solver=Clp ;           
232    osi_uc_solver=CLP ;           
233    osi_exists_solver=${coin_has_clp-"unavailable"}
234    ;;                                             
235  @<:@Dd@:>@@<:@Yy@:>@@<:@Ll@:>@@<:@Pp@:>@*)       
236    osi_lc_solver=dylp ;                           
237    osi_mc_solver=Dylp                             
238    osi_uc_solver=DYLP                             
239    osi_exists_solver=${coin_has_dylp-"unavailable"}
240    ;;                                             
241  @<:@Cc@:>@@<:@Pp@:>@@<:@Xx@:>@*)                 
242    osi_lc_solver=cpx ;                             
243    osi_mc_solver=Cpx                               
244    osi_uc_solver=CPX                               
245    osi_exists_solver=${coin_has_cpx-"unavailable"}
246    ;;
247  @<:@Gg@:>@@<:@Ll@:>@@<:@Pp@:>@@<:@Kk@:>@*)       
248    osi_lc_solver=glpk ;                           
249    osi_mc_solver=Glpk                             
250    osi_uc_solver=GLPK                             
251    osi_exists_solver=${coin_has_glpk-"unavailable"}
252    ;;
253  @<:@Gg@:>@@<:@Rr@:>@@<:@Bb@:>@*)
254    osi_lc_solver=grb ;
255    osi_mc_solver=Grb ;           
256    osi_uc_solver=GRB ;           
257    osi_exists_solver=${coin_has_grb-"unavailable"}
258    ;;                                             
259  @<:@Mm@:>@@<:@Ss@:>@@<:@Kk@:>@*)
260    osi_lc_solver=msk ;
261    osi_mc_solver=Msk
262    osi_uc_solver=MSK
263    osi_exists_solver=${coin_has_msk-"unavailable"}
264    ;;
265  @<:@Ss@:>@@<:@Pp@:>@@<:@Xx@:>@*)
266    osi_lc_solver=spx ;
267    osi_mc_solver=Spx
268    osi_uc_solver=SPX
269    osi_exists_solver=${coin_has_spx-"unavailable"}
270    ;;
271  @<:@Ss@:>@@<:@Yy@:>@@<:@Mm@:>@*)
272    osi_lc_solver=sym ;
273    osi_mc_solver=Sym
274    osi_uc_solver=SYM
275    osi_exists_solver=${coin_has_sym-"unavailable"}
276    ;;
277  @<:@Vv@:>@@<:@Oo@:>@@<:@Ll@:>@*)
278    osi_lc_solver=vol ;
279    osi_mc_solver=Vol
280    osi_uc_solver=VOL
281    osi_exists_solver=${coin_has_vol-"unavailable"}
282    ;;
283  @<:@Xx@:>@@<:@Pp@:>@@<:@Rr@:>@*)
284    osi_lc_solver=xpr ;
285    osi_mc_solver=Xpr
286    osi_uc_solver=XPR
287    osi_exists_solver=${coin_has_xpr-"unavailable"}
288    ;;
289  *)
290    osi_lc_solver=clp ;
291    osi_mc_solver=Clp ;
292    osi_uc_solver=CLP ;
293    osi_exists_solver=${coin_has_clp-"unavailable"}
294    AC_MSG_WARN([Unrecognised solver $1; defaulting to $osi_lc_solver.])
295    ;;
296esac
297
298# Check that the requested solver is available.
299if test $osi_exists_solver = no; then
300  AC_MSG_ERROR([selected default solver $osicbc_with_solver is unavailable.
301  Please select an available solver using the --with-osicbc-default-solver option.])
302fi
303
304# State the result.
305AC_MSG_NOTICE([OsiCbc default solver is $osi_lc_solver])
306
307# And set the configuration variables.
308AC_DEFINE_UNQUOTED([OSICBC_DFLT_SOLVER],
309  [Osi${osi_mc_solver}SolverInterface],
310  [define to the name of the default solver interface class, e.g., OsiClpSolverInterface])
311AC_DEFINE_UNQUOTED([OSICBC_DFLT_SOLVER_HPP],
312  ["Osi${osi_mc_solver}SolverInterface.hpp"],
313  [define to the name of the .hpp file for the default solver interface class, e.g., "OsiClpSolverInterface.hpp" (include quotes)])
314if test $osi_mc_solver = "Clp"; then
315  AC_DEFINE([OSICBC_DFLT_SOLVER_CLP],[1],[define this symbol if clp is the default solver])
316fi
317
318# Last but not least, we need automake conditionals.
319AM_CONDITIONAL([OSICBC_DFLT_SOLVER_CLP],[test $osi_mc_solver = Clp])
320AM_CONDITIONAL([OSICBC_DFLT_SOLVER_CPX],[test $osi_mc_solver = Cpx])
321AM_CONDITIONAL([OSICBC_DFLT_SOLVER_DYLP],[test $osi_mc_solver = Dylp])
322AM_CONDITIONAL([OSICBC_DFLT_SOLVER_GLPK],[test $osi_mc_solver = Glpk])
323AM_CONDITIONAL([OSICBC_DFLT_SOLVER_GRB],[test $osi_mc_solver = Grb])
324AM_CONDITIONAL([OSICBC_DFLT_SOLVER_MSK],[test $osi_mc_solver = Msk])
325AM_CONDITIONAL([OSICBC_DFLT_SOLVER_SPX],[test $osi_mc_solver = Spx])
326AM_CONDITIONAL([OSICBC_DFLT_SOLVER_SYM],[test $osi_mc_solver = Sym])
327AM_CONDITIONAL([OSICBC_DFLT_SOLVER_VOL],[test $osi_mc_solver = Vol])
328AM_CONDITIONAL([OSICBC_DFLT_SOLVER_XPR],[test $osi_mc_solver = Xpr])
329
330##############################################################################
331#                   VPATH links for example input files                      #
332##############################################################################
333
334# In case this is a VPATH configuration we need to make sure that the
335# input files for the examples are available in the VPATH directory.
336
337AC_COIN_VPATH_LINK(examples/sudoku_sample.csv)
338AC_COIN_VPATH_LINK(examples/quad.mps)
339AC_COIN_VPATH_LINK(examples/quad2.mps)
340
341##############################################################################
342#                   Finishing up by writing all the output                   #
343##############################################################################
344
345# Here list all the files that configure should create (except for the
346# configuration header file)
347AC_CONFIG_FILES([Makefile
348                 examples/Makefile
349                 src/Makefile
350                 src/OsiCbc/Makefile
351                 test/Makefile
352                 cbc.pc cbc-uninstalled.pc
353                 osi-cbc.pc osi-cbc-uninstalled.pc])
354
355# Here put the location and name of the configuration header file
356AC_CONFIG_HEADER([inc/config_cbc.h])
357
358# Finally, we let configure write all the output...
359AC_COIN_FINALIZE
Note: See TracBrowser for help on using the repository browser.