source: trunk/coin.m4 @ 3119

Last change on this file since 3119 was 3119, checked in by stefan, 7 years ago

give coin.m4 a fresh start, see also #95

  • Property svn:keywords set to Author Date Id Revision
File size: 5.4 KB
Line 
1# Copyright (C) 2013
2# All Rights Reserved.
3# This file is distributed under the Eclipse Public License.
4#
5# This file defines the common autoconf macros for COIN-OR
6#
7
8# Check requirements
9AC_PREREQ(2.69)
10
11
12###########################################################################
13#                            COIN_CHECK_ISFINITE                          #
14###########################################################################
15
16# This macro checks for a usable implementation of a function to check
17# whether a given floating point number is finite.
18# If a function is found, then the macro defines the symbol
19# toupper($1)_C_FINITE to the name of this function.
20
21AC_DEFUN([AC_COIN_CHECK_ISFINITE],[
22
23AC_LANG_PUSH(C++)
24
25#AC_COIN_CHECK_CXX_CHEADER(math)
26#AC_COIN_CHECK_CXX_CHEADER(float)
27#AC_COIN_CHECK_CXX_CHEADER(ieeefp)
28AC_CHECK_HEADERS([cmath])
29if test "$ac_cv_header_cmath" != "yes"; then
30  AC_CHECK_HEADERS([math.h])
31fi
32AC_CHECK_HEADERS([cfloat])
33if test "$ac_cv_header_cfloat" != "yes"; then
34  AC_CHECK_HEADERS([float.h])
35fi
36AC_CHECK_HEADERS([cieeefp])
37if test "$ac_cv_header_cieeefp" != "yes"; then
38  AC_CHECK_HEADERS([ieeefp.h])
39fi
40
41COIN_C_FINITE=
42AC_CHECK_DECL([isfinite],[COIN_C_FINITE=isfinite],,[
43#ifdef HAVE_CMATH
44# include <cmath>
45#else
46# ifdef HAVE_MATH_H
47#  include <math.h>
48# endif
49#endif
50#ifdef HAVE_CFLOAT
51# include <cfloat>
52#else
53# ifdef HAVE_FLOAT_H
54#  include <float.h>
55# endif
56#endif
57#ifdef HAVE_CIEEEFP
58# include <cieeefp>
59#else
60# ifdef HAVE_IEEEFP_H
61#  include <ieeefp.h>
62# endif
63#endif])
64if test -z "$COIN_C_FINITE"; then
65  AC_CHECK_DECL([finite],[COIN_C_FINITE=finite],,[
66#ifdef HAVE_CMATH
67# include <cmath>
68#else
69# ifdef HAVE_MATH_H
70#  include <math.h>
71# endif
72#endif
73#ifdef HAVE_CFLOAT
74# include <cfloat>
75#else
76# ifdef HAVE_FLOAT_H
77#  include <float.h>
78# endif
79#endif
80#ifdef HAVE_CIEEEFP
81# include <cieeefp>
82#else
83# ifdef HAVE_IEEEFP_H
84#  include <ieeefp.h>
85# endif
86#endif])
87  if test -z "$COIN_C_FINITE"; then
88    AC_CHECK_DECL([_finite],[COIN_C_FINITE=_finite],,[
89#ifdef HAVE_CMATH
90# include <cmath>
91#else
92# ifdef HAVE_MATH_H
93#  include <math.h>
94# endif
95#endif
96#ifdef HAVE_CFLOAT
97# include <cfloat>
98#else
99# ifdef HAVE_FLOAT_H
100#  include <float.h>
101# endif
102#endif
103#ifdef HAVE_CIEEEFP
104# include <cieeefp>
105#else
106# ifdef HAVE_IEEEFP_H
107#  include <ieeefp.h>
108# endif
109#endif])
110  fi
111fi
112if test -z "$COIN_C_FINITE"; then
113  AC_MSG_WARN(Cannot find C-function for checking Inf.)
114else
115  AC_DEFINE_UNQUOTED(COIN_C_FINITE,[$COIN_C_FINITE],
116                     [Define to be the name of C-function for Inf check])
117fi
118
119AC_LANG_POP(C++)
120])
121
122###########################################################################
123#                              COIN_CHECK_ISNAN                           #
124###########################################################################
125
126# This macro checks for a usable implementation of a function to check
127# whether a given floating point number represents NaN.
128# If a function is found, then the macro defines the symbol COIN_C_ISNAN
129# to the name of this function.
130
131AC_DEFUN([AC_COIN_CHECK_ISNAN],[
132
133AC_LANG_PUSH(C++)
134
135#AC_COIN_CHECK_CXX_CHEADER(math)
136#AC_COIN_CHECK_CXX_CHEADER(float)
137#AC_COIN_CHECK_CXX_CHEADER(ieeefp)
138AC_CHECK_HEADERS([cmath])
139if test "$ac_cv_header_cmath" != "yes"; then
140  AC_CHECK_HEADERS([math.h])
141fi
142AC_CHECK_HEADERS([cfloat])
143if test "$ac_cv_header_cfloat" != "yes"; then
144  AC_CHECK_HEADERS([float.h])
145fi
146AC_CHECK_HEADERS([cieeefp])
147if test "$ac_cv_header_cieeefp" != "yes"; then
148  AC_CHECK_HEADERS([ieeefp.h])
149fi
150
151COIN_C_ISNAN=
152AC_CHECK_DECL([isnan],[COIN_C_ISNAN=isnan],,[
153#ifdef HAVE_CMATH
154# include <cmath>
155#else
156# ifdef HAVE_MATH_H
157#  include <math.h>
158# endif
159#endif
160#ifdef HAVE_CFLOAT
161# include <cfloat>
162#else
163# ifdef HAVE_FLOAT_H
164#  include <float.h>
165# endif
166#endif
167#ifdef HAVE_CIEEEFP
168# include <cieeefp>
169#else
170# ifdef HAVE_IEEEFP_H
171#  include <ieeefp.h>
172# endif
173#endif])
174
175# It appears that for some systems (e.g., Mac OSX), cmath will provide only
176# std::isnan, and bare isnan will be unavailable. Typically we need a parameter
177# in the test to allow C++ to do overload resolution.
178
179if test -z "$COIN_C_ISNAN"; then
180  AC_CHECK_DECL([std::isnan(42.42)],[COIN_C_ISNAN=std::isnan],,[
181#ifdef HAVE_CMATH
182# include <cmath>
183#else
184# ifdef HAVE_MATH_H
185#  include <math.h>
186# endif
187#endif
188#ifdef HAVE_CFLOAT
189# include <cfloat>
190#else
191# ifdef HAVE_FLOAT_H
192#  include <float.h>
193# endif
194#endif
195#ifdef HAVE_CIEEEFP
196# include <cieeefp>
197#else
198# ifdef HAVE_IEEEFP_H
199#  include <ieeefp.h>
200# endif
201#endif])
202fi
203
204if test -z "$COIN_C_ISNAN"; then
205  AC_CHECK_DECL([_isnan],[COIN_C_ISNAN=_isnan],,[
206#ifdef HAVE_CMATH
207# include <cmath>
208#else
209# ifdef HAVE_MATH_H
210#  include <math.h>
211# endif
212#endif
213#ifdef HAVE_CFLOAT
214# include <cfloat>
215#else
216# ifdef HAVE_FLOAT_H
217#  include <float.h>
218# endif
219#endif
220#ifdef HAVE_CIEEEFP
221# include <cieeefp>
222#else
223# ifdef HAVE_IEEEFP_H
224#  include <ieeefp.h>
225# endif
226#endif])
227fi
228if test -z "$COIN_C_ISNAN"; then
229  AC_CHECK_DECL([isnand],[COIN_C_ISNAN=isnand],,[
230#ifdef HAVE_CMATH
231# include <cmath>
232#else
233# ifdef HAVE_MATH_H
234#  include <math.h>
235# endif
236#endif
237#ifdef HAVE_CFLOAT
238# include <cfloat>
239#else
240# ifdef HAVE_FLOAT_H
241#  include <float.h>
242# endif
243#endif
244#ifdef HAVE_CIEEEFP
245# include <cieeefp>
246#else
247# ifdef HAVE_IEEEFP_H
248#  include <ieeefp.h>
249# endif
250#endif])
251fi
252if test -z "$COIN_C_ISNAN"; then
253  AC_MSG_WARN(Cannot find C-function for checking NaN.)
254else
255  AC_DEFINE_UNQUOTED(COIN_C_ISNAN,[$COIN_C_ISNAN],
256                     [Define to be the name of C-function for NaN check])
257fi
258
259AC_LANG_POP(C++)
260])
Note: See TracBrowser for help on using the repository browser.