From 4a1681cc24af8189cca3a5c877f438d79025b55d Mon Sep 17 00:00:00 2001 From: caro Date: Sun, 25 Mar 2012 17:25:04 +0000 Subject: [PATCH] Ecore: fix shm_open() check (can be in libc or librt) This works in linux and windows, and should fix shm_detection on BSD (including Mac) BSD, Mac and solaris users : please check that it compiles and shm_open is detected git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@69616 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- Makefile.am | 1 + configure.ac | 55 ++------------------------------- m4/efl_shm_open.m4 | 69 ++++++++++++++++++++++++++++++++++++++++++ src/lib/ecore_evas/Makefile.am | 2 +- 4 files changed, 73 insertions(+), 54 deletions(-) create mode 100644 m4/efl_shm_open.m4 diff --git a/Makefile.am b/Makefile.am index 8a6ef9a..b7be982 100644 --- a/Makefile.am +++ b/Makefile.am @@ -116,6 +116,7 @@ m4/ecore_check_module.m4 \ m4/ecore_check_options.m4 \ m4/efl_doxygen.m4 \ m4/efl_path_max.m4 \ +m4/efl_shm_open.m4 \ m4/efl_tests.m4 \ m4/efl_threads.m4 diff --git a/configure.ac b/configure.ac index 3d93c9b..0641ac0 100644 --- a/configure.ac +++ b/configure.ac @@ -1434,59 +1434,8 @@ if ! test "x${have_atfile_source}" = "xno" ; then ]) fi -SHM_OPEN_LIBS="" - -AC_MSG_CHECKING([whether shm_open is in libc]) -AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#include -#include - ]], - [[ -int fd; -fd = shm_open("/", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); -shm_unlink("/"); - ]])], - [ - have_shm_open="yes" - AC_DEFINE(HAVE_SHM_OPEN, 1, [Have shm_open() call]) - ], - [have_shm_open="no"]) -LIBS="${LIBS_save}" -AC_MSG_RESULT([${have_shm_open}]) - -if ! test "x${have_shm_open}" = "xyes" ; then - AC_MSG_CHECKING([whether shm_open is in librt]) - LIBS_save="${LIBS}" - LIBS="${LIBS} -lrt" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#include -#include - ]], - [[ -int fd; -fd = shm_open("/", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); -shm_unlink("/"); - ]])], - [ - have_shm_open="yes" - AC_DEFINE(HAVE_SHM_OPEN, 1, [Have shm_open() call]) - SHM_OPEN_LIBS="-lrt" - ], - [have_shm_open="no"]) - LIBS="${LIBS_save}" - AC_MSG_RESULT([${have_shm_open}]) -fi - -AC_SUBST([SHM_OPEN_LIBS]) - -AC_MSG_CHECKING([whether shm_open is available]) -AC_MSG_RESULT([${have_shm_open}]) +# shm_open +EFL_CHECK_SHM_OPEN([have_shm_open="yes"], [have_shm_open="no"]) ### Checks for optionnal feature AC_CHECK_FUNC([mallinfo], diff --git a/m4/efl_shm_open.m4 b/m4/efl_shm_open.m4 new file mode 100644 index 0000000..0bf1b0b --- /dev/null +++ b/m4/efl_shm_open.m4 @@ -0,0 +1,69 @@ +dnl Copyright (C) 2010 Vincent Torri +dnl That code is public domain and can be freely used or copied. + +dnl Macro that check if shm_open function is available or not. + +dnl Usage: EFL_CHECK_SHM_OPEN([, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl Call AC_SUBST(EFL_SHM_OPEN_LIBS) +dnl Define HAVE_SHM_OPEN to 1if shm_open is available + +AC_DEFUN([EFL_CHECK_SHM_OPEN], +[ +_efl_have_shm_open="no" + +dnl Check is shm_open is in libc + +AC_MSG_CHECKING([for shm_open in libc]) +AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#include /* For mode constants */ +#include /* For O_* constants */ + ]], + [[ +int fd; + +fd = shm_open("/dev/null", O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO); + ]])], + [_efl_have_shm_open="yes"], + [_efl_have_shm_open="no"]) + +AC_MSG_RESULT([${_efl_have_shm_open}]) + +if test "x$_efl_have_shm_open" = "xno" ; then + AC_MSG_CHECKING([for shm_open in librt]) + + LIBS_save="${LIBS}" + LIBS="${LIBS} -lrt" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#include /* For mode constants */ +#include /* For O_* constants */ + ]], + [[ +int fd; + +fd = shm_open("/dev/null", O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO); + ]])], + [ + EFL_SHM_OPEN_LIBS="-lrt" + _efl_have_shm_open="yes"], + [_efl_have_shm_open="no"]) + + LIBS="${LIBS_save}" + + AC_MSG_RESULT([${_efl_have_shm_open}]) +fi + +AC_SUBST([EFL_SHM_OPEN_LIBS]) + +if test "x$_efl_have_shm_open" = "xyes" ; then + AC_DEFINE([HAVE_SHM_OPEN], [1], [Define to 1 if you have the `shm_open' function.]) +fi + +AS_IF([test "x$_efl_have_shm_open" = "xyes"], [$1], [$2]) + +]) diff --git a/src/lib/ecore_evas/Makefile.am b/src/lib/ecore_evas/Makefile.am index c85af09..cd7f37b 100644 --- a/src/lib/ecore_evas/Makefile.am +++ b/src/lib/ecore_evas/Makefile.am @@ -151,7 +151,7 @@ $(top_builddir)/src/lib/ecore/libecore.la \ @EVAS_LIBS@ \ @EINA_LIBS@ \ @EVIL_LIBS@ \ -@SHM_OPEN_LIBS@ \ +@EFL_SHM_OPEN_LIBS@ \ @WAYLAND_EGL_LIBS@ libecore_evas_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@ -- 2.7.4