[m-rev.] for review: add new configuration option for disabling shared libraries
Julien Fischer
jfischer at opturion.com
Mon Jan 20 22:16:45 AEDT 2020
For review by anyone.
---------------------
Add new configuration option for disabling shared libraries.
configure.ac:
Add the option --disable-shared-libs, which turns off shared libraries
even on systems that support them.
Make the workaround for bug #453 look at the value of the new option,
rather than that of --disable-dynamic-link.
Julien.
diff --git a/configure.ac b/configure.ac
index 579ad91..460a39c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1229,14 +1229,14 @@ AC_CHECK_LIB(m, sin, [MATH_LIB=-lm], [MATH_LIB=])
#-----------------------------------------------------------------------------#
#
-# Add option for dynamic linking.
+# Check whether the user wants to disable the use of shared libraries.
#
-AC_ARG_ENABLE(dynamic-link,
- AC_HELP_STRING([--disable-dynamic-link],
- [disable the use of dynamic linking]),
- [mercury_cv_enable_dynamic_link="$enableval"],
- [mercury_cv_enable_dynamic_link=yes])
+AC_ARG_ENABLE(shared-libs,
+ AC_HELP_STRING([--disable-shared-libs],
+ [do not build shared version of the library even if that is supported]),
+ [mercury_cv_enable_shared_libs="$enableval"],
+ [mercury_cv_enable_shared_libs=yes])
#-----------------------------------------------------------------------------#
#
@@ -2619,7 +2619,7 @@ case "$ac_cv_prog_gcc" in yes)
# An old hack allowing non-local gotos to work with PIC on x86
# will no longer work with GCC 5+ (see mercury_goto.h).
- # The following disables non-local gotos if dynamically linking
+ # The following disables non-local gotos if dynamic linking
# is enabled, even though statically linked libraries (non-PIC)
# would still work.
# Alternatively, we may wish to consider using non-PIC in shared
@@ -2632,7 +2632,7 @@ case "$ac_cv_prog_gcc" in yes)
case $C_COMPILER_TYPE in
gcc_3_*|gcc_4_*) ;;
gcc_*)
- if test "$mercury_cv_enable_dynamic_link" = yes
+ if test "$mercury_cv_enable_shared_libs" = yes
then
mercury_cv_asm_labels=no
mercury_cv_gcc_labels=no
@@ -4400,7 +4400,8 @@ ALLOW_UNDEFINED=""
ERROR_UNDEFINED=""
DEFAULT_LINKAGE="shared"
-case "$host" in
+if test "$mercury_cv_enable_shared_libs" = "yes"; then
+ case "$host" in
i*86-*-linux|i*86-*-linux-gnu|x86_64-*-linux*)
case $ac_cv_prog_gcc in
yes)
@@ -4609,7 +4610,16 @@ case "$host" in
DEFAULT_LINKAGE=static
AC_MSG_RESULT(no)
;;
-esac
+ esac
+else
+ # CFLAGS_FOR_PIC is used by boehm_gc/Makefile when creating libgc.a.
+ # If the system doesn't support shared libraries,
+ # then we should set it to empty, not `-fpic'.
+ CFLAGS_FOR_PIC=
+ EXT_FOR_PIC_OBJECTS=o
+ DEFAULT_LINKAGE=static
+ AC_MSG_RESULT(no)
+fi
#-----------------------------------------------------------------------------#
#
@@ -5211,9 +5221,13 @@ AC_SUBST(NSL_LIBRARY)
#
# Check libraries for dynamic linking.
#
-# XXX This needs to occur after mercury_check_for_functions is defined,
-# but the option defining mercury_cv_enable_dynamic_link is needed earlier.
-#
+
+# XXX this is poorly named.
+AC_ARG_ENABLE(dynamic-link,
+ AC_HELP_STRING([--disable-dynamic-link],
+ [disable the use of dynamic linking]),
+ [mercury_cv_enable_dynamic_link="$enableval"],
+ [mercury_cv_enable_dynamic_link=yes])
if test "$mercury_cv_enable_dynamic_link" = "yes"; then
MERCURY_CHECK_FOR_HEADERS(dlfcn.h)
More information about the reviews
mailing list