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
|
OBJCFLAGS="$OBJCFLAGS -Wall -fexceptions"
OBJCFLAGS="$OBJCFLAGS -fconstant-string-class=OFConstantString"
AX_CHECK_COMPILER_FLAGS(-pipe, [OBJCFLAGS="$OBJCFLAGS -pipe"])
AX_CHECK_COMPILER_FLAGS(-fno-common, [OBJCFLAGS="$OBJCFLAGS -fno-common"])
AX_CHECK_COMPILER_FLAGS(-fno-constant-cfstrings, [
NO_CONST_CFSTRINGS="-fno-constant-cfstrings"
OBJCFLAGS="$OBJCFLAGS -fno-constant-cfstrings"])
AC_SUBST(NO_CONST_CFSTRINGS)
AC_MSG_CHECKING(whether Objective C compiler supports fast enumeration)
AC_TRY_COMPILE([
#import <objc/objc.h>
@protocol OFFastEnumeration
- (int)countByEnumeratingWithState: (void*)state
objects: (id*)objects
count: (int)count;
@end
], [
id n = nil;
for (id i in n);
], [
AC_DEFINE(OF_HAVE_FAST_ENUMERATION, 1,
[Compiler support for Fast Enumeration])
AC_MSG_RESULT(yes)
], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(whether Objective C compiler supports properties)
AC_TRY_COMPILE([
#import <objc/objc.h>
@interface Foo
{
id bar;
}
@property (retain, nonatomic) id bar;
@end
], [
Foo *foo = nil;
[foo setBar: nil];
[foo bar];
], [
AC_DEFINE(OF_HAVE_PROPERTIES, 1, [Compiler support for properties])
AC_SUBST(PROPERTIESTESTS_M, "PropertiesTests.m")
AC_MSG_RESULT(yes)
], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(whether Objective C compiler supports blocks)
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -fblocks"
AC_TRY_COMPILE([], [
int (^foo)(int bar);
foo = ^(int bar) { return 0; }
], [
AC_DEFINE(OF_HAVE_BLOCKS, 1, [Compiler support for blocks])
AC_SUBST(BLOCKS_FLAGS, "-fblocks")
AC_SUBST(OFBLOCKTESTS_M, "OFBlockTests.m")
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
OBJCFLAGS="$old_OBJCFLAGS"
])
AC_CHECK_HEADERS([objfw-rt.h objc/objc.h])
test x"$ac_cv_header_objfw_rt_h" = x"yes" && objc_runtime="ObjFW-RT"
if test x"$ac_cv_header_objc_objc_h" = x"yes"; then
dnl TODO: This is ugly. Let's think of a better check.
AC_EGREP_CPP(gnu, [
#import <objc/objc.h>
#ifdef __objc_INCLUDE_GNU
gnu
#endif
],
[test x"$objc_runtime" = "x" && objc_runtime="GNU"],
[objc_runtime="Apple"])
fi
AC_MSG_CHECKING(which Objective C runtime we use)
case $objc_runtime in
ObjFW-RT)
AC_DEFINE(OF_OBJFW_RUNTIME, 1,
[Whether we use the ObjFW runtime])
AC_SUBST(GNU_RUNTIME, "-fgnu-runtime")
|
|
>
|
|
>
|
>
|
|
>
|
>
|
|
|
|
|
|
>
|
<
>
>
|
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
|
OBJCFLAGS="$OBJCFLAGS -Wall -fexceptions"
OBJCFLAGS="$OBJCFLAGS -fconstant-string-class=OFConstantString"
AX_CHECK_COMPILER_FLAGS(-pipe, [OBJCFLAGS="$OBJCFLAGS -pipe"])
AX_CHECK_COMPILER_FLAGS(-fno-common, [OBJCFLAGS="$OBJCFLAGS -fno-common"])
AX_CHECK_COMPILER_FLAGS(-fno-constant-cfstrings, [
NO_CONST_CFSTRINGS="-fno-constant-cfstrings"
OBJCFLAGS="$OBJCFLAGS -fno-constant-cfstrings"
])
AC_SUBST(NO_CONST_CFSTRINGS)
AC_MSG_CHECKING(whether Objective C compiler supports fast enumeration)
AC_TRY_COMPILE([
#import <objc/objc.h>
@protocol OFFastEnumeration
- (int)countByEnumeratingWithState: (void*)state
objects: (id*)objects
count: (int)count;
@end
], [
id n = nil;
for (id i in n);
], [
AC_DEFINE(OF_HAVE_FAST_ENUMERATION, 1,
[Compiler support for Fast Enumeration])
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING(whether Objective C compiler supports properties)
AC_TRY_COMPILE([
#import <objc/objc.h>
@interface Foo
{
id bar;
}
@property (retain, nonatomic) id bar;
@end
], [
Foo *foo = nil;
[foo setBar: nil];
[foo bar];
], [
AC_DEFINE(OF_HAVE_PROPERTIES, 1, [Compiler support for properties])
AC_SUBST(PROPERTIESTESTS_M, "PropertiesTests.m")
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING(whether Objective C compiler supports blocks)
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -fblocks"
AC_TRY_COMPILE([], [
int (^foo)(int bar);
foo = ^(int bar) { return 0; }
], [
AC_DEFINE(OF_HAVE_BLOCKS, 1, [Compiler support for blocks])
AC_SUBST(BLOCKS_FLAGS, "-fblocks")
AC_SUBST(OFBLOCKTESTS_M, "OFBlockTests.m")
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
OBJCFLAGS="$old_OBJCFLAGS"
])
AC_CHECK_HEADERS([objfw-rt.h objc/objc.h])
test x"$ac_cv_header_objfw_rt_h" = x"yes" && objc_runtime="ObjFW-RT"
AS_IF([test x"$ac_cv_header_objc_objc_h" = x"yes"], [
dnl TODO: This is ugly. Let's think of a better check.
AC_EGREP_CPP(gnu, [
#import <objc/objc.h>
#ifdef __objc_INCLUDE_GNU
gnu
#endif
], [
test x"$objc_runtime" = "x" && objc_runtime="GNU"
], [
objc_runtime="Apple"
])
])
AC_MSG_CHECKING(which Objective C runtime we use)
case $objc_runtime in
ObjFW-RT)
AC_DEFINE(OF_OBJFW_RUNTIME, 1,
[Whether we use the ObjFW runtime])
AC_SUBST(GNU_RUNTIME, "-fgnu-runtime")
|
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
330
|
;;
esac
AC_MSG_RESULT($objc_runtime)
AC_CHECK_FUNC(objc_getProperty,, [
AC_DEFINE(NEED_OBJC_PROPERTIES_INIT, 1,
[Whether objc_properties_init needs to be called])
AC_SUBST(OBJC_PROPERTIES_M, "objc_properties.m")])
AC_CHECK_FUNC(objc_enumerationMutation, [
AC_DEFINE(HAVE_OBJC_ENUMERATIONMUTATION, 1,
[Whether we have objc_enumerationMutation])])
AC_ARG_ENABLE(shared,
AS_HELP_STRING([--disable-shared], [don't build shared library]))
AS_IF([test x"$enable_shared" != x"no"], [
BUILDSYS_SHARED_LIB
AC_SUBST(OBJFW_SHARED_LIB, "${LIB_PREFIX}objfw${LIB_SUFFIX}")])
AC_ARG_ENABLE(static,
AS_HELP_STRING([--enable-static], [build static library]))
AS_IF([test x"$enable_static" = x"yes" -o x"$enable_shared" = x"no"], [
AC_REQUIRE([AC_PROG_RANLIB])
AC_PATH_TOOL(AR, ar)
AC_SUBST(OBJFW_STATIC_LIB, "libobjfw.a")])
AC_DEFINE_UNQUOTED(PLUGIN_SUFFIX, "$PLUGIN_SUFFIX", [Suffix for plugins])
if test x"$PLUGIN_SUFFIX" != "x"; then
AC_SUBST(OFPLUGIN_M, "OFPlugin.m")
AC_SUBST(OFPLUGINTESTS_M, "OFPluginTests.m")
AC_SUBST(TESTPLUGIN, "plugin")
AC_DEFINE(OF_PLUGINS, 1, [Whether we have plugin support])
AC_SUBST(OFPLUGINS_DEF, "-DOF_PLUGINS")
fi
case "$host_os" in
darwin*)
AC_SUBST(REEXPORT_LIBOBJC, [-Wl,-reexport-lobjc])
AC_SUBST(LDFLAGS_REEXPORT, [-Wl,-reexport-lobjfw])
AC_SUBST(MACH_ALIAS_LIST, [-Wl,-alias_list,mach_alias_list])
;;
esac
AC_C_BIGENDIAN([
AC_DEFINE(OF_BIG_ENDIAN, 1, [Whether we are big endian])
AC_SUBST(ENDIANESS_DEF, "-DOF_BIG_ENDIAN")])
AC_MSG_CHECKING(for SIZE_MAX)
AC_EGREP_CPP(yes, [
#include <stdint.h>
#include <limits.h>
#ifdef SIZE_MAX
yes
#endif
], AC_MSG_RESULT(yes), [
AC_MSG_RESULT(no)
AC_MSG_CHECKING(for SIZE_T_MAX)
AC_EGREP_CPP(yes, [
#include <stdint.h>
#include <limits.h>
#ifdef SIZE_T_MAX
yes
#endif
], [
AC_MSG_RESULT(yes)
size_max="SIZE_T_MAX"], [
AC_MSG_RESULT(no)
size_max="((size_t)-1)"])
AC_DEFINE_UNQUOTED(SIZE_MAX, $size_max, [Maximum value for size_t])])
AC_CHECK_FUNC(asprintf, [
have_asprintf="yes"
AC_DEFINE(OF_HAVE_ASPRINTF, 1, [Whether we have asprintf])
AC_SUBST(ASPRINTF_DEF, "-DOF_HAVE_ASPRINTF")
], [
have_asprintf="no"
AC_SUBST(ASPRINTF_M, "asprintf.m")
AC_MSG_CHECKING(whether snprintf returns something useful)
AC_CACHE_VAL(ac_cv_snprintf_useful_ret, [
AC_TRY_RUN([
#include <stdio.h>
int
main()
{
return (snprintf(NULL, 0, "asd") == 3 ? 0 : 1);
}],
ac_cv_snprintf_useful_ret="yes",
ac_cv_snprintf_useful_ret="no",
ac_cv_snprintf_useful_ret="no")])
AC_MSG_RESULT($ac_cv_snprintf_useful_ret)])
test x"$have_asprintf" != x"yes" -a x"$ac_cv_snprintf_useful_ret" != x"yes" && \
AC_MSG_ERROR(No asprintf and no snprintf returning required space!)
AC_CHECK_LIB(m, fmod, LIBS="$LIBS -lm")
AC_CHECK_LIB(dl, dlopen, LIBS="$LIBS -ldl")
AC_ARG_ENABLE(threads,
AS_HELP_STRING([--disable-threads], [disable thread support]))
if test x"$enable_threads" != x"no"; then
case "$host_os" in
mingw*)
AC_MSG_CHECKING(for threads)
AC_MSG_RESULT(win32)
;;
*)
ACX_PTHREAD([
CPPLAGS="$CPPFLAGS $PTHREAD_CFLAGS"
LIBS="$LIBS $PTHREAD_LIBS"
AC_DEFINE(OF_HAVE_PTHREADS, 1,
[Whether we have pthreads])
AC_CHECK_FUNC(pthread_spin_lock, [
AC_DEFINE(OF_HAVE_PTHREAD_SPINLOCKS, 1,
[Whether we have pthread spinlocks])])
AC_CHECK_FUNC(sched_yield, [
AC_DEFINE(OF_HAVE_SCHED_YIELD, 1,
[Whether we have sched_yield])])
], [
AC_MSG_ERROR(No supported threads found!)])
;;
esac
AC_DEFINE(OF_THREADS, 1, [Whether we have threads])
AC_SUBST(OFTHREAD_M, "OFThread.m")
AC_SUBST(OFTHREADTESTS_M, "OFThreadTests.m")
AC_SUBST(THREADING_H, "threading.h")
AC_CHECK_FUNC(objc_sync_enter,, [
AC_SUBST(OBJC_SYNC_M, "objc_sync.m")
AC_DEFINE(NEED_OBJC_SYNC_INIT, 1,
[Whether objc_sync_init needs to be called])])
atomic_ops="none"
AC_MSG_CHECKING(whether we have an atomic ops assembly implementation)
AC_EGREP_CPP(yes, [
#if defined(__GNUC__) && (defined(__i386__) || \
defined(__amd64__) || defined(__x86_64__))
yes
#endif
], [
AC_MSG_RESULT(yes)
atomic_ops="assembly implementation"
], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(whether __sync_* works)
AC_TRY_LINK([#include <stdint.h>], [
int32_t i, j;
if (__sync_add_and_fetch(&i, 1))
j = __sync_sub_and_fetch(&i, 1);
while (!__sync_bool_compare_and_swap(&i, 0, 1));
], [
AC_MSG_RESULT(yes)
test x"$atomic_ops" = x"none" && atomic_ops="gcc builtins"
AC_DEFINE(OF_HAVE_GCC_ATOMIC_OPS, 1,
[Whether gcc atomic operations are available])
], [AC_MSG_RESULT(no)])
AC_CHECK_HEADER(libkern/OSAtomic.h, [
test x"$atomic_ops" = x"none" && atomic_ops="libkern/OSAtomic.h"
AC_DEFINE(OF_HAVE_OSATOMIC, 1,
[Whether we have libkern/OSAtomic.h])
AC_CHECK_FUNC(OSAtomicAdd64Barrier, [
AC_DEFINE(OF_HAVE_OSATOMIC_64, 1,
[Whether we have OSAtomic*64])])])
else
dnl We can only have one thread - therefore everything is atomic
atomic_ops="not needed"
fi
AC_MSG_CHECKING(for atomic operations)
if test x"$atomic_ops" != x"none"; then
AC_DEFINE(OF_ATOMIC_OPS, 1, [Whether we have atomic operations])
AC_SUBST(ATOMIC_H, "atomic.h")
fi
AC_MSG_RESULT($atomic_ops)
AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32")
AC_CHECK_HEADER(poll.h,
[AC_DEFINE(OF_HAVE_POLL, 1, [Whether poll is supported])])
AC_CHECK_HEADERS(sys/select.h,
[AC_DEFINE(OF_HAVE_SYS_SELECT_H, 1, [Whether we have sys/select.h])])
AC_MSG_CHECKING(for getaddrinfo)
AC_TRY_COMPILE([
#include <stddef.h>
#ifndef _WIN32
# include <sys/types.h>
# include <sys/socket.h>
# include <netdb.h>
#else
# define _WIN32_WINNT 0x0501
# include <ws2tcpip.h>
#endif
], [
struct addrinfo ai;
getaddrinfo(NULL, NULL, NULL, NULL);
], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GETADDRINFO, 1, [Whether we have getaddrinfo])
if test x"$enable_threads" != x"no"; then
AC_MSG_CHECKING(whether getaddrinfo is thread-safe)
case "$host_os" in
darwin[[12345]].*)
have_threadsafe_getaddrinfo="no"
;;
darwin*)
|
|
>
|
>
|
<
>
|
|
>
|
<
>
|
>
>
|
>
|
|
>
|
>
|
>
|
|
>
>
|
>
|
|
>
|
>
|
|
>
|
>
|
>
|
>
|
>
|
>
|
<
>
>
>
<
>
|
<
>
|
|
>
|
|
>
|
|
|
|
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
;;
esac
AC_MSG_RESULT($objc_runtime)
AC_CHECK_FUNC(objc_getProperty,, [
AC_DEFINE(NEED_OBJC_PROPERTIES_INIT, 1,
[Whether objc_properties_init needs to be called])
AC_SUBST(OBJC_PROPERTIES_M, "objc_properties.m")
])
AC_CHECK_FUNC(objc_enumerationMutation, [
AC_DEFINE(HAVE_OBJC_ENUMERATIONMUTATION, 1,
[Whether we have objc_enumerationMutation])
])
AC_ARG_ENABLE(shared,
AS_HELP_STRING([--disable-shared], [don't build shared library]))
AS_IF([test x"$enable_shared" != x"no"], [
BUILDSYS_SHARED_LIB
AC_SUBST(OBJFW_SHARED_LIB, "${LIB_PREFIX}objfw${LIB_SUFFIX}")
])
AC_ARG_ENABLE(static, AS_HELP_STRING([--enable-static], [build static library]))
AS_IF([test x"$enable_static" = x"yes" -o x"$enable_shared" = x"no"], [
AC_REQUIRE([AC_PROG_RANLIB])
AC_PATH_TOOL(AR, ar)
AC_SUBST(OBJFW_STATIC_LIB, "libobjfw.a")
])
AC_DEFINE_UNQUOTED(PLUGIN_SUFFIX, "$PLUGIN_SUFFIX", [Suffix for plugins])
AS_IF([test x"$PLUGIN_SUFFIX" != "x"], [
AC_SUBST(OFPLUGIN_M, "OFPlugin.m")
AC_SUBST(OFPLUGINTESTS_M, "OFPluginTests.m")
AC_SUBST(TESTPLUGIN, "plugin")
AC_DEFINE(OF_PLUGINS, 1, [Whether we have plugin support])
AC_SUBST(OFPLUGINS_DEF, "-DOF_PLUGINS")
])
case "$host_os" in
darwin*)
AC_SUBST(REEXPORT_LIBOBJC, [-Wl,-reexport-lobjc])
AC_SUBST(LDFLAGS_REEXPORT, [-Wl,-reexport-lobjfw])
AC_SUBST(MACH_ALIAS_LIST, [-Wl,-alias_list,mach_alias_list])
;;
esac
AC_C_BIGENDIAN([
AC_DEFINE(OF_BIG_ENDIAN, 1, [Whether we are big endian])
AC_SUBST(ENDIANESS_DEF, "-DOF_BIG_ENDIAN")
])
AC_MSG_CHECKING(for SIZE_MAX)
AC_EGREP_CPP(yes, [
#include <stdint.h>
#include <limits.h>
#ifdef SIZE_MAX
yes
#endif
], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
AC_MSG_CHECKING(for SIZE_T_MAX)
AC_EGREP_CPP(yes, [
#include <stdint.h>
#include <limits.h>
#ifdef SIZE_T_MAX
yes
#endif
], [
AC_MSG_RESULT(yes)
size_max="SIZE_T_MAX"], [
AC_MSG_RESULT(no)
size_max="((size_t)-1)"
])
AC_DEFINE_UNQUOTED(SIZE_MAX, $size_max, [Maximum value for size_t])
])
AC_CHECK_FUNC(asprintf, [
have_asprintf="yes"
AC_DEFINE(OF_HAVE_ASPRINTF, 1, [Whether we have asprintf])
AC_SUBST(ASPRINTF_DEF, "-DOF_HAVE_ASPRINTF")
], [
have_asprintf="no"
AC_SUBST(ASPRINTF_M, "asprintf.m")
AC_MSG_CHECKING(whether snprintf returns something useful)
AC_CACHE_VAL(ac_cv_snprintf_useful_ret, [
AC_TRY_RUN([
#include <stdio.h>
int
main()
{
return (snprintf(NULL, 0, "asd") == 3 ? 0 : 1);
}
], [
ac_cv_snprintf_useful_ret="yes",
ac_cv_snprintf_useful_ret="no",
ac_cv_snprintf_useful_ret="no"
])
])
AC_MSG_RESULT($ac_cv_snprintf_useful_ret)
])
test x"$have_asprintf" != x"yes" -a x"$ac_cv_snprintf_useful_ret" != x"yes" && \
AC_MSG_ERROR(No asprintf and no snprintf returning required space!)
AC_CHECK_LIB(m, fmod, LIBS="$LIBS -lm")
AC_CHECK_LIB(dl, dlopen, LIBS="$LIBS -ldl")
AC_ARG_ENABLE(threads,
AS_HELP_STRING([--disable-threads], [disable thread support]))
AS_IF([test x"$enable_threads" != x"no"], [
case "$host_os" in
mingw*)
AC_MSG_CHECKING(for threads)
AC_MSG_RESULT(win32)
;;
*)
ACX_PTHREAD([
CPPLAGS="$CPPFLAGS $PTHREAD_CFLAGS"
LIBS="$LIBS $PTHREAD_LIBS"
AC_DEFINE(OF_HAVE_PTHREADS, 1,
[Whether we have pthreads])
AC_CHECK_FUNC(pthread_spin_lock, [
AC_DEFINE(OF_HAVE_PTHREAD_SPINLOCKS, 1,
[Whether we have pthread spinlocks])
])
AC_CHECK_FUNC(sched_yield, [
AC_DEFINE(OF_HAVE_SCHED_YIELD, 1,
[Whether we have sched_yield])
])
], [
AC_MSG_ERROR(No supported threads found!)
])
;;
esac
AC_DEFINE(OF_THREADS, 1, [Whether we have threads])
AC_SUBST(OFTHREAD_M, "OFThread.m")
AC_SUBST(OFTHREADTESTS_M, "OFThreadTests.m")
AC_SUBST(THREADING_H, "threading.h")
AC_CHECK_FUNC(objc_sync_enter,, [
AC_SUBST(OBJC_SYNC_M, "objc_sync.m")
AC_DEFINE(NEED_OBJC_SYNC_INIT, 1,
[Whether objc_sync_init needs to be called])
])
atomic_ops="none"
AC_MSG_CHECKING(whether we have an atomic ops assembly implementation)
AC_EGREP_CPP(yes, [
#if defined(__GNUC__) && (defined(__i386__) || \
defined(__amd64__) || defined(__x86_64__))
yes
#endif
], [
AC_MSG_RESULT(yes)
atomic_ops="assembly implementation"
], [
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING(whether __sync_* works)
AC_TRY_LINK([#include <stdint.h>], [
int32_t i, j;
if (__sync_add_and_fetch(&i, 1))
j = __sync_sub_and_fetch(&i, 1);
while (!__sync_bool_compare_and_swap(&i, 0, 1));
], [
AC_MSG_RESULT(yes)
test x"$atomic_ops" = x"none" && atomic_ops="gcc builtins"
AC_DEFINE(OF_HAVE_GCC_ATOMIC_OPS, 1,
[Whether gcc atomic operations are available])
], [
AC_MSG_RESULT(no)
])
AC_CHECK_HEADER(libkern/OSAtomic.h, [
test x"$atomic_ops" = x"none" && atomic_ops="libkern/OSAtomic.h"
AC_DEFINE(OF_HAVE_OSATOMIC, 1,
[Whether we have libkern/OSAtomic.h])
AC_CHECK_FUNC(OSAtomicAdd64Barrier, [
AC_DEFINE(OF_HAVE_OSATOMIC_64, 1,
[Whether we have OSAtomic*64])
])
])
], [
dnl We can only have one thread - therefore everything is atomic
atomic_ops="not needed"
])
AC_MSG_CHECKING(for atomic operations)
AS_IF([test x"$atomic_ops" != x"none"], [
AC_DEFINE(OF_ATOMIC_OPS, 1, [Whether we have atomic operations])
AC_SUBST(ATOMIC_H, "atomic.h")
])
AC_MSG_RESULT($atomic_ops)
AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32")
AC_CHECK_HEADER(poll.h, [
AC_DEFINE(OF_HAVE_POLL, 1, [Whether poll is supported])
])
AC_CHECK_HEADERS(sys/select.h, [
AC_DEFINE(OF_HAVE_SYS_SELECT_H, 1, [Whether we have sys/select.h])
])
AC_MSG_CHECKING(for getaddrinfo)
AC_TRY_COMPILE([
#include <stddef.h>
#ifndef _WIN32
# include <sys/types.h>
# include <sys/socket.h>
# include <netdb.h>
#else
# define _WIN32_WINNT 0x0501
# include <ws2tcpip.h>
#endif
], [
struct addrinfo ai;
getaddrinfo(NULL, NULL, NULL, NULL);
], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GETADDRINFO, 1, [Whether we have getaddrinfo])
AS_IF([test x"$enable_threads" != x"no"], [
AC_MSG_CHECKING(whether getaddrinfo is thread-safe)
case "$host_os" in
darwin[[12345]].*)
have_threadsafe_getaddrinfo="no"
;;
darwin*)
|
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
|
have_threadsafe_getaddrinfo="yes"
;;
*)
have_threadsafe_getaddrinfo="unknown"
;;
esac
if test x"$have_threadsafe_getaddrinfo" = x"unknown"; then
AC_EGREP_CPP(yes, [
#include <netdb.h>
#ifdef h_errno
yes
#end
],
[have_threadsafe_getaddrinfo="yes"],
[have_threadsafe_getaddrinfo="no"])
fi
test x"$have_threadsafe_getaddrinfo" = x"yes" && \
AC_DEFINE(HAVE_THREADSAFE_GETADDRINFO, 1,
[Whether getaddrinfo is thread-safe])
AC_MSG_RESULT($have_threadsafe_getaddrinfo)
fi
], [
AC_MSG_RESULT(no)])
AC_CHECK_FUNC(madvise, [AC_DEFINE(HAVE_MADVISE, 1, [Whether we have madvise])])
if test x"$GOBJC" = x"yes"; then
OBJCFLAGS="$OBJCFLAGS -Werror"
AC_MSG_CHECKING(whether gcc has bug objc/27438)
AC_TRY_COMPILE([
#import <objc/objc.h>
@interface OFConstantString
{
Class isa;
const char *string;
unsigned long size;
}
@end
void *_OFConstantStringClassReference;
], [
OFConstantString *test = @"";
test++; /* Get rid of unused variable warning */
], [AC_MSG_RESULT(no)], [
AC_MSG_RESULT([yes, adding -Wno-unused-variable])
OBJCFLAGS="$OBJCFLAGS -Wno-unused-variable"
AC_SUBST(NO_WARN_UNUSED, "-Wno-unused-variable")])
AC_MSG_CHECKING(whether we need -Wno-strict-aliasing due to gcc bugs)
AC_TRY_COMPILE([
#import <objc/objc.h>
@interface OFObject
{
Class isa;
}
@end
static struct {
Class isa;
} object;
], [
OFObject *test = (OFObject*)&object;
test++; /* Get rid of unused variable warning */
], [AC_MSG_RESULT(no)], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$OBJCFLAGS -Wno-strict-aliasing"])
fi
if test x"$cross_compiling" = x"yes"; then
AC_SUBST(BIN_PREFIX, "$host-")
case "$host" in
*-*-mingw*)
AC_PATH_PROG(WINE, wine)
if test x"$WINE" != "x"; then
AC_SUBST(TESTS, "tests")
AC_SUBST(TEST_LAUNCHER, "$WINE")
fi
;;
esac
else
AC_SUBST(TESTS, "tests")
fi
BUILDSYS_INIT
BUILDSYS_TOUCH_DEPS
dnl We don't call AC_PROG_CPP, but only AC_PROG_OBJCPP and set CPP to OBJCPP
dnl and add OBJCPPFLAGS to CPPFLAGS, thus we need to AC_SUBST these ourself
AC_SUBST(CPP)
AC_SUBST(CPPFLAGS)
AC_SUBST(PACKAGE, ObjFW)
AC_CONFIG_FILES([buildsys.mk extra.mk utils/objfw-config])
AC_CONFIG_HEADERS([config.h src/objfw-defs.h])
AC_OUTPUT
|
|
|
|
>
|
<
>
>
|
>
<
>
|
|
>
>
|
>
|
|
>
|
>
|
>
|
>
|
>
|
<
>
>
|
|
<
>
<
>
<
>
|
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
|
have_threadsafe_getaddrinfo="yes"
;;
*)
have_threadsafe_getaddrinfo="unknown"
;;
esac
AS_IF([test x"$have_threadsafe_getaddrinfo" = x"unknown"], [
AC_EGREP_CPP(yes, [
#include <netdb.h>
#ifdef h_errno
yes
#end
], [
have_threadsafe_getaddrinfo="yes"
], [
have_threadsafe_getaddrinfo="no"
])
])
AS_IF([test x"$have_threadsafe_getaddrinfo" = x"yes"], [
AC_DEFINE(HAVE_THREADSAFE_GETADDRINFO, 1,
[Whether getaddrinfo is thread-safe])
])
AC_MSG_RESULT($have_threadsafe_getaddrinfo)
])
], [
AC_MSG_RESULT(no)
])
AC_CHECK_FUNC(madvise, [
AC_DEFINE(HAVE_MADVISE, 1, [Whether we have madvise])
])
AS_IF([test x"$GOBJC" = x"yes"], [
OBJCFLAGS="$OBJCFLAGS -Werror"
AC_MSG_CHECKING(whether gcc has bug objc/27438)
AC_TRY_COMPILE([
#import <objc/objc.h>
@interface OFConstantString
{
Class isa;
const char *string;
unsigned long size;
}
@end
void *_OFConstantStringClassReference;
], [
OFConstantString *test = @"";
test++; /* Get rid of unused variable warning */
], [
AC_MSG_RESULT(no)
], [
AC_MSG_RESULT([yes, adding -Wno-unused-variable])
OBJCFLAGS="$OBJCFLAGS -Wno-unused-variable"
AC_SUBST(NO_WARN_UNUSED, "-Wno-unused-variable")
])
AC_MSG_CHECKING(whether we need -Wno-strict-aliasing due to gcc bugs)
AC_TRY_COMPILE([
#import <objc/objc.h>
@interface OFObject
{
Class isa;
}
@end
static struct {
Class isa;
} object;
], [
OFObject *test = (OFObject*)&object;
test++; /* Get rid of unused variable warning */
], [
AC_MSG_RESULT(no)
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$OBJCFLAGS -Wno-strict-aliasing"
])
])
AS_IF([test x"$cross_compiling" = x"yes"], [
AC_SUBST(BIN_PREFIX, "$host-")
case "$host" in
*-*-mingw*)
AC_PATH_PROG(WINE, wine)
AS_IF([test x"$WINE" != "x"], [
AC_SUBST(TESTS, "tests")
AC_SUBST(TEST_LAUNCHER, "$WINE")
])
;;
esac
], [
AC_SUBST(TESTS, "tests")
])
BUILDSYS_INIT
BUILDSYS_TOUCH_DEPS
dnl We don't call AC_PROG_CPP, but only AC_PROG_OBJCPP and set CPP to OBJCPP
dnl and add OBJCPPFLAGS to CPPFLAGS, thus we need to AC_SUBST these ourself
AC_SUBST(CPP)
AC_SUBST(CPPFLAGS)
AC_SUBST(PACKAGE, ObjFW)
AC_CONFIG_FILES([buildsys.mk extra.mk utils/objfw-config])
AC_CONFIG_HEADERS([config.h src/objfw-defs.h])
AC_OUTPUT
|