[avahi] [Patch] Add Qt5 support

Michael Jones avahi at jonesmz.com
Fri Oct 24 14:55:28 PDT 2014


Also tracked here: https://bugs.gentoo.org/show_bug.cgi?id=525884




diff -rupN avahi-0.6.31/avahi-qt/Makefile.am avahi-qt5/avahi-qt/Makefile.am
--- avahi-0.6.31/avahi-qt/Makefile.am    2010-08-25 19:51:39.011153001 -0500
+++ avahi-qt5/avahi-qt/Makefile.am    2014-10-19 13:55:14.825086832 -0500
@@ -65,4 +65,26 @@ libavahi_qt4_la_LIBADD = $(AM_LDADD) ../
 libavahi_qt4_la_LDFLAGS = $(AM_LDFLAGS) -version-info
$(LIBAVAHI_QT4_VERSION_INFO)
 endif

+if HAVE_QT5
+
+avahiqt5includedir=$(includedir)/avahi-qt5
+avahiqt5include_HEADERS = \
+    qt-watch.h
+
+lib_LTLIBRARIES += \
+    libavahi-qt5.la
+
+BUILT_SOURCES += qt-watch.moc5
+
+libavahi_qt5_la_SOURCES = \
+    qt-watch.cpp
+
+qt-watch.moc5: qt-watch.cpp
+    $(AM_V_GEN)$(MOC_QT5) $^ > $@
+
+libavahi_qt5_la_CPPFLAGS = $(AM_CFLAGS) $(QT5_CFLAGS) -DQT5
$(VISIBILITY_HIDDEN_CFLAGS)
+libavahi_qt5_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la
$(QT5_LIBS)
+libavahi_qt5_la_LDFLAGS = $(AM_LDFLAGS) -version-info
$(LIBAVAHI_QT5_VERSION_INFO)
+endif
+
 CLEANFILES = $(BUILT_SOURCES)
diff -rupN avahi-0.6.31/avahi-qt/qt-watch.cpp
avahi-qt5/avahi-qt/qt-watch.cpp
--- avahi-0.6.31/avahi-qt/qt-watch.cpp    2010-08-25 19:51:39.011153001
-0500
+++ avahi-qt5/avahi-qt/qt-watch.cpp    2014-10-19 13:56:14.076226518 -0500
@@ -18,10 +18,10 @@
 ***/

 #include <sys/time.h>
-#ifdef QT4
-#include <Qt/qsocketnotifier.h>
-#include <Qt/qobject.h>
-#include <Qt/qtimer.h>
+#if defined(QT5) || defined(QT4)
+#include <QSocketNotifier>
+#include <QObject>
+#include <QTimer>
 #else
 #include <qsocketnotifier.h>
 #include <qobject.h>
@@ -114,7 +114,7 @@ AvahiTimeout::AvahiTimeout(const struct
     m_callback(callback), m_userdata(userdata)
 {
     connect(&m_timer, SIGNAL(timeout()), this, SLOT(timeout()));
-#ifdef QT4
+#if defined(QT5) || defined(QT4)
     m_timer.setSingleShot(true);
 #endif
     update(tv);
@@ -125,7 +125,7 @@ void AvahiTimeout::update(const struct t
     m_timer.stop();
     if (tv) {
     AvahiUsec u = avahi_age(tv)/1000;
-#ifdef QT4
+#if defined(QT5) || defined(QT4)
     m_timer.start( (u>0) ? 0 : -u);
 #else
     m_timer.start( (u>0) ? 0 : -u,true);
@@ -191,8 +191,10 @@ const AvahiPoll* avahi_qt_poll_get(void)
     return &qt_poll;
 }

-#ifdef QT4
+#if defined(QT5)
+#include "qt-watch.moc5"
+#elif defined(QT4)
 #include "qt-watch.moc4"
-#else
+#elif defined(QT3)
 #include "qt-watch.moc3"
 #endif
diff -rupN avahi-0.6.31/avahi-qt5.pc.in avahi-qt5/avahi-qt5.pc.in
--- avahi-0.6.31/avahi-qt5.pc.in    1969-12-31 18:00:00.000000000 -0600
+++ avahi-qt5/avahi-qt5.pc.in    2014-10-19 13:55:14.825086832 -0500
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=@libdir@
+includedir=${prefix}/include
+
+Name: avahi-qt5
+Description: Avahi Multicast DNS Responder (QT5 Support)
+Version: @PACKAGE_VERSION@
+Requires.private: Qt5Core >= 5.0.0
+Libs: -L${libdir} -lavahi-qt5
+Cflags: -D_REENTRANT -I${includedir}
diff -rupN avahi-0.6.31/configure.ac avahi-qt5/configure.ac
--- avahi-0.6.31/configure.ac    2012-02-14 15:44:25.484742099 -0600
+++ avahi-qt5/configure.ac    2014-10-19 13:55:14.825086832 -0500
@@ -34,6 +34,7 @@ AC_SUBST(LIBAVAHI_GLIB_VERSION_INFO, [1:
 AC_SUBST(LIBAVAHI_GOBJECT_VERSION_INFO, [0:4:0])
 AC_SUBST(LIBAVAHI_QT3_VERSION_INFO, [1:2:0])
 AC_SUBST(LIBAVAHI_QT4_VERSION_INFO, [1:2:0])
+AC_SUBST(LIBAVAHI_QT5_VERSION_INFO, [1:2:0])
 AC_SUBST(LIBAVAHI_UI_VERSION_INFO, [1:4:1])

 # Do not touch these, since they we took this version-info from upstream
HOWL/Bonjour
@@ -525,6 +526,31 @@ fi
 AM_CONDITIONAL(HAVE_QT4, test "x$HAVE_QT4" = "xyes")

 #
+# Check for Qt 5
+#
+AC_ARG_ENABLE(qt5,
+        AS_HELP_STRING([--disable-qt5],[Disable building of Qt5Core
mainloop integration]),
+        [case "${enableval}" in
+                yes) HAVE_QT5=yes ;;
+                no)  HAVE_QT5=no ;;
+                *) AC_MSG_ERROR(bad value ${enableval} for --enable-qt5) ;;
+        esac],
+        [HAVE_QT5=yes])
+
+if test "x$HAVE_QT5" = "xyes" ; then
+        PKG_CHECK_MODULES( QT5, [ Qt5Core >= 5.0.0 ])
+        AC_SUBST(QT5_CFLAGS)
+        AC_SUBST(QT5_LIBS)
+        QT5_PREFIX="`$PKG_CONFIG --variable=host_bins Qt5Core`"
+        AC_PATH_PROGS(MOC_QT5, [moc-qt5 moc], no, [$QT5_PREFIX])
+        if test "$MOC_QT5" = no; then
+            AC_MSG_ERROR([Could not find QT5 moc])
+        fi
+        AC_SUBST(MOC_QT5)
+fi
+AM_CONDITIONAL(HAVE_QT5, test "x$HAVE_QT5" = "xyes")
+
+#
 # Check for GTK+ 2.0
 #
 AC_ARG_ENABLE(gtk,
@@ -1157,6 +1183,7 @@ echo "
     Enable python-dbus:                        ${HAVE_PYTHON_DBUS}
     Enable QT3:                                ${HAVE_QT3}
     Enable QT4:                                ${HAVE_QT4}
+    Enable QT5:                                ${HAVE_QT5}
     Enable Mono:                               ${HAVE_MONO}
     Enable Monodoc:                            ${HAVE_MONODOC}
     Distribution/OS:                           ${with_distro}
@@ -1226,6 +1253,7 @@ echo "\
     Building avahi-discover-standalone: ${HAVE_GTK2OR3}
     Building libavahi-qt3:              ${HAVE_QT3}
     Building libavahi-qt4:              ${HAVE_QT4}
+    Building libavahi-qt5:              ${HAVE_QT5}
     Building avahi-sharp:               ${HAVE_MONO}
     Building avahi-compat-libdns_sd:    ${ENABLE_COMPAT_LIBDNS_SD}
     Building avahi-compat-howl:         ${ENABLE_COMPAT_HOWL}
diff -rupN avahi-0.6.31/Makefile.am avahi-qt5/Makefile.am
--- avahi-0.6.31/Makefile.am    2011-12-30 15:26:44.925511922 -0600
+++ avahi-qt5/Makefile.am    2014-10-19 13:55:14.825086832 -0500
@@ -43,6 +43,7 @@ EXTRA_DIST = \
     avahi-gobject.pc.in \
     avahi-qt3.pc.in \
     avahi-qt4.pc.in \
+    avahi-qt5.pc.in \
     avahi-sharp.pc.in \
     avahi-ui-sharp.pc.in \
     avahi-compat-libdns_sd.pc.in \
@@ -101,6 +102,10 @@ if HAVE_QT4
 DX_INPUT += \
     $(srcdir)/avahi-qt/qt-watch.h
 endif
+if HAVE_QT5
+DX_INPUT += \
+    $(srcdir)/avahi-qt/qt-watch.h
+endif
 endif

 if HAVE_GLIB
@@ -216,6 +221,11 @@ pkgconfig_DATA += avahi-qt4.pc
 CLEANFILES += avahi-qt4.pc
 endif

+if HAVE_QT5
+pkgconfig_DATA += avahi-qt5.pc
+CLEANFILES += avahi-qt5.pc
+endif
+
 CLEANFILES += avahi.devhelp

 avahi.devhelp: doxygen-run
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/avahi/attachments/20141024/66865ba7/attachment.html>


More information about the avahi mailing list