From 767bac373b93988410269f170a1dcbd45bc97777 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 25 Jun 2010 05:29:23 +0200 Subject: [PATCH] gtk: build for both gtk2 and gtk3 --- Makefile.am | 8 ++++++ avahi-discover-standalone/Makefile.am | 18 ++++++++++--- avahi-ui-gtk3.pc.in | 11 ++++++++ avahi-ui.pc.in | 2 +- avahi-ui/Makefile.am | 29 ++++++++++++++++++-- configure.ac | 38 +++++++++++++++++++++++---- 6 files changed, 94 insertions(+), 12 deletions(-) create mode 100644 avahi-ui-gtk3.pc.in diff --git a/Makefile.am b/Makefile.am index 02e3a9c..15a6cd8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -48,6 +48,7 @@ EXTRA_DIST = \ avahi-compat-libdns_sd.pc.in \ avahi-compat-howl.pc.in \ avahi-ui.pc.in \ + avahi-ui-gtk3.pc.in \ doxygen_to_devhelp.xsl SUBDIRS = \ @@ -196,6 +197,13 @@ CLEANFILES += avahi-ui.pc endif endif +if HAVE_GTK3 +if HAVE_DBUS +pkgconfig_DATA += avahi-ui-gtk3.pc +CLEANFILES += avahi-ui-gtk3.pc +endif +endif + if HAVE_QT3 pkgconfig_DATA += avahi-qt3.pc CLEANFILES += avahi-qt3.pc diff --git a/avahi-discover-standalone/Makefile.am b/avahi-discover-standalone/Makefile.am index 1163575..3995c0a 100644 --- a/avahi-discover-standalone/Makefile.am +++ b/avahi-discover-standalone/Makefile.am @@ -23,8 +23,8 @@ interfaces = \ # This cool debug trap works on i386/gcc only AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' -if HAVE_GTK -if HAVE_GLIB +if HAVE_GTK2OR3 +if HAVE_GLIB bin_PROGRAMS = \ avahi-discover-standalone @@ -33,15 +33,25 @@ avahi_discover_standalone_SOURCES = \ avahi_discover_standalone_CFLAGS = \ $(AM_CFLAGS) \ - $(GLIB20_CFLAGS) $(GTK20_CFLAGS) \ -DAVAHI_INTERFACES_DIR=\"$(interfacesdir)\" avahi_discover_standalone_LDADD = \ $(AM_LDADD) \ ../avahi-common/libavahi-common.la \ ../avahi-glib/libavahi-glib.la \ - ../avahi-core/libavahi-core.la \ + ../avahi-core/libavahi-core.la + +if HAVE_GTK3 +avahi_discover_standalone_CFLAGS += \ + $(GLIB30_CFLAGS) $(GTK30_CFLAGS) +avahi_discover_standalone_LDADD += \ + $(GLIB30_LIBS) $(GTK30_LIBS) +else +avahi_discover_standalone_CFLAGS += \ + $(GLIB20_CFLAGS) $(GTK20_CFLAGS) +avahi_discover_standalone_LDADD += \ $(GLIB20_LIBS) $(GTK20_LIBS) +endif interfaces_DATA = $(interfaces) diff --git a/avahi-ui-gtk3.pc.in b/avahi-ui-gtk3.pc.in new file mode 100644 index 0000000..27c4322 --- /dev/null +++ b/avahi-ui-gtk3.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=${prefix} +libdir=@libdir@ +includedir=${prefix}/include + +Name: avahi-ui +Description: Avahi Multicast DNS Responder (Common GTK3 UI support) +Requires: gtk+-3.0 avahi-client avahi-glib +Version: @PACKAGE_VERSION@ +Libs: -L${libdir} -lavahi-ui-gtk3 +Cflags: -D_REENTRANT -I${includedir} diff --git a/avahi-ui.pc.in b/avahi-ui.pc.in index ca9c2ef..9edeea9 100644 --- a/avahi-ui.pc.in +++ b/avahi-ui.pc.in @@ -4,7 +4,7 @@ libdir=@libdir@ includedir=${prefix}/include Name: avahi-ui -Description: Avahi Multicast DNS Responder (Common GTK UI support) +Description: Avahi Multicast DNS Responder (Common GTK2 UI support) Requires: gtk+-2.0 avahi-client avahi-glib Version: @PACKAGE_VERSION@ Libs: -L${libdir} -lavahi-ui diff --git a/avahi-ui/Makefile.am b/avahi-ui/Makefile.am index 9d5a07a..72d6023 100644 --- a/avahi-ui/Makefile.am +++ b/avahi-ui/Makefile.am @@ -27,7 +27,7 @@ desktop_DATA_in_in = bssh.desktop.in.in bvnc.desktop.in.in EXTRA_DIST = $(desktop_DATA_in_in) -if HAVE_GTK +if HAVE_GTK2OR3 AM_CFLAGS += -DGNOMELOCALEDIR=\"$(datadir)/locale\" if HAVE_DBUS if HAVE_GLIB @@ -37,8 +37,17 @@ avahiincludedir=$(includedir)/avahi-ui avahiinclude_HEADERS = \ avahi-ui.h -lib_LTLIBRARIES = \ +lib_LTLIBRARIES = + +if HAVE_GTK +lib_LTLIBRARIES += \ libavahi-ui.la +endif + +if HAVE_GTK3 +lib_LTLIBRARIES += \ + libavahi-ui-gtk3.la +endif libavahi_ui_la_SOURCES = \ avahi-ui.h avahi-ui.c @@ -46,15 +55,25 @@ libavahi_ui_la_CFLAGS = $(AM_CFLAGS) $(GTK20_CFLAGS) libavahi_ui_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la ../avahi-client/libavahi-client.la ../avahi-glib/libavahi-glib.la $(GTK20_LIBS) libavahi_ui_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_UI_VERSION_INFO) +libavahi_ui_gtk3_la_SOURCES = $(libavahi_ui_la_SOURCES) +libavahi_ui_gtk3_la_CFLAGS = $(AM_CFLAGS) $(GTK30_CFLAGS) +libavahi_ui_gtk3_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la ../avahi-client/libavahi-client.la ../avahi-glib/libavahi-glib.la $(GTK30_LIBS) +libavahi_ui_gtk3_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_UI_VERSION_INFO) + if HAVE_GDBM libavahi_ui_la_SOURCES += ../avahi-utils/stdb.h ../avahi-utils/stdb.c libavahi_ui_la_CFLAGS += -DDATABASE_FILE=\"$(pkglibdir)/service-types.db\" libavahi_ui_la_LIBADD += -lgdbm + +libavahi_ui_gtk3_la_CFLAGS += -DDATABASE_FILE=\"$(pkglibdir)/service-types.db\" +libavahi_ui_gtk3_la_LIBADD += -lgdbm endif if HAVE_DBM libavahi_ui_la_SOURCES += ../avahi-utils/stdb.h ../avahi-utils/stdb.c libavahi_ui_la_CFLAGS += -DDATABASE_FILE=\"$(pkglibdir)/service-types.db\" + +libavahi_ui_gtk3_la_CFLAGS += -DDATABASE_FILE=\"$(pkglibdir)/service-types.db\" endif bin_PROGRAMS = bssh @@ -62,8 +81,14 @@ desktop_DATA += bssh.desktop bvnc.desktop @INTLTOOL_DESKTOP_RULE@ bssh_SOURCES = bssh.c + +if HAVE_GTK3 +bssh_CFLAGS = $(AM_CFLAGS) $(GTK30_CFLAGS) +bssh_LDADD = $(AM_LDADD) $(GTK30_LIBS) ../avahi-client/libavahi-client.la ../avahi-common/libavahi-common.la libavahi-ui-gtk3.la +else bssh_CFLAGS = $(AM_CFLAGS) $(GTK20_CFLAGS) bssh_LDADD = $(AM_LDADD) $(GTK20_LIBS) ../avahi-client/libavahi-client.la ../avahi-common/libavahi-common.la libavahi-ui.la +endif install-exec-local: cd $(DESTDIR)/$(bindir) && \ diff --git a/configure.ac b/configure.ac index 18ae214..2366a00 100644 --- a/configure.ac +++ b/configure.ac @@ -518,10 +518,10 @@ fi AM_CONDITIONAL(HAVE_QT4, test "x$HAVE_QT4" = "xyes") # -# Check for GTK+ +# Check for GTK+ 2.0 # AC_ARG_ENABLE(gtk, - AS_HELP_STRING([--disable-gtk],[Disable use of GTK+]), + AS_HELP_STRING([--disable-gtk],[Disable use of GTK+ 2]), [case "${enableval}" in yes) HAVE_GTK=yes ;; no) HAVE_GTK=no ;; @@ -537,6 +537,28 @@ if test "x$HAVE_GTK" = "xyes" ; then fi AM_CONDITIONAL(HAVE_GTK, test "x$HAVE_GTK" = "xyes") +# +# Check for GTK+ 3.0 +# +AC_ARG_ENABLE(gtk3, + AS_HELP_STRING([--disable-gtk3],[Disable use of GTK+ 3]), + [case "${enableval}" in + yes) HAVE_GTK3=yes ;; + no) HAVE_GTK3=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-gtk3) ;; + esac], + [HAVE_GTK3=yes]) + +if test "x$HAVE_GTK3" = "xyes" ; then + # Check for GTK 3.0 + PKG_CHECK_MODULES(GTK30, [ gtk+-3.0 ]) + AC_SUBST(GTK30_CFLAGS) + AC_SUBST(GTK30_LIBS) +fi +AM_CONDITIONAL(HAVE_GTK3, test "x$HAVE_GTK3" = "xyes") + +AM_CONDITIONAL(HAVE_GTK2OR3, test "x$HAVE_GTK3" = "xyes" -o "x$HAVE_GTK2" = "xyes" ) + # # D-Bus # @@ -1104,7 +1126,8 @@ echo " CFLAGS: ${CFLAGS} Enable GLIB: ${HAVE_GLIB} Enable GLIB GObject: ${HAVE_GOBJECT} - Enable GTK: ${HAVE_GTK} + Enable GTK 2.0: ${HAVE_GTK} + Enable GTK 3.0: ${HAVE_GTK3} Enable D-Bus: ${HAVE_DBUS} With XML: ${with_xml} Enable GDBM: ${HAVE_GDBM} @@ -1156,8 +1179,13 @@ if test "x$ENABLE_AUTOIPD" = "xyes" -a "x$HAVE_LIBDAEMON" != "xyes" ; then ENABLE_AUTOIPD="no (You need libdaemon!)" fi +HAVE_GTK2OR3=no +if test "x$HAVE_GTK" = "xyes" -o "x$HAVE_GTK3" = "xyes" ; then + HAVE_GTK2OR3=yes +fi + BUILD_UI="no" -if test "x$HAVE_GTK" = "xyes" -a "x$BUILD_CLIENT" = "xyes" ; then +if test "x$HAVE_GTK2OR3" = "xyes" -a "x$BUILD_CLIENT" = "xyes" ; then BUILD_UI="yes" fi @@ -1175,7 +1203,7 @@ echo "\ Building avahi-python: ${BUILD_PYTHON} Building libavahi-glib: ${HAVE_GLIB} Building libavahi-gobject: ${BUILD_GOBJECT} - Building avahi-discover-standalone: ${HAVE_GTK} + Building avahi-discover-standalone: ${HAVE_GTK2OR3} Building libavahi-qt3: ${HAVE_QT3} Building libavahi-qt4: ${HAVE_QT4} Building avahi-sharp: ${HAVE_MONO} -- 2.39.2