summaryrefslogtreecommitdiff
path: root/net-dns/avahi/files/avahi-0.9_rc2-qt6.patch
blob: fdff594fd3d3e211b690d9e3323c9604e6c53020 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
From: https://github.com/avahi/avahi/pull/704

From fdc30aff1e72ba22aff11e2d9c0ab486ba63d1a6 Mon Sep 17 00:00:00 2001
From: Antonio Larrosa <antonio.larrosa@gmail.com>
Date: Fri, 30 May 2025 11:42:02 +0200
Subject: [PATCH] Enable building with Qt6

---
 Makefile.am           | 10 ++++++++
 acinclude.m4          |  2 +-
 avahi-qt/Makefile.am  | 22 +++++++++++++++++
 avahi-qt/qt-watch.cpp | 10 ++++----
 avahi-qt6.pc.in       | 11 +++++++++
 common/qt-pie.m4      | 55 +++++++++++++++++++++++++++++++++++++++++++
 common/qt5-pie.m4     | 27 ---------------------
 configure.ac          | 31 +++++++++++++++++++++++-
 8 files changed, 135 insertions(+), 33 deletions(-)
 create mode 100644 avahi-qt6.pc.in
 create mode 100644 common/qt-pie.m4
 delete mode 100644 common/qt5-pie.m4

diff --git a/Makefile.am b/Makefile.am
index 352cdcf25..3df371ad3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -45,6 +45,7 @@ EXTRA_DIST = \
 	avahi-qt3.pc.in \
 	avahi-qt4.pc.in \
 	avahi-qt5.pc.in \
+	avahi-qt6.pc.in \
 	avahi-sharp.pc.in \
 	avahi-ui-sharp.pc.in \
 	avahi-compat-libdns_sd.pc.in \
@@ -108,6 +109,10 @@ if HAVE_QT5
 DX_INPUT += \
 	$(srcdir)/avahi-qt/qt-watch.h
 endif
+if HAVE_QT6
+DX_INPUT += \
+	$(srcdir)/avahi-qt/qt-watch.h
+endif
 endif
 
 if HAVE_GLIB
@@ -236,6 +241,11 @@ pkgconfig_DATA += avahi-qt5.pc
 CLEANFILES += avahi-qt5.pc
 endif
 
+if HAVE_QT6
+pkgconfig_DATA += avahi-qt6.pc
+CLEANFILES += avahi-qt6.pc
+endif
+
 if HAVE_LIBEVENT
 pkgconfig_DATA += avahi-libevent.pc
 CLEANFILES += avahi-libevent.pc
diff --git a/acinclude.m4 b/acinclude.m4
index ccf2ac616..ac922456e 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1,2 +1,2 @@
 sinclude(common/doxygen.m4)
-sincldue(common/qt5-pie.m4)
+sincldue(common/qt-pie.m4)
diff --git a/avahi-qt/Makefile.am b/avahi-qt/Makefile.am
index b404810f7..78069b56c 100644
--- a/avahi-qt/Makefile.am
+++ b/avahi-qt/Makefile.am
@@ -87,4 +87,26 @@ libavahi_qt5_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la $(QT5_LI
 libavahi_qt5_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_QT5_VERSION_INFO)
 endif
 
+if HAVE_QT6
+
+avahiqt6includedir=$(includedir)/avahi-qt6
+avahiqt6include_HEADERS = \
+	qt-watch.h
+
+lib_LTLIBRARIES += \
+	libavahi-qt6.la
+
+BUILT_SOURCES += qt-watch.moc6
+
+libavahi_qt6_la_SOURCES = \
+	qt-watch.cpp
+
+qt-watch.moc6: qt-watch.cpp
+	$(AM_V_GEN)$(MOC_QT6) $^ > $@
+
+libavahi_qt6_la_CPPFLAGS = $(AM_CFLAGS) --std=gnu++17 $(QT6_CFLAGS) -DQT6 $(VISIBILITY_HIDDEN_CFLAGS)
+libavahi_qt6_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la $(QT6_LIBS)
+libavahi_qt6_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_QT6_VERSION_INFO)
+endif
+
 CLEANFILES = $(BUILT_SOURCES)
diff --git a/avahi-qt/qt-watch.cpp b/avahi-qt/qt-watch.cpp
index 14e0c6e6a..cd18bee3d 100644
--- a/avahi-qt/qt-watch.cpp
+++ b/avahi-qt/qt-watch.cpp
@@ -18,7 +18,7 @@
 ***/
 
 #include <sys/time.h>
-#if defined(QT5) || defined(QT4)
+#if defined(QT6) || defined(QT5) || defined(QT4)
 #include <QSocketNotifier>
 #include <QObject>
 #include <QTimer>
@@ -114,7 +114,7 @@ AvahiTimeout::AvahiTimeout(const struct timeval* tv, AvahiTimeoutCallback callba
     m_callback(callback), m_userdata(userdata)
 {
     connect(&m_timer, SIGNAL(timeout()), this, SLOT(timeout()));
-#if defined(QT5) || defined(QT4)
+#if defined(QT6) || defined(QT5) || defined(QT4)
     m_timer.setSingleShot(true);
 #endif
     update(tv);
@@ -125,7 +125,7 @@ void AvahiTimeout::update(const struct timeval *tv)
     m_timer.stop();
     if (tv) {
     AvahiUsec u = avahi_age(tv)/1000;
-#if defined(QT5) || defined(QT4)
+#if defined(QT6) || defined(QT5) || defined(QT4)
     m_timer.start( (u>0) ? 0 : -u);
 #else
     m_timer.start( (u>0) ? 0 : -u,true);
@@ -191,7 +191,9 @@ const AvahiPoll* avahi_qt_poll_get(void)
     return &qt_poll;
 }
 
-#if defined(QT5)
+#if defined(QT6)
+#include "qt-watch.moc6"
+#elif defined(QT5)
 #include "qt-watch.moc5"
 #elif defined(QT4)
 #include "qt-watch.moc4"
diff --git a/avahi-qt6.pc.in b/avahi-qt6.pc.in
new file mode 100644
index 000000000..ce9f13758
--- /dev/null
+++ b/avahi-qt6.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=@libdir@
+includedir=${prefix}/include
+
+Name: avahi-qt6
+Description: Avahi Multicast DNS Responder (QT6 Support)
+Version: @PACKAGE_VERSION@
+Requires: Qt6Core >= 6.0.0
+Libs: -L${libdir} -lavahi-qt6
+Cflags: -D_REENTRANT -I${includedir}
diff --git a/common/qt-pie.m4 b/common/qt-pie.m4
new file mode 100644
index 000000000..8f35e548b
--- /dev/null
+++ b/common/qt-pie.m4
@@ -0,0 +1,55 @@
+AC_DEFUN([AC_AVAHI_QT5_ADD_PIC_IF_NEEDED],
+[
+    AC_LANG_PUSH([C++])
+	save_CPPFLAGS="$CPPFLAGS"
+	CPPFLAGS="$CPPFLAGS $QT5_CFLAGS"
+	AC_MSG_CHECKING([whether Qt works without -fPIC])
+	AC_PREPROC_IFELSE(
+		[AC_LANG_SOURCE([[#include <QtCore>]])],
+		[AC_MSG_RESULT(yes)],
+		[
+			AC_MSG_RESULT(no)
+			AC_MSG_CHECKING([whether Qt works with -fPIC])
+			CPPFLAGS="$CPPFLAGS -fPIC"
+			AC_PREPROC_IFELSE(
+				[AC_LANG_SOURCE([[#include <QtCore>]])],
+				[
+					AC_MSG_RESULT(yes)
+					QT5_CFLAGS="$QT5_CFLAGS -fPIC"
+				],
+				[
+					AC_MSG_RESULT(no)
+					AC_MSG_ERROR(Couldn't compile Qt without -fPIC nor with -fPIC)
+				])
+		])
+	CPPFLAGS="$save_CPPFLAGS"
+    AC_LANG_POP([C++])
+])
+
+AC_DEFUN([AC_AVAHI_QT6_ADD_PIC_IF_NEEDED],
+[
+    AC_LANG_PUSH([C++])
+	save_CPPFLAGS="$CPPFLAGS"
+	CPPFLAGS="$CPPFLAGS $QT6_CFLAGS"
+	AC_MSG_CHECKING([whether Qt works without -fPIC])
+	AC_PREPROC_IFELSE(
+		[AC_LANG_SOURCE([[#include <QtCore>]])],
+		[AC_MSG_RESULT(yes)],
+		[
+			AC_MSG_RESULT(no)
+			AC_MSG_CHECKING([whether Qt works with -fPIC])
+			CPPFLAGS="$CPPFLAGS -fPIC"
+			AC_PREPROC_IFELSE(
+				[AC_LANG_SOURCE([[#include <QtCore>]])],
+				[
+					AC_MSG_RESULT(yes)
+					QT6_CFLAGS="$QT6_CFLAGS -fPIC"
+				],
+				[
+					AC_MSG_RESULT(no)
+					AC_MSG_ERROR(Couldn't compile Qt without -fPIC nor with -fPIC)
+				])
+		])
+	CPPFLAGS="$save_CPPFLAGS"
+    AC_LANG_POP([C++])
+])
diff --git a/common/qt5-pie.m4 b/common/qt5-pie.m4
deleted file mode 100644
index 10d564c8f..000000000
--- a/common/qt5-pie.m4
+++ /dev/null
@@ -1,27 +0,0 @@
-AC_DEFUN([AC_AVAHI_QT_ADD_PIC_IF_NEEDED],
-[
-    AC_LANG_PUSH([C++])
-	save_CPPFLAGS="$CPPFLAGS"
-	CPPFLAGS="$CPPFLAGS $QT5_CFLAGS"
-	AC_MSG_CHECKING([whether Qt works without -fPIC])
-	AC_PREPROC_IFELSE(
-		[AC_LANG_SOURCE([[#include <QtCore>]])],
-		[AC_MSG_RESULT(yes)],
-		[
-			AC_MSG_RESULT(no)
-			AC_MSG_CHECKING([whether Qt works with -fPIC])
-			CPPFLAGS="$CPPFLAGS -fPIC"
-			AC_PREPROC_IFELSE(
-				[AC_LANG_SOURCE([[#include <QtCore>]])],
-				[
-					AC_MSG_RESULT(yes)
-					QT5_CFLAGS="$QT5_CFLAGS -fPIC"
-				],
-				[
-					AC_MSG_RESULT(no)
-					AC_MSG_ERROR(Couldn't compile Qt without -fPIC nor with -fPIC)
-				])
-		])
-	CPPFLAGS="$save_CPPFLAGS"
-    AC_LANG_POP([C++])
-])
diff --git a/configure.ac b/configure.ac
index 31bce3d76..5959df14e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,6 +36,7 @@ AC_SUBST(LIBAVAHI_GOBJECT_VERSION_INFO, [0:5: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_QT6_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
@@ -557,7 +558,7 @@ AC_ARG_ENABLE(qt5,
 
 if test "x$HAVE_QT5" = "xyes" ; then
         PKG_CHECK_MODULES( QT5, [ Qt5Core >= 5.0.0 ])
-        AC_AVAHI_QT_ADD_PIC_IF_NEEDED
+        AC_AVAHI_QT5_ADD_PIC_IF_NEEDED
         AC_SUBST(QT5_CFLAGS)
         AC_SUBST(QT5_LIBS)
         QT5_PREFIX="`$PKG_CONFIG --variable=host_bins Qt5Core`"
@@ -569,6 +570,32 @@ if test "x$HAVE_QT5" = "xyes" ; then
 fi
 AM_CONDITIONAL(HAVE_QT5, test "x$HAVE_QT5" = "xyes")
 
+#
+# Check for Qt 6
+#
+AC_ARG_ENABLE(qt6,
+        AS_HELP_STRING([--disable-qt6],[Disable building of Qt6Core mainloop integration]),
+        [case "${enableval}" in
+                yes) HAVE_QT6=yes ;;
+                no)  HAVE_QT6=no ;;
+                *) AC_MSG_ERROR(bad value ${enableval} for --enable-qt6) ;;
+        esac],
+        [HAVE_QT6=yes])
+
+if test "x$HAVE_QT6" = "xyes" ; then
+        PKG_CHECK_MODULES( QT6, [ Qt6Core >= 6.0.0 ])
+        AC_AVAHI_QT6_ADD_PIC_IF_NEEDED
+        AC_SUBST(QT6_CFLAGS)
+        AC_SUBST(QT6_LIBS)
+        QT6_PREFIX="`$PKG_CONFIG --variable=libexecdir Qt6Core`"
+        AC_PATH_PROGS(MOC_QT6, [moc-qt6 moc], no, [$QT6_PREFIX])
+        if test "$MOC_QT6" = no; then
+            AC_MSG_ERROR([Could not find QT6 moc])
+        fi
+        AC_SUBST(MOC_QT6)
+fi
+AM_CONDITIONAL(HAVE_QT6, test "x$HAVE_QT6" = "xyes")
+
 #
 # Check for GTK+ 2.0
 #
@@ -1222,6 +1249,7 @@ echo "
     Enable QT3:                                ${HAVE_QT3}
     Enable QT4:                                ${HAVE_QT4}
     Enable QT5:                                ${HAVE_QT5}
+    Enable QT6:                                ${HAVE_QT6}
     Enable Mono:                               ${HAVE_MONO}
     Enable Monodoc:                            ${HAVE_MONODOC}
     Distribution/OS:                           ${with_distro}
@@ -1292,6 +1320,7 @@ echo "\
     Building libavahi-qt3:              ${HAVE_QT3}
     Building libavahi-qt4:              ${HAVE_QT4}
     Building libavahi-qt5:              ${HAVE_QT5}
+    Building libavahi-qt6:              ${HAVE_QT6}
     Building avahi-sharp:               ${HAVE_MONO}
     Building avahi-compat-libdns_sd:    ${ENABLE_COMPAT_LIBDNS_SD}
     Building avahi-compat-howl:         ${ENABLE_COMPAT_HOWL}