summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2002-07-04 21:07:08 +0000
committerSascha Schumann <sas@php.net>2002-07-04 21:07:08 +0000
commitad198758edfdff40192dc1ac390874d1fae20abe (patch)
tree2ceecae3b79b18ad3aca84a1d68e20c3f3b8f64b
parent1b1d5da9074a5f69a9f68525025a8e09bc9674b6 (diff)
downloadphp-git-ad198758edfdff40192dc1ac390874d1fae20abe.tar.gz
1. PHP_CHECK_FUNC(func, lib1, lib2, ..., libn) searches for
func and __func using LIBS, and if unsuccessful, searches each specified lib. Defines HAVE_FUNC, if found. If func/__func is found in library foo, HAVE_LIBFOO is defined. (Jani, me) 2. Autoconf 2.5x is more pedantic regarding locating header files. We include the proper header files now in the check. (me) 3. The nsl/bind/socket/etc checks have been rewritten using PHP_CHECK_FUNC. This ensures that no extra library is used, if the symbol is available in libc which avoids issues on BSD/OS, OpenBSD and others. (Jani)
-rw-r--r--acinclude.m465
-rw-r--r--configure.in100
2 files changed, 95 insertions, 70 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index f8fc1e7006..35cc8bafac 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -927,8 +927,8 @@ dnl
dnl internal, don't use
AC_DEFUN(PHP_ADD_LIBRARY_SKELETON,[
case $1 in
- c|c_r|pthread*) ;;
- *) ifelse($3,,[
+ c|c_r|pthread*[)] ;;
+ *[)] ifelse($3,,[
PHP_X_ADD_LIBRARY($1,$2,$5)
],[
if test "$ext_shared" = "yes"; then
@@ -1471,3 +1471,64 @@ AC_DEFUN(PHP_SETUP_ICONV, [
ifelse([$3],[],,[else $3])
fi
])
+
+AC_DEFUN(PHP_DEF_HAVE,[AC_DEFINE([HAVE_]translit($1,a-z_-,A-Z__), 1, [ ])])
+
+dnl
+dnl PHP_CHECK_FUNC_LIB(func, libs)
+dnl This macro checks whether 'func' or '__func' exists
+dnl in the specified library.
+dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS.
+dnl This should be called in the ACTION-IF-NOT-FOUND part of PHP_CHECK_FUNC
+dnl
+
+dnl autoconf undefines the builtin "shift" :-(
+dnl If possible, we use the builtin shift anyway, otherwise we use
+dnl the ubercool definition I have tested so far with FreeBSD/GNU m4
+ifdef([builtin],[builtin(define, phpshift, [builtin(shift, $@)])],[
+define([phpshift],[ifelse(index([$@],[,]),-1,,[substr([$@],incr(index([$@],[,])))])])
+])
+
+AC_DEFUN(PHP_CHECK_FUNC_LIB,[
+ ifelse($2,,:,[
+ unset ac_cv_lib_$2[]_$1
+ unset ac_cv_lib_$2[]___$1
+ unset found
+ AC_CHECK_LIB($2, $1, [found=yes], [
+ AC_CHECK_LIB($2, __$1, [found=yes], [found=no])
+ ])
+
+ if test "$found" = "yes"; then
+ PHP_ADD_LIBRARY($2)
+ PHP_DEF_HAVE($1)
+ PHP_DEF_HAVE(lib$2)
+ ac_cv_func_$1=yes
+ else
+ PHP_CHECK_FUNC_LIB($1,phpshift(phpshift($@)))
+ fi
+ ])
+])
+
+dnl
+dnl PHP_CHECK_FUNC(func, ...)
+dnl This macro checks whether 'func' or '__func' exists
+dnl in the default libraries and as a fall back in the specified library.
+dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS.
+dnl
+AC_DEFUN(PHP_CHECK_FUNC,[
+ unset ac_cv_func_$1
+ unset ac_cv_func___$1
+ unset found
+
+ AC_CHECK_FUNC($1, [found=yes],[ AC_CHECK_FUNC(__$1,[found=yes],[found=no]) ])
+
+ case $found in
+ yes)
+ PHP_DEF_HAVE($1)
+ ac_cv_func_$1=yes
+ ;;
+ ifelse($#,1,,[
+ *) PHP_CHECK_FUNC_LIB($@) ;;
+ ])
+ esac
+])
diff --git a/configure.in b/configure.in
index f92ff6a905..07a01781b8 100644
--- a/configure.in
+++ b/configure.in
@@ -298,76 +298,29 @@ test -d /usr/ucblib && PHP_ADD_LIBPATH(/usr/ucblib)
dnl First, library checks.
dnl -------------------------------------------------------------------------
-AC_CHECK_LIB(socket, socket, [
- PHP_ADD_LIBRARY(socket)
- AC_DEFINE(HAVE_LIBSOCKET,1,[ ]) ], [
- AC_CHECK_LIB(socket, htonl, [
- PHP_ADD_LIBRARY(socket)
- ])])
-
dnl Some systems (OpenServer 5) dislike -lsocket -lnsl, so we try
dnl to avoid -lnsl checks, if we already have the functions which
dnl are usually in libnsl
dnl Also, uClibc will bark at linking with glibc's libnsl.
-unset ac_cv_func_gethostname
-unset ac_cv_func_yp_get_default_domain
-case $host_alias in
- *unixware* | *sco*)
- AC_CHECK_FUNC(gethostname, [
- php_no_nsl_checks=yes
- ])
- ;;
-esac
-AC_CHECK_FUNC(yp_get_default_domain, [
- php_no_nsl_checks=yes
-])
-unset ac_cv_func_gethostname
-unset ac_cv_func_yp_get_default_domain
-
-if test "$php_no_nsl_checks" != "yes"; then
-
-AC_CHECK_LIB(nsl, gethostname, [
- PHP_ADD_LIBRARY(nsl)
- AC_DEFINE(HAVE_LIBNSL,1,[ ]) ],[
- AC_CHECK_LIB(nsl, gethostbyaddr, [
- PHP_ADD_LIBRARY(nsl)
- AC_DEFINE(HAVE_LIBNSL,1,[ ]) ], [])
-])
+PHP_CHECK_FUNC(socket, socket)
+PHP_CHECK_FUNC(htonl, socket)
+PHP_CHECK_FUNC(gethostname, nsl)
+PHP_CHECK_FUNC(gethostbyaddr, nsl)
+PHP_CHECK_FUNC(yp_get_default_domain, nsl)
-fi
-
-AC_CHECK_LIB(dl, dlopen,[PHP_ADD_LIBRARY(dl)])
-
-dnl The sin may be in a library which need not be specifed
-dnl as well as res_search resides in libsocket
+AC_CHECK_LIB(dl, dlopen, [PHP_ADD_LIBRARY(dl)])
AC_CHECK_LIB(m, sin)
-dnl Only include libbind if inet_aton is not found in
-dnl libresolv.
-AC_CHECK_LIB(resolv, inet_aton, [], [
- AC_CHECK_LIB(bind, inet_aton, [], [
- AC_CHECK_LIB(bind, __inet_aton)
- ])
-])
-
-dnl The res_search may be in libsocket as well, and if it is
-dnl make sure to check for dn_skipname in libresolv, or if res_search
-dnl is in neither of these libs, still check for dn_skipname in libresolv
-AC_CHECK_LIB(socket, res_search, [
- AC_CHECK_LIB(resolv, dn_skipname)
- AC_CHECK_LIB(resolv, __dn_skipname)
- LIBS="$LIBS -lsocket"
- AC_DEFINE(HAVE_LIBSOCKET,1,[ ]) ], [
- AC_CHECK_LIB(resolv, res_search, [
- LIBS="$LIBS -lresolv"
- AC_DEFINE(HAVE_LIBRESOLV,1,[ ])
- ], [
- AC_CHECK_LIB(resolv, dn_skipname)
- AC_CHECK_LIB(resolv, __dn_skipname)
- ])
-])
+dnl Check for resolver routines.
+dnl Need to check for both res_search and __res_search
+dnl in -lc, -lbind, -lresolv and -lsocket
+PHP_CHECK_FUNC(res_search, resolv, bind, socket)
+dnl Check for inet_aton and dn_skipname
+dnl in -lc, -lbind and -lresolv
+PHP_CHECK_FUNC(inet_aton, resolv, bind)
+PHP_CHECK_FUNC(dn_skipname, resolv, bind)
dnl Then headers.
@@ -384,8 +337,11 @@ else
fi
PHP_MISSING_FCLOSE_DECL
dnl QNX requires unix.h to allow functions in libunix to work properly
-AC_CHECK_HEADERS(
+AC_CHECK_HEADERS([ \
ApplicationServices/ApplicationServices.h \
+sys/types.h \
+sys/time.h \
+netinet/in.h \
alloca.h \
arpa/inet.h \
arpa/nameser.h \
@@ -398,7 +354,6 @@ langinfo.h \
limits.h \
locale.h \
mach-o/dyld.h \
-netinet/in.h \
pwd.h \
resolv.h \
signal.h \
@@ -418,15 +373,26 @@ sys/statfs.h \
sys/statvfs.h \
sys/vfs.h \
sys/sysexits.h \
-sys/time.h \
-sys/types.h \
sys/varargs.h \
sys/wait.h \
unistd.h \
unix.h \
utime.h \
sys/utsname.h \
-)
+],[],[],[
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_NAMESER_H
+#include <arpa/nameser.h>
+#endif
+])
@@ -494,7 +460,6 @@ flock \
gai_strerror \
gcvt \
getlogin \
-gethostbyaddr \
getprotobyname \
getprotobynumber \
getservbyname \
@@ -502,7 +467,6 @@ getservbyport \
getrusage \
gettimeofday \
gmtime_r \
-inet_aton \
isascii \
link \
localtime_r \