Skip to content

Commit

Permalink
configure.ac: Support multiple GDK backends in one build
Browse files Browse the repository at this point in the history
  • Loading branch information
krh committed Jan 3, 2011
1 parent ae7e5fc commit cacee7e
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 72 deletions.
4 changes: 2 additions & 2 deletions Makefile.am
Expand Up @@ -71,8 +71,8 @@ gtk+-*-3.0-uninstalled.pc: gtk+-3.0-uninstalled.pc
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = gdk-3.0.pc gtk+-3.0.pc gail-3.0.pc

pkgconfig_DATA += $(patsubst %,gtk+-%-3.0.pc,@gdktarget@)
pkgconfig_DATA += $(patsubst %,gdk-%-3.0.pc,@gdktarget@)
pkgconfig_DATA += ${GDK_BACKENDS:%=gtk+-%-3.0.pc}
pkgconfig_DATA += ${GDK_BACKENDS:%=gdk-%-3.0.pc}

if OS_UNIX
pkgconfig_DATA += gtk+-unix-print-3.0.pc
Expand Down
10 changes: 8 additions & 2 deletions Makefile.decl
Expand Up @@ -17,9 +17,15 @@ XIDS = 101 102 103 104 105 106 107 197 199 211 223 227 293 307 308 309 310 311 \
1008 1009 4703 4721 4723 4729 4733 4751 9973 9974 9975 9976 9977 9978 9979 \
9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 \
9995 9996 9997 9998 9999

if USE_X11
SKIP_GDKTARGET = \
false
else
SKIP_GDKTARGET = \
test "$(gdktarget)" != "x11" \
&& echo "Gtk+Tests:INFO: Skipping GUI tests for non-X11 target."
echo "Gtk+Tests:INFO: Skipping GUI tests for non-X11 target."
endif

XVFB_START = \
${XVFB} -help 2>/dev/null 1>&2 \
&& XID=`for id in $(XIDS) ; do test -e /tmp/.X$$id-lock || { echo $$id; exit 0; }; done; exit 1` \
Expand Down
2 changes: 1 addition & 1 deletion README.win32
Expand Up @@ -85,7 +85,7 @@ LDFLAGS="-L/devel/dist/${ARCH}/${LIBPNG}/lib \
LIBS=-lintl \
CFLAGS=-O2 \
./configure \
--with-gdktarget=win32 \
--enable-win32-backend \
--disable-gdiplus \
--with-included-immodules \
--without-libjasper \
Expand Down
116 changes: 68 additions & 48 deletions configure.ac
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

#
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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
])

Expand Down Expand Up @@ -1626,4 +1646,4 @@ perf/Makefile
AC_OUTPUT

echo "configuration:
target: $gdktarget"
backends: $GDK_BACKENDS"
28 changes: 20 additions & 8 deletions docs/reference/gtk/building.sgml
Expand Up @@ -360,9 +360,14 @@ How to compile GTK+ itself
<group>
<arg>--enable-packagekit</arg>
<arg>--disable-packagekit</arg>
</group>
<group>
<arg>--with-gdktarget=[x11/win32/quartz]</arg>
</group>
<group>
<arg>--enable-x11-backend</arg>
<arg>--disable-x11-backend</arg>
<arg>--enable-win32-backend</arg>
<arg>--disable-win32-backend</arg>
<arg>--enable-quartz-backend</arg>
<arg>--disable-quartz-backend</arg>
</group>
<group>
<arg>--enable-introspection=[no/auto/yes]</arg>
Expand Down Expand Up @@ -545,13 +550,20 @@ How to compile GTK+ itself
</formalpara>

<formalpara>
<title><systemitem>--with-gdktarget</systemitem></title>
<title><systemitem>--enable-x11-backend</systemitem>,
<systemitem>--disable-x11-backend</systemitem>,
<systemitem>--enable-win32-backend</systemitem>,
<systemitem>--disable-win32-backend</systemitem>,
<systemitem>--enable-quartz-backend</systemitem>,
and <systemitem>--disable-quartz-backend</systemitem></title>

<para>
Toggles between the supported backends for GDK.
The default is x11, unless the platform is Windows, in which
case the default is win32. Other supported backends are
the quartz backend for OS X.
Enables specific backends for GDK. If none of these options
are given, the x11 backend will be enabled by default,
unless the platform is Windows, in which case the default is
win32. If any backend is explicitly enabled or disabled, no
other platform will be enabled automatically. Other
supported backends are the quartz backend for OS X.
</para>
</formalpara>
<formalpara>
Expand Down
2 changes: 1 addition & 1 deletion gdk-3.0.pc.in
Expand Up @@ -2,7 +2,7 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
target=@gdktarget@
targets=@GDK_BACKENDS@

Name: GDK
Description: GTK+ Drawing Kit
Expand Down
5 changes: 2 additions & 3 deletions gdk/Makefile.am
Expand Up @@ -8,7 +8,8 @@ INTROSPECTION_COMPILER_ARGS = \
--includedir=$(srcdir) \
--includedir=.

SUBDIRS = $(gdktarget) . tests
SUBDIRS = $(GDK_BACKENDS) . tests

DIST_SUBDIRS = win32 x11 quartz tests

CLEANFILES =
Expand Down Expand Up @@ -38,8 +39,6 @@ INCLUDES = \
$(GTK_DEBUG_FLAGS) \
$(GDK_DEP_CFLAGS)

gtarget=$(gdktarget)

if PLATFORM_WIN32
no_undefined = -no-undefined
endif
Expand Down
6 changes: 3 additions & 3 deletions gtk+-3.0-uninstalled.pc.in
@@ -1,10 +1,10 @@
target=@gdktarget@
targets=@GDK_BACKENDS@

gtk_binary_version=@GTK_BINARY_VERSION@

Name: GTK+ Uninstalled
Description: GTK+ Graphical UI Library (${target} target), Not Installed
Version: @VERSION@
Requires: gdk-${target}-@GTK_API_VERSION@-uninstalled @GTK_PACKAGES@
Libs: ${pc_top_builddir}/${pcfiledir}/gtk/libgtk-${target}-@GTK_API_VERSION@.la @GTK_EXTRA_LIBS@
Requires: gdk-@GTK_API_VERSION@-uninstalled @GTK_PACKAGES@
Libs: ${pc_top_builddir}/${pcfiledir}/gtk/libgtk-@GTK_API_VERSION@.la @GTK_EXTRA_LIBS@
Cflags: -I${pc_top_builddir}/${pcfiledir}/@srcdir@ -I${pc_top_builddir}/${pcfiledir} @GTK_EXTRA_CFLAGS@
2 changes: 1 addition & 1 deletion gtk+-3.0.pc.in
Expand Up @@ -2,7 +2,7 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
target=@gdktarget@
targets=@GDK_BACKENDS@

gtk_binary_version=@GTK_BINARY_VERSION@
gtk_host=@host@
Expand Down
2 changes: 1 addition & 1 deletion gtk+-unix-print-3.0.pc.in
Expand Up @@ -2,7 +2,7 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
target=@gdktarget@
targets=@GDK_BACKENDS@

gtk_binary_version=@GTK_BINARY_VERSION@
gtk_host=@host@
Expand Down
2 changes: 0 additions & 2 deletions gtk/Makefile.am
Expand Up @@ -57,8 +57,6 @@ INCLUDES = \
$(gtk_clipboard_dnd_c_sources_CFLAGS) \
$(INCLUDED_IMMODULE_DEFINE)

gtarget=$(gdktarget)

if PLATFORM_WIN32
no_undefined = -no-undefined
endif
Expand Down

0 comments on commit cacee7e

Please sign in to comment.