cvs: php4 / acinclude.m4 configure.in

From: Date: Thu, 04 Jul 2002 21:07:08 +0000
Subject: cvs: php4 / acinclude.m4 configure.in
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-12712@lists.php.net to get a copy of this message
sas Thu Jul 4 17:07:08 2002 EDT Modified files: /php4 acinclude.m4 configure.in Log: 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) Index: php4/acinclude.m4 diff -u php4/acinclude.m4:1.193 php4/acinclude.m4:1.194 --- php4/acinclude.m4:1.193 Sun Jun 30 21:01:06 2002 +++ php4/acinclude.m4 Thu Jul 4 17:07:08 2002 @@ -1,4 +1,4 @@ -dnl $Id: acinclude.m4,v 1.193 2002/07/01 01:01:06 imajes Exp $ +dnl $Id: acinclude.m4,v 1.194 2002/07/04 21:07:08 sas Exp $ dnl dnl This file contains local autoconf functions. @@ -927,8 +927,8 @@ 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 @@ -1470,4 +1470,65 @@ $2 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 ]) Index: php4/configure.in diff -u php4/configure.in:1.357 php4/configure.in:1.358 --- php4/configure.in:1.357 Tue Jul 2 05:31:33 2002 +++ php4/configure.in Thu Jul 4 17:07:08 2002 @@ -1,4 +1,4 @@ -dnl ## $Id: configure.in,v 1.357 2002/07/02 09:31:33 sas Exp $ -*- sh -*- +dnl ## $Id: configure.in,v 1.358 2002/07/04 21:07:08 sas Exp $ -*- sh -*- dnl ## Process this file with autoconf to produce a configure script. divert(1) @@ -298,76 +298,29 @@ 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 +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) -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,[ ]) ], []) -]) - -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 @@ 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 @@ limits.h \ locale.h \ mach-o/dyld.h \ -netinet/in.h \ pwd.h \ resolv.h \ signal.h \ @@ -418,15 +373,26 @@ 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 @@ gai_strerror \ gcvt \ getlogin \ -gethostbyaddr \ getprotobyname \ getprotobynumber \ getservbyname \ @@ -502,7 +467,6 @@ getrusage \ gettimeofday \ gmtime_r \ -inet_aton \ isascii \ link \ localtime_r \

« previous php.cvs (#12712) next »