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

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

Fix up handling of nauty now that COIN_CHK_LIB has a functioning link check.

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