summaryrefslogtreecommitdiff
path: root/m4/efl_check_funcs.m4
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-09-16 10:57:48 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-09-16 10:57:48 +0000
commit785f2a6b3a70454ecfe94addc6480ebf20c44c13 (patch)
tree17a195d2c1f022cd480fd0e0b95be5035ad915e2 /m4/efl_check_funcs.m4
parentdfc0331373c3f98df7cb996abc588c7dcf44af0a (diff)
merge : add eina
currently, examples, tests and benchmark are not set. That's the next things i'll do SVN revision: 76710
Diffstat (limited to 'm4/efl_check_funcs.m4')
-rw-r--r--m4/efl_check_funcs.m4436
1 files changed, 436 insertions, 0 deletions
diff --git a/m4/efl_check_funcs.m4 b/m4/efl_check_funcs.m4
new file mode 100644
index 0000000000..d72fb34344
--- /dev/null
+++ b/m4/efl_check_funcs.m4
@@ -0,0 +1,436 @@
1dnl Copyright (C) 2012 Vincent Torri <vincent dot torri at gmail dot com>
2dnl This code is public domain and can be freely used or copied.
3
4dnl Macros that check functions availability for the EFL:
5
6dnl dirfd
7dnl dladdr
8dnl dlopen
9dnl fnmatch
10dnl iconv
11dnl setxattr (an al.)
12dnl shm_open
13
14
15dnl _EFL_CHECK_FUNC_DIRFD is for internal use
16dnl _EFL_CHECK_FUNC_DIRFD(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
17
18AC_DEFUN([_EFL_CHECK_FUNC_DIRFD],
19[
20AC_LINK_IFELSE(
21 [
22 AC_LANG_PROGRAM(
23 [[
24#ifdef HAVE_DIRENT_H
25# include <dirent.h>
26#endif
27 ]],
28 [[
29int main(void)
30{
31 DIR *dirp;
32 return dirfd(dirp);
33}
34 ]])
35 ],
36 [_efl_have_fct="yes"],
37 [_efl_have_fct="no"])
38
39AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
40])
41
42dnl _EFL_CHECK_FUNC_DLADDR_PRIV is for internal use
43dnl _EFL_CHECK_FUNC_DLADDR_PRIV(EFL, LIB, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
44
45AC_DEFUN([_EFL_CHECK_FUNC_DLADDR_PRIV],
46[
47m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
48m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
49
50LIBS_save="${LIBS}"
51LIBS="${LIBS} $2"
52AC_LINK_IFELSE(
53 [AC_LANG_PROGRAM(
54 [[
55#define _GNU_SOURCE
56#include <dlfcn.h>
57 ]],
58 [[
59int res = dladdr(0, 0);
60 ]])],
61 [
62 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} $2"
63 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} $2"
64 _efl_have_fct="yes"
65 ],
66 [_efl_have_fct="no"])
67
68LIBS="${LIBS_save}"
69
70AS_IF([test "x${_efl_have_fct}" = "xyes"], [$3], [$4])
71
72m4_popdef([DOWNEFL])
73m4_popdef([UPEFL])
74])
75
76dnl _EFL_CHECK_FUNC_DLADDR is for internal use
77dnl _EFL_CHECK_FUNC_DLADDR(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
78
79AC_DEFUN([_EFL_CHECK_FUNC_DLADDR],
80[
81m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
82m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
83
84case "$host_os" in
85 mingw*)
86 _efl_have_fct="yes"
87 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} -ldl"
88 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} -ldl"
89 ;;
90 *)
91 _efl_have_fct="no"
92
93dnl Check is dladdr is in libc
94 _EFL_CHECK_FUNC_DLADDR_PRIV([$1], [], [_efl_have_fct="yes"], [_efl_have_fct="no"])
95
96dnl Check is dlopen is in libdl
97 if test "x${_efl_have_fct}" = "xno" ; then
98 _EFL_CHECK_FUNC_DLADDR_PRIV([$1], [-ldl], [_efl_have_fct="yes"], [_efl_have_fct="no"])
99 fi
100 ;;
101esac
102
103AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
104
105m4_popdef([DOWNEFL])
106m4_popdef([UPEFL])
107])
108
109dnl _EFL_CHECK_FUNC_DLOPEN_PRIV is for internal use
110dnl _EFL_CHECK_FUNC_DLOPEN_PRIV(EFL, LIB, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
111
112AC_DEFUN([_EFL_CHECK_FUNC_DLOPEN_PRIV],
113[
114m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
115m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
116
117LIBS_save="${LIBS}"
118LIBS="${LIBS} $2"
119AC_LINK_IFELSE(
120 [AC_LANG_PROGRAM(
121 [[
122#include <dlfcn.h>
123 ]],
124 [[
125void *h = dlopen(0, 0);
126 ]])],
127 [
128 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} $2"
129 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} $2"
130 _efl_have_fct="yes"
131 ],
132 [_efl_have_fct="no"])
133
134LIBS="${LIBS_save}"
135
136AS_IF([test "x${_efl_have_fct}" = "xyes"], [$3], [$4])
137
138m4_popdef([DOWNEFL])
139m4_popdef([UPEFL])
140])
141
142dnl _EFL_CHECK_FUNC_DLOPEN is for internal use
143dnl _EFL_CHECK_FUNC_DLOPEN(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
144
145AC_DEFUN([_EFL_CHECK_FUNC_DLOPEN],
146[
147m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
148m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
149
150case "$host_os" in
151 mingw*)
152 _efl_have_fct="yes"
153 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} -ldl"
154 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} -ldl"
155 ;;
156 *)
157 _efl_have_fct="no"
158
159dnl Check is dlopen is in libc
160 _EFL_CHECK_FUNC_DLOPEN_PRIV([$1], [], [_efl_have_fct="yes"], [_efl_have_fct="no"])
161
162dnl Check is dlopen is in libdl
163 if test "x${_efl_have_fct}" = "xno" ; then
164 _EFL_CHECK_FUNC_DLOPEN_PRIV([$1], [-ldl], [_efl_have_fct="yes"], [_efl_have_fct="no"])
165 fi
166 ;;
167esac
168
169AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
170
171m4_popdef([DOWNEFL])
172m4_popdef([UPEFL])
173])
174
175dnl _EFL_CHECK_FUNC_FNMATCH_PRIV is for internal use
176dnl _EFL_CHECK_FUNC_FNMATCH_PRIV(EFL, LIB, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
177
178AC_DEFUN([_EFL_CHECK_FUNC_FNMATCH_PRIV],
179[
180m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
181m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
182
183LIBS_save="${LIBS}"
184LIBS="${LIBS} $2"
185AC_LINK_IFELSE(
186 [AC_LANG_PROGRAM(
187 [[
188#include <stdlib.h>
189#include <fnmatch.h>
190 ]],
191 [[
192int g = fnmatch(NULL, NULL, 0);
193 ]])],
194 [
195 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} $2"
196 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} $2"
197 _efl_have_fct="yes"
198 ],
199 [_efl_have_fct="no"])
200
201LIBS="${LIBS_save}"
202
203AS_IF([test "x${_efl_have_fct}" = "xyes"], [$3], [$4])
204
205m4_popdef([DOWNEFL])
206m4_popdef([UPEFL])
207])
208
209dnl _EFL_CHECK_FUNC_FNMATCH is for internal use
210dnl _EFL_CHECK_FUNC_FNMATCH(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
211
212AC_DEFUN([_EFL_CHECK_FUNC_FNMATCH],
213[
214case "$host_os" in
215 mingw*)
216 _efl_have_fct="yes"
217 ;;
218 *)
219dnl Check is fnmatch is in libc
220 _EFL_CHECK_FUNC_FNMATCH_PRIV([$1], [], [_efl_have_fct="yes"], [_efl_have_fct="no"])
221
222dnl Check is fnmatch is in libfnmatch
223 if test "x${_efl_have_fct}" = "xno" ; then
224 _EFL_CHECK_FUNC_FNMATCH_PRIV([$1], [-lfnmatch], [_efl_have_fct="yes"], [_efl_have_fct="no"])
225 fi
226
227dnl Check is fnmatch is in libiberty
228 if test "x${_efl_have_fct}" = "xno" ; then
229 _EFL_CHECK_FUNC_FNMATCH_PRIV([$1], [-liberty], [_efl_have_fct="yes"], [_efl_have_fct="no"])
230 fi
231 ;;
232esac
233
234AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
235])
236
237dnl _EFL_CHECK_FUNC_ICONV_PRIV is for internal use
238dnl _EFL_CHECK_FUNC_ICONV_PRIV(EFL, LIB, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
239
240AC_DEFUN([_EFL_CHECK_FUNC_ICONV_PRIV],
241[
242m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
243m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
244
245LIBS_save="${LIBS}"
246LIBS="${LIBS} $2"
247AC_LINK_IFELSE(
248 [AC_LANG_PROGRAM(
249 [[
250#include <stdlib.h>
251#include <iconv.h>
252 ]],
253 [[
254iconv_t ic;
255size_t count = iconv(ic, NULL, NULL, NULL, NULL);
256 ]])],
257 [
258 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} $2"
259 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} $2"
260 _efl_have_fct="yes"
261 ],
262 [_efl_have_fct="no"])
263
264LIBS="${LIBS_save}"
265
266AS_IF([test "x${_efl_have_fct}" = "xyes"], [$3], [$4])
267
268m4_popdef([DOWNEFL])
269m4_popdef([UPEFL])
270])
271
272dnl _EFL_CHECK_FUNC_ICONV is for internal use
273dnl _EFL_CHECK_FUNC_ICONV(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
274
275AC_DEFUN([_EFL_CHECK_FUNC_ICONV],
276[
277AC_ARG_WITH([iconv-link],
278 AC_HELP_STRING([--with-iconv-link=ICONV_LINK], [explicitly specify an iconv link option]),
279 [
280 _efl_have_fct="yes"
281 iconv_libs=${withval}
282 ],
283 [_efl_have_fct="no"])
284
285AC_MSG_CHECKING([for explicit iconv link options])
286if test "x${iconv_libs}" = "x" ; then
287 AC_MSG_RESULT([no explicit iconv link option])
288else
289 AC_MSG_RESULT([${iconv_libs}])
290fi
291
292dnl Check is iconv is in libc
293if test "x${_efl_have_fct}" = "xno" ; then
294 _EFL_CHECK_FUNC_ICONV_PRIV([$1], [], [_efl_have_fct="yes"], [_efl_have_fct="no"])
295fi
296
297dnl Check is iconv is in libiconv
298if test "x${_efl_have_fct}" = "xno" ; then
299 _EFL_CHECK_FUNC_ICONV_PRIV([$1], [-liconv], [_efl_have_fct="yes"], [_efl_have_fct="no"])
300fi
301
302dnl Check is iconv is in libiconv_plug
303if test "x${_efl_have_fct}" = "xno" ; then
304 _EFL_CHECK_FUNC_ICONV_PRIV([$1], [-liconv_plug], [_efl_have_fct="yes"], [_efl_have_fct="no"])
305fi
306
307AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
308])
309
310dnl _EFL_CHECK_FUNC_SETXATTR is for internal use
311dnl _EFL_CHECK_FUNC_SETXATTR(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
312
313AC_DEFUN([_EFL_CHECK_FUNC_SETXATTR],
314[
315AC_COMPILE_IFELSE(
316 [AC_LANG_PROGRAM(
317 [[
318#include <stdlib.h>
319#include <sys/types.h>
320#include <sys/xattr.h>
321 ]],
322 [[
323size_t tmp = listxattr("/", NULL, 0);
324tmp = getxattr("/", "user.ethumb.md5", NULL, 0);
325setxattr("/", "user.ethumb.md5", NULL, 0, 0);
326 ]])],
327 [_efl_have_fct="yes"],
328 [_efl_have_fct="no"])
329
330AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
331])
332
333dnl _EFL_CHECK_FUNC_SHM_OPEN_PRIV is for internal use
334dnl _EFL_CHECK_FUNC_SHM_OPEN_PRIV(EFL, LIB, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
335
336AC_DEFUN([_EFL_CHECK_FUNC_SHM_OPEN_PRIV],
337[
338m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
339m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
340
341LIBS_save="${LIBS}"
342LIBS="${LIBS} $2"
343AC_LINK_IFELSE(
344 [AC_LANG_PROGRAM(
345 [[
346#include <sys/mman.h>
347#include <sys/stat.h> /* For mode constants */
348#include <fcntl.h> /* For O_* constants */
349 ]],
350 [[
351int fd;
352
353fd = shm_open("/dev/null", O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO);
354 ]])],
355 [
356 m4_defn([UPEFL])[]_LIBS="$m4_defn([UPEFL])[]_LIBS $2"
357 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} $2"
358 _efl_have_fct="yes"
359 ],
360 [_efl_have_fct="no"])
361
362LIBS="${LIBS_save}"
363
364AS_IF([test "x${_efl_have_fct}" = "xyes"], [$3], [$4])
365
366m4_popdef([DOWNEFL])
367m4_popdef([UPEFL])
368])
369
370dnl _EFL_CHECK_FUNC_SHM_OPEN is for internal use
371dnl _EFL_CHECK_FUNC_SHM_OPEN(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
372
373AC_DEFUN([_EFL_CHECK_FUNC_SHM_OPEN],
374[
375_efl_have_fct="no"
376
377dnl Check is shm_open is in libc
378_EFL_CHECK_FUNC_SHM_OPEN_PRIV([$1], [],
379 [_efl_have_fct="yes"],
380 [_efl_have_fct="no"])
381
382dnl Check is shm_open is in librt
383if test "x${_efl_have_fct}" = "xno" ; then
384 _EFL_CHECK_FUNC_SHM_OPEN_PRIV([$1], [-lrt],
385 [_efl_have_fct="yes"],
386 [_efl_have_fct="no"])
387fi
388
389AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
390])
391
392dnl Macro that checks function availability
393dnl
394dnl EFL_CHECK_FUNC(EFL, FUNCTION)
395dnl AC_SUBST : EFL_CFLAGS and EFL_LIBS (EFL being replaced by its value)
396dnl AC_DEFINE : EFL_HAVE_FUNCTION (FUNCTION being replaced by its value)
397dnl result in efl_func_function (function being replaced by its value)
398
399AC_DEFUN([EFL_CHECK_FUNC],
400[
401m4_pushdef([UP], m4_translit([$2], [-a-z], [_A-Z]))dnl
402m4_pushdef([DOWN], m4_translit([$2], [-A-Z], [_a-z]))dnl
403
404m4_default([_EFL_CHECK_FUNC_]m4_defn([UP]))($1, [have_fct="yes"], [have_fct="no"])
405
406if test "x$2" = "xsetxattr" ; then
407 AC_MSG_CHECKING([for extended attributes])
408else
409 AC_MSG_CHECKING([for ]m4_defn([DOWN]))
410fi
411
412AC_MSG_RESULT([${have_fct}])
413
414if test "x${have_fct}" = "xyes" ; then
415 if test "x$2" = "xsetxattr" ; then
416 AC_DEFINE([HAVE_XATTR], [1], [Define to 1 if you have the `listxattr', `setxattr' and `getxattr' functions.])
417 else
418 AC_DEFINE([HAVE_]m4_defn([UP]), [1], [Define to 1 if you have the `]m4_defn([DOWN])[' function.])
419 fi
420fi
421
422efl_func_[]m4_defn([DOWN])="${have_fct}"
423
424m4_popdef([DOWN])
425m4_popdef([UP])
426])
427
428dnl Macro that iterates over a sequence of space separated functions
429dnl and that calls EFL_CHECK_FUNC() for each of these functions
430dnl
431dnl EFL_CHECK_FUNCS(EFL, FUNCTIONS)
432
433AC_DEFUN([EFL_CHECK_FUNCS],
434[
435m4_foreach_w([fct], [$2], [EFL_CHECK_FUNC($1, m4_defn([fct]))])
436])