1# libsocket.m4 serial 1 - based on gnulib socketlib.m4 2dnl Copyright (C) 2008-2012 Free Software Foundation, Inc. 3dnl This file is free software; the Free Software Foundation 4dnl gives unlimited permission to copy and/or distribute it, 5dnl with or without modifications, as long as this notice is preserved. 6 7dnl npth_SOCKETLIB 8dnl Determines the library to use for socket functions. 9dnl Sets and AC_SUBSTs LIBSOCKET. 10AC_DEFUN([npth_LIBSOCKET], 11[ 12 LIBSOCKET= 13 dnl Unix API. 14 dnl Solaris has most socket functions in libsocket. 15 dnl Haiku has most socket functions in libnetwork. 16 dnl BeOS has most socket functions in libnet. 17 AC_CACHE_CHECK([for library containing setsockopt], [npth_cv_lib_socket], [ 18 npth_cv_lib_socket= 19 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern 20#ifdef __cplusplus 21"C" 22#endif 23char setsockopt();]], [[setsockopt();]])], 24 [], 25 [npth_save_LIBS="$LIBS" 26 LIBS="$npth_save_LIBS -lsocket" 27 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern 28#ifdef __cplusplus 29"C" 30#endif 31char setsockopt();]], [[setsockopt();]])], 32 [npth_cv_lib_socket="-lsocket"]) 33 if test -z "$npth_cv_lib_socket"; then 34 LIBS="$npth_save_LIBS -lnetwork" 35 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern 36#ifdef __cplusplus 37"C" 38#endif 39char setsockopt();]], [[setsockopt();]])], 40 [npth_cv_lib_socket="-lnetwork"]) 41 if test -z "$npth_cv_lib_socket"; then 42 LIBS="$npth_save_LIBS -lnet" 43 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern 44#ifdef __cplusplus 45"C" 46#endif 47char setsockopt();]], [[setsockopt();]])], 48 [npth_cv_lib_socket="-lnet"]) 49 fi 50 fi 51 LIBS="$npth_save_LIBS" 52 ]) 53 if test -z "$npth_cv_lib_socket"; then 54 npth_cv_lib_socket="none needed" 55 fi 56 ]) 57 if test "$npth_cv_lib_socket" != "none needed"; then 58 LIBSOCKET="$npth_cv_lib_socket" 59 fi 60 AC_SUBST([LIBSOCKET]) 61]) 62