MFH: - Allow using extra headers in PHP_CHECK_SIZEOF

This commit is contained in:
Jani Taskinen 2007-07-25 22:49:39 +00:00
parent 2600cf9c20
commit 5a1c39f71d

View File

@ -1026,21 +1026,17 @@ dnl -------------------------------------------------------------------------
dnl Checks for structures, typedefs, broken functions, etc. dnl Checks for structures, typedefs, broken functions, etc.
dnl ------------------------------------------------------------------------- dnl -------------------------------------------------------------------------
dnl Internal helper macro
dnl _PHP_CHECK_SIZEOF(type, cross-value, extra-headers [, found-action [, not-found-action]])
dnl dnl
dnl PHP_CHECK_SIZEOF(TYPE [, CROSS-SIZE]) AC_DEFUN([_PHP_CHECK_SIZEOF], [
dnl Enhanced version of AC_CHECK_SIZEOF for checking more types php_cache_value=php_cv_sizeof_[]$1
dnl than just those defined in stdio.h AC_CACHE_VAL(php_cv_sizeof_[]$1, [
dnl old_LIBS=$LIBS
AC_DEFUN(PHP_CHECK_SIZEOF, LIBS=
[changequote(<<, >>)dnl old_LDFLAGS=$LDFLAGS
dnl The name to #define. LDFLAGS=
define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl AC_TRY_RUN([#include <stdio.h>
dnl The cache variable name.
define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
changequote([, ])dnl
AC_MSG_CHECKING(size of $1)
AC_CACHE_VAL(AC_CV_NAME,
[AC_TRY_RUN([#include <stdio.h>
#if STDC_HEADERS #if STDC_HEADERS
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h> #include <stddef.h>
@ -1051,17 +1047,41 @@ AC_CACHE_VAL(AC_CV_NAME,
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
$3
int main() int main()
{ {
FILE *f=fopen("conftestval", "w"); FILE *fp = fopen("conftestval", "w");
if (!f) return(1); if (!fp) return(1);
fprintf(f, "%d\n", sizeof($1)); fprintf(fp, "%d\n", sizeof($1));
return(0); return(0);
}], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$2], , , AC_CV_NAME=$2))])dnl }
AC_MSG_RESULT($AC_CV_NAME) ], [
AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in a $1.]) eval $php_cache_value=`cat conftestval`
undefine([AC_TYPE_NAME])dnl ], [
undefine([AC_CV_NAME])dnl eval $php_cache_value=0
], [
ifelse([$2],,[eval $php_cache_value=0], [eval $php_cache_value=$2])
])
LDFLAGS=$old_LDFLAGS
LIBS=$old_LIBS
])
if eval test "\$$php_cache_value" != "0"; then
ifelse([$4],[],:,[$4])
ifelse([$5],[],,[else $5])
fi
])
dnl
dnl PHP_CHECK_SIZEOF(type, cross-value, extra-headers)
dnl
AC_DEFUN(PHP_CHECK_SIZEOF, [
AC_MSG_CHECKING([size of $1])
_PHP_CHECK_SIZEOF($1, $2, $3, [
AC_DEFINE_UNQUOTED([SIZEOF_]translit($1,a-z,A-Z_), [$]php_cv_sizeof_[]$1, [Size of $1])
AC_DEFINE_UNQUOTED([HAVE_]translit($1,a-z,A-Z_), 1, [Whether $1 is available])
])
AC_MSG_RESULT([[$][php_cv_sizeof_]translit($1, ,_)])
]) ])
dnl dnl