From 8a1eafc6b453dbbb4b68e1fce821518eb109b1f4 Mon Sep 17 00:00:00 2001 From: caro Date: Sun, 25 Mar 2012 11:12:32 +0000 Subject: [PATCH] Eina: fix shm_open() check (can be in libc or librt) + various autotools cleaning 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: http://svn.enlightenment.org/svn/e/trunk/eina@69608 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- configure.ac | 228 +++++++++++++++++++--------------------------- eina.pc.in | 2 +- m4/common/efl_shm_open.m4 | 69 ++++++++++++++ src/lib/Makefile.am | 2 +- src/lib/eina_file.c | 2 +- src/lib/eina_main.c | 2 +- src/tests/Makefile.am | 2 +- 7 files changed, 166 insertions(+), 141 deletions(-) create mode 100644 m4/common/efl_shm_open.m4 diff --git a/configure.ac b/configure.ac index 38fb13d..6594d1a 100644 --- a/configure.ac +++ b/configure.ac @@ -260,6 +260,7 @@ AM_CONDITIONAL(EINA_ENABLE_BENCHMARK_E17, test "x${enable_benchmark_e17}" = "xye ### Checks for programs AC_PROG_CC +#for src/tests... AC_PROG_CXX # pkg-config @@ -309,12 +310,12 @@ else fi -# Evil library for compilation on Windows CE +# Evil library for compilation on Windows EFL_EINA_BUILD="" case "$host_os" in mingw*) - PKG_CHECK_MODULES([EVIL], [evil >= 1.0.0]) + PKG_CHECK_EXISTS([EVIL], [evil >= 1.0.0]) AC_DEFINE([HAVE_EVIL], [1], [Set to 1 if evil package is installed]) requirement_eina="${requirement_eina} evil" EFL_EINA_BUILD="-DEFL_EINA_BUILD" @@ -322,6 +323,35 @@ case "$host_os" in esac AC_SUBST([EFL_EINA_BUILD]) +# Checks for portability layer + +PKG_CHECK_MODULES([EXOTIC], + [exotic], + [enable_exotic="yes"], + [enable_exotic="no"]) + +if test "x${enable_exotic}" = "xyes"; then + requirement_eina="exotic ${requirement_eina}" + EINA_CFLAGS="${EINA_CFLAGS} ${EXOTIC_CFLAGS}" + EINA_LIBS="${EXOTIC_LIBS}" + + EINA_CONFIGURE_HAVE_EXOTIC="#define EINA_HAVE_EXOTIC" + AC_DEFINE([HAVE_EXOTIC_H], [1], [Define to 1 if you have Exotic.]) +fi +AM_CONDITIONAL([EINA_HAVE_EXOTIC], [test "x${enable_exotic}" = "xyes"]) +AC_SUBST([EINA_CONFIGURE_HAVE_EXOTIC]) + +case "$host_vendor" in + ps3*) + PKG_CHECK_MODULES([ESCAPE], [escape]) + AC_DEFINE(HAVE_ESCAPE, 1, [Set to 1 if Escape package is installed]) + requirement_eina="${requirement_eina} escape" + EINA_CFLAGS="${ESCAPE_CFLAGS} ${EINA_CFLAGS}" + ;; +esac + +AC_SUBST([EINA_CFLAGS]) + # Check ememoa memory pool library AC_ARG_ENABLE([ememoa], @@ -352,8 +382,56 @@ PKG_CHECK_MODULES([ECORE_EVAS], AM_CONDITIONAL([BUILD_TILER_EXAMPLE], [test "x${build_tiler_example}" = "xyes"]) +### Checks for header files +AC_HEADER_ASSERT +AC_HEADER_TIME +AC_HEADER_DIRENT + +AC_CHECK_HEADERS([unistd.h libgen.h inttypes.h stdint.h sys/types.h siginfo.h strings.h sys/mman.h execinfo.h mcheck.h]) + +if test "x${ac_cv_header_inttypes_h}" = "xyes" ; then + EINA_CONFIGURE_HAVE_INTTYPES_H="#define EINA_HAVE_INTTYPES_H" + AC_DEFINE([HAVE_INTTYPES_H], [1], [Define to 1 if you have the header file.]) +fi +AC_SUBST([EINA_CONFIGURE_HAVE_INTTYPES_H]) + +if test "x${ac_cv_header_inttypes_h}" = "xyes" ; then + EINA_CONFIGURE_HAVE_STDINT_H="#define EINA_HAVE_STDINT_H" + AC_DEFINE([HAVE_STDINT_H], [1], [Define to 1 if you have the header file.]) +fi +AC_SUBST([EINA_CONFIGURE_HAVE_STDINT_H]) + +### Checks for types + +# wchar_t + +AC_CHECK_SIZEOF([wchar_t]) +EINA_SIZEOF_WCHAR_T=$ac_cv_sizeof_wchar_t +AC_SUBST([EINA_SIZEOF_WCHAR_T]) +AC_CHECK_TYPES([siginfo_t], [], [], + [[ +#include +#if HAVE_SIGINFO_H +# include +#endif + ]]) + +# struct dirent + +AC_CHECK_TYPES([struct dirent], [have_dirent="yes"], [have_dirent="no"], + [[ +#include + ]]) + +if test "x${have_dirent}" = "xyes" ; then + EINA_CONFIGURE_HAVE_DIRENT_H="#define EINA_HAVE_DIRENT_H" + AC_DEFINE([HAVE_DIRENT_H], [1], [Define to 1 if you have a valid header file.]) +fi +AC_SUBST([EINA_CONFIGURE_HAVE_DIRENT_H]) + +### Checks for structures + ### Checks for compiler characteristics -AC_C_CONST AC_C_BIGENDIAN AC_C_INLINE AC_PROG_CC_STDC @@ -384,58 +462,16 @@ m4_ifdef([v_mic], EFL_COMPILER_FLAG([-Wshadow]) -### Checks for portability layer - -PKG_CHECK_MODULES([EXOTIC], - [exotic], - [enable_exotic="yes"], - [enable_exotic="no"]) - -if test "x${enable_exotic}" = "xyes"; then - requirement_eina="exotic ${requirement_eina}" - EINA_CFLAGS="${EINA_CFLAGS} ${EXOTIC_CFLAGS}" - EINA_LIBS="${EXOTIC_LIBS}" - - EINA_CONFIGURE_HAVE_EXOTIC="#define EINA_HAVE_EXOTIC" - AC_DEFINE([HAVE_EXOTIC_H], [1], [Define to 1 if you have Exotic.]) -fi -AM_CONDITIONAL([EINA_HAVE_EXOTIC], [test "x${enable_exotic}" = "xyes"]) -AC_SUBST([EINA_CONFIGURE_HAVE_EXOTIC]) - -case "$host_vendor" in - ps3*) - PKG_CHECK_MODULES([ESCAPE], [escape]) - AC_DEFINE(HAVE_ESCAPE, 1, [Set to 1 if Escape package is installed]) - requirement_eina="${requirement_eina} escape" - EINA_CFLAGS="${ESCAPE_CFLAGS} ${EINA_CFLAGS}" - ;; -esac - -AC_SUBST([EINA_CFLAGS]) +EFL_CHECK_PATH_MAX ### Checks for linker characteristics EINA_LIBS= lt_enable_auto_import="" case "${host_os}" in mingw*) - EINA_LIBS="${EINA_LIBS} -ldl ${EVIL_LIBS} -lm" + EINA_LIBS="${EINA_LIBS} ${EVIL_LIBS}" lt_enable_auto_import="-Wl,--enable-auto-import" ;; - dragonfly*|openbsd*) - EINA_LIBS="${EINA_LIBS} -lm" - ;; - freebsd*|netbsd*) - EINA_LIBS="${EINA_LIBS} -lrt -lm" - ;; - darwin*) - EINA_LIBS="${EINA_LIBS} -lm" - ;; - cygwin*) - EINA_LIBS="${EINA_LIBS} -ldl -lm" - ;; - *) - EINA_LIBS="${EINA_LIBS} -lrt -ldl -lm" - ;; esac case "$host_vendor" in ps3*) @@ -448,63 +484,18 @@ AC_SUBST([lt_enable_auto_import]) EFL_LINKER_FLAG([-fno-strict-aliasing]) -CFLAGS="${CFLAGS} ${EINA_CFLAGS}" -LDFLAGS="${LDFLAGS} ${EINA_LDFLAGS}" -LIBS="${LIBS} ${EINA_LIBS}" - -### Checks for header files -AC_HEADER_ASSERT -AC_HEADER_TIME -EFL_CHECK_PATH_MAX -AC_CHECK_HEADERS([unistd.h libgen.h inttypes.h stdint.h sys/types.h siginfo.h strings.h sys/mman.h execinfo.h]) - -if test "x${ac_cv_header_inttypes_h}" = "xyes" ; then - EINA_CONFIGURE_HAVE_INTTYPES_H="#define EINA_HAVE_INTTYPES_H" - AC_DEFINE([HAVE_INTTYPES_H], [1], [Define to 1 if you have the header file.]) -fi -AC_SUBST([EINA_CONFIGURE_HAVE_INTTYPES_H]) - -if test "x${ac_cv_header_inttypes_h}" = "xyes" ; then - EINA_CONFIGURE_HAVE_STDINT_H="#define EINA_HAVE_STDINT_H" - AC_DEFINE([HAVE_STDINT_H], [1], [Define to 1 if you have the header file.]) -fi -AC_SUBST([EINA_CONFIGURE_HAVE_STDINT_H]) - -### Checks for types - -AC_CHECK_SIZEOF([wchar_t]) -EINA_SIZEOF_WCHAR_T=$ac_cv_sizeof_wchar_t -AC_SUBST([EINA_SIZEOF_WCHAR_T]) -AC_CHECK_TYPES([siginfo_t], [], [], - [[#include - #if HAVE_SIGINFO_H - # include - #endif - ]]) - -### Check if dirent.h is usable - -AC_CHECK_TYPES([struct dirent], [have_dirent="yes"], [have_dirent="no"], - [[#include - ]]) - -if test "x${have_dirent}" = "xyes" ; then - EINA_CONFIGURE_HAVE_DIRENT_H="#define EINA_HAVE_DIRENT_H" - AC_DEFINE([HAVE_DIRENT_H], [1], [Define to 1 if you have a valid header file.]) -fi -AC_SUBST([EINA_CONFIGURE_HAVE_DIRENT_H]) - ### Checks for library functions -AC_ISC_POSIX AC_FUNC_ALLOCA -AC_CHECK_FUNCS([strlcpy openat fstatat fpathconf execvp backtrace backtrace_symbols]) +AC_CHECK_FUNCS([strlcpy openat fstatat fpathconf execvp backtrace backtrace_symbols malloc_usable_size mtrace]) AC_MSG_CHECKING([for dirfd]) AC_LINK_IFELSE( [ AC_LANG_PROGRAM( [[ -#include +#ifdef HAVE_DIRENT_H +# include +#endif ]], [[ int main(void) @@ -523,12 +514,6 @@ if test "x${have_dirfd}" = "xyes" ; then AC_DEFINE([HAVE_DIRFD], [1], [ Define to 1 if you have the `dirfd' function or macro.]) fi -# check debug information for malloc -AC_CHECK_FUNCS([malloc_usable_size], [malloc_true_size="yes"], [malloc_true_size="no"]) -if test "x${malloc_true_size}" = "xyes" ; then - AC_DEFINE([HAVE_MALLOC_USABLE_SIZE], [1], [We will be able to know the exact amount of wasted memory]) -fi - want_debug_malloc="no" AC_ARG_ENABLE([debug-malloc], [AC_HELP_STRING([--enable-debug-malloc], [enable debugging of malloc usage overhead in our allocator @<:@default=enabled@:>@])], @@ -540,7 +525,7 @@ AC_ARG_ENABLE([debug-malloc], fi ], [want_debug_malloc="no"]) -if test "x${malloc_true_size}" = "xyes" -a "x${want_debug_malloc}" = "xyes"; then +if test "x${ac_cv_func_malloc_usable_size}" = "xyes" && test "x${want_debug_malloc}" = "xyes"; then AC_DEFINE([EINA_DEBUG_MALLOC], [1], [Turn on debugging overhead in mempool]) fi @@ -551,6 +536,7 @@ case "$host_os" in # managed by evil AC_DEFINE([HAVE_DLADDR]) AC_DEFINE([HAVE_DLOPEN]) + dlopen_libs="-ldl" ;; *) AC_CHECK_FUNCS([dlopen], [res="yes"], [res="no"]) @@ -598,8 +584,6 @@ if test "x${enable_log}" = "xyes"; then fi AC_SUBST([EINA_CONFIGURE_ENABLE_LOG]) -AC_CHECK_HEADERS([mcheck.h], [AC_DEFINE([HAVE_MCHECK], [1], [Have mcheck.h])]) -AC_CHECK_FUNCS([mtrace], [AC_DEFINE([HAVE_MTRACE], [1], [Have mtrace])]) # iconv library have_iconv="no" @@ -702,37 +686,8 @@ if test "x${have_iconv}" = "xyes" ; then AC_DEFINE([HAVE_ICONV], [1], [Set to 1 if iconv library is installed]) fi -# shmopen -have_shmopen=no -AC_MSG_CHECKING([for shm_open availability]) - -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); - ]])], - [have_shmopen="yes"], - [have_shmopen="no"]) - -LIBS="${LIBS_save}" - -AC_MSG_RESULT([${have_shmopen}]) - -if test "x${have_shmopen}" = "xyes"; then - AC_DEFINE([HAVE_SHMOPEN], [1], [Define to 1 if you have the `shm_open' function.]) - rt_libs="-lrt" -fi - -AC_SUBST([rt_libs]) +# shm_open +EFL_CHECK_SHM_OPEN([have_shm_open="yes"], [have_shm_open="no"]) # extended attribute @@ -859,6 +814,7 @@ echo " Amalgamation.........: ${do_amalgamation}" echo " Iconv support........: ${have_iconv}" echo " File dirfd...........: ${have_dirfd}" echo " File xattr...........: ${have_xattr}" +echo " shm_open.............: ${have_shm_open}" echo echo " Documentation........: ${build_doc}" echo " Tests................: ${enable_tests}" diff --git a/eina.pc.in b/eina.pc.in index eb8a016..d0d5071 100644 --- a/eina.pc.in +++ b/eina.pc.in @@ -8,5 +8,5 @@ Description: A Library that implements fast data types and miscellaneous tools @pkgconfig_requires_private@: @requirement_eina@ Version: @VERSION@ Libs: -L${libdir} -leina @EFL_PTHREAD_LIBS@ -Libs.private: @EFL_FNMATCH_LIBS@ @EFL_PTHREAD_LIBS@ @rt_libs@ @iconv_libs@ @EINA_LIBS@ +Libs.private: @EFL_FNMATCH_LIBS@ @EFL_SHM_OPEN_LIBS@ @EFL_PTHREAD_LIBS@ @iconv_libs@ @EINA_LIBS@ Cflags: -I${includedir}/eina-@VMAJ@ -I${includedir}/eina-@VMAJ@/eina diff --git a/m4/common/efl_shm_open.m4 b/m4/common/efl_shm_open.m4 new file mode 100644 index 0000000..0bf1b0b --- /dev/null +++ b/m4/common/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/Makefile.am b/src/lib/Makefile.am index 5de2848..fc1ac7f 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -170,7 +170,7 @@ else libeina_la_SOURCES = $(base_sources) endif -libeina_la_LIBADD = @iconv_libs@ @rt_libs@ @EINA_LIBS@ @dlopen_libs@ +libeina_la_LIBADD = @iconv_libs@ @EFL_SHM_OPEN_LIBS@ @EINA_LIBS@ @dlopen_libs@ -lm libeina_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@ @EFL_PTHREAD_LIBS@ libeina_la_CFLAGS = @EINA_CFLAGS@ @EFL_PTHREAD_CFLAGS@ diff --git a/src/lib/eina_file.c b/src/lib/eina_file.c index c465301..1431c05 100644 --- a/src/lib/eina_file.c +++ b/src/lib/eina_file.c @@ -953,7 +953,7 @@ eina_file_open(const char *path, Eina_Bool shared) if (!filename) return NULL; if (shared) -#ifdef HAVE_SHMOPEN +#ifdef HAVE_SHM_OPEN fd = shm_open(filename, O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO); #else goto on_error; diff --git a/src/lib/eina_main.c b/src/lib/eina_main.c index f233929..5440993 100644 --- a/src/lib/eina_main.c +++ b/src/lib/eina_main.c @@ -37,7 +37,7 @@ # endif #endif -#ifdef HAVE_MCHECK +#ifdef HAVE_MCHECK_H # ifdef HAVE_MTRACE # define MT 1 # endif diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index cf500f5..258496c 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -86,7 +86,7 @@ module_dummy_la_CPPFLAGS = \ -I$(top_builddir)/src/include \ -I$(top_builddir)/src/lib \ @EFL_EINA_BUILD@ -module_dummy_la_LIBADD = $(top_builddir)/src/lib/libeina.la @EINA_LIBS@ +module_dummy_la_LIBADD = $(top_builddir)/src/lib/libeina.la @EINA_LIBS@ -lm module_dummy_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version module_dummy_la_LIBTOOLFLAGS = --tag=disable-static -- 2.7.4