diff --git a/legacy/evas/configure.ac b/legacy/evas/configure.ac index c8323842bc..f7a33d72a4 100644 --- a/legacy/evas/configure.ac +++ b/legacy/evas/configure.ac @@ -587,31 +587,9 @@ if test "x$res" = "xyes"; then AC_DEFINE(HAVE_LROUND, 1, C99 lround function exists) fi -SHM_OPEN_LINK="" -AC_MSG_CHECKING([whether shm_open() is present]) -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_LINK="-lrt" - ], - [have_shm_open="no"]) -LIBS=${LIBS_save} -AC_MSG_RESULT([${have_shm_open}]) -AC_SUBST(SHM_OPEN_LINK) +if test "x${want_evas_image_loader_generic}" = "xyes" ; then + EFL_CHECK_SHM_OPEN +fi # (shm_open (for cache server) AC_ARG_ENABLE([evas-cserve], @@ -628,29 +606,11 @@ AC_MSG_CHECKING(whether to build shared cache server and support) AC_MSG_RESULT(${want_evas_cserve}) if test "x${want_evas_cserve}" = "xyes" ; then - AC_MSG_CHECKING([whether shm_open() is present]) - 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("/"); - ]])], - [want_evas_cserve="yes"], - [want_evas_cserve="no"]) - LIBS=${LIBS_save} - AC_MSG_RESULT([${want_evas_cserve}]) + EFL_CHECK_SHM_OPEN([want_evas_cserve="yes"], [want_evas_cserve="no"]) fi if test "x${want_evas_cserve}" = "xyes" ; then - AC_DEFINE(EVAS_CSERVE, 1, [Shared caceh server.]) + AC_DEFINE(EVAS_CSERVE, 1, [Shared cache server.]) fi AM_CONDITIONAL([EVAS_CSERVE], [test "x${want_evas_cserve}" = "xyes"]) diff --git a/legacy/evas/m4/efl_shm_open.m4 b/legacy/evas/m4/efl_shm_open.m4 new file mode 100644 index 0000000000..ce3bcf8aef --- /dev/null +++ b/legacy/evas/m4/efl_shm_open.m4 @@ -0,0 +1,70 @@ +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/legacy/evas/src/lib/cserve/Makefile.am b/legacy/evas/src/lib/cserve/Makefile.am index 6ff6e2a51d..f2bf1e4bfe 100644 --- a/legacy/evas/src/lib/cserve/Makefile.am +++ b/legacy/evas/src/lib/cserve/Makefile.am @@ -29,4 +29,4 @@ evas_cs_server.c \ evas_cs_client.c \ evas_cs_mem.c -libevas_cserve_la_LIBADD = @EINA_LIBS@ -lrt +libevas_cserve_la_LIBADD = @EINA_LIBS@ @EFL_SHM_OPEN_LIBS@ diff --git a/legacy/evas/src/modules/loaders/generic/Makefile.am b/legacy/evas/src/modules/loaders/generic/Makefile.am index 1f72bfc738..aba1f003dc 100644 --- a/legacy/evas/src/modules/loaders/generic/Makefile.am +++ b/legacy/evas/src/modules/loaders/generic/Makefile.am @@ -20,7 +20,7 @@ pkg_LTLIBRARIES = module.la module_la_SOURCES = evas_image_load_generic.c -module_la_LIBADD = @EINA_LIBS@ @evas_image_loader_generic_libs@ @SHM_OPEN_LINK@ $(top_builddir)/src/lib/libevas.la +module_la_LIBADD = @EINA_LIBS@ @evas_image_loader_generic_libs@ @EFL_SHM_OPEN_LIBS@ $(top_builddir)/src/lib/libevas.la module_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version module_la_LIBTOOLFLAGS = --tag=disable-static @@ -29,7 +29,7 @@ else noinst_LTLIBRARIES = libevas_loader_generic.la libevas_loader_generic_la_SOURCES = evas_image_load_generic.c -libevas_loader_generic_la_LIBADD = @evas_image_loader_generic_libs@ @SHM_OPEN_LINK@ +libevas_loader_generic_la_LIBADD = @evas_image_loader_generic_libs@ @EFL_SHM_OPEN_LIBS@ endif endif