summaryrefslogtreecommitdiff
path: root/m4/efl_check_funcs.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/efl_check_funcs.m4')
-rw-r--r--m4/efl_check_funcs.m4333
1 files changed, 0 insertions, 333 deletions
diff --git a/m4/efl_check_funcs.m4 b/m4/efl_check_funcs.m4
deleted file mode 100644
index b44f20b..0000000
--- a/m4/efl_check_funcs.m4
+++ /dev/null
@@ -1,333 +0,0 @@
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 fcntl
10dnl fnmatch
11dnl gettimeofday
12dnl iconv
13dnl setxattr (an al.)
14dnl shm_open
15
16dnl EFL_CHECK_LIB_CODE(EFL, LIB, VARIABLE, HEADER, BODY)
17dnl wrapper around AC_LINK_IFELSE(AC_LANG_PROGRAM()) to check
18dnl if some code would work with the given lib.
19dnl If the code work, EFL_ADD_LIBS(EFL, LIB) will be called
20dnl At the end VARIABLE will be "yes" or "no"
21AC_DEFUN([EFL_CHECK_LIB_CODE],
22[
23LIBS_save="${LIBS}"
24LIBS="${LIBS} $2"
25AC_LINK_IFELSE([AC_LANG_PROGRAM([$4], [$5])],
26 [EFL_ADD_LIBS([$1], [$2])
27 $3="yes"], [$3="no"])
28LIBS="${LIBS_save}"
29])
30
31dnl EFL_FIND_LIB_FOR_CODE(EFL, LIBS, VARIABLE, HEADER, BODY)
32AC_DEFUN([EFL_FIND_LIB_FOR_CODE],
33[
34dnl first try without lib (libc)
35EFL_CHECK_LIB_CODE([$1], [], [$3], [$4], [$5])
36
37if test "${$3}" = "no" && test "x$2" != "x"; then
38dnl loop through given libraries
39 for trylib in $2; do
40 EFL_CHECK_LIB_CODE([$1], [${trylib}], [$3], [$4], [$5])
41 if test "${$3}" = "yes"; then
42 break
43 fi
44 done
45fi
46])
47
48dnl _EFL_CHECK_FUNC_DIRFD is for internal use
49dnl _EFL_CHECK_FUNC_DIRFD(EFL, VARIABLE)
50
51AC_DEFUN([_EFL_CHECK_FUNC_DIRFD],
52[EFL_CHECK_LIB_CODE([$1], [], [$2], [[
53#ifdef HAVE_DIRENT_H
54# include <dirent.h>
55#endif
56]], [[DIR *dirp; return dirfd(dirp);]])
57])
58
59dnl _EFL_CHECK_FUNC_DLADDR is for internal use
60dnl _EFL_CHECK_FUNC_DLADDR(EFL, VARIABLE)
61AC_DEFUN([_EFL_CHECK_FUNC_DLADDR],
62[
63dllibs=""
64case "$host_os" in
65 linux*)
66 dllibs="-ldl"
67 ;;
68 *)
69 ;;
70esac
71case "$host_os" in
72 mingw*)
73 $2="yes"
74 ;;
75 *)
76 EFL_FIND_LIB_FOR_CODE([$1], [$dllibs], [$2], [[
77#ifndef _GNU_SOURCE
78# define _GNU_SOURCE
79#endif
80#include <stdlib.h>
81#include <dlfcn.h>
82]], [[int res = dladdr(NULL, NULL);]])
83 ;;
84esac
85])
86
87dnl _EFL_CHECK_FUNC_DLOPEN is for internal use
88dnl _EFL_CHECK_FUNC_DLOPEN(EFL, VARIABLE)
89AC_DEFUN([_EFL_CHECK_FUNC_DLOPEN],
90[
91dllibs=""
92case "$host_os" in
93 linux*)
94 dllibs="-ldl"
95 ;;
96 *)
97 ;;
98esac
99case "$host_os" in
100 mingw*)
101 $2="yes"
102 ;;
103 *)
104 EFL_FIND_LIB_FOR_CODE([$1], [$dllibs], [$2], [[
105#include <dlfcn.h>
106]], [[void *h = dlopen(0, 0);]])
107 ;;
108esac
109])
110
111dnl _EFL_CHECK_FUNC_DLSYM is for internal use
112dnl _EFL_CHECK_FUNC_DLSYM(EFL, VARIABLE)
113AC_DEFUN([_EFL_CHECK_FUNC_DLSYM],
114[
115dllibs=""
116case "$host_os" in
117 linux*)
118 dllibs="-ldl"
119 ;;
120 *)
121 ;;
122esac
123case "$host_os" in
124 mingw*)
125 $2="yes"
126 ;;
127 *)
128 EFL_FIND_LIB_FOR_CODE([$1], [$dllibs], [$2], [[
129#ifndef _GNU_SOURCE
130# define _GNU_SOURCE
131#endif
132#include <stdlib.h>
133#include <dlfcn.h>
134]], [[void *res = dlsym(NULL, NULL);]])
135 ;;
136esac
137])
138
139dnl _EFL_CHECK_FUNC_FCNTL is for internal use
140dnl _EFL_CHECK_FUNC_FCNTL(EFL, VARIABLE)
141AC_DEFUN([_EFL_CHECK_FUNC_FCNTL],
142[
143case "$host_os" in
144 mingw*)
145 $2="yes"
146 ;;
147 *)
148 EFL_FIND_LIB_FOR_CODE([$1], [], [$2], [[
149#include <fcntl.h>
150]], [[int g = fcntl(0, 0);]])
151 ;;
152esac
153])
154
155dnl _EFL_CHECK_FUNC_FNMATCH is for internal use
156dnl _EFL_CHECK_FUNC_FNMATCH(EFL, VARIABLE)
157AC_DEFUN([_EFL_CHECK_FUNC_FNMATCH],
158[
159case "$host_os" in
160 mingw*)
161 $2="yes"
162 ;;
163 *)
164 EFL_FIND_LIB_FOR_CODE([$1], [-lfnmatch -liberty], [$2], [[
165#include <stdlib.h>
166#include <fnmatch.h>
167]], [[int g = fnmatch(NULL, NULL, 0);]])
168 ;;
169esac
170])
171
172dnl _EFL_CHECK_FUNC_SCHED_GETCPU is for internal use
173dnl _EFL_CHECK_FUNC_SCHED_GETCPU(EFL, VARIABLE)
174AC_DEFUN([_EFL_CHECK_FUNC_SCHED_GETCPU],
175[
176 EFL_CHECK_LIB_CODE([$1], [], [$2], [[
177#include <sched.h>
178]], [[int cpu = sched_getcpu();]])
179])
180
181dnl _EFL_CHECK_FUNC_GETTIMEOFDAY is for internal use
182dnl _EFL_CHECK_FUNC_GETTIMEOFDAY(EFL, VARIABLE)
183AC_DEFUN([_EFL_CHECK_FUNC_GETTIMEOFDAY],
184[
185case "$host_os" in
186 mingw*)
187 $2="yes"
188 ;;
189 *)
190 EFL_CHECK_LIB_CODE([$1], [], [$2], [[
191#include <stdlib.h>
192#include <sys/time.h>
193]], [[int res = gettimeofday(NULL, NULL);]])
194
195 if test "${$2}" = "no" && test "x${enable_exotic}" = "xyes"; then
196 SAVE_CFLAGS="${CFLAGS}"
197 CFLAGS="${CFLAGS} ${EXOTIC_CFLAGS}"
198 EFL_CHECK_LIB_CODE([$1], [${EXOTIC_LIBS}], [$2], [[
199#include <Exotic.h>
200]], [[int res = gettimeofday(NULL, NULL);]])
201 CFLAGS="${SAVE_CFLAGS}"
202 fi
203 ;;
204esac
205])
206
207dnl _EFL_CHECK_FUNC_ICONV is for internal use
208dnl _EFL_CHECK_FUNC_ICONV(EFL, VARIABLE)
209AC_DEFUN([_EFL_CHECK_FUNC_ICONV],
210[dnl
211AC_ARG_WITH([iconv-link],
212 AC_HELP_STRING([--with-iconv-link=ICONV_LINK], [explicitly specify an iconv link option]),
213 [
214 $2="yes"
215 iconv_libs=${withval}
216 ],
217 [$2="no"])
218
219if test "x${iconv_libs}" = "x" ; then
220 EFL_FIND_LIB_FOR_CODE([$1], [-liconv -liconv_plug], [$2], [[
221#include <stdlib.h>
222#include <iconv.h>
223]], [[iconv_t ic; size_t count = iconv(ic, NULL, NULL, NULL, NULL);]])
224fi
225])
226
227dnl _EFL_CHECK_FUNC_SETXATTR is for internal use
228dnl _EFL_CHECK_FUNC_SETXATTR(EFL, VARIABLE)
229AC_DEFUN([_EFL_CHECK_FUNC_SETXATTR],
230[EFL_CHECK_LIB_CODE([$1], [], [$2], [[
231#include <stdlib.h>
232#include <sys/types.h>
233#include <sys/xattr.h>
234]], [[
235size_t tmp = listxattr("/", NULL, 0);
236tmp = getxattr("/", "user.ethumb.md5", NULL, 0);
237setxattr("/", "user.ethumb.md5", NULL, 0, 0);
238]])
239
240if test "${$2}" = "yes"; then
241 AC_DEFINE([HAVE_XATTR], [1], [Define to 1 if you have the `listxattr', `setxattr' and `getxattr' functions.])
242fi
243])
244
245dnl _EFL_CHECK_FUNC_SHM_OPEN is for internal use
246dnl _EFL_CHECK_FUNC_SHM_OPEN(EFL, VARIABLE)
247AC_DEFUN([_EFL_CHECK_FUNC_SHM_OPEN],
248[
249shmlibs=""
250case "$host_os" in
251 linux*)
252 shmlibs="-lrt"
253 ;;
254 *)
255 ;;
256esac
257EFL_FIND_LIB_FOR_CODE([$1], [$shmlibs], [$2], [[
258#include <sys/mman.h>
259#include <sys/stat.h> /* For mode constants */
260#include <fcntl.h> /* For O_* constants */
261]], [[
262int fd = shm_open("/dev/null", O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO);
263]])
264])
265
266dnl _EFL_CHECK_FUNC_SPLICE is for internal use
267dnl _EFL_CHECK_FUNC_SPLICE(EFL, VARIABLE)
268AC_DEFUN([_EFL_CHECK_FUNC_SPLICE],
269[EFL_FIND_LIB_FOR_CODE([$1], [], [$2], [[
270#include <unistd.h>
271#include <fcntl.h>
272]], [[
273long ret = splice(0, 0, 1, 0, 400, 0);
274]])
275])
276
277dnl _EFL_CHECK_FUNC_GETPAGESIZE is for internal use
278dnl _EFL_CHECK_FUNC_GETPAGESIZE(EFL, VARIABLE)
279AC_DEFUN([_EFL_CHECK_FUNC_GETPAGESIZE],
280[EFL_FIND_LIB_FOR_CODE([$1], [], [$2], [[
281#ifdef HAVE_UNISTD_H
282# include <unistd.h>
283#endif
284]],
285[[
286long sz;
287sz = getpagesize();
288]])
289])
290
291dnl _EFL_CHECK_FUNC_PRCTL is for internal use
292dnl _EFL_CHECK_FUNC_PRCTL(EFL, VARIABLE)
293AC_DEFUN([_EFL_CHECK_FUNC_PRCTL],
294[EFL_FIND_LIB_FOR_CODE([$1], [], [$2], [[
295#include <sys/prctl.h>
296]],
297[[
298prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
299]])
300])
301
302dnl Macro that checks function availability
303dnl
304dnl EFL_CHECK_FUNC(EFL, FUNCTION)
305dnl AC_SUBST : EFL_CFLAGS and EFL_LIBS (EFL being replaced by its value)
306dnl AC_DEFINE : HAVE_FUNCTION (FUNCTION being replaced by its value)
307dnl result in efl_func_function (function being replaced by its value)
308
309AC_DEFUN([EFL_CHECK_FUNC],
310[dnl
311m4_pushdef([UP], m4_translit([$2], [-a-z], [_A-Z]))dnl
312m4_pushdef([DOWN], m4_translit([$2], [-A-Z], [_a-z]))dnl
313
314m4_default([_EFL_CHECK_FUNC_]m4_defn([UP]))($1, [have_fct])
315AC_MSG_CHECKING([for $2])
316AC_MSG_RESULT([${have_fct}])
317
318if test "x${have_fct}" = "xyes" ; then
319 AC_DEFINE([HAVE_]m4_defn([UP]), [1], [Define to 1 if you have the `]m4_defn([DOWN])[' function.])
320fi
321
322efl_func_[]m4_defn([DOWN])="${have_fct}"
323m4_popdef([DOWN])dnl
324m4_popdef([UP])dnl
325])
326
327dnl Macro that iterates over a sequence of space separated functions
328dnl and that calls EFL_CHECK_FUNC() for each of these functions
329dnl
330dnl EFL_CHECK_FUNCS(EFL, FUNCTIONS)
331
332AC_DEFUN([EFL_CHECK_FUNCS],
333[m4_foreach_w([fct], [$2], [EFL_CHECK_FUNC($1, m4_defn([fct]))])])