Skip to content

Commit 4465e50

Browse files
authored
Use AC_SEARCH_LIBS for socketpair, gethostname and gethostbyaddr (#14116)
The socketpair(): * C library: Solaris 11.4 and most other systems * libsocket: Solaris <= 11.3 and illumos * libnetwork: Haiku The gethostname() check is moved to AC_CHECK_FUNCS: * C library: most systems * libnsl: none * libnetwork: Haiku (which is already checked in the libraries section) The gethostbyaddr(): * C library: most systems, Solaris 11.4 * libnsl: Solaris 11.3, illumos * libnetwork: Haiku This also removes redundant unused symbols: - HAVE_GETHOSTBYADDR - HAVE_LIBNETWORK - HAVE_LIBNSL The outdated comment about -lnsl and -lsocket linking has been removed because these systems are long not supported anymore and this issue is not relevant anymore like mentioned. The initial solution was different than the one with the PHP_CHECK_FUNC macros at the current versions. See commit a188fac where the gethostbyaddr() was checked conditionally based on the gethostname() availability in libc. Main issue was mostly related to the redundant nsl library being always linked because of the AC_CHECK_LIB.
1 parent cad0e55 commit 4465e50

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

configure.ac

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,16 +356,17 @@ test -d /usr/ucblib && PHP_ADD_LIBPATH(/usr/ucblib)
356356
dnl First, library checks.
357357
dnl ----------------------------------------------------------------------------
358358

359-
dnl Some systems (OpenServer 5) dislike -lsocket -lnsl, so we try to avoid -lnsl
360-
dnl checks, if we already have the functions which are usually in libnsl. Also,
361-
dnl uClibc will bark at linking with glibc's libnsl.
362-
363359
AC_SEARCH_LIBS([socket], [socket network])
364-
PHP_CHECK_FUNC(socketpair, socket, network)
365-
PHP_CHECK_FUNC(gethostname, nsl, network)
366-
PHP_CHECK_FUNC(gethostbyaddr, nsl, network)
360+
361+
AC_CHECK_FUNCS([socketpair],,
362+
[AC_SEARCH_LIBS([socketpair], [socket network],
363+
[AC_DEFINE([HAVE_SOCKETPAIR], [1])])])
364+
365+
AC_SEARCH_LIBS([gethostbyaddr], [nsl network])
366+
367367
AC_SEARCH_LIBS([dlopen], [dl],
368368
[AC_DEFINE([HAVE_LIBDL], [1], [Define to 1 if the dl library is available.])])
369+
369370
AC_SEARCH_LIBS([sin], [m])
370371

371372
case $host_alias in
@@ -588,6 +589,7 @@ ftok \
588589
funopen \
589590
gai_strerror \
590591
getcwd \
592+
gethostname \
591593
getloadavg \
592594
getlogin \
593595
getprotobyname \

0 commit comments

Comments
 (0)