]> git.meshlink.io Git - catta/commitdiff
Hide everything except for the avahi_qt_poll_get symbol if possible in the qt bindings
authorSjoerd Simons <sjoerd@luon.net>
Sun, 22 Jun 2008 15:31:08 +0000 (17:31 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 23 Jun 2008 22:17:34 +0000 (00:17 +0200)
avahi-qt/Makefile.am
avahi-qt/qt-watch.h
common/gcc_visibility.m4 [new file with mode: 0644]
configure.ac

index 4cd047b684db46ce076e6ac9d19e9bfe0e47eb40..de135958621b12b66c15df88070ceae6baf6a9dd 100644 (file)
@@ -40,10 +40,9 @@ libavahi_qt3_la_SOURCES = \
 qt-watch.moc3: qt-watch.cpp
        $(MOC_QT3) $^ > $@
 
-libavahi_qt3_la_CPPFLAGS = $(AM_CFLAGS) $(QT3_CFLAGS)
+libavahi_qt3_la_CPPFLAGS = $(AM_CFLAGS) $(QT3_CFLAGS) $(VISIBILITY_HIDDEN_CFLAGS)
 libavahi_qt3_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la $(QT3_LIBS)
 libavahi_qt3_la_LDFLAGS = $(AM_LDFLAGS) -export-dynamic -version-info $(LIBAVAHI_QT3_VERSION_INFO)
-
 endif
 
 if HAVE_QT4
@@ -63,10 +62,9 @@ libavahi_qt4_la_SOURCES = \
 qt-watch.moc4: qt-watch.cpp
        $(MOC_QT4) $^ > $@
 
-libavahi_qt4_la_CPPFLAGS = $(AM_CFLAGS) $(QT4_CFLAGS) -DQT4
+libavahi_qt4_la_CPPFLAGS = $(AM_CFLAGS) $(QT4_CFLAGS) -DQT4 $(VISIBILITY_HIDDEN_CFLAGS)
 libavahi_qt4_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la $(QT4_LIBS)
-libavahi_qt4_la_LDFLAGS = $(AM_LDFLAGS) -export-dynamic -version-info $(LIBAVAHI_QT4_VERSION_INFO)
-
+libavahi_qt4_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_QT4_VERSION_INFO)
 endif
 
 CLEANFILES = $(BUILT_SOURCES)
index 0a3476dff291cccd022b8559b8e2c4fd4ae847a3..a702a7615ee4ce53a1432b8fd6bd5e6fa1caceaf 100644 (file)
 AVAHI_C_DECL_BEGIN
 
 /** Setup abstract poll structure for integration with Qt main loop  */
-const AvahiPoll* avahi_qt_poll_get(void);
+const AvahiPoll* avahi_qt_poll_get(void)
+#ifdef HAVE_VISIBILITY_HIDDEN
+__attribute__ ((visibility("default")))
+#endif
+;
 
 AVAHI_C_DECL_END
 
diff --git a/common/gcc_visibility.m4 b/common/gcc_visibility.m4
new file mode 100644 (file)
index 0000000..6b5a89d
--- /dev/null
@@ -0,0 +1,36 @@
+dnl @synopsis CHECK_VISIBILITY([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+dnl
+dnl @summary check for the gcc -fvisibility flag
+dnl
+
+AC_DEFUN([CHECK_VISIBILITY_HIDDEN], [
+  save_CFLAGS="$CFLAGS"
+  VISIBILITY_HIDDEN_CFLAGS=""
+  OPTION=-fvisibility=hidden
+
+  AC_MSG_CHECKING(for gcc $OPTION support)
+
+  CFLAGS="$CFLAGS $OPTION"
+
+  AC_TRY_COMPILE([
+      int default_vis __attribute__ ((visibility("default")));
+      int hidden_vis __attribute__ ((visibility("hidden")));
+    ],
+    [],
+    ac_visibility_supported=yes,
+    ac_visibility_supported=no)
+  AC_MSG_RESULT($ac_visibility_supported)
+
+  if test x"$ac_visibility_supported" = xyes; then
+    ifelse([$1],,AC_DEFINE(HAVE_GCC_VISIBILITY,1,[Define if you have gcc -fvisibility=hidden support ]),[$1])
+    VISIBILITY_HIDDEN_CFLAGS="$OPTION -DHAVE_VISIBILITY_HIDDEN"
+    AC_DEFINE(HAVE_VISIBILITY_HIDDEN,[],[Support for visibility hidden])
+  else
+    $2
+    :
+  fi
+
+  AC_SUBST(VISIBILITY_HIDDEN_CFLAGS)
+
+  CFLAGS="$save_CFLAGS"
+])
index 5590fddd41a9d7f8c3c8cbe2b553702baf60a56f..a4e4a0a99a0cc86e12bcc634c5fad2e60fb752b8 100644 (file)
@@ -366,6 +366,9 @@ AC_TYPE_PID_T
 
 AC_CHECK_DECLS(environ)
 
+# check if gcc's -fvisibility is supported
+CHECK_VISIBILITY_HIDDEN
+
 enable_chroot=yes
 AC_CHECK_HEADERS([sys/capability.h],,enable_chroot=no)
 AC_CHECK_HEADERS([sys/prctl.h],,enable_chroot=no)