-
Notifications
You must be signed in to change notification settings - Fork 193
/
configure.in
290 lines (264 loc) · 5.96 KB
/
configure.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
dnl Process this file with autoconf to produce a configure script.
AC_INIT(crf_learn.cpp)
AH_TEMPLATE([HAVE_TLS_KEYWORD], [])
AH_TEMPLATE([HAVE_SYS_CONF_SC_NPROCESSORS_CONF], [])
AM_INIT_AUTOMAKE(CRF++, 0.59)
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_PROG_GCC_TRADITIONAL
AC_PROG_MAKE_SET
AC_ISC_POSIX
AC_CYGWIN
AC_LANG_CPLUSPLUS
AC_PROG_LIBTOOL
AC_CONFIG_MACRO_DIR([m4])
dnl Checks for libraries.
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(string.h stdlib.h unistd.h fcntl.h \
sys/stat.h sys/mman.h sys/times.h \
ctype.h sys/types.h math.h pthread.h)
AC_TYPE_SIZE_T
dnl Checks for libraries.
AC_CHECK_LIB(m,pow)
AC_CHECK_LIB(m,exp)
AC_CHECK_LIB(m,log)
AC_CHECK_LIB(pthread,pthread_create)
AC_CHECK_LIB(pthread,pthread_join)
AC_FUNC_MMAP
dnl
dnl Check for GNU make
dnl
AC_MSG_CHECKING(whether make is GNU Make)
if $ac_make --version 2>/dev/null | grep '^GNU Make ' >/dev/null ; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
if test "$host_vendor" = "sun" ; then
AC_MSG_ERROR("SUN make does not work for building maxent. Please install GNU make")
fi
fi
dnl
dnl check gcc
dnl
if test -n "$GCC"; then
CFLAGS="-O3 -Wall";
CXXFLAGS="-O3 -Wall";
fi
AC_DEFUN(ADD_CC_FLAG, [
AC_MSG_CHECKING(whether ${CC-cc} accepts $1)
AC_LANG_SAVE
AC_LANG_C
XCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $1"
AC_TRY_LINK([], [],
[AC_MSG_RESULT([ ok, adding $1 to CFLAGS])],
[CFLAGS="$XCFLAGS"])
AC_LANG_RESTORE
])
AC_DEFUN(ADD_CXX_FLAG, [
AC_MSG_CHECKING(whether ${CXX-c++} accepts $1)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
XCXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $1"
AC_TRY_LINK([], [],
[AC_MSG_RESULT([ ok, adding $1 to CXXFLAGS])],
[CXXFLAGS="$XCXXFLAGS"])
AC_LANG_RESTORE
])
# On Intel systems with gcc, we may need to compile with -mieee-fp to
# get full support for IEEE floating point.
#
# On Alpha/OSF systems, we need -mieee.
#
# On AIX systems, we need to limit the amount of stuff that goes in
# the TOC.
case "$host" in
changequote(,)dnl
i[3456789]86-*-*)
changequote([,])dnl
ADD_CC_FLAG(-mieee-fp)
ADD_CXX_FLAG(-mieee-fp)
;;
alpha*-*-*)
ADD_CC_FLAG(-mieee)
ADD_CXX_FLAG(-mieee)
;;
*ibm-aix4*)
ADD_CC_FLAG(-mminimal-toc)
ADD_CXX_FLAG(-mminimal-toc)
;;
esac
dnl
dnl check C++ features
dnl
AC_DEFUN(CHECK_CXX_STL, [
AC_MSG_CHECKING(if ${CXX-c++} supports stl <$1> (required))
AC_TRY_COMPILE(
[
#include <$1>
], [
;
], [
ac_stl_$1=yes
], [
config_error=yes
AC_WARN(${CXX-c++} stl <$1> does not work)
])
AC_MSG_RESULT([$ac_stl_$1])
])
CHECK_CXX_STL(string)
CHECK_CXX_STL(vector)
CHECK_CXX_STL(map)
CHECK_CXX_STL(set)
CHECK_CXX_STL(iostream)
CHECK_CXX_STL(fstream)
CHECK_CXX_STL(sstream)
CHECK_CXX_STL(stdexcept)
# check for const_cast
AC_MSG_CHECKING([if ${CXX-c++} supports template <class T> (required)])
AC_TRY_COMPILE(
[
template <class T> T foo (T &i) { return i++; };
],[
int i = 0;
double d = 0.0;
foo(i); foo(d);
],[
ac_template=yes
],[
AC_WARN(${CXX-c++} template <class T> does not work)
config_error=yes
])
AC_MSG_RESULT([$ac_template])
# check for const_cast
AC_MSG_CHECKING([if ${CXX-c++} supports const_cast<> (required)])
AC_TRY_COMPILE(
[
class foo;
],[
const foo *c=0;
foo *c1=const_cast<foo*>(c);
],[
ac_const_cast=yes
],[
AC_WARN(${CXX-c++} const_cast<> does not work)
config_error=yes
])
AC_MSG_RESULT([$ac_const_cast])
# check for static_cast<>
AC_MSG_CHECKING(if ${CXX-c++} supports static_cast<> (required))
AC_TRY_COMPILE(
[
class foo;
],[
foo *c = 0;
void *c1 = static_cast<void *>(c);
],[
ac_static_cast=yes
],[
AC_WARN(${CXX-c++} static_cast<> does not work)
config_error=yes
])
AC_MSG_RESULT([$ac_static_cast])
# check for dynamic_cast<>
AC_MSG_CHECKING(if ${CXX-c++} supports dynamic_cast<> (required))
AC_TRY_COMPILE(
[
class foo {};
class bar: public foo {};
],[
bar *c = 0;
foo *c1 = dynamic_cast<foo *>(c);
],[
ac_dynamic_cast=yes
],[
AC_WARN(${CXX-c++} dynamic_cast<> does not work)
config_error=yes
])
AC_MSG_RESULT([$ac_dynamic_cast])
# check for try
AC_MSG_CHECKING(if ${CXX-c++} supports exception handler (required))
AC_TRY_COMPILE(
[
;
],[
try {
int i = 0;
}
catch (char *e) {
}
catch (...) {
}
],[
ac_exception=yes
],[
AC_WARN(${CXX-c++} exception does not work)
config_error=yes
])
AC_MSG_RESULT([$ac_exception])
# check for namespaces
AC_MSG_CHECKING(if ${CXX-c++} supports namespaces (required) )
AC_TRY_COMPILE(
[
namespace Foo { struct A {}; }
using namespace Foo;
],[
A a;
],[
ac_namespaces=yes
dnl AC_DEFINE(HAVE_CXX_NAMESPACE)
],[
config_error=yes
ac_namespaces=no
])
AC_MSG_RESULT([$ac_namespaces])
dnl __thread keyword
AC_MSG_CHECKING([if ${CXX-c++} supports __thread (optional)])
AC_TRY_COMPILE(
[
__thread int a = 0;
],[
a = 10;
],[
enable_tls=yes
],[
enable_tls=no
])
AC_MSG_RESULT([$enable_tls])
if test "$enable_tls" = "no"; then
AC_MSG_WARN([__thread keyword is not supported on this environment. \
Error handling of CRF++, e.g., CRFPP::getLastError(), is not thread safe.])
else
AC_DEFINE([HAVE_TLS_KEYWORD])
fi
AC_MSG_CHECKING([if ${CXX-c++} supports _SC_NPROCESSORS_CONF (optional)])
AC_TRY_COMPILE(
[
#include <unistd.h>
long n = sysconf(_SC_NPROCESSORS_CONF);
],[
n = 10;
],[
enable_sysconf_sc_nprocessors_conf=yes
],[
enable_sysconf_sc_nprocessors_conf=no
])
AC_MSG_RESULT([$enable_sysconf_sc_nprocessors_conf])
if test "$enable_sysconf_sc_nprocessors_conf" = "no"; then
AC_MSG_WARN([_SC_NPROCESSORS_CONF on this environment.])
else
AC_DEFINE([HAVE_SYS_CONF_SC_NPROCESSORS_CONF])
fi
AC_MSG_CHECKING(if ${CXX-c++} environment provides all required features)
if test "x$config_error" = xyes ; then
AC_MSG_RESULT([no])
AC_MSG_ERROR([Your compiler is not powerful enough to compile CRF++. \
If it should be, see config.log for more information of why it failed.])
fi
AC_MSG_RESULT([yes])
AC_SUBST(datarootdir)
AM_CONFIG_HEADER(config.h)
AC_OUTPUT([Makefile Makefile.msvc swig/version.h])