package upload
[framework/uifw/ecore.git] / m4 / efl_shm_open.m4
1 dnl Copyright (C) 2010 Vincent Torri <vtorri at univ-evry dot fr>
2 dnl That code is public domain and can be freely used or copied.
3
4 dnl Macro that check if shm_open function is available or not.
5
6 dnl Usage: EFL_CHECK_SHM_OPEN([, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
7 dnl Call AC_SUBST(EFL_SHM_OPEN_LIBS)
8 dnl Define HAVE_SHM_OPEN to 1if shm_open is available
9
10 AC_DEFUN([EFL_CHECK_SHM_OPEN],
11 [
12 _efl_have_shm_open="no"
13
14 dnl Check is shm_open is in libc
15
16 AC_MSG_CHECKING([for shm_open in libc])
17 AC_LINK_IFELSE(
18    [AC_LANG_PROGRAM(
19        [[
20 #include <sys/mman.h>
21 #include <sys/stat.h>        /* For mode constants */
22 #include <fcntl.h>           /* For O_* constants */
23        ]],
24        [[
25 int fd;
26
27 fd = shm_open("/dev/null", O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO);
28        ]])],
29    [_efl_have_shm_open="yes"],
30    [_efl_have_shm_open="no"])
31
32 AC_MSG_RESULT([${_efl_have_shm_open}])
33
34 if test "x$_efl_have_shm_open" = "xno" ; then
35    AC_MSG_CHECKING([for shm_open in librt])
36
37    LIBS_save="${LIBS}"
38    LIBS="${LIBS} -lrt"
39    AC_LINK_IFELSE(
40       [AC_LANG_PROGRAM(
41           [[
42 #include <sys/mman.h>
43 #include <sys/stat.h>        /* For mode constants */
44 #include <fcntl.h>           /* For O_* constants */
45           ]],
46           [[
47 int fd;
48
49 fd = shm_open("/dev/null", O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO);
50           ]])],
51       [
52        EFL_SHM_OPEN_LIBS="-lrt"
53        _efl_have_shm_open="yes"],
54       [_efl_have_shm_open="no"])
55
56    LIBS="${LIBS_save}"
57
58    AC_MSG_RESULT([${_efl_have_shm_open}])
59 fi
60
61 AC_SUBST([EFL_SHM_OPEN_LIBS])
62
63 if test "x$_efl_have_shm_open" = "xyes" ; then
64    AC_DEFINE([HAVE_SHM_OPEN], [1], [Define to 1 if you have the `shm_open' function.])
65 fi
66
67 AS_IF([test "x$_efl_have_shm_open" = "xyes"], [$1], [$2])
68
69 ])