source: branches/autotools-update/Cbc/configure.ac @ 2414

Last change on this file since 2414 was 2414, checked in by lou, 2 years ago

Remove COIN_INIT_LIBVARS.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.1 KB
Line 
1# Copyright (C) 2006, 2007 International Business Machines.
2# All Rights Reserved.
3# This file is distributed under the Eclipse Public License.
4
5## $Id: configure.ac 2414 2018-11-03 00:51:05Z 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],[coin-or-cbc],
16        [https://projects.coin-or.org/Cbc])
17
18AC_COPYRIGHT([
19Copyright 2006 International Business Machines and others.
20All Rights Reserved.
21This file is part of the open source package Coin which is distributed
22under the Eclipse Public License.])
23
24# List one file in the package so that the configure script can test
25# whether the package is actually there.
26
27AC_CONFIG_SRCDIR(src/CbcTree.hpp)
28
29# Do some initialization work (version numbers, change prefix default, ...)
30
31AC_COIN_INITIALIZE(Cbc)
32
33#############################################################################
34#                         Standard build tool stuff                         #
35#############################################################################
36
37# Get the name of the C++ compiler and appropriate compiler options
38
39AC_COIN_PROG_CXX
40
41# Not sure where this should be defined. Override for now.
42
43AM_CONDITIONAL(COIN_CXX_IS_CL,[test 1 = 0])
44
45# Initialize libtool
46
47AC_COIN_PROG_LIBTOOL
48
49#############################################################################
50#                   Math headers                                            #
51#############################################################################
52
53# Check for cmath/math.h, cfloat/float.h, cieeefp/ieeefp.h
54
55AC_COIN_CHECK_MATH_HDRS
56
57#############################################################################
58#                            COIN-OR components                             #
59#############################################################################
60
61m4_foreach_w([myvar],[CoinUtils Osi Cgl Clp],
62  [ AC_COIN_CHK_PKG(myvar,[CbcLib CbcGeneric])
63    if test $coin_has_[]m4_tolower(myvar) != yes ; then
64      AC_MSG_ERROR([Required package myvar is not available.])
65    fi
66  ])
67
68AC_COIN_CHK_PKG(OsiClp,[CbcLib CbcGeneric],[osi-clp])
69if test $coin_has_osiclp != yes ; then
70  AC_MSG_ERROR("Required package OsiClp unavailable.")
71fi
72
73# Optional package for command line edit support
74
75AC_COIN_CHK_GNU_READLINE([CbcLib CbcGeneric])
76
77#############################################################################
78#                       Other third party software                          #
79#############################################################################
80
81# Ampl Solver library
82
83AC_COIN_CHK_PKG(ASL,[CbcLib CbcGeneric],[coinasl])
84
85# Nauty library (for symmetry detection). This doesn't seem to work any more;
86# compilation fails looking for zapSymmetry, which doesn't exist.
87# nauty.h
88
89AC_COIN_CHK_LIB([Nauty],[CbcLib CbcGeneric],[-lnauty],[],[],[nauty])
90
91#############################################################################
92
93# Finalize flags for CbcLib, add the result to OsiCbc, and finalize flags for
94# it.
95
96AC_COIN_FINALIZE_FLAGS([CbcLib])
97AC_COIN_CHK_HERE([CbcLib],[OsiCbcLib])
98AC_COIN_FINALIZE_FLAGS(OsiCbcLib)
99
100# The rest are not required for linking against Cbc but are used for the unit
101# test. For the data packages, we just want XXX_DATA for use in Makefile.am.
102
103AC_COIN_CHK_PKG(OsiTests,[CbcUnitTest],[osi-unittests])
104AC_COIN_CHK_PKG(Sample,,[coindatasample],,dataonly)
105AC_COIN_CHK_PKG(Netlib,,[coindatanetlib],,dataonly)
106AC_COIN_CHK_PKG(Miplib3,,[coindatamiplib3],,dataonly)
107
108AC_COIN_FINALIZE_FLAGS(CbcUnitTest)
109
110#############################################################################
111#                    LP solvers other than CLP                              #
112#############################################################################
113
114# Check which other LP solvers are available, some of them become a dependency
115# of CbcGeneric
116
117AC_COIN_CHK_PKG(DyLP,[CbcGeneric],[osi-dylp])
118AC_COIN_CHK_PKG(Vol,,[osi-vol])
119AC_COIN_CHK_PKG(Cpx,[CbcLib CbcGeneric],[osi-cplex])
120AC_COIN_CHK_PKG(Glpk,[CbcGeneric],[osi-glpk])
121AC_COIN_CHK_PKG(Grb,,[osi-gurobi])
122AC_COIN_CHK_PKG(Msk,[CbcGeneric],[osi-mosek])
123AC_COIN_CHK_PKG(Spx,[CbcGeneric],[osi-soplex])
124AC_COIN_CHK_PKG(Xpr,,[osi-xpress])
125
126AC_COIN_FINALIZE_FLAGS(CbcGeneric)
127
128#############################################################################
129#                       CbcGeneric configuration                            #
130#############################################################################
131
132# Are we building cbc-generic? Default is no (false).
133
134AC_ARG_WITH([cbc-generic],
135  AS_HELP_STRING([--with-cbc-generic],
136                 [specify whether to build cbc-generic (default: no)]),
137  [case $withval in
138    yes) cbc_with_cbc_generic=true ;;
139      *) cbc_with_cbc_generic=false ;;
140   esac],
141  [cbc_with_cbc_generic=false])
142if test x"$cbc_with_cbc_generic" = xyes ; then
143  AC_MSG_NOTICE([building cbc-generic])
144fi
145AM_CONDITIONAL(CBC_BUILD_CBC_GENERIC,
146               test x"$cbc_with_cbc_generic" = xtrue)
147
148# Set the default solver for cbc-generic. In theory, any OsiXXX should work.
149# In practice, only the three listed below have had any testing.
150
151AC_MSG_CHECKING(for cbc-generic default solver)
152AC_ARG_WITH([cbc-generic-solver],
153            AC_HELP_STRING([--with-cbc-generic-solver],
154                           [specify default solver for cbc-generic in lower
155                            case letters (if not given, clp is assumed)]),
156            [cbc_default_solver=$withval],
157            [cbc_default_solver=clp])
158AC_MSG_RESULT($cbc_default_solver)
159
160# FIXME what about cplex and mosek here?
161case $cbc_default_solver in
162    clp)
163      ;;
164   dylp)
165      ;;
166   glpk)
167      ;;
168 soplex)
169      ;;
170      *)
171      AC_MSG_WARN([Unrecognised solver $cbc_default_solver chosen as cbc-generic default solver.])
172      ;;
173esac
174AC_DEFINE_UNQUOTED([CBC_DEFAULT_SOLVER],"$cbc_default_solver",
175  [Define to the name of the default solver to be used in cbc-generic in small letters])
176
177
178#############################################################################
179#                       Cbc parallel configuration                          #
180#############################################################################
181
182# First we define a new option, --enable-cbc-parallel
183
184AC_ARG_ENABLE([cbc-parallel],
185[AC_HELP_STRING([--enable-cbc-parallel],
186                [enables compilation of the SMP version of Cbc])])
187
188if test "$enable_cbc_parallel" = yes; then
189  # Define the preprocessor macro
190  AC_DEFINE([CBC_THREAD],[1],[Define to 1 if the SMP version of Cbc should be compiled])
191  if test $coin_cxx_is_cl = true ;
192  then  # Windows / cl
193    # TODO we should check whether the library works and pthread.h is indeed there
194    AC_ARG_WITH(pthreadsw32-lib,
195      AC_HELP_STRING([--with-pthreadsw32-lib],
196        [specify the name of the pthreads win32 library (for cl/icl builds only)]),
197      [CBCLIB_LFLAGS="$withval $CBCLIB_LFLAGS"],
198      [AC_MSG_WARN([--enable-cbc-parallel selected, but --with-pthreadsw32-lib not given])
199       CBCLIB_LFLAGS="pthreadVCE2.lib $CBCLIB_LFLAGS"])
200   
201    AC_ARG_WITH(pthreadsw32-incdir,
202      AC_HELP_STRING([--with-pthreadsw32-incdir],
203        [specify the path of the pthreads win32 header file (for cl/icl builds only)]),
204      [CBCLIB_CFLAGS="$CBCLIB_CFLAGS -I$withval"],
205      [AC_MSG_WARN([--enable-cbc-parallel selected, but --with-pthreadsw32-incdir not given])])
206  else   # not Windows
207    AC_CHECK_LIB([pthread],[pthread_create],
208      [CBCLIB_LFLAGS="-lpthread $CBCLIB_LFLAGS"],
209      [AC_MSG_ERROR([--enable-cbc-parallel selected, but -lpthreads unavailable])])
210    AC_CHECK_LIB([rt],[clock_gettime],
211      [CBCLIB_LFLAGS="-lrt $CBCLIB_LFLAGS"
212       AC_DEFINE([HAVE_CLOCK_GETTIME],[1],[Define if clock_gettime and rt library is available])
213                 ],
214      [AC_MSG_WARN([--enable-cbc-parallel selected, but -lrt unavailable; using gettimeofday instead of clock_gettime])])
215  fi
216  AC_MSG_NOTICE([Cbc multithreading enabled]);
217fi
218
219##############################################################################
220#                            OsiCbc configuration                            #
221##############################################################################
222
223# Handles configuration of the underlying default solver in OsiCbc. The issue
224# is that OsiCbc defines a default solver, used when the client does not     
225# specify a solver in the constructor. The default solver must, therefore,   
226# be present in the build. This macro checks that this is true, and sets the
227# compile-time symbols OSICBC_DFLT_SOLVER, OSICBC_CLP_DFLT_SOLVER, and
228# OSICBC_DFLT_SOLVER_HPP that control the build. The parameter default_solver
229# should normally be clp, unless you're working on some other solver.
230
231# Ideally, this macro would not require enumeration of solvers, but the
232# effort required to avoid it is just not justified at present. One enumeration
233# is hidden in AC_OSI_CANONICAL. The other is visible, the AM_CONDITIONAL
234# list at the end.                                                             
235
236# In an ideal world this macro would do absolutely nothing if Cbc is not
237# present, but autotools is not an ideal world and we have to satisfy its
238# requirements. In particular, the AM_CONDITIONAL macros need to execute or
239# automake will complain. Really the only thing we need to suppress is the
240# check that the default solver exists. All the rest is irrelevant when Cbc
241# isn't present (hence OsiCbc will be configured but not actually compiled).
242
243# Process the with-osicbc-default-solver option.
244
245AC_ARG_WITH([osicbc-default-solver],
246  AS_HELP_STRING([--with-osicbc-default-solver],
247     [specify underlying solver for OsiCbc (default clp)]),
248     [osicbc_with_solver=$withval],
249     [osicbc_with_solver=clp])
250
251case "${osicbc_with_solver}" in
252  @<:@Cc@:>@@<:@Ll@:>@@<:@Pp@:>@*)
253    osi_lc_solver=clp ;           
254    osi_mc_solver=Clp ;           
255    osi_uc_solver=CLP ;           
256    osi_exists_solver=${coin_has_clp-"unavailable"}
257    ;;                                             
258  @<:@Dd@:>@@<:@Yy@:>@@<:@Ll@:>@@<:@Pp@:>@*)       
259    osi_lc_solver=dylp ;                           
260    osi_mc_solver=Dylp                             
261    osi_uc_solver=DYLP                             
262    osi_exists_solver=${coin_has_dylp-"unavailable"}
263    ;;                                             
264  @<:@Cc@:>@@<:@Pp@:>@@<:@Xx@:>@*)                 
265    osi_lc_solver=cpx ;                             
266    osi_mc_solver=Cpx                               
267    osi_uc_solver=CPX                               
268    osi_exists_solver=${coin_has_cpx-"unavailable"}
269    ;;
270  @<:@Gg@:>@@<:@Ll@:>@@<:@Pp@:>@@<:@Kk@:>@*)       
271    osi_lc_solver=glpk ;                           
272    osi_mc_solver=Glpk                             
273    osi_uc_solver=GLPK                             
274    osi_exists_solver=${coin_has_glpk-"unavailable"}
275    ;;
276  @<:@Gg@:>@@<:@Rr@:>@@<:@Bb@:>@*)
277    osi_lc_solver=grb ;
278    osi_mc_solver=Grb ;           
279    osi_uc_solver=GRB ;           
280    osi_exists_solver=${coin_has_grb-"unavailable"}
281    ;;                                             
282  @<:@Mm@:>@@<:@Ss@:>@@<:@Kk@:>@*)
283    osi_lc_solver=msk ;
284    osi_mc_solver=Msk
285    osi_uc_solver=MSK
286    osi_exists_solver=${coin_has_msk-"unavailable"}
287    ;;
288  @<:@Ss@:>@@<:@Pp@:>@@<:@Xx@:>@*)
289    osi_lc_solver=spx ;
290    osi_mc_solver=Spx
291    osi_uc_solver=SPX
292    osi_exists_solver=${coin_has_spx-"unavailable"}
293    ;;
294  @<:@Ss@:>@@<:@Yy@:>@@<:@Mm@:>@*)
295    osi_lc_solver=sym ;
296    osi_mc_solver=Sym
297    osi_uc_solver=SYM
298    osi_exists_solver=${coin_has_sym-"unavailable"}
299    ;;
300  @<:@Vv@:>@@<:@Oo@:>@@<:@Ll@:>@*)
301    osi_lc_solver=vol ;
302    osi_mc_solver=Vol
303    osi_uc_solver=VOL
304    osi_exists_solver=${coin_has_vol-"unavailable"}
305    ;;
306  @<:@Xx@:>@@<:@Pp@:>@@<:@Rr@:>@*)
307    osi_lc_solver=xpr ;
308    osi_mc_solver=Xpr
309    osi_uc_solver=XPR
310    osi_exists_solver=${coin_has_xpr-"unavailable"}
311    ;;
312  *)
313    osi_lc_solver=clp ;
314    osi_mc_solver=Clp ;
315    osi_uc_solver=CLP ;
316    osi_exists_solver=${coin_has_clp-"unavailable"}
317    AC_MSG_WARN([Unrecognised solver $1; defaulting to $osi_lc_solver.])
318    ;;
319esac
320
321# Check that the requested solver is available.
322if test $osi_exists_solver = no; then
323  AC_MSG_ERROR([selected default solver $osicbc_with_solver is unavailable.
324  Please select an available solver using the --with-osicbc-default-solver option.])
325fi
326
327# State the result.
328AC_MSG_NOTICE([OsiCbc default solver is $osi_lc_solver])
329
330# And set the configuration variables.
331AC_DEFINE_UNQUOTED([OSICBC_DFLT_SOLVER],
332  [Osi${osi_mc_solver}SolverInterface],
333  [define to the name of the default solver interface class, e.g., OsiClpSolverInterface])
334AC_DEFINE_UNQUOTED([OSICBC_DFLT_SOLVER_HPP],
335  ["Osi${osi_mc_solver}SolverInterface.hpp"],
336  [define to the name of the .hpp file for the default solver interface class, e.g., "OsiClpSolverInterface.hpp" (include quotes)])
337if test $osi_mc_solver = "Clp"; then
338  AC_DEFINE([OSICBC_DFLT_SOLVER_CLP],[1],[define this symbol if clp is the default solver])
339fi
340
341# Last but not least, we need automake conditionals.
342AM_CONDITIONAL([OSICBC_DFLT_SOLVER_CLP],[test $osi_mc_solver = Clp])
343AM_CONDITIONAL([OSICBC_DFLT_SOLVER_CPX],[test $osi_mc_solver = Cpx])
344AM_CONDITIONAL([OSICBC_DFLT_SOLVER_DYLP],[test $osi_mc_solver = Dylp])
345AM_CONDITIONAL([OSICBC_DFLT_SOLVER_GLPK],[test $osi_mc_solver = Glpk])
346AM_CONDITIONAL([OSICBC_DFLT_SOLVER_GRB],[test $osi_mc_solver = Grb])
347AM_CONDITIONAL([OSICBC_DFLT_SOLVER_MSK],[test $osi_mc_solver = Msk])
348AM_CONDITIONAL([OSICBC_DFLT_SOLVER_SPX],[test $osi_mc_solver = Spx])
349AM_CONDITIONAL([OSICBC_DFLT_SOLVER_SYM],[test $osi_mc_solver = Sym])
350AM_CONDITIONAL([OSICBC_DFLT_SOLVER_VOL],[test $osi_mc_solver = Vol])
351AM_CONDITIONAL([OSICBC_DFLT_SOLVER_XPR],[test $osi_mc_solver = Xpr])
352
353##############################################################################
354#                   VPATH links for example input files                      #
355##############################################################################
356
357# In case this is a VPATH configuration we need to make sure that the
358# input files for the examples are available in the VPATH directory.
359
360# AC_COIN_VPATH_LINK(examples/sudoku_sample.csv)
361# AC_COIN_VPATH_LINK(examples/quad.mps)
362# AC_COIN_VPATH_LINK(examples/quad2.mps)
363
364#############################################################################
365#                  Check for doxygen                                        #
366#############################################################################
367
368AC_COIN_DOXYGEN([CoinUtils Osi Clp DyLP Cgl Vol])
369
370##############################################################################
371#                   Finishing up by writing all the output                   #
372##############################################################################
373
374# Here list all the files that configure should create (except for the
375# configuration header file)
376AC_CONFIG_FILES([Makefile
377                 examples/Makefile
378                 src/Makefile
379                 src/OsiCbc/Makefile
380                 test/Makefile
381                 cbc.pc
382                 osi-cbc.pc])
383AC_CONFIG_FILES([doxydoc/doxygen.conf])
384
385# Here put the location and name of the configuration header file
386AC_CONFIG_HEADER([src/config.h src/config_cbc.h])
387
388# Finally, we let configure write all the output...
389AC_COIN_FINALIZE
Note: See TracBrowser for help on using the repository browser.