-
Notifications
You must be signed in to change notification settings - Fork 4
/
configure.in
330 lines (303 loc) · 7.08 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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/mecab.cpp)
AH_TEMPLATE([HAVE_GCC_ATOMIC_OPS], [])
AH_TEMPLATE([HAVE_OSX_ATOMIC_OPS], [])
AH_TEMPLATE([HAVE_TLS_KEYWORD], [])
AM_INIT_AUTOMAKE(mecab, 0.996/ko-0.9.2)
AC_CONFIG_MACRO_DIR([m4])
# DIC_VERSION XXYY
DIC_VERSION="102"
# Before making a release, the LTVERSION string should be modified.
# The string is of the form C:R:A.
# - If interfaces have been changed or added, but binary compatibility has
# been preserved, change to C+1:0:A+1
# - If binary compatibility has been broken (eg removed or changed interfaces)
# change to C+1:0:0
# - If the interface is the same as the previous version, change to C:R+1:A
LTVERSION="2:0:0"
AC_SUBST(LTVERSION)
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_PROG_GCC_TRADITIONAL
AC_PROG_MAKE_SET
AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL
AC_ISC_POSIX
AC_C_BIGENDIAN
AC_CYGWIN
AM_ICONV
AC_LANG_CPLUSPLUS
AC_LANG(C)
AC_HEADER_STDC
AC_C_CONST
AC_C_BIGENDIAN
AC_CHECK_HEADERS(string.h stdlib.h unistd.h fcntl.h stdint.h \
sys/stat.h sys/mman.h sys/times.h sys/types.h dirent.h \
ctype.h sys/types.h io.h windows.h pthread.h)
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF(size_t)
AC_TYPE_SIZE_T
AC_TYPE_UNSIGNED_LONG_LONG_INT
AC_FUNC_MMAP
AC_CHECK_LIB(stdc++, main, MECAB_LIBS="-lstdc++")
AC_CHECK_LIB(pthread,pthread_create)
AC_CHECK_LIB(pthread,pthread_join)
AC_CHECK_FUNCS(getenv)
AC_CHECK_FUNCS(opendir)
AC_LANG(C++)
AC_ARG_ENABLE(utf8-only,
[ --enable-utf8-only use utf8 only [default no]])
if test "$enable_utf8_only" = "yes"; then
MECAB_USE_UTF8_ONLY="-DMECAB_USE_UTF8_ONLY"
else
MECAB_USE_UTF8_ONLY=""
fi
LIBS="$LIBS $MECAB_LIBS $LIBICONV"
AC_SUBST(MECAB_LIBS)
AC_SUBST(MECAB_USE_UTF8_ONLY)
MECAB_LIBEXEC_DIR="$libexecdir/mecab"
AC_SUBST(MECAB_LIBEXEC_DIR)
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 MeCab. Please install GNU make")
fi
fi
dnl
dnl check gcc
dnl
if test -n "$GCC"; then
CFLAGS="-O3 -Wall "
CXXFLAGS="-O3 -Wall "
fi
dnl
dnl check Char Code
dnl
AC_ARG_WITH(
charset,
[ --with-charset=charset set default charset (euc/sjis/utf8))],
[CHARSET=${withval}], [CHARSET='euc']
)
CHARSET=$CHARSET
AC_SUBST(CHARSET)
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(vector)
CHECK_CXX_STL(list)
CHECK_CXX_STL(map)
CHECK_CXX_STL(set)
CHECK_CXX_STL(queue)
CHECK_CXX_STL(functional)
CHECK_CXX_STL(algorithm)
CHECK_CXX_STL(string)
CHECK_CXX_STL(iostream)
CHECK_CXX_STL(sstream)
CHECK_CXX_STL(fstream)
# 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 reinterpret_cast
AC_MSG_CHECKING(if ${CXX-c++} supports reinterpret_cast<> (required))
AC_TRY_COMPILE(
[
int *a = 0;
],[
char *p = reinterpret_cast<char *>(a);
],[
ac_reinterpret_cast=yes
],[
AC_WARN(${CXX-c++} reinterpret_cast<> does not work)
config_error=yes
])
AC_MSG_RESULT([$ac_reinterpret_cast])
# 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 MeCab, e.g., MeCab::getLastError(), is not thread safe.])
else
AC_DEFINE([HAVE_TLS_KEYWORD])
fi
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])
AC_MSG_CHECKING([if ${CXX-c++} supports GCC native atomic operations (optional)])
AC_TRY_COMPILE(
[
#include <sched.h>
],[
int a = 10;
__sync_fetch_and_add(&a, 10);
__sync_val_compare_and_swap(&a, 0, 10);
sched_yield();
],[
enable_gcc_atomic_ops=yes
],[
enable_gcc_atomic_ops=no
])
AC_MSG_RESULT([$enable_gcc_atomic_ops])
if test "$enable_gcc_atomic_ops" = "yes"; then
AC_DEFINE([HAVE_GCC_ATOMIC_OPS])
fi
AC_MSG_CHECKING([if ${CXX-c++} supports OSX native atomic operations (optional)])
AC_TRY_COMPILE(
[
#include <libkern/OSAtomic.h>
],[
int a = 10;
OSAtomicAdd32(10, &a);
OSAtomicCompareAndSwapInt(10, 0, &a);
],[
enable_osx_atomic_ops=yes
],[
enable_osx_atomic_ops=no
])
AC_MSG_RESULT([$enable_osx_atomic_ops])
if test "$enable_osx_atomic_ops" = "yes"; then
AC_DEFINE([HAVE_OSX_ATOMIC_OPS])
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 MeCab. \
If it should be, see config.log for more information of why it failed.])
fi
AC_MSG_RESULT([yes])
case "$host_os" in
mingw* | os2*)
MECAB_DEFAULT_RC='c:\\\\Program Files\\\\mecab\\\\etc\\\\mecabrc'
CFLAGS="$CFLAGS -municode -DUNICODE -D_UNICODE"
CXXFLAGS="$CXXFLAGS -municode -DUNICODE -D_UNICODE"
;;
*)
MECAB_DEFAULT_RC="$sysconfdir/mecabrc"
;;
esac
AC_SUBST(MECAB_DEFAULT_RC)
AC_SUBST(datarootdir)
AC_SUBST(DIC_VERSION)
AM_CONFIG_HEADER(config.h)
AC_OUTPUT([
Makefile
src/Makefile
src/Makefile.msvc
man/Makefile
doc/Makefile
tests/Makefile
swig/version.h
mecab.iss
mecab-config
mecabrc ],
chmod +x mecab-config \
)