]> Pileus Git - ~andy/gtk/blobdiff - configure.ac
configure.ac: Support multiple GDK backends in one build
[~andy/gtk] / configure.ac
index 522bf69f8b80a128bfa2248b4c51a42def2831e4..d163ca2a248babb3fdaf00c263d735a16b70ad14 100644 (file)
@@ -255,22 +255,57 @@ AC_ARG_ENABLE(xinput,
                               [support XInput extension if available [default=yes]])],,
               [enable_xinput="yes"])
 
-if test "$platform_win32" = yes; then
-  gdktarget=win32
-else
-  gdktarget=x11
+AC_ARG_ENABLE(x11-backend,
+              [AC_HELP_STRING([--enable-x11-backend],
+                              [enable the X11 gdk backend])],
+                             [backend_set=yes])
+AC_ARG_ENABLE(win32-backend,
+              [AC_HELP_STRING([--enable-win32-backend],
+                              [enable the Win32 gdk backend])],
+                             [backend_set=yes])
+AC_ARG_ENABLE(quartz-backend,
+              [AC_HELP_STRING([--enable-quartz-backend],
+                              [enable the quartz gdk backend])],
+                             [backend_set=yes])
+
+if test -z "$backend_set"; then
+  if test "$platform_win32" = yes; then
+    enable_win32_backend=yes
+  else
+    enable_x11_backend=yes
+  fi
+fi
+
+cairo_backends=
+GDK_BACKENDS=
+
+if test "x$enable_x11_backend" == xyes; then
+  # GDK calls the xlib backend "x11," cairo calls it "xlib." Other
+  # backend names are identical.
+  cairo_backends="$cairo_backends cairo-xlib"
+  GDK_BACKENDS="$GDK_BACKENDS x11"
+  # Pull in gio-unix for GDesktopAppInfo usage, see at least
+  # gdkapplaunchcontext-x11.c
+  GIO_PACKAGE=gio-unix-2.0
 fi
 
-AC_ARG_WITH(gdktarget,
-            AC_HELP_STRING([--with-gdktarget=@<:@x11/win32/quartz@:>@],
-                           [select non-default GDK target]),
-            gdktarget=$with_gdktarget)
+if test "x$enable_win32_backend" == xyes; then
+  cairo_backends="$cairo_backends cairo-win32"
+  GDK_BACKENDS="$GDK_BACKENDS win32"
+  GIO_PACKAGE=gio-2.0
+fi
 
-AC_SUBST(gdktarget)
-case $gdktarget in
-  x11|win32|quartz) ;;
-  *) AC_MSG_ERROR([Invalid target for GDK: use x11, quartz or win32.]);;
-esac
+if test "x$enable_quartz_backend" == xyes; then
+  cairo_backends="$cairo_backends cairo-quartz"
+  GDK_BACKENDS="$GDK_BACKENDS quartz"
+  GIO_PACKAGE=gio-2.0
+fi
+
+AC_SUBST(GDK_BACKENDS)
+
+if test -z "$GDK_BACKENDS"; then
+  AC_MSG_ERROR([No GDK backends selected.])
+fi
 
 if test "x$enable_debug" = "xyes"; then
   test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
@@ -363,18 +398,7 @@ PKG_CHECK_MODULES(BASE_DEPENDENCIES,
    cairo-gobject >= cairo_required_version dnl
    gdk-pixbuf-2.0 >= gdk_pixbuf_required_version])
 
-## In addition to checking that cairo is present, we also need to
-## check that the correct cairo backend is there. E.g. if the GDK
-## target is win32 we need the cairo-win32 backend and so on.
-cairo_backend=$gdktarget
-
-# GDK calls the xlib backend "x11," cairo calls it "xlib." Other
-# backend names are identical.
-if test "x$cairo_backend" = "xx11"; then
-   cairo_backend=xlib
-fi
-PKG_CHECK_MODULES(CAIRO_BACKEND,
-  [cairo-$cairo_backend >= cairo_required_version])
+PKG_CHECK_MODULES(CAIRO_BACKEND, [$cairo_backends])
 
 if test "$os_win32" != yes; then
     # libtool option to control which symbols are exported
@@ -744,11 +768,11 @@ else
 fi
 
 all_immodules="am-et,cedilla,cyrillic-translit"
-if test "$gdktarget" = "win32"; then
+if test "x$enable_win32_backend" == xyes; then
    all_immodules="${all_immodules},ime"
 fi
 all_immodules="${all_immodules},inuktitut,ipa,multipress,thai,ti-er,ti-et,viqr"
-if test "$gdktarget" = "x11"; then
+if test "x$enable_x11_backend" == xyes; then
    all_immodules="${all_immodules},xim"
 fi
 
@@ -842,7 +866,7 @@ GDK_EXTRA_CFLAGS=
 GTK_DEP_PACKAGES_FOR_X=
 GTK_DEP_LIBS_FOR_X=
 
-if test "x$gdktarget" = "xx11"; then
+if test "x$enable_x11_backend" == xyes; then
   X_PACKAGES=fontconfig
 
   #
@@ -1101,14 +1125,15 @@ else
   AM_CONDITIONAL(HAVE_X11R6, false)
 fi
 
-if test "x$gdktarget" = "xwin32"; then
+
+if test "x$enable_win32_backend" == xyes; then
   GDK_EXTRA_LIBS="$GDK_EXTRA_LIBS -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid"
   AM_CONDITIONAL(USE_WIN32, true)
 else
   AM_CONDITIONAL(USE_WIN32, false)
 fi
 
-if test "x$gdktarget" = "xquartz"; then
+if test "x$enable_quartz_backend" == xyes; then
   GDK_EXTRA_LIBS="$GDK_EXTRA_LIBS -framework Cocoa"
   AM_CONDITIONAL(USE_QUARTZ, true)
 else
@@ -1117,7 +1142,7 @@ fi
 
 # Check for Pango flags
 
-if test "x$gdktarget" = "xwin32"; then
+if test "x$enable_win32_backend" == xyes; then
        PANGO_PACKAGES="pangowin32 pangocairo"
 else
        PANGO_PACKAGES="pango pangocairo"
@@ -1152,12 +1177,7 @@ fi
 CFLAGS="$saved_cflags"
 LDFLAGS="$saved_ldflags"
 
-# Pull in gio-unix for GDesktopAppInfo usage, see at least gdkapplaunchcontext-x11.c
-if test "x$gdktarget" = "xx11"; then
-  GDK_PACKAGES="$PANGO_PACKAGES gio-unix-2.0 $X_PACKAGES gdk-pixbuf-2.0 cairo-$cairo_backend cairo-gobject"
-else
-  GDK_PACKAGES="$PANGO_PACKAGES gio-2.0 gdk-pixbuf-2.0 cairo-$cairo_backend cairo-gobject"
-fi
+GDK_PACKAGES="$PANGO_PACKAGES $GIO_PACKAGE $X_PACKAGES gdk-pixbuf-2.0 $cairo_backends cairo-gobject"
 
 GDK_DEP_LIBS="$GDK_EXTRA_LIBS `$PKG_CONFIG --libs $GDK_PACKAGES`"
 GDK_DEP_CFLAGS="`$PKG_CONFIG --cflags  gthread-2.0 $GDK_PACKAGES` $GDK_EXTRA_CFLAGS"
@@ -1207,7 +1227,7 @@ else
 fi
 
 GTK_PACKAGES="atk cairo cairo-gobject gdk-pixbuf-2.0 gio-2.0"
-if test "x$gdktarget" = "xx11"; then
+if test "x$enable_x11_backend" == xyes; then
   GTK_PACKAGES="$GTK_PACKAGES pangoft2"
 fi
 GTK_EXTRA_LIBS=
@@ -1524,18 +1544,18 @@ _______EOF
        fi
 ],[
 gdk_windowing=''
-if expr "$gdktarget" : ".*x11.*" > /dev/null ; then
-  gdk_windowing='$gdk_windowing
-#define GDK_WINDOWING_X11'
+if test "x$enable_x11_backend" == xyes; then
+  gdk_windowing="\$gdk_windowing
+#define GDK_WINDOWING_X11"
 fi
-if expr "$gdktarget" : ".*win32.*" > /dev/null ; then
-  gdk_windowing='$gdk_windowing
+if test "x$enable_win32_backend" == xyes; then
+  gdk_windowing="\$gdk_windowing
 #define GDK_NATIVE_WINDOW_POINTER
-#define GDK_WINDOWING_WIN32'
+#define GDK_WINDOWING_WIN32"
 fi
-if expr "$gdktarget" : ".*quartz.*" > /dev/null ; then
-  gdk_windowing='$gdk_windowing
-#define GDK_WINDOWING_QUARTZ'
+if test "x$enable_quartz_backend" == xyes; then
+  gdk_windowing="\$gdk_windowing
+#define GDK_WINDOWING_QUARTZ"
 fi
 ])
 
@@ -1626,4 +1646,4 @@ perf/Makefile
 AC_OUTPUT
 
 echo "configuration:
-        target:             $gdktarget"
+        backends:             $GDK_BACKENDS"