Fix libphobos linking on Solaris 11
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Tue, 19 Feb 2019 09:24:50 +0000 (09:24 +0000)
committerRainer Orth <ro@gcc.gnu.org>
Tue, 19 Feb 2019 09:24:50 +0000 (09:24 +0000)
* m4/druntime/libraries.m4 (DRUNTIME_LIBRARIES_NET): New macro.
* configure.ac: Invoke it.
* configure: Regenerate.

From-SVN: r269012

libphobos/ChangeLog
libphobos/configure
libphobos/configure.ac
libphobos/m4/druntime/libraries.m4

index 5e24d948513980c692231e79e7fa2eee9b3532d6..5279c891e55a102a2fb9033f1af3762bf14ed863 100644 (file)
@@ -1,3 +1,9 @@
+2019-02-19  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+       * m4/druntime/libraries.m4 (DRUNTIME_LIBRARIES_NET): New macro.
+       * configure.ac: Invoke it.
+       * configure: Regenerate.
+
 2019-02-19  Johannes Pfau  <johannespfau@gmail.com>
 
        PR d/88127
index 7bb034b841d2b3cdea62a2d6c47aec1b58f76035..d86934b59a5d77528a450fd1e72ed07064151429 100755 (executable)
@@ -14749,6 +14749,121 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 fi
 
 
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket libraries" >&5
+$as_echo_n "checking for socket libraries... " >&6; }
+if ${druntime_cv_lib_sockets+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  druntime_cv_lib_sockets=
+     druntime_check_both=no
+     ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect"
+if test "x$ac_cv_func_connect" = xyes; then :
+  druntime_check_socket=no
+else
+  druntime_check_socket=yes
+fi
+
+     if test "$druntime_check_socket" = "yes"; then
+       unset ac_cv_func_connect
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lsocket" >&5
+$as_echo_n "checking for main in -lsocket... " >&6; }
+if ${ac_cv_lib_socket_main+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsocket  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+return main ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_socket_main=yes
+else
+  ac_cv_lib_socket_main=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_main" >&5
+$as_echo "$ac_cv_lib_socket_main" >&6; }
+if test "x$ac_cv_lib_socket_main" = xyes; then :
+  druntime_cv_lib_sockets="-lsocket"
+else
+  druntime_check_both=yes
+fi
+
+     fi
+     if test "$druntime_check_both" = "yes"; then
+       druntime_old_libs=$LIBS
+       LIBS="$LIBS -lsocket -lnsl"
+       unset ac_cv_func_accept
+       ac_fn_c_check_func "$LINENO" "accept" "ac_cv_func_accept"
+if test "x$ac_cv_func_accept" = xyes; then :
+  druntime_check_nsl=no
+                     druntime_cv_lib_sockets="-lsocket -lnsl"
+fi
+
+       unset ac_cv_func_accept
+       LIBS=$druntime_old_libs
+     fi
+     unset ac_cv_func_gethostbyname
+     druntime_old_libs="$LIBS"
+     ac_fn_c_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname"
+if test "x$ac_cv_func_gethostbyname" = xyes; then :
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lnsl" >&5
+$as_echo_n "checking for main in -lnsl... " >&6; }
+if ${ac_cv_lib_nsl_main+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lnsl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+return main ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_nsl_main=yes
+else
+  ac_cv_lib_nsl_main=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_main" >&5
+$as_echo "$ac_cv_lib_nsl_main" >&6; }
+if test "x$ac_cv_lib_nsl_main" = xyes; then :
+  druntime_cv_lib_sockets="$druntime_cv_lib_sockets -lnsl"
+fi
+
+fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $druntime_cv_lib_sockets" >&5
+$as_echo "$druntime_cv_lib_sockets" >&6; }
+  LIBS="$LIBS $druntime_cv_lib_sockets"
+
+
 
 # Check whether --with-target-system-zlib was given.
 if test "${with_target_system_zlib+set}" = set; then :
index b436dc034ae07f37ef31f8b89e1d39832bd68ec4..96010333a39410f31ef2d46aa17650f26cd0605f 100644 (file)
@@ -141,6 +141,7 @@ WITH_LOCAL_DRUNTIME([
 DRUNTIME_LIBRARIES_ATOMIC
 DRUNTIME_LIBRARIES_BACKTRACE
 DRUNTIME_LIBRARIES_DLOPEN
+DRUNTIME_LIBRARIES_NET
 DRUNTIME_LIBRARIES_ZLIB
 DRUNTIME_INSTALL_DIRECTORIES
 
index 35a791d137a57171ddea8d1c7db7c9ac64c00089..41c888066bcd3c0f7ee09f28fcf14e0d9bb22352 100644 (file)
@@ -42,6 +42,40 @@ AC_DEFUN([DRUNTIME_LIBRARIES_DLOPEN],
 ])
 
 
+# DRUNTIME_LIBRARIES_NET
+# -----------------------
+# Autodetect and add networking library to LIBS if necessary.
+AC_DEFUN([DRUNTIME_LIBRARIES_NET],
+[
+  dnl Test for -lsocket and -lnsl.  Copied from libjava/configure.ac.
+  AC_CACHE_CHECK([for socket libraries], druntime_cv_lib_sockets,
+    [druntime_cv_lib_sockets=
+     druntime_check_both=no
+     AC_CHECK_FUNC(connect, druntime_check_socket=no, druntime_check_socket=yes)
+     if test "$druntime_check_socket" = "yes"; then
+       unset ac_cv_func_connect
+       AC_CHECK_LIB(socket, main, druntime_cv_lib_sockets="-lsocket",
+                   druntime_check_both=yes)
+     fi
+     if test "$druntime_check_both" = "yes"; then
+       druntime_old_libs=$LIBS
+       LIBS="$LIBS -lsocket -lnsl"
+       unset ac_cv_func_accept
+       AC_CHECK_FUNC(accept,
+                    [druntime_check_nsl=no
+                     druntime_cv_lib_sockets="-lsocket -lnsl"])
+       unset ac_cv_func_accept
+       LIBS=$druntime_old_libs
+     fi
+     unset ac_cv_func_gethostbyname
+     druntime_old_libs="$LIBS"
+     AC_CHECK_FUNC(gethostbyname, ,
+                  [AC_CHECK_LIB(nsl, main,
+                   [druntime_cv_lib_sockets="$druntime_cv_lib_sockets -lnsl"])])
+  ])
+  LIBS="$LIBS $druntime_cv_lib_sockets"
+])
+
 # DRUNTIME_LIBRARIES_ZLIB
 # -----------------------
 # Allow specifying whether to use the system zlib or