diff configure.ac @ 29313:6dea3b384846

Optionally disable building libraries with visibility attributes (bug #59820). * configure.ac: Add argument --disable-lib-visibility-flags to manually disable building and linking Octave libraries with visibility attributes. * Makefile.am: Use compiler flags for symbol visibility according to configure result. * oct-conf-post.in.h, build-aux/mk-octave-config-h.sh: Set preprocessor macros with visibility attributes to empty optionally.
author Markus Mützel <markus.muetzel@gmx.de>
date Sat, 23 Jan 2021 10:54:47 +0100
parents d4d56704978e
children 6c2fa2293242
line wrap: on
line diff
--- a/configure.ac	Sat Jan 23 11:27:46 2021 +0100
+++ b/configure.ac	Sat Jan 23 10:54:47 2021 +0100
@@ -2680,6 +2680,32 @@
   [if test "$enableval" = yes; then install_build_logs=yes; fi])
 AM_CONDITIONAL([AMCOND_INSTALL_BUILD_LOGS], [test $install_build_logs = yes])
 
+### Determine whether libraries should be linked with visibility attributes
+
+ENABLE_LIB_VISIBILITY_FLAGS=yes
+AC_ARG_ENABLE(lib-visibility-flags,
+  [AS_HELP_STRING([--disable-lib-visibility-flags],
+    [don't build libraries with visibility flags (export all symbols)])],
+  [case $enableval in
+     yes) ENABLE_LIB_VISIBILITY_FLAGS=yes ;;
+     no) ENABLE_LIB_VISIBILITY_FLAGS=no ;;
+     *) AC_MSG_ERROR([bad value $enableval for --enable-lib-visibility-flags]) ;;
+   esac])
+
+if test $ENABLE_LIB_VISIBILITY_FLAGS = yes; then
+  AC_DEFINE(OCTAVE_ENABLE_LIB_VISIBILITY_FLAGS, 1,
+    [Define to 1 if building libraries with visibility flags])
+else
+  case $host_os in
+    msdosmsvc | mingw* | cygwin*)
+      LDFLAGS="$LDFLAGS -Wl,--export-all-symbols"
+    ;;
+  esac
+fi
+
+AM_CONDITIONAL([AMCOND_LIB_VISIBILITY_FLAGS],
+  [test $ENABLE_LIB_VISIBILITY_FLAGS = yes])
+
 ### Add extra compiler flags now that feature testing is complete.
 
 ## Add warning flags