From de924d73d145c21f2836a79e2ad4ff08af733278 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 13 Aug 2014 16:43:03 +0900 Subject: [PATCH] add the build configuration to distinguish between x11 and wayland Change-Id: Id6008924406df494cbdc2234e4f972c7d372d813 --- configure.ac | 14 ++++++++++++++ packaging/libtbm.spec | 19 ++++++++++++++++++- src/tbm_bufmgr.c | 10 ++++++++-- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index a338076..c4440d3 100644 --- a/configure.ac +++ b/configure.ac @@ -41,6 +41,13 @@ DEFAULT_BUFMGR_MODULE_PATH="/usr/lib/bufmgr" AC_ARG_WITH(bufmgr-module-path, AS_HELP_STRING([--with-bufmgr-module-path=PATH], [tbm bufmgr module dir]), [ BUFMGR_MODULE_PATH="$withval" ], [ BUFMGR_MODULE_PATH="${DEFAULT_BUFMGR_MODULE_PATH}" ]) + +# set the window system platform where the bufmgr initializes +AC_ARG_WITH(tbm-platform, AS_HELP_STRING([--with-tbm-platform=WINSYS], [tbm platform (default: X11)]), + [ TBM_PLATFORM="$withval" ], + [ TBM_PLATFORM="X11" ]) +AC_SUBST(TBM_PLATFORM) + #AC_DEFINE(BUFMGR_MODULE_DIR, "${BUFMGR_MODULE_PATH}", [Directory for the modules of tbm_bufmgr]) AC_DEFINE_UNQUOTED(BUFMGR_MODULE_DIR, "${BUFMGR_MODULE_PATH}", [Directory for the modules of tbm_bufmgr]) @@ -63,6 +70,12 @@ LIBTBM_LIBS="$PTHREADSTUBS_LIBS $LIBDRM_LIBS $LIBDRI2_LIBS $X11_LIBS $CAPI_LIBS" AC_SUBST(LIBTBM_CFLAGS) AC_SUBST(LIBTBM_LIBS) +if test "x$TBM_PLATFORM" = "xX11"; then + AC_DEFINE(HAVE_X11,1,[The window system is X11.]) +else + AC_DEFINE(HAVE_WAYLAND,1,[The window system is WAYLAND.]) +fi + AC_OUTPUT([ src/Makefile drm_slp/Makefile @@ -75,5 +88,6 @@ echo "LDFLAGS : $LDFLAGS" echo "LIBTBM_CFLAGS : $LIBTBM_CFLAGS" echo "LIBTBM_LIBS : $LIBTBM_LIBS" echo "BUFMGR_MODULE_DIR : $BUFMGR_MODULE_PATH" +echo "TBM_PLATFORM : $TBM_PLATFORM" echo "" diff --git a/packaging/libtbm.spec b/packaging/libtbm.spec index c31276e..4cbd0be 100644 --- a/packaging/libtbm.spec +++ b/packaging/libtbm.spec @@ -1,3 +1,6 @@ +#%bcond_with x +%bcond_with wayland + Name: libtbm Version: 1.1.0 Release: 3 @@ -8,8 +11,11 @@ Source0: %{name}-%{version}.tar.gz BuildRequires: pkgconfig(pthread-stubs) BuildRequires: pkgconfig(libdrm) +%if %{with wayland} +%else BuildRequires: pkgconfig(x11) BuildRequires: pkgconfig(libdri2) +%endif BuildRequires: pkgconfig(capi-base-common) %description @@ -31,8 +37,13 @@ Development Files. %build -%reconfigure --prefix=%{_prefix} \ +%if %{with wayland} +%reconfigure --prefix=%{_prefix} --with-tbm-platform=WAYLAND \ + CFLAGS="${CFLAGS} -Wall -Werror" LDFLAGS="${LDFLAGS} -Wl,--hash-style=both -Wl,--as-needed" +%else +%reconfigure --prefix=%{_prefix} --with-tbm-platform=X11 \ CFLAGS="${CFLAGS} -Wall -Werror" LDFLAGS="${LDFLAGS} -Wl,--hash-style=both -Wl,--as-needed" +%endif make %{?_smp_mflags} @@ -55,7 +66,10 @@ rm -rf %{buildroot} %defattr(-,root,root,-) /usr/share/license/%{name} %{_libdir}/libtbm.so.* +%if %{with wayland} +%else %{_libdir}/libdrm_slp.so.* +%endif %files devel %defattr(-,root,root,-) @@ -66,6 +80,9 @@ rm -rf %{buildroot} %{_includedir}/tbm_bufmgr_backend.h %{_includedir}/tbm_type.h %{_libdir}/libtbm.so +%if %{with wayland} +%else %{_libdir}/libdrm_slp.so +%endif %{_libdir}/pkgconfig/libtbm.pc diff --git a/src/tbm_bufmgr.c b/src/tbm_bufmgr.c index 13224b1..35d6885 100755 --- a/src/tbm_bufmgr.c +++ b/src/tbm_bufmgr.c @@ -36,9 +36,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "tbm_bufmgr_backend.h" #include "tbm_bufmgr_tgl.h" #include "list.h" +#ifdef HAVE_X11 #include #include #include +#endif #define DEBUG #ifdef DEBUG @@ -807,8 +809,9 @@ static int _tbm_load_module (tbm_bufmgr bufmgr, int fd) return ret; } +#ifdef HAVE_X11 static int -_tbm_bufmgr_get_drm_fd() +_tbm_bufmgr_get_drm_fd_x11() { int screen; Display *display; @@ -893,6 +896,7 @@ _tbm_bufmgr_get_drm_fd() XCloseDisplay(display); return fd; } +#endif tbm_bufmgr tbm_bufmgr_init (int fd) @@ -926,7 +930,9 @@ tbm_bufmgr_init (int fd) if (fd < 0) { - fd = _tbm_bufmgr_get_drm_fd(); +#ifdef HAVE_X11 + fd = _tbm_bufmgr_get_drm_fd_x11(); +#endif if (fd < 0) { TBM_LOG ("[libtbm:%d] Fail get drm fd\n", getpid()); -- 2.7.4