[atk] Use Visiblity-based Symbol Exporting



commit 41442d82fdafcb0f38f179700090fb79d104b299
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Apr 14 13:26:03 2014 +0800

    Use Visiblity-based Symbol Exporting
    
    Update the autotools files to determine the compiler directive used to mark
    a symbol for export, and use the appropriate CFLAGS as necessary.  Also
    make MinGW builds not to generate atk.def and attempt to generate and
    install a Visual Studio .lib file from there.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=728031

 atk/Makefile.am |   39 +-------
 atk/atk.symbols |  276 -------------------------------------------------------
 configure.ac    |   30 ++++++
 3 files changed, 34 insertions(+), 311 deletions(-)
---
diff --git a/atk/Makefile.am b/atk/Makefile.am
index 354c0e2..53421bf 100644
--- a/atk/Makefile.am
+++ b/atk/Makefile.am
@@ -19,7 +19,8 @@ AM_CPPFLAGS = \
        -DATK_DISABLE_DEPRECATED        \
        -DATK_COMPILATION       \
        -DATK_LOCALEDIR="\"$(datadir)/locale\"" \
-       $(DEP_CFLAGS)
+       $(DEP_CFLAGS)   \
+       $(ATK_HIDDEN_VISIBILITY_CFLAGS)
 
 lib_LTLIBRARIES = libatk-1.0.la
 
@@ -191,41 +192,13 @@ endif
 
 if OS_WIN32
 libatk_1_0_la_LDFLAGS += -export-symbols atk.def -no-undefined -Wl,atk-win32-res.o
-libatk_1_0_la_DEPENDENCIES = atk-win32-res.o atk.def
-
-install-def-file:
-       $(INSTALL) atk.def $(DESTDIR)$(libdir)/atk-1.0.def
-uninstall-def-file:
-       -rm $(DESTDIR)$(libdir)/atk-1.0.def
-else
-install-def-file:
-uninstall-def-file:
+libatk_1_0_la_DEPENDENCIES = atk-win32-res.o
 endif
 
 atk-win32-res.o: atk.rc
        $(WINDRES) $< $@
 
-if MS_LIB_AVAILABLE
-noinst_DATA = atk-$(ATK_API_VERSION).lib
-
-install-ms-lib:
-       $(INSTALL) atk-$(ATK_API_VERSION).lib $(DESTDIR)$(libdir)
-
-uninstall-ms-lib:
-       -rm $(DESTDIR)$(libdir)/atk-$(ATK_API_VERSION).lib
-else
-install-ms-lib:
-uninstall-ms-lib:
-endif
-
-atk.def: atk.symbols
-       (echo -e EXPORTS; $(CPP) -P -DINCLUDE_VARIABLES -DG_OS_WIN32 -DALL_FILES - <$(srcdir)/atk.symbols | 
sed -e '/^$$/d' -e 's/^/    /' -e 's/G_GNUC_[^ ]*//g') > atk.def
-
-atk-$(ATK_API_VERSION).lib: libatk-$(ATK_API_VERSION).la atk.def
-       lib -machine:$(LIB_EXE_MACHINE_FLAG) -name:libatk-$(ATK_API_VERSION)-$(LT_CURRENT_MINUS_AGE).dll 
-def:atk.def -out:$@
-
-
-EXTRA_DIST = atk.symbols atk.rc.in atkmarshal.list atk.rc atkversion.h.in
+EXTRA_DIST = atk.rc.in atkmarshal.list atk.rc atkversion.h.in
 
 DISTCLEANFILES = \
   stamp-atkmarshal.h stamp-atkmarshal.c \
@@ -235,7 +208,3 @@ distclean-local:
        if test $(srcdir) = .; then :; else \
          rm -f atkmarshal.h atkmarshal.c atk-enum-types.h atk-enum-types.c; \
        fi
-
-install-data-local: install-ms-lib install-def-file
-
-uninstall-local: uninstall-ms-lib uninstall-def-file
diff --git a/configure.ac b/configure.ac
index fe8b2fa..9ec6d62 100644
--- a/configure.ac
+++ b/configure.ac
@@ -229,6 +229,36 @@ if test x"$PYTHON" = xyes; then
 fi
 AM_PATH_PYTHON(2.5,,PYTHON="/usr/bin/env python2.5")
 
+# Check for the visibility flags
+ATK_HIDDEN_VISIBILITY_CFLAGS=""
+case "$host" in
+  *-*-mingw*)
+    dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
+    AC_DEFINE([_ATK_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern],
+              [defines how to decorate public symbols while building])
+    CFLAGS="${CFLAGS} -fvisibility=hidden"
+    ;;
+  *)
+    dnl on other compilers, check if we can do -fvisibility=hidden
+    SAVED_CFLAGS="${CFLAGS}"
+    CFLAGS="-fvisibility=hidden"
+    AC_MSG_CHECKING([for -fvisibility=hidden compiler flag])
+    AC_TRY_COMPILE([], [int main (void) { return 0; }],
+                   AC_MSG_RESULT(yes)
+                   enable_fvisibility_hidden=yes,
+                   AC_MSG_RESULT(no)
+                   enable_fvisibility_hidden=no)
+    CFLAGS="${SAVED_CFLAGS}"
+
+    AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [
+      AC_DEFINE([_ATK_EXTERN], [__attribute__((visibility("default"))) extern],
+                [defines how to decorate public symbols while building])
+      ATK_HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"
+    ])
+    ;;
+esac
+AC_SUBST(ATK_HIDDEN_VISIBILITY_CFLAGS)
+
 GNOME_COMPILE_WARNINGS([maximum])
 
 AC_CONFIG_FILES([


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]