1dnl macros for X-related detections
2dnl AC_SUBST's HAVE_X, X_CFLAGS, X_LIBS
3AC_DEFUN([AG_GST_CHECK_X],
4[
5  AC_PATH_XTRA
6  ac_cflags_save="$CFLAGS"
7  ac_cppflags_save="$CPPFLAGS"
8  CFLAGS="$CFLAGS $X_CFLAGS"
9  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
10
11  dnl now try to find the HEADER
12  HAVE_X="no"
13  AC_CHECK_HEADER([X11/Xlib.h], [
14    dnl and then the library with the most uniquitous function
15    AC_CHECK_LIB(X11, [XSync], [HAVE_X="yes"], [], [$X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS])
16  ], [], [AC_INCLUDES_DEFAULT])
17
18  if test "x$HAVE_X" = "xno"
19  then
20    AC_MSG_NOTICE([cannot find X11 development files])
21  else
22    dnl this is much more than we want
23    X_LIBS="$X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS"
24    dnl AC_PATH_XTRA only defines the path needed to find the X libs,
25    dnl it does not add the libs; therefore we add them here
26    X_LIBS="$X_LIBS -lX11"
27    AC_SUBST(X_CFLAGS)
28    AC_SUBST(X_LIBS)
29  fi
30  AC_SUBST(HAVE_X)
31
32  CFLAGS="$ac_cflags_save"
33  CPPFLAGS="$ac_cppflags_save"
34])
35
36dnl *** XVideo ***
37dnl Look for the PIC library first, Debian requires it.
38dnl Check debian-devel archives for gory details.
39dnl 20020110:
40dnl At the moment XFree86 doesn't distribute shared libXv due
41dnl to unstable API.  On many platforms you CAN NOT link a shared
42dnl lib to a static non-PIC lib.  This is what the xvideo GStreamer
43dnl plug-in wants to do.  So Debian distributes a PIC compiled
44dnl version of the static lib for plug-ins to link to when it is
45dnl inappropriate to link the main application to libXv directly.
46dnl FIXME: add check if this platform can support linking to a
47dnl        non-PIC libXv, if not then don not use Xv.
48dnl FIXME: perhaps warn user if they have a shared libXv since
49dnl        this is an error until XFree86 starts shipping one
50AC_DEFUN([AG_GST_CHECK_XV],
51[
52  if test x$HAVE_X = xyes; then
53    AC_CHECK_LIB(Xv_pic, XvQueryExtension,
54                 HAVE_XVIDEO="yes", HAVE_XVIDEO="no",
55                 $X_LIBS -lXext)
56
57    if test x$HAVE_XVIDEO = xyes; then
58      XVIDEO_LIBS="-lXv_pic -lXext"
59      AC_SUBST(XVIDEO_LIBS)
60    else
61      dnl try again using something else if we didn't find it first
62      if test x$HAVE_XVIDEO = xno; then
63        AC_CHECK_LIB(Xv, XvQueryExtension,
64                   HAVE_XVIDEO="yes", HAVE_XVIDEO="no",
65                   $X_LIBS -lXext)
66
67        if test x$HAVE_XVIDEO = xyes; then
68          XVIDEO_LIBS="-lXv -lXext"
69          AC_SUBST(XVIDEO_LIBS)
70        fi
71      fi
72    fi
73  fi
74])
75