]> err.no Git - sope/blob - libFoundation/aclocal.m4
added NSCopying to EOQualifier
[sope] / libFoundation / aclocal.m4
1 AC_SUBST(MAKE)
2 AC_SUBST(OBJC_RUNTIME)
3 AC_SUBST(OBJC_RUNTIME_FLAG)
4 AC_SUBST(BROKEN_COMPILER)
5 AC_SUBST(BROKEN_BUILTIN_APPLY)
6 AC_SUBST(NO_NESTED_FUNCTIONS)
7 AC_SUBST(PCCTS_CFLAGS)
8 AC_SUBST(HOST)dnl
9 AC_SUBST(HOST_CPU)dnl
10 AC_SUBST(HOST_VENDOR)dnl
11 AC_SUBST(HOST_OS)dnl
12 AC_SUBST(TARGET)dnl
13 AC_SUBST(TARGET_CPU)dnl
14 AC_SUBST(TARGET_VENDOR)dnl
15 AC_SUBST(TARGET_OS)dnl
16 AC_SUBST(STRUCT_ALIGNMENT)dnl
17 dnl
18 dnl
19 AC_DEFUN(AC_LANG_OBJECTIVE_C,
20 [AC_REQUIRE([AC_PROG_CC])dnl
21 define([AC_LANG], [AC_LANG_OBJECTIVE_C])dnl
22 OLD_IFS=$IFS
23 IFS=:
24 for i in $LD_LIBRARY_PATH
25 do
26   LDFLAGS="-L$i $LDFLAGS"
27 done
28 IFS=$OLD_IFS
29 LIBS="-lobjc $LIBS"
30 ac_ext=m
31 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
32 ac_cpp='$CPP $OBJC_RUNTIME_FLAG'
33 ac_compile='${CC-cc} -c $OBJC_RUNTIME_FLAG $CFLAGS conftest.$ac_ext 1>&AC_FD_CC 2>&AC_FD_CC'
34 ac_link='${CC-cc} -o conftest $OBJC_RUNTIME_FLAG $CFLAGS $LDFLAGS conftest.$ac_ext $LIBS $OBJC_LIBS 1>&AC_FD_CC 2>&AC_FD_CC'
35 ])dnl
36 dnl
37 dnl
38 AC_DEFUN(AC_CHECK_NESTED_FUNCTIONS,
39 [AC_REQUIRE([AC_PROG_CC])dnl
40 AC_MSG_CHECKING(whether nested functions work)
41 AC_CACHE_VAL(ac_cv_nested_functions,
42 [AC_LANG_SAVE[]dnl
43 AC_LANG_OBJECTIVE_C[]
44 AC_TRY_RUN([
45 f(void (*nested)())
46 {
47     (*nested)();
48 }
49
50 main()
51 {
52     int a = 0;
53     void nested()
54     {
55         a = 1;
56     }
57     f(nested);
58     if(a != 1)
59         exit(1);
60     exit(0);
61 }
62 ], ac_cv_nested_functions=yes, ac_cv_nested_functions=no,
63 ac_cv_nested_functions=yes)
64 AC_LANG_RESTORE[]
65 ])dnl
66 AC_MSG_RESULT(${ac_cv_nested_functions})
67 NO_NESTED_FUNCTIONS=no
68 if test $ac_cv_nested_functions = no; then
69     AC_DEFINE(NO_NESTED_FUNCTIONS)
70     NO_NESTED_FUNCTIONS=yes
71 fi
72 ])dnl
73 dnl
74 dnl
75 AC_DEFUN(AC_BROKEN_COMPILER,
76 [AC_REQUIRE([AC_PROG_CC])dnl
77 AC_MSG_CHECKING(if the Objective-C compiler crashes with nested functions)
78 AC_CACHE_VAL(ac_cv_broken_compiler,
79 [AC_LANG_SAVE[]dnl
80 AC_LANG_OBJECTIVE_C[]
81 AC_TRY_RUN([
82 #include <objc/objc.h>
83 #include <objc/Object.h>
84
85 void f()
86 {
87     auto void h(id);
88
89     void h(id exception)
90     {
91         [Object alloc];
92         {
93             void clean(void)
94             {
95             }
96         }
97     }
98 }
99
100 void g()
101 {
102     auto void h(id);
103
104     void h(id exception)
105     {
106         [Object alloc];
107     }
108 }
109
110 main()
111 {
112     exit(0);
113 }
114 ], ac_cv_broken_compiler=no,
115 ac_cv_broken_compiler=yes,
116 ac_cv_broken_compiler=no)
117 AC_LANG_RESTORE[]
118 ])dnl
119 BROKEN_COMPILER=${ac_cv_broken_compiler}
120 if test ${ac_cv_nested_functions} = no -o ${ac_cv_broken_compiler} = yes; then
121   ac_cv_broken_compiler=yes;
122   BROKEN_COMPILER=yes;
123   AC_DEFINE(BROKEN_COMPILER)
124 fi
125 AC_MSG_RESULT(${ac_cv_broken_compiler})
126 ])dnl
127 dnl
128 dnl
129 AC_DEFUN(AC_BROKEN_BUILTIN_APPLY,
130 [AC_REQUIRE([AC_PROG_CC])dnl
131 AC_MSG_CHECKING(whether __builtin_apply and __builtin_return are broken)
132 AC_CACHE_VAL(ac_cv_broken_builtin_apply,
133 [AC_LANG_SAVE[]dnl
134 AC_LANG_OBJECTIVE_C[]
135 AC_TRY_RUN([
136 #include <objc/Object.h>
137
138 float value = 123.456;
139
140 @interface MyObject : Object
141 @end
142
143 @implementation MyObject
144 - (float)floatValue
145 {
146     return value;
147 }
148 @end
149
150 @interface Forwarder : Object
151 {
152     id object;
153 }
154 @end
155
156 @implementation Forwarder
157 - setObject:anObject
158 {
159     object = anObject;
160     return self;
161 }
162
163 - (void*)forward:(SEL)selector:(void*)argframe
164 {
165     IMP imp = [object methodFor:@selector(floatValue)];
166     void* retframe;
167     void* frame = malloc(116);
168     *(void**)frame = NULL;
169     retframe = __builtin_apply((void(*)(void))imp, frame, 0);
170     if(*(long double*)(((char*)retframe) + 8) == (long double)value)
171         exit(0);
172     exit(1);
173 }
174 @end
175
176 int main()
177 {
178     id fwd = [[[Forwarder alloc] init] setObject:[MyObject alloc]];
179     [fwd floatValue];
180     exit(0);
181     return 0; // keep compiler happy
182 }
183 ], ac_cv_broken_builtin_apply=no,
184 ac_cv_broken_builtin_apply=yes,
185 ac_cv_broken_builtin_apply=no)
186 AC_LANG_RESTORE[]
187 ])dnl
188 AC_MSG_RESULT(${ac_cv_broken_builtin_apply})
189 BROKEN_BUILTIN_APPLY=${ac_cv_broken_builtin_apply}
190 if test $BROKEN_BUILTIN_APPLY = yes; then
191     AC_DEFINE(BROKEN_BUILTIN_APPLY)
192 fi
193 ])dnl
194 dnl
195 dnl
196 AC_DEFUN(AC_CHECK_MATH_LIB,
197 [AC_REQUIRE([AC_PROG_CC])dnl
198 dnl temporary rename AC_MSG_RESULT to do nothing
199 define(old_AC_MSG_RESULT, defn([AC_MSG_RESULT]))dnl
200 define([AC_MSG_RESULT],)dnl
201 AC_CHECK_FUNC(sqrt, ,
202 [dnl On linux, to link a program that use math functions we must link with libm.a
203 LIBS="$LIBS -lm -lc"
204 ac_cv_func_sqrt=no
205 AC_TRY_LINK(, [
206 double sqrt(double);
207 sqrt(2.0);
208 ], ac_cv_func_sqrt="-lm -lc")
209 ])
210 define([AC_MSG_RESULT], defn([old_AC_MSG_RESULT]))dnl
211 undefine([old_AC_MSG_RESULT])dnl
212 AC_MSG_RESULT($ac_cv_func_sqrt)
213 ])dnl
214 dnl
215 dnl
216 AC_DEFUN(AC_STRUCT_ALIGNMENT,
217 [AC_REQUIRE([AC_PROG_CC])dnl
218 AC_MSG_CHECKING(for the C structures alignment)
219 AC_CACHE_VAL(ac_cv_struct_alignment,
220 [AC_TRY_RUN([#include <stdio.h>
221
222 struct simple {
223     double x;
224     char y;
225 } simple1;
226
227 int struct_alignment = __alignof__ (simple1);
228
229 main()
230 {
231   FILE *f=fopen("conftestval", "w");
232   if (!f) exit(1);
233   fprintf(f, "%u\n", struct_alignment);
234   exit(0);
235 }
236 ], ac_cv_struct_alignment=`cat conftestval`,
237 ac_cv_struct_alignment=0,
238 ifelse([$2], , , ac_cv_struct_alignment=$2))])dnl
239 AC_MSG_RESULT($ac_cv_struct_alignment)
240 STRUCT_ALIGNMENT=$ac_cv_struct_alignment
241 ])dnl
242 dnl
243 dnl
244 AC_DEFUN(AC_COMPILE_CHECK_SIZEOF,
245 [changequote(<<, >>)dnl 
246 dnl The name to #define. 
247 define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl 
248 dnl The cache variable name. 
249 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl 
250 changequote([, ])dnl 
251 AC_MSG_CHECKING(size of $1) 
252 AC_CACHE_VAL(AC_CV_NAME, 
253 [for ac_size in 4 8 1 2 16 $2 ; do # List sizes in rough order of prevalence. 
254   AC_TRY_COMPILE([#include "confdefs.h" 
255 #include <sys/types.h> 
256 $2 
257 ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size) 
258   if test x$AC_CV_NAME != x ; then break; fi 
259 done 
260 ]) 
261 if test x$AC_CV_NAME = x ; then 
262   echo "cannot determine a size for $1";
263   AC_CV_NAME=0; 
264 fi 
265 AC_MSG_RESULT($AC_CV_NAME) 
266 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1]) 
267 undefine([AC_TYPE_NAME])dnl 
268 undefine([AC_CV_NAME])dnl 
269 ])