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