Emotion: Fix shm_open check + various autotools cleaning
authorcaro <caro@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 25 Mar 2012 18:43:21 +0000 (18:43 +0000)
committercaro <caro@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 25 Mar 2012 18:43:21 +0000 (18:43 +0000)
   This works in linux, 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/emotion@69618 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

Makefile.am
configure.ac
m4/efl_shm_open.m4 [new file with mode: 0644]
m4/emotion_check.m4
src/generic_players/vlc/Makefile.am
src/lib/emotion_main.c
src/modules/generic/Makefile.am

index 2ef6b69..248f9bd 100644 (file)
@@ -4,18 +4,41 @@ ACLOCAL_AMFLAGS = -I m4
 
 SUBDIRS = src data doc
 
-MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess emotion.spec \
-                       config.h.in config.sub configure install-sh \
-                      ltconfig ltmain.sh missing mkinstalldirs \
-                      stamp-h.in emotion_docs.tar \
-                      emotion.pc acconfig.h depcomp \
-                          $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)-doc.tar.bz2
-
-bin_SCRIPTS =
-
-EXTRA_DIST = README AUTHORS COPYING \
-       emotion.spec emotion.spec.in emotion.pc.in  \
-       emotion.pc.in
+MAINTAINERCLEANFILES = \
+Makefile.in \
+aclocal.m4 \
+config.guess \
+config.h.in \
+config.sub \
+configure \
+depcomp \
+install-sh \
+ltconfig \
+ltmain.sh \
+missing \
+mkinstalldirs \
+stamp-h.in \
+$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.gz \
+$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2 \
+$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)-doc.tar.bz2
+
+EXTRA_DIST = \
+README \
+AUTHORS \
+COPYING \
+autogen.sh \
+emotion.spec \
+emotion.spec.in \
+emotion.pc.in \
+m4/ac_attribute.m4 \
+m4/efl_binary.m4 \
+m4/efl_doxygen.m4 \
+m4/efl_edje_external.m4 \
+m4/efl_examples.m4 \
+m4/efl_shm_open.m4 \
+m4/emotion_check.m4 \
+m4/gst-element-check.m4
+
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = emotion.pc
index 37edf6a..8c3cc17 100644 (file)
@@ -108,8 +108,9 @@ EFL_CHECK_DOXYGEN([build_doc="yes"], [build_doc="no"])
 
 ### Checks for libraries
 
-PKG_CHECK_MODULES(EMOTION, [eina >= 1.2.0 evas >= 1.2.0 ecore >= 1.2.0 eet >= 1.6.0])
-requirement_emotion="ecore >= 1.2.0 evas >= 1.2.0 eina >= 1.2.0 eet >= 1.6.0"
+requirement_emotion="ecore >= 1.2.0 evas >= 1.2.0 eet >= 1.6.0 eina >= 1.2.0"
+PKG_CHECK_MODULES(EMOTION, [${requirement_emotion}])
+
 
 if test "x${have_emotion_test}" = "xyes" ; then
    PKG_CHECK_MODULES(EMOTION_BIN, [eina >= 1.2.0 evas >= 1.2.0 ecore >= 1.2.0 ecore-evas >= 1.2.0 edje >= 1.2.0])
@@ -144,11 +145,96 @@ if test "x${have_eeze}" = "xyes"; then
    requirement_emotion="${requirement_emotion} eeze >= 1.0.99"
 fi
 
+PKG_CHECK_MODULES([EIO], [eio >= 1.0.0], [have_eio="yes"], [have_eio="no"])
+if test "x${have_eio}" = "xyes"; then
+   AC_DEFINE(HAVE_EIO, 1, [Use EIO for asynchronous file access])
+   requirement_emotion="eio >= 1.0.0 ${requirement_emotion}"
+fi
+
+AM_CONDITIONAL([HAVE_EIO], [test "x${have_eio}" = "xyes"])
+
+# ecore-x availability, used for XV, VAAPI, VDPAU output.
+
+have_ecore_x="no"
+AC_ARG_ENABLE([ecore-x],
+   [AC_HELP_STRING([--disable-ecore-x], [disable ecore-x support. @<:@default=detect@:>@])],
+   [
+    if test "x${enableval}" = "xyes" || test "x${enableval}" = "xauto" ; then
+       want_ecore_x=${enableval}
+    else
+       want_ecore_x="no"
+    fi
+   ],
+   [want_ecore_x="auto"])
+
+if ! test "x$want_ecore_x" = "xno" ; then
+   PKG_CHECK_MODULES([ECORE_X],
+      [ecore-x >= 1.2.0],
+      [
+       AC_DEFINE(HAVE_ECORE_X, 1, [X11 support for Ecore])
+       have_ecore_x="yes"
+       requirement_elm="ecore-x >= 1.2.0 ${requirement_elm}"
+      ],
+      [have_ecore_x="no"]
+   )
+else
+    have_ecore_x="no"
+fi
+
+if test "x$want_ecore_x" = "xyes" && test "x$have_ecore_x" = "xno" ; then
+    AC_MSG_ERROR([ecore-x support requested, but not found by pkg-config.])
+fi
+
+# Check if gstreamer X Overlay is available
+build_xoverlay="no"
+if test "x${enable_gstreamer}" = "xyes" ; then
+   PKG_CHECK_MODULES([GSTREAMER_INTERFACE],
+      [gstreamer-interfaces-0.10 >= 0.10.34],
+      [build_xoverlay="yes"],
+      [build_xoverlay="no"])
+   if test "x${build_xoverlay}" = "xyes" ; then
+      save_CPPFLAGS=$CPPFLAGS
+      CPPFLAGS="$CPPFLAGS ${GSTREAMER_CFLAGS} ${GSTREAMER_INTERFACE_CFLAGS}"
+      AC_CHECK_HEADER([gst/interfaces/xoverlay.h],
+         [
+          AC_DEFINE(HAVE_XOVERLAY_H, 1, [Build with Gstreamer Xoverlay support])
+          build_xoverlay="yes"
+         ],
+         [build_xoverlay="no"])
+      CPPFLAGS=$save_CPPFLAGS
+
+      save_LDFLAGS=${LDFLAGS}
+      LDFLAGS="${LDFLAGS} ${GSTREAMER_INTERFACES}"
+      AC_CHECK_LIB([gstinterfaces-0.10],
+         [gst_x_overlay_set_window_handle],
+         [AC_DEFINE([HAVE_X_OVERLAY_SET], [1], [Use gst_x_overlay_set_window_handle instead of old deprecated gst_x_overlay_set_xwindow_id])])
+      LDFLAGS=$sava_LDFLAGS
+   fi
+fi
+
 ### Checks for header files
-AC_HEADER_STDC
 
 AC_CHECK_HEADERS([unistd.h])
 
+# Check for video4linux
+
+AC_MSG_CHECKING([for V4L2])
+AC_COMPILE_IFELSE(
+   [AC_LANG_PROGRAM(
+       [[
+#include <stdio.h>
+#include <linux/videodev2.h>
+       ]],
+       [[
+fprintf(stdout, "%i\n", V4L2_CAP_VIDEO_CAPTURE);
+       ]])],
+   [
+    AC_DEFINE(HAVE_V4L2, 1, [Define to 1 if you have Video4Linux 2 available])
+    have_v4l2="yes"
+   ],
+   [have_v4l2="no"])
+AC_MSG_RESULT([${have_v4l2}])
+
 ### Checks for types
 
 
@@ -156,14 +242,12 @@ AC_CHECK_HEADERS([unistd.h])
 
 
 ### Checks for compiler characteristics
-AC_C_CONST
 AC_C_BIGENDIAN
-AC_PROG_CC_STDC
 AC_C___ATTRIBUTE__
 
 EFL_EMOTION_BUILD=""
 case "$host_os" in
-   mingw32ce* | cegcc*)
+   mingw32ce*)
       EMOTION_CPPFLAGS="-D_WIN32_WCE=0x0420"
       EFL_EMOTION_BUILD="-DEFL_EMOTION_BUILD"
       ;;
@@ -182,30 +266,16 @@ AC_SUBST(EMOTION_CPPFLAGS)
 
 lt_enable_auto_import=""
 case "$host_os" in
-   mingw* | cegcc*)
+   mingw*)
       lt_enable_auto_import="-Wl,--enable-auto-import"
       ;;
 esac
 AC_SUBST(lt_enable_auto_import)
 
-### Check for video4linux
 
-AC_COMPILE_IFELSE(
-   [AC_LANG_PROGRAM(
-       [[
-#include <stdio.h>
-#include <linux/videodev2.h>
-       ]],
-       [[
-fprintf(stdout, "%i\n", V4L2_CAP_VIDEO_CAPTURE);
-       ]])],
-   [
-     AC_DEFINE(HAVE_V4L2, 1, [Define to 1 if you have Video4Linux 2 available])
-     have_v4l2="yes"
-   ],
-   [have_v4l2="no"])
-AC_MSG_CHECKING([for V4L2])
-AC_MSG_RESULT([${have_v4l2}])
+### Checks for library functions
+AC_FUNC_ALLOCA
+
 
 ### Modules
 
@@ -220,70 +290,6 @@ if test "x${enable_xine}" = "xno" && test "x${enable_gstreamer}" = "xno" && test
 fi
 
 
-PKG_CHECK_MODULES([EIO],
-       [eio],
-       [
-        have_eio="yes"
-        AC_DEFINE(HAVE_EIO, 1, [Use EIO for asynchronous file access])
-        requirement_emotion="eio ${requirement_emotion}"
-       ],
-       [have_eio="no"])
-
-AM_CONDITIONAL([HAVE_EIO], [test "x${have_eio}" = "xyes"])
-
-## Check Ecore-X availability, used for XV, VAAPI, VDPAU output.
-
-have_ecore_x="no"
-want_ecore_x="auto"
-AC_ARG_ENABLE([ecore-x],
-   [AC_HELP_STRING([--disable-ecore-x], [disable ecore-x support. @<:@default=detect@:>@])],
-   [want_ecore_x=$enableval], [])
-
-if test "x$want_ecore_x" != "xno"; then
-   PKG_CHECK_MODULES([ECORE_X],
-      [ecore-x >= 1.2.0],
-      [
-       AC_DEFINE(HAVE_ECORE_X, 1, [X11 support for Ecore])
-       have_ecore_x="yes"
-       requirement_elm="ecore-x >= 1.2.0 ${requirement_elm}"
-      ],
-      [have_ecore_x="no"]
-   )
-else
-    have_ecore_x="no"
-fi
-if test "x$want_ecore_x" = "xyes" -a "x$have_ecore_x" = "xno"; then
-    AC_MSG_ERROR([ecore-x support requested, but not found by pkg-config.])
-fi
-
-## Check if gstreamer X Overlay is available
-build_xoverlay="no"
-if test "x$enable_gstreamer" = "xyes"; then
-   PKG_CHECK_MODULES([GSTREAMER_INTERFACE],
-       [ gstreamer-interfaces-0.10 >= 0.10.34 ],
-       [ build_xoverlay="yes" ],
-       [ build_xoverlay="no" ]
-   )
-   if test "x${build_xoverlay}" = "xyes"; then
-      save_CPPFLAGS=$CPPFLAGS
-      CPPFLAGS="$CPPFLAGS ${GSTREAMER_CFLAGS} ${GSTREAMER_INTERFACE_CFLAGS}"
-      AC_CHECK_HEADER([gst/interfaces/xoverlay.h],
-       [
-         AC_DEFINE(HAVE_XOVERLAY_H, 1, [Build with Gstreamer Xoverlay support])
-         build_xoverlay="yes"
-       ], [
-         build_xoverlay="no"
-       ]
-      )
-      CPPFLAGS=$save_CPPFLAGS
-
-      save_LDFLAGS=$LDFLAGS
-      LDFLAGS="$LDFLAGS ${GSTREAMER_INTERFACES}"
-      AC_CHECK_LIB(gstinterfaces-0.10, gst_x_overlay_set_window_handle, AC_DEFINE(HAVE_X_OVERLAY_SET, 1, [Use gst_x_overlay_set_window_handle instead of old deprecated gst_x_overlay_set_xwindow_id]))
-      LDFLAGS=$sava_LDFLAGS
-   fi
-fi
-
 ### install and build examples
 
 EFL_CHECK_BUILD_EXAMPLES([enable_build_examples="yes"], [enable_build_examples="no"])
diff --git a/m4/efl_shm_open.m4 b/m4/efl_shm_open.m4
new file mode 100644 (file)
index 0000000..0bf1b0b
--- /dev/null
@@ -0,0 +1,69 @@
+dnl Copyright (C) 2010 Vincent Torri <vtorri at univ-evry dot fr>
+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 <sys/mman.h>
+#include <sys/stat.h>        /* For mode constants */
+#include <fcntl.h>           /* 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 <sys/mman.h>
+#include <sys/stat.h>        /* For mode constants */
+#include <fcntl.h>           /* 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])
+
+])
index a1d93ac..043ae44 100644 (file)
@@ -172,28 +172,8 @@ AC_ARG_ENABLE(generic-[]DOWN,
    ],
    [enable_module="auto"])
 
-SHM_OPEN_LIBS=""
-AC_COMPILE_IFELSE(
-   [AC_LANG_PROGRAM(
-       [[
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-       ]],
-       [[
-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"])
-AC_SUBST(SHM_OPEN_LIBS)
-
-AC_MSG_CHECKING([shm_open])
-AC_MSG_RESULT([${have_shm_open}])
+# shm_open
+EFL_CHECK_SHM_OPEN([have_shm_open="yes"], [have_shm_open="no"])
 
 if test "x${have_shm_open}" != "xyes"; then
   enable_generic="no"
index 6b00d28..ca9d22a 100644 (file)
@@ -15,4 +15,4 @@ internal_bin_PROGRAMS = em_generic_vlc
 
 em_generic_vlc_SOURCES = emotion_generic_vlc.c
 em_generic_vlc_DEPENDENCIES = $(top_srcdir)/src/modules/generic/Emotion_Generic_Plugin.h
-em_generic_vlc_LDADD = @GENERIC_VLC_LIBS@ -lpthread -lrt
+em_generic_vlc_LDADD = @GENERIC_VLC_LIBS@ -lpthread
index 7fd93e8..a5e9694 100644 (file)
@@ -2,6 +2,32 @@
 # include "config.h"
 #endif
 
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_ALLOCA_H
+# include <alloca.h>
+#elif !defined alloca
+# ifdef __GNUC__
+#  define alloca __builtin_alloca
+# elif defined _AIX
+#  define alloca __alloca
+# elif defined _MSC_VER
+#  include <malloc.h>
+#  define alloca _alloca
+# elif !defined HAVE_ALLOCA
+#  ifdef  __cplusplus
+extern "C"
+#  endif
+void *alloca (size_t);
+# endif
+#endif
+
 #include <stdio.h>
 
 #ifdef EMOTION_HAVE_EEZE
index 04fbab5..23be987 100644 (file)
@@ -22,7 +22,7 @@ includesdir = $(includedir)/emotion-@VMAJ@
 noinst_HEADERS = emotion_generic.h
 
 em_generic_la_SOURCES = emotion_generic.c
-em_generic_la_LIBADD = @EMOTION_LIBS@ @SHM_OPEN_LIBS@ $(top_builddir)/src/lib/libemotion.la
+em_generic_la_LIBADD = @EMOTION_LIBS@ @EFL_SHM_OPEN_LIBS@ $(top_builddir)/src/lib/libemotion.la
 em_generic_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version
 em_generic_la_LIBTOOLFLAGS = --tag=disable-static
 em_generic_la_DEPENDENCIES = emotion_generic.h Emotion_Generic_Plugin.h