1 dnl Copyright (C) 2012 Vincent Torri <vincent dot torri at gmail dot com>
2 dnl This code is public domain and can be freely used or copied.
4 dnl Macros that check functions availability for the EFL:
15 dnl _EFL_CHECK_FUNC_DIRFD is for internal use
16 dnl _EFL_CHECK_FUNC_DIRFD(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
18 AC_DEFUN([_EFL_CHECK_FUNC_DIRFD],
36 [_efl_have_fct="yes"],
39 AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
42 dnl _EFL_CHECK_FUNC_DLADDR_PRIV is for internal use
43 dnl _EFL_CHECK_FUNC_DLADDR_PRIV(EFL, LIB, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
45 AC_DEFUN([_EFL_CHECK_FUNC_DLADDR_PRIV],
47 m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
48 m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
59 int res = dladdr(0, 0);
62 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} $2"
63 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} $2"
70 AS_IF([test "x${_efl_have_fct}" = "xyes"], [$3], [$4])
76 dnl _EFL_CHECK_FUNC_DLADDR is for internal use
77 dnl _EFL_CHECK_FUNC_DLADDR(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
79 AC_DEFUN([_EFL_CHECK_FUNC_DLADDR],
81 m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
82 m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
87 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} -ldl"
88 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} -ldl"
93 dnl Check is dladdr is in libc
94 _EFL_CHECK_FUNC_DLADDR_PRIV([$1], [], [_efl_have_fct="yes"], [_efl_have_fct="no"])
96 dnl 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"])
103 AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
109 dnl _EFL_CHECK_FUNC_DLOPEN_PRIV is for internal use
110 dnl _EFL_CHECK_FUNC_DLOPEN_PRIV(EFL, LIB, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
112 AC_DEFUN([_EFL_CHECK_FUNC_DLOPEN_PRIV],
114 m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
115 m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
125 void *h = dlopen(0, 0);
128 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} $2"
129 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} $2"
132 [_efl_have_fct="no"])
136 AS_IF([test "x${_efl_have_fct}" = "xyes"], [$3], [$4])
142 dnl _EFL_CHECK_FUNC_DLOPEN is for internal use
143 dnl _EFL_CHECK_FUNC_DLOPEN(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
145 AC_DEFUN([_EFL_CHECK_FUNC_DLOPEN],
147 m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
148 m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
153 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} -ldl"
154 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} -ldl"
159 dnl Check is dlopen is in libc
160 _EFL_CHECK_FUNC_DLOPEN_PRIV([$1], [], [_efl_have_fct="yes"], [_efl_have_fct="no"])
162 dnl 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"])
169 AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
175 dnl _EFL_CHECK_FUNC_FNMATCH_PRIV is for internal use
176 dnl _EFL_CHECK_FUNC_FNMATCH_PRIV(EFL, LIB, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
178 AC_DEFUN([_EFL_CHECK_FUNC_FNMATCH_PRIV],
180 m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
181 m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
192 int g = fnmatch(NULL, NULL, 0);
195 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} $2"
196 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} $2"
199 [_efl_have_fct="no"])
203 AS_IF([test "x${_efl_have_fct}" = "xyes"], [$3], [$4])
209 dnl _EFL_CHECK_FUNC_FNMATCH is for internal use
210 dnl _EFL_CHECK_FUNC_FNMATCH(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
212 AC_DEFUN([_EFL_CHECK_FUNC_FNMATCH],
219 dnl Check is fnmatch is in libfnmatch
220 _EFL_CHECK_FUNC_FNMATCH_PRIV([$1], [-lfnmatch], [_efl_have_fct="yes"], [_efl_have_fct="no"])
222 dnl 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"])
229 AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
232 dnl _EFL_CHECK_FUNC_ICONV_PRIV is for internal use
233 dnl _EFL_CHECK_FUNC_ICONV_PRIV(EFL, LIB, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
235 AC_DEFUN([_EFL_CHECK_FUNC_ICONV_PRIV],
237 m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
238 m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
250 size_t count = iconv(ic, NULL, NULL, NULL, NULL);
253 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} $2"
254 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} $2"
257 [_efl_have_fct="no"])
261 AS_IF([test "x${_efl_have_fct}" = "xyes"], [$3], [$4])
267 dnl _EFL_CHECK_FUNC_ICONV is for internal use
268 dnl _EFL_CHECK_FUNC_ICONV(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
270 AC_DEFUN([_EFL_CHECK_FUNC_ICONV],
272 AC_ARG_WITH([iconv-link],
273 AC_HELP_STRING([--with-iconv-link=ICONV_LINK], [explicitly specify an iconv link option]),
276 iconv_libs=${withval}
278 [_efl_have_fct="no"])
280 AC_MSG_CHECKING([for explicit iconv link options])
281 if test "x${iconv_libs}" = "x" ; then
282 AC_MSG_RESULT([no explicit iconv link option])
284 AC_MSG_RESULT([${iconv_libs}])
287 dnl Check is iconv is in libc
288 if test "x${_efl_have_fct}" = "xno" ; then
289 _EFL_CHECK_FUNC_ICONV_PRIV([$1], [], [_efl_have_fct="yes"], [_efl_have_fct="no"])
292 dnl Check is iconv is in libiconv
293 if test "x${_efl_have_fct}" = "xno" ; then
294 _EFL_CHECK_FUNC_ICONV_PRIV([$1], [-liconv], [_efl_have_fct="yes"], [_efl_have_fct="no"])
297 dnl Check is iconv is in libiconv_plug
298 if test "x${_efl_have_fct}" = "xno" ; then
299 _EFL_CHECK_FUNC_ICONV_PRIV([$1], [-liconv_plug], [_efl_have_fct="yes"], [_efl_have_fct="no"])
302 AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
305 dnl _EFL_CHECK_FUNC_SETXATTR is for internal use
306 dnl _EFL_CHECK_FUNC_SETXATTR(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
308 AC_DEFUN([_EFL_CHECK_FUNC_SETXATTR],
314 #include <sys/types.h>
315 #include <sys/xattr.h>
318 size_t tmp = listxattr("/", NULL, 0);
319 tmp = getxattr("/", "user.ethumb.md5", NULL, 0);
320 setxattr("/", "user.ethumb.md5", NULL, 0, 0);
322 [_efl_have_fct="yes"],
323 [_efl_have_fct="no"])
325 AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
328 dnl _EFL_CHECK_FUNC_SHM_OPEN_PRIV is for internal use
329 dnl _EFL_CHECK_FUNC_SHM_OPEN_PRIV(EFL, LIB, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
331 AC_DEFUN([_EFL_CHECK_FUNC_SHM_OPEN_PRIV],
333 m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
334 m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
341 #include <sys/mman.h>
342 #include <sys/stat.h> /* For mode constants */
343 #include <fcntl.h> /* For O_* constants */
348 fd = shm_open("/dev/null", O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO);
351 m4_defn([UPEFL])[]_LIBS="$ m4_defn([UPEFL])[]_LIBS $2"
352 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} $2"
355 [_efl_have_fct="no"])
359 AS_IF([test "x${_efl_have_fct}" = "xyes"], [$3], [$4])
365 dnl _EFL_CHECK_FUNC_SHM_OPEN is for internal use
366 dnl _EFL_CHECK_FUNC_SHM_OPEN(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
368 AC_DEFUN([_EFL_CHECK_FUNC_SHM_OPEN],
372 dnl 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"])
377 dnl Check is shm_open is in librt
378 if 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"])
384 AS_IF([test "x${_efl_have_fct}" = "xyes"], [$2], [$3])
387 dnl Macro that checks function availability
389 dnl EFL_CHECK_FUNC(EFL, FUNCTION)
390 dnl AC_SUBST : EFL_CFLAGS and EFL_LIBS (EFL being replaced by its value)
391 dnl AC_DEFINE : EFL_HAVE_FUNCTION (FUNCTION being replaced by its value)
392 dnl result in efl_func_function (function being replaced by its value)
394 AC_DEFUN([EFL_CHECK_FUNC],
396 m4_pushdef([UP], m4_translit([$2], [-a-z], [_A-Z]))dnl
397 m4_pushdef([DOWN], m4_translit([$2], [-A-Z], [_a-z]))dnl
399 m4_default([_EFL_CHECK_FUNC_]m4_defn([UP]))($1, [have_fct="yes"], [have_fct="no"])
401 if test "x$2" = "xsetxattr" ; then
402 AC_MSG_CHECKING([for extended attributes])
404 AC_MSG_CHECKING([for ]m4_defn([DOWN]))
407 AC_MSG_RESULT([${have_fct}])
409 if 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.])
413 AC_DEFINE([HAVE_]m4_defn([UP]), [1], [Define to 1 if you have the `]m4_defn([DOWN])[' function.])
417 efl_func_[]m4_defn([DOWN])="${have_fct}"
423 dnl Macro that iterates over a sequence of space separated function
424 dnl and that call EFL_CHECK_FUNC() for each of these functions
426 dnl EFL_CHECK_FUNCS(EFL, FUNCTIONS)
428 AC_DEFUN([EFL_CHECK_FUNCS],
430 m4_foreach_w([fct], [$2], [EFL_CHECK_FUNC($1, m4_defn([fct]))])