Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 593 lines (531 sloc) 14.323 kb
7806d0d @Midar Increase version to 0.6-dev.
authored
1 AC_INIT(ObjFW, 0.6-dev, js@webkeks.org)
1abfa03 @Midar Initial import.
authored
2 AC_CONFIG_SRCDIR(src)
3
00cd3e7 @Midar Initial PSP port.
authored
4 AS_IF([test x"$host" = x"psp"], [
0e6afa0 @Midar More changes to port ObjFW to PSP.
authored
5 OBJCFLAGS="-G0 $OBJCFLAGS"
749c24e @Midar More work on the PSP port.
authored
6 LIBS="$LIBS -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc"
7 LIBS="$LIBS -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver"
8 LIBS="$LIBS -lpsputility -lpspuser -lpspkernel"
00cd3e7 @Midar Initial PSP port.
authored
9 ])
10
1abfa03 @Midar Initial import.
authored
11 AC_CANONICAL_HOST
12
6f9a9a7 @Midar Rename all .c files to .m so we only need an OBJC and no CC.
authored
13 AC_LANG([Objective C])
14 AC_PROG_OBJC
8ff4aaf @Midar Make sure we never even check for CC by using OBJCPP as CPP.
authored
15 AC_PROG_OBJCPP
1abfa03 @Midar Initial import.
authored
16 AC_PROG_LN_S
9c6f6cc @Midar Check for install in configure.
authored
17 AC_PROG_INSTALL
d96729b @Midar Check for SIZE_T, fallback to SIZE_T_MAX or define as (size_t)-1.
authored
18 AC_PROG_EGREP
1abfa03 @Midar Initial import.
authored
19
8ff4aaf @Midar Make sure we never even check for CC by using OBJCPP as CPP.
authored
20 CPP="$OBJCPP"
21 CPPFLAGS="$CPPFLAGS $OBJCPPFLAGS"
6bc2865 @Midar Add support for the new GNU runtime.
authored
22 OBJCFLAGS="$OBJCFLAGS -Wall -fexceptions -fobjc-exceptions"
1be5c80 @Midar Rename OFConstString to OFConstantString.
authored
23 OBJCFLAGS="$OBJCFLAGS -fconstant-string-class=OFConstantString"
6f9a9a7 @Midar Rename all .c files to .m so we only need an OBJC and no CC.
authored
24
2cbd4d0 @Midar Use -std=gnu99 instead of -std=c99. c99 gives trouble with glibc.
authored
25 AX_CHECK_COMPILER_FLAGS(-std=gnu99, [OBJCFLAGS="$OBJCFLAGS -std=gnu99"])
6f9a9a7 @Midar Rename all .c files to .m so we only need an OBJC and no CC.
authored
26 AX_CHECK_COMPILER_FLAGS(-pipe, [OBJCFLAGS="$OBJCFLAGS -pipe"])
27 AX_CHECK_COMPILER_FLAGS(-fno-common, [OBJCFLAGS="$OBJCFLAGS -fno-common"])
28 AX_CHECK_COMPILER_FLAGS(-fno-constant-cfstrings, [
29 NO_CONST_CFSTRINGS="-fno-constant-cfstrings"
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
30 OBJCFLAGS="$OBJCFLAGS -fno-constant-cfstrings"
31 ])
1411b3a @Midar Check if -Wshorten-64-to-32 is available.
authored
32 AX_CHECK_COMPILER_FLAGS(-Wshorten-64-to-32, [OBJCFLAGS="$OBJCFLAGS -pipe"])
6f9a9a7 @Midar Rename all .c files to .m so we only need an OBJC and no CC.
authored
33 AC_SUBST(NO_CONST_CFSTRINGS)
983a6a6 @Midar Preliminary OFConstString implementation and support for @"" literals.
authored
34
c16a7fd @Midar Check for fast enumeration support in compiler and run tests.
authored
35 AC_MSG_CHECKING(whether Objective C compiler supports fast enumeration)
36 AC_TRY_COMPILE([
170ebb1 @Midar Work around a compiler bug that can happen in the configure script.
authored
37 @protocol OFFastEnumeration
38 - (int)countByEnumeratingWithState: (void*)state
17b8217 @Midar It seems id is already defined by clang and newer GCCs.
authored
39 objects: (id*)objects
170ebb1 @Midar Work around a compiler bug that can happen in the configure script.
authored
40 count: (int)count;
41 @end
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
42 ], [
17b8217 @Midar It seems id is already defined by clang and newer GCCs.
authored
43 id n = (id)0;
44 for (id i in n);
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
45 ], [
a6b1da4 @Midar Test if compiler supports properties and if so run property tests.
authored
46 AC_DEFINE(OF_HAVE_FAST_ENUMERATION, 1,
47 [Compiler support for Fast Enumeration])
48 AC_MSG_RESULT(yes)
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
49 ], [
50 AC_MSG_RESULT(no)
51 ])
a6b1da4 @Midar Test if compiler supports properties and if so run property tests.
authored
52
53 AC_MSG_CHECKING(whether Objective C compiler supports properties)
54 AC_TRY_COMPILE([
55 @interface Foo
56 {
57 id bar;
58 }
59
17b8217 @Midar It seems id is already defined by clang and newer GCCs.
authored
60 @property (retain, nonatomic) id bar;
a6b1da4 @Midar Test if compiler supports properties and if so run property tests.
authored
61 @end
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
62 ], [
17b8217 @Midar It seems id is already defined by clang and newer GCCs.
authored
63 Foo *foo = (id)0;
64 [foo setBar: (id)0];
a6b1da4 @Midar Test if compiler supports properties and if so run property tests.
authored
65 [foo bar];
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
66 ], [
a6b1da4 @Midar Test if compiler supports properties and if so run property tests.
authored
67 AC_DEFINE(OF_HAVE_PROPERTIES, 1, [Compiler support for properties])
5777e36 @Midar Rename tests files so they are named after the category they implement.
authored
68 AC_SUBST(PROPERTIESTESTS_M, "PropertiesTests.m")
c16a7fd @Midar Check for fast enumeration support in compiler and run tests.
authored
69 AC_MSG_RESULT(yes)
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
70 ], [
71 AC_MSG_RESULT(no)
72 ])
64cb023 @Midar Initial support for blocks.
authored
73
70f6afc @Midar Check whether optional protocols are supported.
authored
74 AC_MSG_CHECKING(whether Objective C compiler supports optional protocols)
75 AC_TRY_COMPILE([
76 @protocol Proto
77 @optional
78 + (void)foo;
79 @end
80
81 @interface Foo <Proto>
82 @end
83
84 @implementation Foo
85 @end
86 ], [
87 [Foo foo];
88 ], [
89 AC_DEFINE(OF_HAVE_OPTIONAL_PROTOCOLS, 1,
90 [Compiler support for optional protocols])
91 AC_MSG_RESULT(yes)
92 ], [
93 AC_MSG_RESULT(no)
94 ])
95
64cb023 @Midar Initial support for blocks.
authored
96 AC_MSG_CHECKING(whether Objective C compiler supports blocks)
97 old_OBJCFLAGS="$OBJCFLAGS"
98 OBJCFLAGS="$OBJCFLAGS -fblocks"
99 AC_TRY_COMPILE([], [
100 int (^foo)(int bar);
101 foo = ^(int bar) { return 0; }
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
102 ], [
64cb023 @Midar Initial support for blocks.
authored
103 AC_DEFINE(OF_HAVE_BLOCKS, 1, [Compiler support for blocks])
16154d6 @Midar Add flags for blocks to objfw-config.
authored
104 AC_SUBST(BLOCKS_FLAGS, "-fblocks")
bfb1ec0 @Midar Add tests for blocks.
authored
105 AC_SUBST(OFBLOCKTESTS_M, "OFBlockTests.m")
64cb023 @Midar Initial support for blocks.
authored
106 AC_MSG_RESULT(yes)
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
107 ], [
64cb023 @Midar Initial support for blocks.
authored
108 AC_MSG_RESULT(no)
109 OBJCFLAGS="$old_OBJCFLAGS"
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
110 ])
c16a7fd @Midar Check for fast enumeration support in compiler and run tests.
authored
111
2b8e9ec @Midar Add support for ObjFW-RT, the ObjFW Objective C runtime.
authored
112 AC_CHECK_HEADERS([objfw-rt.h objc/objc.h])
113
114 test x"$ac_cv_header_objfw_rt_h" = x"yes" && objc_runtime="ObjFW-RT"
115
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
116 AS_IF([test x"$ac_cv_header_objc_objc_h" = x"yes"], [
6bc2865 @Midar Add support for the new GNU runtime.
authored
117 AC_EGREP_CPP(yes, [
2b8e9ec @Midar Add support for ObjFW-RT, the ObjFW Objective C runtime.
authored
118 #import <objc/objc.h>
6bc2865 @Midar Add support for the new GNU runtime.
authored
119 #ifdef __GNU_LIBOBJC__
120 yes
2b8e9ec @Midar Add support for ObjFW-RT, the ObjFW Objective C runtime.
authored
121 #endif
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
122 ], [
0cc0fe0 @Midar A few minor improvements in configure.ac.
authored
123 test x"$objc_runtime" = x"" && objc_runtime="GNU"
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
124 ], [
6bc2865 @Midar Add support for the new GNU runtime.
authored
125 dnl TODO: This is ugly. Let's think of a better check.
126 AC_EGREP_CPP(yes, [
127 #import <objc/objc.h>
128 #ifdef __objc_INCLUDE_GNU
129 yes
130 #endif
131 ], [
0cc0fe0 @Midar A few minor improvements in configure.ac.
authored
132 test x"$objc_runtime" = x"" && objc_runtime="old GNU"
6bc2865 @Midar Add support for the new GNU runtime.
authored
133 ], [
134 objc_runtime="Apple"
135 ])
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
136 ])
137 ])
2b8e9ec @Midar Add support for ObjFW-RT, the ObjFW Objective C runtime.
authored
138
9f9e9e9 @Midar Better checking which runtime we use.
authored
139 AC_MSG_CHECKING(which Objective C runtime we use)
2b8e9ec @Midar Add support for ObjFW-RT, the ObjFW Objective C runtime.
authored
140 case $objc_runtime in
141 ObjFW-RT)
142 AC_DEFINE(OF_OBJFW_RUNTIME, 1,
143 [Whether we use the ObjFW runtime])
144 AC_SUBST(GNU_RUNTIME, "-fgnu-runtime")
145 OBJCFLAGS="$OBJCFLAGS -fgnu-runtime"
00cd3e7 @Midar Initial PSP port.
authored
146 LIBS="-lobjfw-rt $LIBS"
2b8e9ec @Midar Add support for ObjFW-RT, the ObjFW Objective C runtime.
authored
147 ;;
148 Apple)
149 AC_DEFINE(OF_APPLE_RUNTIME, 1,
150 [Whether we use the Apple ObjC runtime])
00cd3e7 @Midar Initial PSP port.
authored
151 LIBS="-lobjc $LIBS"
2b8e9ec @Midar Add support for ObjFW-RT, the ObjFW Objective C runtime.
authored
152 ;;
153 GNU)
154 AC_DEFINE(OF_GNU_RUNTIME, 1,
155 [Whether we use the GNU ObjC runtime])
00cd3e7 @Midar Initial PSP port.
authored
156 LIBS="-lobjc $LIBS"
2b8e9ec @Midar Add support for ObjFW-RT, the ObjFW Objective C runtime.
authored
157 ;;
6bc2865 @Midar Add support for the new GNU runtime.
authored
158 "old GNU")
159 AC_DEFINE(OF_OLD_GNU_RUNTIME, 1,
160 [Whether we use the old GNU ObjC runtime])
00cd3e7 @Midar Initial PSP port.
authored
161 LIBS="-lobjc $LIBS"
6bc2865 @Midar Add support for the new GNU runtime.
authored
162 ;;
2b8e9ec @Midar Add support for ObjFW-RT, the ObjFW Objective C runtime.
authored
163 *)
164 AC_MSG_RESULT(none)
165 AC_MSG_ERROR(No ObjC runtime found! Please install ObjFW-RT!)
166 ;;
167 esac
9f9e9e9 @Midar Better checking which runtime we use.
authored
168 AC_MSG_RESULT($objc_runtime)
169
6a21ccd @Midar Add support for ObjC 2 properties.
authored
170 AC_CHECK_FUNC(objc_getProperty,, [
e72cac9 @Midar Change spinlock implementation, add fallbacks and move to threading.h.
authored
171 AC_DEFINE(NEED_OBJC_PROPERTIES_INIT, 1,
172 [Whether objc_properties_init needs to be called])
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
173 AC_SUBST(OBJC_PROPERTIES_M, "objc_properties.m")
174 ])
6a21ccd @Midar Add support for ObjC 2 properties.
authored
175
524fe7b @Midar Check for objc_enumerationMutation and provide it if it's missing.
authored
176 AC_CHECK_FUNC(objc_enumerationMutation, [
177 AC_DEFINE(HAVE_OBJC_ENUMERATIONMUTATION, 1,
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
178 [Whether we have objc_enumerationMutation])
179 ])
524fe7b @Midar Check for objc_enumerationMutation and provide it if it's missing.
authored
180
0cc0fe0 @Midar A few minor improvements in configure.ac.
authored
181 AC_CHECK_TOOL(AR, ar)
34545aa @Midar Split OFExceptions.{h,m} into one file per exception.
authored
182 AC_PROG_RANLIB
b1e6ff6 @Midar Update buildsys. This allows building a static and a shared lib at once.
authored
183 AC_ARG_ENABLE(shared,
0cc0fe0 @Midar A few minor improvements in configure.ac.
authored
184 AS_HELP_STRING([--disable-shared], [do not build shared library]))
b1e6ff6 @Midar Update buildsys. This allows building a static and a shared lib at once.
authored
185 AS_IF([test x"$enable_shared" != x"no"], [
186 BUILDSYS_SHARED_LIB
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
187 AC_SUBST(OBJFW_SHARED_LIB, "${LIB_PREFIX}objfw${LIB_SUFFIX}")
34545aa @Midar Split OFExceptions.{h,m} into one file per exception.
authored
188 AC_SUBST(EXCEPTIONS_LIB_A, "exceptions.lib.a")
189 AC_SUBST(EXCEPTIONS_EXCEPTIONS_LIB_A, "exceptions/exceptions.lib.a")
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
190 ])
191 AC_ARG_ENABLE(static, AS_HELP_STRING([--enable-static], [build static library]))
b1e6ff6 @Midar Update buildsys. This allows building a static and a shared lib at once.
authored
192 AS_IF([test x"$enable_static" = x"yes" -o x"$enable_shared" = x"no"], [
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
193 AC_SUBST(OBJFW_STATIC_LIB, "libobjfw.a")
34545aa @Midar Split OFExceptions.{h,m} into one file per exception.
authored
194 AC_SUBST(EXCEPTIONS_A, "exceptions.a")
195 AC_SUBST(EXCEPTIONS_EXCEPTIONS_A, "exceptions/exceptions.a")
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
196 ])
b1e6ff6 @Midar Update buildsys. This allows building a static and a shared lib at once.
authored
197
da0721d @Midar Preliminary OFPlugin implementation.
authored
198 AC_DEFINE_UNQUOTED(PLUGIN_SUFFIX, "$PLUGIN_SUFFIX", [Suffix for plugins])
0cc0fe0 @Midar A few minor improvements in configure.ac.
authored
199 AS_IF([test x"$PLUGIN_SUFFIX" != x""], [
da0721d @Midar Preliminary OFPlugin implementation.
authored
200 AC_SUBST(OFPLUGIN_M, "OFPlugin.m")
5777e36 @Midar Rename tests files so they are named after the category they implement.
authored
201 AC_SUBST(OFPLUGINTESTS_M, "OFPluginTests.m")
8b77c5f @Midar Migration of OFPlugin tests to new testing framework.
authored
202 AC_SUBST(TESTPLUGIN, "plugin")
203 AC_DEFINE(OF_PLUGINS, 1, [Whether we have plugin support])
204 AC_SUBST(OFPLUGINS_DEF, "-DOF_PLUGINS")
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
205 ])
da0721d @Midar Preliminary OFPlugin implementation.
authored
206
ac6df8b @Midar Add flags for reexporting libobjc and ObjFW.
authored
207 case "$host_os" in
208 darwin*)
673cf2f @Midar Only use mach_alias_list on x86_64.
authored
209 AC_SUBST(REEXPORT_LIBOBJC, ["-Wl,-reexport-lobjc"])
210 AC_SUBST(LDFLAGS_REEXPORT, ["-Wl,-reexport-lobjfw"])
211 AC_SUBST(MACH_ALIAS_LIST,
212 ["-Xarch_x86_64 -Wl,-alias_list,mach_alias_list"])
ac6df8b @Midar Add flags for reexporting libobjc and ObjFW.
authored
213 ;;
214 esac
215
19c4522 @Midar Add objfw.h which includes everything.
authored
216 AC_C_BIGENDIAN([
217 AC_DEFINE(OF_BIG_ENDIAN, 1, [Whether we are big endian])
2ed013d @Midar Check floating point endianess.
authored
218 ])
219
220 AC_MSG_CHECKING(for floating point endianess)
221 float_endianess="unknown"
222 AC_TRY_COMPILE([
223 double endianess = 184092775106.859375;
224 ], [
225 ], [
226 AS_IF([$EGREP BEndian conftest.$ac_objext >/dev/null], [
227 AC_DEFINE(OF_FLOAT_BIG_ENDIAN, 1,
228 [Whether floats are big endian])
229 float_endianess="big endian"
230 ], [
231 AS_IF([$EGREP naidnEB conftest.$ac_objext >/dev/null], [
232 float_endianess="little endian"
233 ])
234 ])
235 ])
236 AC_MSG_RESULT($float_endianess)
237 AS_IF([test x"$float_endianess" = x"unknown"], [
238 AC_MSG_ERROR([FP implementation does not conform to IEEE 754!])
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
239 ])
1abfa03 @Midar Initial import.
authored
240
d96729b @Midar Check for SIZE_T, fallback to SIZE_T_MAX or define as (size_t)-1.
authored
241 AC_MSG_CHECKING(for SIZE_MAX)
242 AC_EGREP_CPP(yes, [
243 #include <stdint.h>
244 #include <limits.h>
245
246 #ifdef SIZE_MAX
247 yes
3a9d7e7 @Midar Add .xcodeproj.
authored
248 #endif
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
249 ], [
250 AC_MSG_RESULT(yes)
251 ], [
d96729b @Midar Check for SIZE_T, fallback to SIZE_T_MAX or define as (size_t)-1.
authored
252 AC_MSG_RESULT(no)
253 AC_MSG_CHECKING(for SIZE_T_MAX)
254 AC_EGREP_CPP(yes, [
255 #include <stdint.h>
256 #include <limits.h>
257
258 #ifdef SIZE_T_MAX
259 yes
3a9d7e7 @Midar Add .xcodeproj.
authored
260 #endif
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
261 ], [
d96729b @Midar Check for SIZE_T, fallback to SIZE_T_MAX or define as (size_t)-1.
authored
262 AC_MSG_RESULT(yes)
263 size_max="SIZE_T_MAX"], [
264 AC_MSG_RESULT(no)
359fa80 @Midar Add +[distantFuture] and +[distantPast] to OFDate.
authored
265 size_max="(~(size_t)0)"
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
266 ])
267 AC_DEFINE_UNQUOTED(SIZE_MAX, $size_max, [Maximum value for size_t])
268 ])
d96729b @Midar Check for SIZE_T, fallback to SIZE_T_MAX or define as (size_t)-1.
authored
269
0e0f1df @Midar Don't compile asprintf.c if not needed.
authored
270 AC_CHECK_FUNC(asprintf, [
476a328 @Midar More work on the PSP port.
authored
271 case "$host" in
272 *-psp-*)
273 dnl asprintf is broken on the PSP, but snprintf works.
274 have_asprintf="no"
275 AC_SUBST(ASPRINTF_M, "asprintf.m")
276 ac_cv_snprintf_useful_ret="yes"
277 ;;
278 *)
edfaa5f @Midar Oops. Broke the check for asprintf. Fixed.
authored
279 have_asprintf="yes"
476a328 @Midar More work on the PSP port.
authored
280 AC_DEFINE(OF_HAVE_ASPRINTF, 1,
281 [Whether we have asprintf])
282 AC_SUBST(ASPRINTF_DEF, "-DOF_HAVE_ASPRINTF")
283 ;;
284 esac
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
285 ], [
1f5325e @Midar Check whether we can use snprintf in our asprintf implementation.
authored
286 have_asprintf="no"
6f9a9a7 @Midar Rename all .c files to .m so we only need an OBJC and no CC.
authored
287 AC_SUBST(ASPRINTF_M, "asprintf.m")
af73dbf @Midar Only check if snprintf returns required space if there's no asprintf.
authored
288
289 AC_MSG_CHECKING(whether snprintf returns something useful)
290 AC_CACHE_VAL(ac_cv_snprintf_useful_ret, [
291 AC_TRY_RUN([
292 #include <stdio.h>
293
294 int
295 main()
296 {
297 return (snprintf(NULL, 0, "asd") == 3 ? 0 : 1);
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
298 }
299 ], [
c37d364 @Midar Fix broken snprintf test.
authored
300 ac_cv_snprintf_useful_ret="yes"
301 ], [
302 ac_cv_snprintf_useful_ret="no"
303 ], [
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
304 ac_cv_snprintf_useful_ret="no"
305 ])
306 ])
307 AC_MSG_RESULT($ac_cv_snprintf_useful_ret)
308 ])
225c538 @Midar Cache checks that don't work when crosscompiling.
authored
309 test x"$have_asprintf" != x"yes" -a x"$ac_cv_snprintf_useful_ret" != x"yes" && \
1f5325e @Midar Check whether we can use snprintf in our asprintf implementation.
authored
310 AC_MSG_ERROR(No asprintf and no snprintf returning required space!)
311
469d3ba @Midar Add -lm if available.
authored
312 AC_CHECK_LIB(m, fmod, LIBS="$LIBS -lm")
6f9a9a7 @Midar Rename all .c files to .m so we only need an OBJC and no CC.
authored
313 AC_CHECK_LIB(dl, dlopen, LIBS="$LIBS -ldl")
314
0f4216a @Midar Make it possible to build ObjFW without support for threads.
authored
315 AC_ARG_ENABLE(threads,
316 AS_HELP_STRING([--disable-threads], [disable thread support]))
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
317 AS_IF([test x"$enable_threads" != x"no"], [
0f4216a @Midar Make it possible to build ObjFW without support for threads.
authored
318 case "$host_os" in
e72cac9 @Midar Change spinlock implementation, add fallbacks and move to threading.h.
authored
319 mingw*)
320 AC_MSG_CHECKING(for threads)
32a4c44 @Midar Add +[thread] to OFThread and allow -[init].
authored
321 AC_MSG_RESULT(WinAPI)
e72cac9 @Midar Change spinlock implementation, add fallbacks and move to threading.h.
authored
322 ;;
323 *)
324 ACX_PTHREAD([
325 CPPLAGS="$CPPFLAGS $PTHREAD_CFLAGS"
326 LIBS="$LIBS $PTHREAD_LIBS"
327 AC_DEFINE(OF_HAVE_PTHREADS, 1,
328 [Whether we have pthreads])
329 AC_CHECK_FUNC(pthread_spin_lock, [
330 AC_DEFINE(OF_HAVE_PTHREAD_SPINLOCKS, 1,
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
331 [Whether we have pthread spinlocks])
332 ])
e72cac9 @Midar Change spinlock implementation, add fallbacks and move to threading.h.
authored
333 AC_CHECK_FUNC(sched_yield, [
334 AC_DEFINE(OF_HAVE_SCHED_YIELD, 1,
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
335 [Whether we have sched_yield])
336 ])
337 ], [
338 AC_MSG_ERROR(No supported threads found!)
339 ])
e72cac9 @Midar Change spinlock implementation, add fallbacks and move to threading.h.
authored
340 ;;
0f4216a @Midar Make it possible to build ObjFW without support for threads.
authored
341 esac
342
343 AC_DEFINE(OF_THREADS, 1, [Whether we have threads])
344 AC_SUBST(OFTHREAD_M, "OFThread.m")
5777e36 @Midar Rename tests files so they are named after the category they implement.
authored
345 AC_SUBST(OFTHREADTESTS_M, "OFThreadTests.m")
b187448 @Midar Don't test OFHTTPRequest if we have no threads.
authored
346 AC_SUBST(OFHTTPREQUESTTESTS_M, "OFHTTPRequestTests.m")
0f4216a @Midar Make it possible to build ObjFW without support for threads.
authored
347 AC_SUBST(THREADING_H, "threading.h")
348
349 AC_CHECK_FUNC(objc_sync_enter,, [
350 AC_SUBST(OBJC_SYNC_M, "objc_sync.m")
351 AC_DEFINE(NEED_OBJC_SYNC_INIT, 1,
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
352 [Whether objc_sync_init needs to be called])
353 ])
a988466 @Midar Make retain/release atomic.
authored
354
3712e91 @Midar Nicer checking for atomic ops.
authored
355 atomic_ops="none"
356
e7f2af4 @Midar Assembly implementation for atomic operations (x86 and AMD64).
authored
357 AC_MSG_CHECKING(whether we have an atomic ops assembly implementation)
358 AC_EGREP_CPP(yes, [
359 #if defined(__GNUC__) && (defined(__i386__) || \
360 defined(__amd64__) || defined(__x86_64__))
361 yes
362 #endif
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
363 ], [
3712e91 @Midar Nicer checking for atomic ops.
authored
364 AC_MSG_RESULT(yes)
e7f2af4 @Midar Assembly implementation for atomic operations (x86 and AMD64).
authored
365 atomic_ops="assembly implementation"
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
366 ], [
367 AC_MSG_RESULT(no)
368 ])
e7f2af4 @Midar Assembly implementation for atomic operations (x86 and AMD64).
authored
369
1cbff1a @Midar Check for all atomic ops implementations available.
authored
370 AC_MSG_CHECKING(whether __sync_* works)
371 AC_TRY_LINK([#include <stdint.h>], [
372 int32_t i, j;
373 if (__sync_add_and_fetch(&i, 1))
374 j = __sync_sub_and_fetch(&i, 1);
375 while (!__sync_bool_compare_and_swap(&i, 0, 1));
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
376 ], [
1cbff1a @Midar Check for all atomic ops implementations available.
authored
377 AC_MSG_RESULT(yes)
378 test x"$atomic_ops" = x"none" && atomic_ops="gcc builtins"
379 AC_DEFINE(OF_HAVE_GCC_ATOMIC_OPS, 1,
380 [Whether gcc atomic operations are available])
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
381 ], [
382 AC_MSG_RESULT(no)
383 ])
1cbff1a @Midar Check for all atomic ops implementations available.
authored
384
385 AC_CHECK_HEADER(libkern/OSAtomic.h, [
386 test x"$atomic_ops" = x"none" && atomic_ops="libkern/OSAtomic.h"
f5076ed @Midar Check if 64 bit version of OSAtomic* functions is available.
authored
387 AC_DEFINE(OF_HAVE_OSATOMIC, 1,
388 [Whether we have libkern/OSAtomic.h])
389 AC_CHECK_FUNC(OSAtomicAdd64Barrier, [
390 AC_DEFINE(OF_HAVE_OSATOMIC_64, 1,
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
391 [Whether we have OSAtomic*64])
392 ])
393 ])
394 ], [
f754473 @Midar Define OF_ATOMIC_OPS if we don't have threads.
authored
395 dnl We can only have one thread - therefore everything is atomic
3712e91 @Midar Nicer checking for atomic ops.
authored
396 atomic_ops="not needed"
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
397 ])
3712e91 @Midar Nicer checking for atomic ops.
authored
398
399 AC_MSG_CHECKING(for atomic operations)
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
400 AS_IF([test x"$atomic_ops" != x"none"], [
f754473 @Midar Define OF_ATOMIC_OPS if we don't have threads.
authored
401 AC_DEFINE(OF_ATOMIC_OPS, 1, [Whether we have atomic operations])
d74f09f @Midar Only install atomic.h if atomic ops are available.
authored
402 AC_SUBST(ATOMIC_H, "atomic.h")
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
403 ])
3712e91 @Midar Nicer checking for atomic ops.
authored
404 AC_MSG_RESULT($atomic_ops)
54b954e @Midar Check for pthreads.
authored
405
9c6db75 @Midar Add -lsocket to LIBS if libsocket has socket(). Solaris needs this.
authored
406 AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
9ba2708 @Midar Link against -lnetwork if available.
authored
407 AC_CHECK_LIB(network, socket, LIBS="$LIBS -lnetwork")
c5dc9d8 @Midar A few win32 fixes.
authored
408 AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32")
96cb9a6 @Midar Add Win32 support to OFTCPSocket. Even IPv6 works!
authored
409
3a62ada @Midar Add OFDate.
authored
410 AC_CHECK_FUNC(gmtime_r, [
411 AC_DEFINE(HAVE_GMTIME_R, 1, [Whether we have gmtime_r])
412 ])
32563b2 @Midar Add methods for local time to OFDate.
authored
413 AC_CHECK_FUNC(localtime_r, [
414 AC_DEFINE(HAVE_LOCALTIME_R, 1, [Whether we have localtime_r])
415 ])
3a62ada @Midar Add OFDate.
authored
416
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
417 AC_CHECK_HEADER(poll.h, [
418 AC_DEFINE(OF_HAVE_POLL, 1, [Whether poll is supported])
419 ])
420 AC_CHECK_HEADERS(sys/select.h, [
421 AC_DEFINE(OF_HAVE_SYS_SELECT_H, 1, [Whether we have sys/select.h])
422 ])
2403a5e @Midar Fallback to select() in OFSocketObserver if poll() is unavailable.
authored
423
a21c44d @Midar Fall back to gethostbyname + locking if getaddrinfo is missing.
authored
424 AC_MSG_CHECKING(for getaddrinfo)
425 AC_TRY_COMPILE([
426 #include <stddef.h>
427 #ifndef _WIN32
e75d16f @Midar Update buildsys.
authored
428 # include <sys/types.h>
429 # include <sys/socket.h>
430 # include <netdb.h>
a21c44d @Midar Fall back to gethostbyname + locking if getaddrinfo is missing.
authored
431 #else
e75d16f @Midar Update buildsys.
authored
432 # define _WIN32_WINNT 0x0501
56014e1 @Midar Fix the getaddrinfo test on win32.
authored
433 # include <windows.h>
e75d16f @Midar Update buildsys.
authored
434 # include <ws2tcpip.h>
c16a7fd @Midar Check for fast enumeration support in compiler and run tests.
authored
435 #endif
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
436 ], [
a21c44d @Midar Fall back to gethostbyname + locking if getaddrinfo is missing.
authored
437 struct addrinfo ai;
438 getaddrinfo(NULL, NULL, NULL, NULL);
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
439 ], [
77a7b06 @Midar Check whether getaddrinfo is thread-safe and use locks if not.
authored
440 AC_MSG_RESULT(yes)
a21c44d @Midar Fall back to gethostbyname + locking if getaddrinfo is missing.
authored
441 AC_DEFINE(HAVE_GETADDRINFO, 1, [Whether we have getaddrinfo])
225c538 @Midar Cache checks that don't work when crosscompiling.
authored
442
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
443 AS_IF([test x"$enable_threads" != x"no"], [
0f4216a @Midar Make it possible to build ObjFW without support for threads.
authored
444 AC_MSG_CHECKING(whether getaddrinfo is thread-safe)
445
446 case "$host_os" in
447 darwin[[12345]].*)
448 have_threadsafe_getaddrinfo="no"
449 ;;
450 darwin*)
451 have_threadsafe_getaddrinfo="yes"
452 ;;
453 freebsd[[1234]].* | freebsd5.[[1234]]*)
454 have_threadsafe_getaddrinfo="no"
455 ;;
456 freebsd*)
457 have_threadsafe_getaddrinfo="yes"
458 ;;
459 netbsd[[123]].*)
460 have_threadsafe_getaddrinfo="no"
461 ;;
462 netbsd*)
463 have_threadsafe_getaddrinfo="yes"
464 ;;
465 solaris*)
466 have_threadsafe_getaddrinfo="yes"
467 ;;
468 *)
469 have_threadsafe_getaddrinfo="unknown"
470 ;;
77a7b06 @Midar Check whether getaddrinfo is thread-safe and use locks if not.
authored
471 esac
472
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
473 AS_IF([test x"$have_threadsafe_getaddrinfo" = x"unknown"], [
77a7b06 @Midar Check whether getaddrinfo is thread-safe and use locks if not.
authored
474 AC_EGREP_CPP(yes, [
aea65ed @Midar Properly check for thread-safe getaddrinfo if it's unknown.
authored
475 #ifndef _WIN32
476 # include <sys/types.h>
477 # include <sys/socket.h>
478 # include <netdb.h>
479 #else
480 # define _WIN32_WINNT 0x0501
481 # include <windows.h>
482 # include <ws2tcpip.h>
483 #endif
484
77a7b06 @Midar Check whether getaddrinfo is thread-safe and use locks if not.
authored
485 #ifdef h_errno
486 yes
487 #end
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
488 ], [
489 have_threadsafe_getaddrinfo="yes"
490 ], [
491 have_threadsafe_getaddrinfo="no"
492 ])
493 ])
77a7b06 @Midar Check whether getaddrinfo is thread-safe and use locks if not.
authored
494
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
495 AS_IF([test x"$have_threadsafe_getaddrinfo" = x"yes"], [
77a7b06 @Midar Check whether getaddrinfo is thread-safe and use locks if not.
authored
496 AC_DEFINE(HAVE_THREADSAFE_GETADDRINFO, 1,
497 [Whether getaddrinfo is thread-safe])
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
498 ])
77a7b06 @Midar Check whether getaddrinfo is thread-safe and use locks if not.
authored
499
500 AC_MSG_RESULT($have_threadsafe_getaddrinfo)
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
501 ])
502 ], [
503 AC_MSG_RESULT(no)
504 ])
77a7b06 @Midar Check whether getaddrinfo is thread-safe and use locks if not.
authored
505
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
506 AC_CHECK_FUNC(madvise, [
507 AC_DEFINE(HAVE_MADVISE, 1, [Whether we have madvise])
508 ])
0fcd9db @Midar Check for sys/mman.h before trying to use madvise.
authored
509
0b888ce @Midar Increase blocks compatibility by replacing NSAutoreleasePool.
authored
510 AS_IF([test x"$objc_runtime" = x"Apple"], [
7f64f62 @Midar Check for NSObject.h instead of Foundation.h. Really speeds things up.
authored
511 AC_CHECK_HEADER(Foundation/NSObject.h, [
0b888ce @Midar Increase blocks compatibility by replacing NSAutoreleasePool.
authored
512 AC_SUBST(FOUNDATION_COMPAT_M, "foundation-compat.m")
513 ])
514 ])
515
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
516 AS_IF([test x"$GOBJC" = x"yes"], [
1411b3a @Midar Check if -Wshorten-64-to-32 is available.
authored
517 OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wcast-align -Wpointer-arith"
518 OBJCFLAGS="$OBJCFLAGS -Werror"
033c909 @Midar Separate C and ObjC checks.
authored
519
520 AC_MSG_CHECKING(whether gcc has bug objc/27438)
521 AC_TRY_COMPILE([
1be5c80 @Midar Rename OFConstString to OFConstantString.
authored
522 @interface OFConstantString
033c909 @Midar Separate C and ObjC checks.
authored
523 {
875e801 @Midar Don't depend on objc/objc.h for compiler checks.
authored
524 struct objc_class *isa;
033c909 @Midar Separate C and ObjC checks.
authored
525 const char *string;
526 unsigned long size;
527 }
528 @end
529
1be5c80 @Midar Rename OFConstString to OFConstantString.
authored
530 void *_OFConstantStringClassReference;
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
531 ], [
1be5c80 @Midar Rename OFConstString to OFConstantString.
authored
532 OFConstantString *test = @"";
5ab8e5c @Midar configure.ac: Fix two tests that would fail with Clang + new ABI.
authored
533 (void)test; /* Get rid of unused variable warning */
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
534 ], [
535 AC_MSG_RESULT(no)
536 ], [
02ee996 @Midar Better checking which warnings need to be disabled due to gcc bugs.
authored
537 AC_MSG_RESULT([yes, adding -Wno-unused-variable])
013625f @Midar Add -Wno-unused-variable to objfw-config if we got gcc bug objc/27438.
authored
538 OBJCFLAGS="$OBJCFLAGS -Wno-unused-variable"
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
539 AC_SUBST(NO_WARN_UNUSED, "-Wno-unused-variable")
540 ])
02ee996 @Midar Better checking which warnings need to be disabled due to gcc bugs.
authored
541
542 AC_MSG_CHECKING(whether we need -Wno-strict-aliasing due to gcc bugs)
543 AC_TRY_COMPILE([
544 @interface OFObject
545 {
546 Class isa;
547 }
548 @end
549
550 static struct {
875e801 @Midar Don't depend on objc/objc.h for compiler checks.
authored
551 struct objc_class *isa;
02ee996 @Midar Better checking which warnings need to be disabled due to gcc bugs.
authored
552 } object;
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
553 ], [
02ee996 @Midar Better checking which warnings need to be disabled due to gcc bugs.
authored
554 OFObject *test = (OFObject*)&object;
5ab8e5c @Midar configure.ac: Fix two tests that would fail with Clang + new ABI.
authored
555 (void)test; /* Get rid of unused variable warning */
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
556 ], [
557 AC_MSG_RESULT(no)
558 ], [
02ee996 @Midar Better checking which warnings need to be disabled due to gcc bugs.
authored
559 AC_MSG_RESULT(yes)
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
560 OBJCFLAGS="$OBJCFLAGS -Wno-strict-aliasing"
561 ])
562 ])
10889bb @Midar -Wall was added too early to (OBJ)CFLAGS.
authored
563
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
564 AS_IF([test x"$cross_compiling" = x"yes"], [
037c69d @Midar Prefix utils in if we're doing a crosscompile.
authored
565 AC_SUBST(BIN_PREFIX, "$host-")
566
d90b1f1 @Midar $target -> $host
authored
567 case "$host" in
f043500 @Midar When crosscompiling for win32, use wine for the tests, if possible.
authored
568 *-*-mingw*)
e159be2 @Midar More style improvements.
authored
569 AC_CHECK_PROG(WINE, wine, wine)
f043500 @Midar When crosscompiling for win32, use wine for the tests, if possible.
authored
570
0cc0fe0 @Midar A few minor improvements in configure.ac.
authored
571 AS_IF([test x"$WINE" != x""], [
c68b08c @Midar Rename tests_new to tests.
authored
572 AC_SUBST(TESTS, "tests")
f043500 @Midar When crosscompiling for win32, use wine for the tests, if possible.
authored
573 AC_SUBST(TEST_LAUNCHER, "$WINE")
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
574 ])
f043500 @Midar When crosscompiling for win32, use wine for the tests, if possible.
authored
575 ;;
576 esac
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
577 ], [
c68b08c @Midar Rename tests_new to tests.
authored
578 AC_SUBST(TESTS, "tests")
6cc3867 @Midar Bring some consistency into the style of configure.ac.
authored
579 ])
3f63b8e @Midar Only run tests if we're not cross-compiling.
authored
580
e75d16f @Midar Update buildsys.
authored
581 BUILDSYS_INIT
0006a43 @Midar Update buildsys.
authored
582 BUILDSYS_TOUCH_DEPS
583
8ff4aaf @Midar Make sure we never even check for CC by using OBJCPP as CPP.
authored
584 dnl We don't call AC_PROG_CPP, but only AC_PROG_OBJCPP and set CPP to OBJCPP
0cc0fe0 @Midar A few minor improvements in configure.ac.
authored
585 dnl and add OBJCPPFLAGS to CPPFLAGS, thus we need to AC_SUBST these ourself.
8ff4aaf @Midar Make sure we never even check for CC by using OBJCPP as CPP.
authored
586 AC_SUBST(CPP)
587 AC_SUBST(CPPFLAGS)
588
4e2c431 @Midar Rename objfw to ObjFW for better framework compatibility.
authored
589 AC_SUBST(PACKAGE, ObjFW)
3ff08d8 @Midar Move objfw-config.in and objfw-compile into utils subdir.
authored
590 AC_CONFIG_FILES([buildsys.mk extra.mk utils/objfw-config])
5748c3e @Midar Move ObjFW definitions to a header that gets installed.
authored
591 AC_CONFIG_HEADERS([config.h src/objfw-defs.h])
1abfa03 @Midar Initial import.
authored
592 AC_OUTPUT
Something went wrong with that request. Please try again.