summaryrefslogtreecommitdiff
path: root/m4/efl_check_funcs.m4
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2012-12-30 21:10:52 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2012-12-30 21:10:52 +0000
commit8bbef8fe2805429a99de29c264c37f177b3132bc (patch)
treea4f94fea96e64f6eccf08910571b678a601655c2 /m4/efl_check_funcs.m4
parent458b70bbe697f6a2bb83038293c3a41727a3ddfd (diff)
efl: refactor EFL_CHECK_LIB() and EFL_CHECK_FUNC()
- introduce EFL_CHECK_LIB_CODE() that does the try-link - introduce EFL_FIND_LIB_FOR_CODE() that will use EFL_CHECK_LIB_CODE() into multiple libraries - also fix dladdr() test (was missing .h in #include <stdlib>) SVN revision: 81909
Diffstat (limited to 'm4/efl_check_funcs.m4')
-rw-r--r--m4/efl_check_funcs.m4518
1 files changed, 103 insertions, 415 deletions
diff --git a/m4/efl_check_funcs.m4 b/m4/efl_check_funcs.m4
index 109ad06..f931953 100644
--- a/m4/efl_check_funcs.m4
+++ b/m4/efl_check_funcs.m4
@@ -12,534 +12,224 @@ dnl iconv
12dnl setxattr (an al.) 12dnl setxattr (an al.)
13dnl shm_open 13dnl shm_open
14 14
15 15dnl EFL_CHECK_LIB_CODE(EFL, LIB, VARIABLE, HEADER, BODY)
16dnl _EFL_CHECK_FUNC_DIRFD is for internal use 16dnl wrapper around AC_LINK_IFELSE(AC_LANG_PROGRAM()) to check
17dnl _EFL_CHECK_FUNC_DIRFD(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) 17dnl if some code would work with the given lib.
18 18dnl If the code work, EFL_ADD_LIBS(EFL, LIB) will be called
19AC_DEFUN([_EFL_CHECK_FUNC_DIRFD], 19dnl At the end VARIABLE will be "yes" or "no"
20AC_DEFUN([EFL_CHECK_LIB_CODE],
20[ 21[
21AC_LINK_IFELSE( 22LIBS_save="${LIBS}"
22 [ 23LIBS="${LIBS} $2"
23 AC_LANG_PROGRAM( 24AC_LINK_IFELSE([AC_LANG_PROGRAM([$4], [$5])],
24 [[ 25 [EFL_ADD_LIBS([$1], [$2])
25#ifdef HAVE_DIRENT_H 26 $3="yes"], [$3="no"])
26# include <dirent.h> 27LIBS="${LIBS_save}"
27#endif
28 ]],
29 [[
30int main(void)
31{
32 DIR *dirp;
33 return dirfd(dirp);
34}
35 ]])
36 ],
37 [_efl_have_fct="yes"],
38 [_efl_have_fct="no"])
39
40AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
41]) 28])
42 29
43dnl _EFL_CHECK_FUNC_DLADDR_PRIV is for internal use 30dnl EFL_FIND_LIB_FOR_CODE(EFL, LIBS, VARIABLE, HEADER, BODY)
44dnl _EFL_CHECK_FUNC_DLADDR_PRIV(EFL, LIB, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) 31AC_DEFUN([EFL_FIND_LIB_FOR_CODE],
45
46AC_DEFUN([_EFL_CHECK_FUNC_DLADDR_PRIV],
47[ 32[
48m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl 33dnl first try without lib (libc)
49m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl 34EFL_CHECK_LIB_CODE([$1], [], [$3], [$4], [$5])
50
51LIBS_save="${LIBS}"
52LIBS="${LIBS} $2"
53AC_LINK_IFELSE(
54 [AC_LANG_PROGRAM(
55 [[
56#ifndef _GNU_SOURCE
57# define _GNU_SOURCE
58#endif
59#include <stdlib>
60#include <dlfcn.h>
61 ]],
62 [[
63int res = dladdr(NULL, NULL);
64 ]])],
65 [
66 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} $2"
67 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} $2"
68 _efl_have_fct="yes"
69 ],
70 [_efl_have_fct="no"])
71 35
72LIBS="${LIBS_save}" 36if test "${$3}" = "no" && test "x$2" != "x"; then
37dnl loop through given libraries
38 for trylib in $2; do
39 EFL_CHECK_LIB_CODE([$1], [${trylib}], [$3], [$4], [$5])
40 if test "${$3}" = "yes"; then
41 break
42 fi
43 done
44fi
45])
73 46
74AS_IF([test "x${_efl_have_fct}" = "xyes"], [$3], [$4]) 47dnl _EFL_CHECK_FUNC_DIRFD is for internal use
48dnl _EFL_CHECK_FUNC_DIRFD(EFL, VARIABLE)
75 49
76m4_popdef([DOWNEFL]) 50AC_DEFUN([_EFL_CHECK_FUNC_DIRFD],
77m4_popdef([UPEFL]) 51[EFL_CHECK_LIB_CODE([$1], [], [$2], [[
52#ifdef HAVE_DIRENT_H
53# include <dirent.h>
54#endif
55]], [[DIR *dirp; return dirfd(dirp);]])
78]) 56])
79 57
80dnl _EFL_CHECK_FUNC_DLADDR is for internal use 58dnl _EFL_CHECK_FUNC_DLADDR is for internal use
81dnl _EFL_CHECK_FUNC_DLADDR(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) 59dnl _EFL_CHECK_FUNC_DLADDR(EFL, VARIABLE)
82
83AC_DEFUN([_EFL_CHECK_FUNC_DLADDR], 60AC_DEFUN([_EFL_CHECK_FUNC_DLADDR],
84[ 61[
85m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
86m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
87
88case "$host_os" in 62case "$host_os" in
89 mingw*) 63 mingw*)
90 _efl_have_fct="yes" 64 $2="yes"
91 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} -ldl" 65 EFL_ADD_LIBS([$1], [-ldl])
92 ;; 66 ;;
93 *) 67 *)
94 _efl_have_fct="no" 68 EFL_FIND_LIB_FOR_CODE([$1], [-ldl], [$2], [[
95 69#ifndef _GNU_SOURCE
96dnl Check is dladdr is in libc 70# define _GNU_SOURCE
97 _EFL_CHECK_FUNC_DLADDR_PRIV([$1], [], [_efl_have_fct="yes"], [_efl_have_fct="no"]) 71#endif
98 72#include <stdlib.h>
99dnl Check is dlopen is in libdl 73#include <dlfcn.h>
100 if test "x${_efl_have_fct}" = "xno" ; then 74]], [[int res = dladdr(NULL, NULL);]])
101 _EFL_CHECK_FUNC_DLADDR_PRIV([$1], [-ldl], [_efl_have_fct="yes"], [_efl_have_fct="no"])
102 fi
103 ;; 75 ;;
104esac 76esac
105
106AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
107
108m4_popdef([DOWNEFL])
109m4_popdef([UPEFL])
110])
111
112dnl _EFL_CHECK_FUNC_DLOPEN_PRIV is for internal use
113dnl _EFL_CHECK_FUNC_DLOPEN_PRIV(EFL, LIB, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
114
115AC_DEFUN([_EFL_CHECK_FUNC_DLOPEN_PRIV],
116[
117m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
118m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
119
120LIBS_save="${LIBS}"
121LIBS="${LIBS} $2"
122AC_LINK_IFELSE(
123 [AC_LANG_PROGRAM(
124 [[
125#include <dlfcn.h>
126 ]],
127 [[
128void *h = dlopen(0, 0);
129 ]])],
130 [
131 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} $2"
132 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} $2"
133 _efl_have_fct="yes"
134 ],
135 [_efl_have_fct="no"])
136
137LIBS="${LIBS_save}"
138
139AS_IF([test "x${_efl_have_fct}" = "xyes"], [$3], [$4])
140
141m4_popdef([DOWNEFL])
142m4_popdef([UPEFL])
143]) 77])
144 78
145dnl _EFL_CHECK_FUNC_DLOPEN is for internal use 79dnl _EFL_CHECK_FUNC_DLOPEN is for internal use
146dnl _EFL_CHECK_FUNC_DLOPEN(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) 80dnl _EFL_CHECK_FUNC_DLOPEN(EFL, VARIABLE)
147
148AC_DEFUN([_EFL_CHECK_FUNC_DLOPEN], 81AC_DEFUN([_EFL_CHECK_FUNC_DLOPEN],
149[ 82[
150m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
151m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
152
153case "$host_os" in 83case "$host_os" in
154 mingw*) 84 mingw*)
155 _efl_have_fct="yes" 85 $2="yes"
156 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} -ldl" 86 EFL_ADD_LIBS([$1], [-ldl])
157 ;; 87 ;;
158 *) 88 *)
159 _efl_have_fct="no" 89 EFL_FIND_LIB_FOR_CODE([$1], [-ldl], [$2], [[
160 90#include <dlfcn.h>
161dnl Check is dlopen is in libc 91]], [[void *h = dlopen(0, 0);]])
162 _EFL_CHECK_FUNC_DLOPEN_PRIV([$1], [], [_efl_have_fct="yes"], [_efl_have_fct="no"])
163
164dnl Check is dlopen is in libdl
165 if test "x${_efl_have_fct}" = "xno" ; then
166 _EFL_CHECK_FUNC_DLOPEN_PRIV([$1], [-ldl], [_efl_have_fct="yes"], [_efl_have_fct="no"])
167 fi
168 ;; 92 ;;
169esac 93esac
170
171AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
172
173m4_popdef([DOWNEFL])
174m4_popdef([UPEFL])
175])
176
177dnl _EFL_CHECK_FUNC_DLSYM_PRIV is for internal use
178dnl _EFL_CHECK_FUNC_DLSYM_PRIV(EFL, LIB, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
179
180AC_DEFUN([_EFL_CHECK_FUNC_DLSYM_PRIV],
181[
182m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
183m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
184
185LIBS_save="${LIBS}"
186LIBS="${LIBS} $2"
187AC_LINK_IFELSE(
188 [AC_LANG_PROGRAM(
189 [[
190#ifndef _GNU_SOURCE
191# define _GNU_SOURCE
192#endif
193#include <stdlib.h>
194#include <dlfcn.h>
195 ]],
196 [[
197void *res = dlsym(NULL, NULL);
198 ]])],
199 [
200 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} $2"
201 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} $2"
202 _efl_have_fct="yes"
203 ],
204 [_efl_have_fct="no"])
205
206LIBS="${LIBS_save}"
207
208AS_IF([test "x${_efl_have_fct}" = "xyes"], [$3], [$4])
209
210m4_popdef([DOWNEFL])
211m4_popdef([UPEFL])
212]) 94])
213 95
214dnl _EFL_CHECK_FUNC_DLSYM is for internal use 96dnl _EFL_CHECK_FUNC_DLSYM is for internal use
215dnl _EFL_CHECK_FUNC_DLSYM(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) 97dnl _EFL_CHECK_FUNC_DLSYM(EFL, VARIABLE)
216
217AC_DEFUN([_EFL_CHECK_FUNC_DLSYM], 98AC_DEFUN([_EFL_CHECK_FUNC_DLSYM],
218[ 99[
219m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
220m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
221
222case "$host_os" in 100case "$host_os" in
223 mingw*) 101 mingw*)
224 _efl_have_fct="yes" 102 $2="yes"
225 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} -ldl" 103 EFL_ADD_LIBS([$1], [-ldl])
226 ;; 104 ;;
227 *) 105 *)
228 _efl_have_fct="no" 106 EFL_FIND_LIB_FOR_CODE([$1], [-ldl], [$2], [[
229 107#ifndef _GNU_SOURCE
230dnl Check is dlsym is in libc 108# define _GNU_SOURCE
231 _EFL_CHECK_FUNC_DLSYM_PRIV([$1], [], [_efl_have_fct="yes"], [_efl_have_fct="no"]) 109#endif
232 110#include <stdlib.h>
233dnl Check is dlopen is in libdl 111#include <dlfcn.h>
234 if test "x${_efl_have_fct}" = "xno" ; then 112]], [[void *res = dlsym(NULL, NULL);]])
235 _EFL_CHECK_FUNC_DLSYM_PRIV([$1], [-ldl], [_efl_have_fct="yes"], [_efl_have_fct="no"])
236 fi
237 ;; 113 ;;
238esac 114esac
239
240AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
241
242m4_popdef([DOWNEFL])
243m4_popdef([UPEFL])
244])
245
246dnl _EFL_CHECK_FUNC_FNMATCH_PRIV is for internal use
247dnl _EFL_CHECK_FUNC_FNMATCH_PRIV(EFL, LIB, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
248
249AC_DEFUN([_EFL_CHECK_FUNC_FNMATCH_PRIV],
250[
251m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
252m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
253
254LIBS_save="${LIBS}"
255LIBS="${LIBS} $2"
256AC_LINK_IFELSE(
257 [AC_LANG_PROGRAM(
258 [[
259#include <stdlib.h>
260#include <fnmatch.h>
261 ]],
262 [[
263int g = fnmatch(NULL, NULL, 0);
264 ]])],
265 [
266 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} $2"
267 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} $2"
268 _efl_have_fct="yes"
269 ],
270 [_efl_have_fct="no"])
271
272LIBS="${LIBS_save}"
273
274AS_IF([test "x${_efl_have_fct}" = "xyes"], [$3], [$4])
275
276m4_popdef([DOWNEFL])
277m4_popdef([UPEFL])
278]) 115])
279 116
280dnl _EFL_CHECK_FUNC_FNMATCH is for internal use 117dnl _EFL_CHECK_FUNC_FNMATCH is for internal use
281dnl _EFL_CHECK_FUNC_FNMATCH(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) 118dnl _EFL_CHECK_FUNC_FNMATCH(EFL, VARIABLE)
282
283AC_DEFUN([_EFL_CHECK_FUNC_FNMATCH], 119AC_DEFUN([_EFL_CHECK_FUNC_FNMATCH],
284[ 120[
285case "$host_os" in 121case "$host_os" in
286 mingw*) 122 mingw*)
287 _efl_have_fct="yes" 123 $2="yes"
288 ;; 124 ;;
289 *) 125 *)
290dnl Check is fnmatch is in libc 126 EFL_FIND_LIB_FOR_CODE([$1], [-lfnmatch -liberty], [$2], [[
291 _EFL_CHECK_FUNC_FNMATCH_PRIV([$1], [], [_efl_have_fct="yes"], [_efl_have_fct="no"]) 127#include <stdlib.h>
292 128#include <fnmatch.h>
293dnl Check is fnmatch is in libfnmatch 129]], [[int g = fnmatch(NULL, NULL, 0);]])
294 if test "x${_efl_have_fct}" = "xno" ; then
295 _EFL_CHECK_FUNC_FNMATCH_PRIV([$1], [-lfnmatch], [_efl_have_fct="yes"], [_efl_have_fct="no"])
296 fi
297
298dnl Check is fnmatch is in libiberty
299 if test "x${_efl_have_fct}" = "xno" ; then
300 _EFL_CHECK_FUNC_FNMATCH_PRIV([$1], [-liberty], [_efl_have_fct="yes"], [_efl_have_fct="no"])
301 fi
302 ;; 130 ;;
303esac 131esac
304
305AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
306]) 132])
307 133
308dnl _EFL_CHECK_FUNC_GETTIMEOFDAY is for internal use 134dnl _EFL_CHECK_FUNC_GETTIMEOFDAY is for internal use
309dnl _EFL_CHECK_FUNC_GETTIMEOFDAY(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) 135dnl _EFL_CHECK_FUNC_GETTIMEOFDAY(EFL, VARIABLE)
310
311AC_DEFUN([_EFL_CHECK_FUNC_GETTIMEOFDAY], 136AC_DEFUN([_EFL_CHECK_FUNC_GETTIMEOFDAY],
312[ 137[
313case "$host_os" in 138case "$host_os" in
314 mingw*) 139 mingw*)
315 _efl_have_fct="yes" 140 $2="yes"
316 ;; 141 ;;
317 *) 142 *)
318 AC_LINK_IFELSE( 143 EFL_CHECK_LIB_CODE([$1], [], [$2], [[
319 [AC_LANG_PROGRAM([[
320#include <stdlib.h> 144#include <stdlib.h>
321#include <sys/time.h> 145#include <sys/time.h>
322 ]], 146]], [[int res = gettimeofday(NULL, NULL);]])
323 [[
324int res;
325res = gettimeofday(NULL, NULL);
326 ]])],
327 [_efl_have_fct="yes"],
328 [_efl_have_fct="no"])
329 147
330 if test "x${_efl_have_fct}" = "xno" && test "x${enable_exotic}" = "xyes"; then 148 if test "${$2}" = "no" && test "x${enable_exotic}" = "xyes"; then
331 SAVE_LIBS="${LIBS}"
332 SAVE_CFLAGS="${CFLAGS}" 149 SAVE_CFLAGS="${CFLAGS}"
333 LIBS="${LIBS} ${EXOTIC_LIBS}"
334 CFLAGS="${CFLAGS} ${EXOTIC_CFLAGS}" 150 CFLAGS="${CFLAGS} ${EXOTIC_CFLAGS}"
335 AC_LINK_IFELSE( 151 EFL_CHECK_LIB_CODE([$1], [${EXOTIC_LIBS}], [$2], [[
336 [AC_LANG_PROGRAM([[
337#include <Exotic.h> 152#include <Exotic.h>
338 ]], 153]], [[int res = gettimeofday(NULL, NULL);]])
339 [[
340int res;
341res = gettimeofday(NULL, NULL);
342 ]])],
343 [_efl_have_fct="yes"],
344 [_efl_have_fct="no"])
345 LIBS="${SAVE_LIBS}"
346 CFLAGS="${SAVE_CFLAGS}" 154 CFLAGS="${SAVE_CFLAGS}"
347 fi 155 fi
348 ;; 156 ;;
349esac 157esac
350
351AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
352])
353
354dnl _EFL_CHECK_FUNC_ICONV_PRIV is for internal use
355dnl _EFL_CHECK_FUNC_ICONV_PRIV(EFL, LIB, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
356
357AC_DEFUN([_EFL_CHECK_FUNC_ICONV_PRIV],
358[
359m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
360m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
361
362LIBS_save="${LIBS}"
363LIBS="${LIBS} $2"
364AC_LINK_IFELSE(
365 [AC_LANG_PROGRAM(
366 [[
367#include <stdlib.h>
368#include <iconv.h>
369 ]],
370 [[
371iconv_t ic;
372size_t count = iconv(ic, NULL, NULL, NULL, NULL);
373 ]])],
374 [
375 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} $2"
376 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} $2"
377 _efl_have_fct="yes"
378 ],
379 [_efl_have_fct="no"])
380
381LIBS="${LIBS_save}"
382
383AS_IF([test "x${_efl_have_fct}" = "xyes"], [$3], [$4])
384
385m4_popdef([DOWNEFL])
386m4_popdef([UPEFL])
387]) 158])
388 159
389dnl _EFL_CHECK_FUNC_ICONV is for internal use 160dnl _EFL_CHECK_FUNC_ICONV is for internal use
390dnl _EFL_CHECK_FUNC_ICONV(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) 161dnl _EFL_CHECK_FUNC_ICONV(EFL, VARIABLE)
391
392AC_DEFUN([_EFL_CHECK_FUNC_ICONV], 162AC_DEFUN([_EFL_CHECK_FUNC_ICONV],
393[ 163[dnl
394AC_ARG_WITH([iconv-link], 164AC_ARG_WITH([iconv-link],
395 AC_HELP_STRING([--with-iconv-link=ICONV_LINK], [explicitly specify an iconv link option]), 165 AC_HELP_STRING([--with-iconv-link=ICONV_LINK], [explicitly specify an iconv link option]),
396 [ 166 [
397 _efl_have_fct="yes" 167 $2="yes"
398 iconv_libs=${withval} 168 iconv_libs=${withval}
399 ], 169 ],
400 [_efl_have_fct="no"]) 170 [$2="no"])
401 171
402AC_MSG_CHECKING([for explicit iconv link options])
403if test "x${iconv_libs}" = "x" ; then 172if test "x${iconv_libs}" = "x" ; then
404 AC_MSG_RESULT([no explicit iconv link option]) 173 EFL_FIND_LIB_FOR_CODE([$1], [-liconv -liconv_plug], [$2], [[
405else 174#include <stdlib.h>
406 AC_MSG_RESULT([${iconv_libs}]) 175#include <iconv.h>
407fi 176]], [[iconv_t ic; size_t count = iconv(ic, NULL, NULL, NULL, NULL);]])
408
409dnl Check is iconv is in libc
410if test "x${_efl_have_fct}" = "xno" ; then
411 _EFL_CHECK_FUNC_ICONV_PRIV([$1], [], [_efl_have_fct="yes"], [_efl_have_fct="no"])
412fi
413
414dnl Check is iconv is in libiconv
415if test "x${_efl_have_fct}" = "xno" ; then
416 _EFL_CHECK_FUNC_ICONV_PRIV([$1], [-liconv], [_efl_have_fct="yes"], [_efl_have_fct="no"])
417fi
418
419dnl Check is iconv is in libiconv_plug
420if test "x${_efl_have_fct}" = "xno" ; then
421 _EFL_CHECK_FUNC_ICONV_PRIV([$1], [-liconv_plug], [_efl_have_fct="yes"], [_efl_have_fct="no"])
422fi 177fi
423
424AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
425]) 178])
426 179
427dnl _EFL_CHECK_FUNC_SETXATTR is for internal use 180dnl _EFL_CHECK_FUNC_SETXATTR is for internal use
428dnl _EFL_CHECK_FUNC_SETXATTR(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) 181dnl _EFL_CHECK_FUNC_SETXATTR(EFL, VARIABLE)
429
430AC_DEFUN([_EFL_CHECK_FUNC_SETXATTR], 182AC_DEFUN([_EFL_CHECK_FUNC_SETXATTR],
431[ 183[EFL_CHECK_LIB_CODE([$1], [], [$2], [[
432AC_COMPILE_IFELSE(
433 [AC_LANG_PROGRAM(
434 [[
435#include <stdlib.h> 184#include <stdlib.h>
436#include <sys/types.h> 185#include <sys/types.h>
437#include <sys/xattr.h> 186#include <sys/xattr.h>
438 ]], 187]], [[
439 [[
440size_t tmp = listxattr("/", NULL, 0); 188size_t tmp = listxattr("/", NULL, 0);
441tmp = getxattr("/", "user.ethumb.md5", NULL, 0); 189tmp = getxattr("/", "user.ethumb.md5", NULL, 0);
442setxattr("/", "user.ethumb.md5", NULL, 0, 0); 190setxattr("/", "user.ethumb.md5", NULL, 0, 0);
443 ]])], 191]])
444 [_efl_have_fct="yes"],
445 [_efl_have_fct="no"])
446 192
447AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3]) 193if test "${$2}" = "yes"; then
194 AC_DEFINE([HAVE_XATTR], [1], [Define to 1 if you have the `listxattr', `setxattr' and `getxattr' functions.])
195fi
448]) 196])
449 197
450dnl _EFL_CHECK_FUNC_SHM_OPEN_PRIV is for internal use 198dnl _EFL_CHECK_FUNC_SHM_OPEN is for internal use
451dnl _EFL_CHECK_FUNC_SHM_OPEN_PRIV(EFL, LIB, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) 199dnl _EFL_CHECK_FUNC_SHM_OPEN(EFL, VARIABLE)
452 200AC_DEFUN([_EFL_CHECK_FUNC_SHM_OPEN],
453AC_DEFUN([_EFL_CHECK_FUNC_SHM_OPEN_PRIV], 201[EFL_FIND_LIB_FOR_CODE([$1], [-lrt], [$2], [[
454[
455m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
456m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
457
458LIBS_save="${LIBS}"
459LIBS="${LIBS} $2"
460AC_LINK_IFELSE(
461 [AC_LANG_PROGRAM(
462 [[
463#include <sys/mman.h> 202#include <sys/mman.h>
464#include <sys/stat.h> /* For mode constants */ 203#include <sys/stat.h> /* For mode constants */
465#include <fcntl.h> /* For O_* constants */ 204#include <fcntl.h> /* For O_* constants */
466 ]], 205]], [[
467 [[ 206int fd = shm_open("/dev/null", O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO);
468int fd; 207]])
469
470fd = shm_open("/dev/null", O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO);
471 ]])],
472 [
473 m4_defn([UPEFL])[]_LIBS="$m4_defn([UPEFL])[]_LIBS $2"
474 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} $2"
475 _efl_have_fct="yes"
476 ],
477 [_efl_have_fct="no"])
478
479LIBS="${LIBS_save}"
480
481AS_IF([test "x${_efl_have_fct}" = "xyes"], [$3], [$4])
482
483m4_popdef([DOWNEFL])
484m4_popdef([UPEFL])
485])
486
487dnl _EFL_CHECK_FUNC_SHM_OPEN is for internal use
488dnl _EFL_CHECK_FUNC_SHM_OPEN(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
489
490AC_DEFUN([_EFL_CHECK_FUNC_SHM_OPEN],
491[
492_efl_have_fct="no"
493
494dnl Check is shm_open is in libc
495_EFL_CHECK_FUNC_SHM_OPEN_PRIV([$1], [],
496 [_efl_have_fct="yes"],
497 [_efl_have_fct="no"])
498
499dnl Check is shm_open is in librt
500if test "x${_efl_have_fct}" = "xno" ; then
501 _EFL_CHECK_FUNC_SHM_OPEN_PRIV([$1], [-lrt],
502 [_efl_have_fct="yes"],
503 [_efl_have_fct="no"])
504fi
505
506AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
507]) 208])
508 209
509dnl Macro that checks function availability 210dnl Macro that checks function availability
510dnl 211dnl
511dnl EFL_CHECK_FUNC(EFL, FUNCTION) 212dnl EFL_CHECK_FUNC(EFL, FUNCTION)
512dnl AC_SUBST : EFL_CFLAGS and EFL_LIBS (EFL being replaced by its value) 213dnl AC_SUBST : EFL_CFLAGS and EFL_LIBS (EFL being replaced by its value)
513dnl AC_DEFINE : EFL_HAVE_FUNCTION (FUNCTION being replaced by its value) 214dnl AC_DEFINE : HAVE_FUNCTION (FUNCTION being replaced by its value)
514dnl result in efl_func_function (function being replaced by its value) 215dnl result in efl_func_function (function being replaced by its value)
515 216
516AC_DEFUN([EFL_CHECK_FUNC], 217AC_DEFUN([EFL_CHECK_FUNC],
517[ 218[dnl
518m4_pushdef([UP], m4_translit([$2], [-a-z], [_A-Z]))dnl 219m4_pushdef([UP], m4_translit([$2], [-a-z], [_A-Z]))dnl
519m4_pushdef([DOWN], m4_translit([$2], [-A-Z], [_a-z]))dnl 220m4_pushdef([DOWN], m4_translit([$2], [-A-Z], [_a-z]))dnl
520 221
521m4_default([_EFL_CHECK_FUNC_]m4_defn([UP]))($1, [have_fct="yes"], [have_fct="no"]) 222m4_default([_EFL_CHECK_FUNC_]m4_defn([UP]))($1, [have_fct])
522 223AC_MSG_CHECKING([for $2])
523if test "x$2" = "xsetxattr" ; then
524 AC_MSG_CHECKING([for extended attributes])
525else
526 AC_MSG_CHECKING([for ]m4_defn([DOWN]))
527fi
528
529AC_MSG_RESULT([${have_fct}]) 224AC_MSG_RESULT([${have_fct}])
530 225
531if test "x${have_fct}" = "xyes" ; then 226if test "x${have_fct}" = "xyes" ; then
532 if test "x$2" = "xsetxattr" ; then 227 AC_DEFINE([HAVE_]m4_defn([UP]), [1], [Define to 1 if you have the `]m4_defn([DOWN])[' function.])
533 AC_DEFINE([HAVE_XATTR], [1], [Define to 1 if you have the `listxattr', `setxattr' and `getxattr' functions.])
534 else
535 AC_DEFINE([HAVE_]m4_defn([UP]), [1], [Define to 1 if you have the `]m4_defn([DOWN])[' function.])
536 fi
537fi 228fi
538 229
539efl_func_[]m4_defn([DOWN])="${have_fct}" 230efl_func_[]m4_defn([DOWN])="${have_fct}"
540 231m4_popdef([DOWN])dnl
541m4_popdef([DOWN]) 232m4_popdef([UP])dnl
542m4_popdef([UP])
543]) 233])
544 234
545dnl Macro that iterates over a sequence of space separated functions 235dnl Macro that iterates over a sequence of space separated functions
@@ -548,6 +238,4 @@ dnl
548dnl EFL_CHECK_FUNCS(EFL, FUNCTIONS) 238dnl EFL_CHECK_FUNCS(EFL, FUNCTIONS)
549 239
550AC_DEFUN([EFL_CHECK_FUNCS], 240AC_DEFUN([EFL_CHECK_FUNCS],
551[ 241[m4_foreach_w([fct], [$2], [EFL_CHECK_FUNC($1, m4_defn([fct]))])])
552m4_foreach_w([fct], [$2], [EFL_CHECK_FUNC($1, m4_defn([fct]))])
553])