summaryrefslogtreecommitdiff
path: root/legacy/eina/m4/common/efl_check_funcs.m4
diff options
context:
space:
mode:
Diffstat (limited to 'legacy/eina/m4/common/efl_check_funcs.m4')
-rw-r--r--legacy/eina/m4/common/efl_check_funcs.m4431
1 files changed, 431 insertions, 0 deletions
diff --git a/legacy/eina/m4/common/efl_check_funcs.m4 b/legacy/eina/m4/common/efl_check_funcs.m4
new file mode 100644
index 0000000..5322c41
--- /dev/null
+++ b/legacy/eina/m4/common/efl_check_funcs.m4
@@ -0,0 +1,431 @@
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 libfnmatch
220 _EFL_CHECK_FUNC_FNMATCH_PRIV([$1], [-lfnmatch], [_efl_have_fct="yes"], [_efl_have_fct="no"])
221
222dnl Check is fnmatch is in libiberty
223 if test "x${_efl_have_fct}" = "xno" ; then
224 _EFL_CHECK_FUNC_FNMATCH_PRIV([$1], [-liberty], [_efl_have_fct="yes"], [_efl_have_fct="no"])
225 fi
226 ;;
227esac
228
229AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
230])
231
232dnl _EFL_CHECK_FUNC_ICONV_PRIV is for internal use
233dnl _EFL_CHECK_FUNC_ICONV_PRIV(EFL, LIB, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
234
235AC_DEFUN([_EFL_CHECK_FUNC_ICONV_PRIV],
236[
237m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
238m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
239
240LIBS_save="${LIBS}"
241LIBS="${LIBS} $2"
242AC_LINK_IFELSE(
243 [AC_LANG_PROGRAM(
244 [[
245#include <stdlib.h>
246#include <iconv.h>
247 ]],
248 [[
249iconv_t ic;
250size_t count = iconv(ic, NULL, NULL, NULL, NULL);
251 ]])],
252 [
253 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} $2"
254 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} $2"
255 _efl_have_fct="yes"
256 ],
257 [_efl_have_fct="no"])
258
259LIBS="${LIBS_save}"
260
261AS_IF([test "x${_efl_have_fct}" = "xyes"], [$3], [$4])
262
263m4_popdef([DOWNEFL])
264m4_popdef([UPEFL])
265])
266
267dnl _EFL_CHECK_FUNC_ICONV is for internal use
268dnl _EFL_CHECK_FUNC_ICONV(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
269
270AC_DEFUN([_EFL_CHECK_FUNC_ICONV],
271[
272AC_ARG_WITH([iconv-link],
273 AC_HELP_STRING([--with-iconv-link=ICONV_LINK], [explicitly specify an iconv link option]),
274 [
275 _efl_have_fct="yes"
276 iconv_libs=${withval}
277 ],
278 [_efl_have_fct="no"])
279
280AC_MSG_CHECKING([for explicit iconv link options])
281if test "x${iconv_libs}" = "x" ; then
282 AC_MSG_RESULT([no explicit iconv link option])
283else
284 AC_MSG_RESULT([${iconv_libs}])
285fi
286
287dnl Check is iconv is in libc
288if test "x${_efl_have_fct}" = "xno" ; then
289 _EFL_CHECK_FUNC_ICONV_PRIV([$1], [], [_efl_have_fct="yes"], [_efl_have_fct="no"])
290fi
291
292dnl Check is iconv is in libiconv
293if test "x${_efl_have_fct}" = "xno" ; then
294 _EFL_CHECK_FUNC_ICONV_PRIV([$1], [-liconv], [_efl_have_fct="yes"], [_efl_have_fct="no"])
295fi
296
297dnl Check is iconv is in libiconv_plug
298if test "x${_efl_have_fct}" = "xno" ; then
299 _EFL_CHECK_FUNC_ICONV_PRIV([$1], [-liconv_plug], [_efl_have_fct="yes"], [_efl_have_fct="no"])
300fi
301
302AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
303])
304
305dnl _EFL_CHECK_FUNC_SETXATTR is for internal use
306dnl _EFL_CHECK_FUNC_SETXATTR(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
307
308AC_DEFUN([_EFL_CHECK_FUNC_SETXATTR],
309[
310AC_COMPILE_IFELSE(
311 [AC_LANG_PROGRAM(
312 [[
313#include <stdlib.h>
314#include <sys/types.h>
315#include <sys/xattr.h>
316 ]],
317 [[
318size_t tmp = listxattr("/", NULL, 0);
319tmp = getxattr("/", "user.ethumb.md5", NULL, 0);
320setxattr("/", "user.ethumb.md5", NULL, 0, 0);
321 ]])],
322 [_efl_have_fct="yes"],
323 [_efl_have_fct="no"])
324
325AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
326])
327
328dnl _EFL_CHECK_FUNC_SHM_OPEN_PRIV is for internal use
329dnl _EFL_CHECK_FUNC_SHM_OPEN_PRIV(EFL, LIB, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
330
331AC_DEFUN([_EFL_CHECK_FUNC_SHM_OPEN_PRIV],
332[
333m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
334m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
335
336LIBS_save="${LIBS}"
337LIBS="${LIBS} $2"
338AC_LINK_IFELSE(
339 [AC_LANG_PROGRAM(
340 [[
341#include <sys/mman.h>
342#include <sys/stat.h> /* For mode constants */
343#include <fcntl.h> /* For O_* constants */
344 ]],
345 [[
346int fd;
347
348fd = shm_open("/dev/null", O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO);
349 ]])],
350 [
351 m4_defn([UPEFL])[]_LIBS="$ m4_defn([UPEFL])[]_LIBS $2"
352 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} $2"
353 _efl_have_fct="yes"
354 ],
355 [_efl_have_fct="no"])
356
357LIBS="${LIBS_save}"
358
359AS_IF([test "x${_efl_have_fct}" = "xyes"], [$3], [$4])
360
361m4_popdef([DOWNEFL])
362m4_popdef([UPEFL])
363])
364
365dnl _EFL_CHECK_FUNC_SHM_OPEN is for internal use
366dnl _EFL_CHECK_FUNC_SHM_OPEN(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
367
368AC_DEFUN([_EFL_CHECK_FUNC_SHM_OPEN],
369[
370_efl_have_fct="no"
371
372dnl Check is shm_open is in libc
373_EFL_CHECK_FUNC_SHM_OPEN_PRIV([$1], [],
374 [_efl_have_fct="yes"],
375 [_efl_have_fct="no"])
376
377dnl Check is shm_open is in librt
378if test "x${_efl_have_fct}" = "xno" ; then
379 _EFL_CHECK_FUNC_SHM_OPEN_PRIV([$1], [-lrt],
380 [_efl_have_fct="yes"],
381 [_efl_have_fct="no"])
382fi
383
384AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
385])
386
387dnl Macro that checks function availability
388dnl
389dnl EFL_CHECK_FUNC(EFL, FUNCTION)
390dnl AC_SUBST : EFL_CFLAGS and EFL_LIBS (EFL being replaced by its value)
391dnl AC_DEFINE : EFL_HAVE_FUNCTION (FUNCTION being replaced by its value)
392dnl result in efl_func_function (function being replaced by its value)
393
394AC_DEFUN([EFL_CHECK_FUNC],
395[
396m4_pushdef([UP], m4_translit([$2], [-a-z], [_A-Z]))dnl
397m4_pushdef([DOWN], m4_translit([$2], [-A-Z], [_a-z]))dnl
398
399m4_default([_EFL_CHECK_FUNC_]m4_defn([UP]))($1, [have_fct="yes"], [have_fct="no"])
400
401if test "x$2" = "xsetxattr" ; then
402 AC_MSG_CHECKING([for extended attributes])
403else
404 AC_MSG_CHECKING([for ]m4_defn([DOWN]))
405fi
406
407AC_MSG_RESULT([${have_fct}])
408
409if test "x${have_fct}" = "xyes" ; then
410 if test "x$2" = "xsetxattr" ; then
411 AC_DEFINE([HAVE_XATTR], [1], [Define to 1 if you have the `listxattr', `setxattr' and `getxattr' functions.])
412 else
413 AC_DEFINE([HAVE_]m4_defn([UP]), [1], [Define to 1 if you have the `]m4_defn([DOWN])[' function.])
414 fi
415fi
416
417efl_func_[]m4_defn([DOWN])="${have_fct}"
418
419m4_popdef([DOWN])
420m4_popdef([UP])
421])
422
423dnl Macro that iterates over a sequence of space separated function
424dnl and that call EFL_CHECK_FUNC() for each of these functions
425dnl
426dnl EFL_CHECK_FUNCS(EFL, FUNCTIONS)
427
428AC_DEFUN([EFL_CHECK_FUNCS],
429[
430m4_foreach_w([fct], [$2], [EFL_CHECK_FUNC($1, m4_defn([fct]))])
431])