From b8b59d939de175c91c94c273bb01ed64b7d36828 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sun, 17 Nov 2013 18:51:20 +0100 Subject: [PATCH] Configure: Moved configure's detection of XShm to a dedicated macro The original check was not compliant with autoconf's syntax, did not have a very good behaviour for user and was not easy to make evolve. The new macro: - uses as much as possible autoconf macros for portability and code consistency; - checks also for header usability with the compiler; - provides a consistent behaviour on yes/no/auto (if user explicitly enables support, do not silently disable if not found; if library is found but not the header, complain to let user install it or explicitly disable support) Signed-off-by: Christophe CURIS --- configure.ac | 32 ++++++++++---------------------- m4/wm_xext_check.m4 | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 22 deletions(-) diff --git a/configure.ac b/configure.ac index 72597747..2f1fc71c 100644 --- a/configure.ac +++ b/configure.ac @@ -499,6 +499,16 @@ AC_ARG_ENABLE([shape], [enable_shape=auto]) WM_XEXT_CHECK_XSHAPE +dnl MIT-SHM support +dnl =============== +AC_ARG_ENABLE([shm], + [AS_HELP_STRING([--disable-shm], [disable usage of MIT-SHM extension])], + [AS_CASE(["$enableval"], + [yes|no], [], + [AC_MSG_ERROR([bad value $enableval for --enable-shm]) ]) ], + [enable_shm=auto]) +WM_XEXT_CHECK_XSHM + dnl XINERAMA support dnl ================ AC_ARG_ENABLE([xinerama], @@ -587,28 +597,6 @@ AC_SUBST(XFTFLAGS) AC_SUBST(XFTLIBS) -dnl MIT-SHM support -dnl =============== -shm=yes -AC_ARG_ENABLE(shm, AS_HELP_STRING([--disable-shm], [disable usage of MIT-SHM extension]), - shm=$enableval, shm=yes) - -if test "$shm" = yes; then - AC_CHECK_LIB(Xext, XShmAttach, ok=yes, ok=no, $XLFLAGS $XLIBS) - - if test "$ok" = yes; then - AC_CHECK_FUNC(shmget, ok=yes, ok=no) - fi - - if test "$ok" = yes; then - if test "$added_xext" = no; then - XLIBS="-lXext $XLIBS" - fi - AC_DEFINE(USE_XSHM, 1, [define if X's shared memory extension is available (set by configure)]) - fi -fi - - dnl ============================================== dnl Graphic Format Libraries dnl ============================================== diff --git a/m4/wm_xext_check.m4 b/m4/wm_xext_check.m4 index a8c45f4a..f5b44f3b 100644 --- a/m4/wm_xext_check.m4 +++ b/m4/wm_xext_check.m4 @@ -39,6 +39,42 @@ AC_DEFUN_ONCE([WM_XEXT_CHECK_XSHAPE], ]) dnl AC_DEFUN +# WM_XEXT_CHECK_XSHM +# ------------------ +# +# Check for the MIT-SHM extension for Shared Memory support +# The check depends on variable 'enable_shm' being either: +# yes - detect, fail if not found +# no - do not detect, disable support +# auto - detect, disable if not found +# +# When found, append appropriate stuff in XLIBS, and append info to +# the variable 'supported_xext' +# When not found, append info to variable 'unsupported' +AC_DEFUN_ONCE([WM_XEXT_CHECK_XSHM], +[WM_LIB_CHECK([XShm], [-lXext], [XShmAttach], [$XLIBS], + [wm_save_CFLAGS="$CFLAGS" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([dnl +@%:@include +@%:@include +], [dnl + XShmSegmentInfo si; + + XShmAttach(NULL, &si);])], + [], + [AC_MSG_ERROR([found $CACHEVAR but cannot compile using XShm header])]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([dnl +@%:@include +@%:@include +], [dnl + shmget(IPC_PRIVATE, 1024, IPC_CREAT);])], + [], + [AC_MSG_ERROR([found $CACHEVAR but cannot compile using ipc/shm headers])]) + CFLAGS="$wm_save_CFLAGS"], + [supported_xext], [XLIBS], [enable_shm], [-])dnl +]) dnl AC_DEFUN + + # WM_XEXT_CHECK_XINERAMA # ---------------------- # -- 2.11.4.GIT