1dnl $Id$ -*- autoconf -*- 2 3dnl 4dnl Check if flush should be called explicitly after buffered io 5dnl 6AC_CACHE_CHECK([whether flush should be called explicitly after a buffered io], ac_cv_flush_io,[ 7AC_TRY_RUN( [ 8#include <stdio.h> 9#include <stdlib.h> 10 11int main(int argc, char **argv) 12{ 13 char *filename = tmpnam(NULL); 14 char buffer[64]; 15 int result = 0; 16 17 FILE *fp = fopen(filename, "wb"); 18 if (NULL == fp) 19 return 0; 20 fputs("line 1\n", fp); 21 fputs("line 2\n", fp); 22 fclose(fp); 23 24 fp = fopen(filename, "rb+"); 25 if (NULL == fp) 26 return 0; 27 fgets(buffer, sizeof(buffer), fp); 28 fputs("line 3\n", fp); 29 rewind(fp); 30 fgets(buffer, sizeof(buffer), fp); 31 if (0 != strcmp(buffer, "line 1\n")) 32 result = 1; 33 fgets(buffer, sizeof(buffer), fp); 34 if (0 != strcmp(buffer, "line 3\n")) 35 result = 1; 36 fclose(fp); 37 unlink(filename); 38 39 exit(result); 40} 41],[ 42 ac_cv_flush_io=no 43],[ 44 ac_cv_flush_io=yes 45],[ 46 ac_cv_flush_io=no 47])]) 48if test "$ac_cv_flush_io" = "yes"; then 49 AC_DEFINE(HAVE_FLUSHIO, 1, [Define if flush should be called explicitly after a buffered io.]) 50fi 51 52dnl 53dnl Check for crypt() capabilities 54dnl 55if test "$ac_cv_func_crypt" = "no"; then 56 AC_CHECK_LIB(crypt, crypt, [ 57 LIBS="-lcrypt $LIBS -lcrypt" 58 AC_DEFINE(HAVE_CRYPT, 1, [ ]) 59 ]) 60fi 61 62AC_CACHE_CHECK(for standard DES crypt, ac_cv_crypt_des,[ 63 AC_TRY_RUN([ 64#if HAVE_UNISTD_H 65#include <unistd.h> 66#endif 67 68#if HAVE_CRYPT_H 69#include <crypt.h> 70#endif 71 72int main() { 73#if HAVE_CRYPT 74 char *encrypted = crypt("rasmuslerdorf","rl"); 75 exit(!encrypted || strcmp(encrypted,"rl.3StKT.4T8M")); 76#else 77 exit(1); 78#endif 79}],[ 80 ac_cv_crypt_des=yes 81],[ 82 ac_cv_crypt_des=no 83],[ 84 ac_cv_crypt_des=yes 85])]) 86 87AC_CACHE_CHECK(for extended DES crypt, ac_cv_crypt_ext_des,[ 88 AC_TRY_RUN([ 89#if HAVE_UNISTD_H 90#include <unistd.h> 91#endif 92 93#if HAVE_CRYPT_H 94#include <crypt.h> 95#endif 96 97int main() { 98#if HAVE_CRYPT 99 char *encrypted = crypt("rasmuslerdorf","_J9..rasm"); 100 exit(!encrypted || strcmp(encrypted,"_J9..rasmBYk8r9AiWNc")); 101#else 102 exit(1); 103#endif 104}],[ 105 ac_cv_crypt_ext_des=yes 106],[ 107 ac_cv_crypt_ext_des=no 108],[ 109 ac_cv_crypt_ext_des=no 110])]) 111 112AC_CACHE_CHECK(for MD5 crypt, ac_cv_crypt_md5,[ 113AC_TRY_RUN([ 114#if HAVE_UNISTD_H 115#include <unistd.h> 116#endif 117 118#if HAVE_CRYPT_H 119#include <crypt.h> 120#endif 121 122int main() { 123#if HAVE_CRYPT 124 char salt[15], answer[40]; 125 char *encrypted; 126 127 salt[0]='$'; salt[1]='1'; salt[2]='$'; 128 salt[3]='r'; salt[4]='a'; salt[5]='s'; 129 salt[6]='m'; salt[7]='u'; salt[8]='s'; 130 salt[9]='l'; salt[10]='e'; salt[11]='$'; 131 salt[12]='\0'; 132 strcpy(answer,salt); 133 strcat(answer,"rISCgZzpwk3UhDidwXvin0"); 134 encrypted = crypt("rasmuslerdorf",salt); 135 exit(!encrypted || strcmp(encrypted,answer)); 136#else 137 exit(1); 138#endif 139}],[ 140 ac_cv_crypt_md5=yes 141],[ 142 ac_cv_crypt_md5=no 143],[ 144 ac_cv_crypt_md5=no 145])]) 146 147AC_CACHE_CHECK(for Blowfish crypt, ac_cv_crypt_blowfish,[ 148AC_TRY_RUN([ 149#if HAVE_UNISTD_H 150#include <unistd.h> 151#endif 152 153#if HAVE_CRYPT_H 154#include <crypt.h> 155#endif 156 157int main() { 158#if HAVE_CRYPT 159 char salt[30], answer[70]; 160 char *encrypted; 161 162 salt[0]='$'; salt[1]='2'; salt[2]='a'; salt[3]='$'; salt[4]='0'; salt[5]='7'; salt[6]='$'; salt[7]='\0'; 163 strcat(salt,"rasmuslerd............"); 164 strcpy(answer,salt); 165 strcpy(&answer[29],"nIdrcHdxcUxWomQX9j6kvERCFjTg7Ra"); 166 encrypted = crypt("rasmuslerdorf",salt); 167 exit(!encrypted || strcmp(encrypted,answer)); 168#else 169 exit(1); 170#endif 171}],[ 172 ac_cv_crypt_blowfish=yes 173],[ 174 ac_cv_crypt_blowfish=no 175],[ 176 ac_cv_crypt_blowfish=no 177])]) 178 179AC_CACHE_CHECK(for SHA512 crypt, ac_cv_crypt_sha512,[ 180AC_TRY_RUN([ 181#if HAVE_UNISTD_H 182#include <unistd.h> 183#endif 184 185#if HAVE_CRYPT_H 186#include <crypt.h> 187#endif 188 189int main() { 190#if HAVE_CRYPT 191 char salt[21], answer[21+86]; 192 char *encrypted; 193 194 strcpy(salt,"\$6\$rasmuslerdorf\$"); 195 strcpy(answer, salt); 196 strcat(answer, "EeHCRjm0bljalWuALHSTs1NB9ipEiLEXLhYeXdOpx22gmlmVejnVXFhd84cEKbYxCo.XuUTrW.RLraeEnsvWs/"); 197 encrypted = crypt("rasmuslerdorf",salt); 198 exit(!encrypted || strcmp(encrypted,answer)); 199#else 200 exit(1); 201#endif 202}],[ 203 ac_cv_crypt_sha512=yes 204],[ 205 ac_cv_crypt_sha512=no 206],[ 207 ac_cv_crypt_sha512=no 208])]) 209 210AC_CACHE_CHECK(for SHA256 crypt, ac_cv_crypt_sha256,[ 211AC_TRY_RUN([ 212#if HAVE_UNISTD_H 213#include <unistd.h> 214#endif 215 216#if HAVE_CRYPT_H 217#include <crypt.h> 218#endif 219 220int main() { 221#if HAVE_CRYPT 222 char salt[21], answer[21+43]; 223 char *encrypted; 224 225 strcpy(salt,"\$5\$rasmuslerdorf\$"); 226 strcpy(answer, salt); 227 strcat(answer, "cFAm2puLCujQ9t.0CxiFIIvFi4JyQx5UncCt/xRIX23"); 228 encrypted = crypt("rasmuslerdorf",salt); 229 exit(!encrypted || strcmp(encrypted,answer)); 230#else 231 exit(1); 232#endif 233}],[ 234 ac_cv_crypt_sha256=yes 235],[ 236 ac_cv_crypt_sha256=no 237],[ 238 ac_cv_crypt_sha256=no 239])]) 240 241 242dnl 243dnl If one of them is missing, use our own implementation, portable code is then possible 244dnl 245if test "$ac_cv_crypt_blowfish" = "no" || test "$ac_cv_crypt_des" = "no" || test "$ac_cv_crypt_ext_des" = "no" || test "$ac_cv_crypt_md5" = "no" || test "$ac_cv_crypt_sha512" = "no" || test "$ac_cv_crypt_sha256" = "no" || test "x$php_crypt_r" = "x0"; then 246 247 dnl 248 dnl Check for __alignof__ support in the compiler 249 dnl 250 AC_CACHE_CHECK(whether the compiler supports __alignof__, ac_cv_alignof_exists,[ 251 AC_TRY_COMPILE([ 252 ],[ 253 int align = __alignof__(int); 254 ],[ 255 ac_cv_alignof_exists=yes 256 ],[ 257 ac_cv_alignof_exists=no 258 ])]) 259 if test "$ac_cv_alignof_exists" = "yes"; then 260 AC_DEFINE([HAVE_ALIGNOF], 1, [whether the compiler supports __alignof__]) 261 fi 262 263 AC_DEFINE_UNQUOTED(PHP_USE_PHP_CRYPT_R, 1, [Whether PHP has to use its own crypt_r for blowfish, des, ext des and md5]) 264 265 PHP_ADD_SOURCES(PHP_EXT_DIR(standard), crypt_freesec.c crypt_blowfish.c crypt_sha512.c crypt_sha256.c php_crypt_r.c) 266else 267 AC_DEFINE_UNQUOTED(PHP_USE_PHP_CRYPT_R, 0, [Whether PHP has to use its own crypt_r for blowfish, des and ext des]) 268fi 269 270dnl 271dnl Check for __attribute__ ((__aligned__)) support in the compiler 272dnl 273AC_CACHE_CHECK(whether the compiler supports aligned attribute, ac_cv_attribute_aligned,[ 274AC_TRY_COMPILE([ 275],[ 276 unsigned char test[32] __attribute__ ((__aligned__ (__alignof__ (int)))); 277],[ 278 ac_cv_attribute_aligned=yes 279],[ 280 ac_cv_attribute_aligned=no 281])]) 282if test "$ac_cv_attribute_aligned" = "yes"; then 283 AC_DEFINE([HAVE_ATTRIBUTE_ALIGNED], 1, [whether the compiler supports __attribute__ ((__aligned__))]) 284fi 285 286dnl 287dnl Check for available functions 288dnl 289dnl log2 could be used to improve the log function, however it requires C99. The check for log2 should be turned on, 290dnl as soon as we support C99. 291AC_CHECK_FUNCS(getcwd getwd asinh acosh atanh log1p hypot glob strfmon nice fpclass mempcpy strpncpy) 292AC_CHECK_DECLS([isnan, isinf], [], [], [[#include <math.h>]]) 293AC_FUNC_FNMATCH 294 295dnl 296dnl Check if there is a support means of creating a new process 297dnl and defining which handles it receives 298dnl 299AC_CHECK_FUNCS(fork CreateProcess, [ 300 php_can_support_proc_open=yes 301 break 302],[ 303 php_can_support_proc_open=no 304]) 305AC_MSG_CHECKING([if your OS can spawn processes with inherited handles]) 306if test "$php_can_support_proc_open" = "yes"; then 307 AC_MSG_RESULT(yes) 308 AC_DEFINE(PHP_CAN_SUPPORT_PROC_OPEN,1, [Define if your system has fork/vfork/CreateProcess]) 309else 310 AC_MSG_RESULT(no) 311fi 312 313PHP_ENABLE_CHROOT_FUNC=no 314case "$PHP_SAPI" in 315 embed) 316 PHP_ENABLE_CHROOT_FUNC=yes 317 ;; 318 319 none) 320 for PROG in $PHP_BINARIES; do 321 case "$PROG" in 322 cgi|cli|phpdbg) 323 PHP_ENABLE_CHROOT_FUNC=yes 324 ;; 325 326 *) 327 PHP_ENABLE_CHROOT_FUNC=no 328 break 329 ;; 330 esac 331 done 332 ;; 333esac 334 335if test "$PHP_ENABLE_CHROOT_FUNC" = "yes"; then 336 AC_DEFINE(ENABLE_CHROOT_FUNC, 1, [Whether to enable chroot() function]) 337fi 338 339dnl 340dnl Detect library functions needed by php dns_xxx functions 341dnl ext/standard/php_dns.h will collect these in a single define: HAVE_FULL_DNS_FUNCS 342dnl 343PHP_CHECK_FUNC(res_nsearch, resolv, bind, socket) 344PHP_CHECK_FUNC(res_ndestroy, resolv, bind, socket) 345PHP_CHECK_FUNC(dns_search, resolv, bind, socket) 346PHP_CHECK_FUNC(dn_expand, resolv, bind, socket) 347PHP_CHECK_FUNC(dn_skipname, resolv, bind, socket) 348 349dnl 350dnl These are old deprecated functions 351dnl 352 353PHP_CHECK_FUNC(res_search, resolv, bind, socket) 354 355dnl 356dnl Check if atof() accepts NAN 357dnl 358AC_CACHE_CHECK(whether atof() accepts NAN, ac_cv_atof_accept_nan,[ 359AC_TRY_RUN([ 360#include <math.h> 361#include <stdlib.h> 362 363#if HAVE_DECL_ISNAN 364#define zend_isnan(a) isnan(a) 365#elif defined(HAVE_FPCLASS) 366#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN)) 367#else 368#define zend_isnan(a) 0 369#endif 370 371int main(int argc, char** argv) 372{ 373 return zend_isnan(atof("NAN")) ? 0 : 1; 374} 375],[ 376 ac_cv_atof_accept_nan=yes 377],[ 378 ac_cv_atof_accept_nan=no 379],[ 380 ac_cv_atof_accept_nan=no 381])]) 382if test "$ac_cv_atof_accept_nan" = "yes"; then 383 AC_DEFINE([HAVE_ATOF_ACCEPTS_NAN], 1, [whether atof() accepts NAN]) 384fi 385 386dnl 387dnl Check if atof() accepts INF 388dnl 389AC_CACHE_CHECK(whether atof() accepts INF, ac_cv_atof_accept_inf,[ 390AC_TRY_RUN([ 391#include <math.h> 392#include <stdlib.h> 393 394#if HAVE_DECL_ISINF 395#define zend_isinf(a) isinf(a) 396#elif defined(INFINITY) 397/* Might not work, but is required by ISO C99 */ 398#define zend_isinf(a) (((a)==INFINITY || (a)==-INFINITY)?1:0) 399#elif defined(HAVE_FPCLASS) 400#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF)) 401#else 402#define zend_isinf(a) 0 403#endif 404 405int main(int argc, char** argv) 406{ 407 return zend_isinf(atof("INF")) && zend_isinf(atof("-INF")) ? 0 : 1; 408} 409],[ 410 ac_cv_atof_accept_inf=yes 411],[ 412 ac_cv_atof_accept_inf=no 413],[ 414 ac_cv_atof_accept_inf=no 415])]) 416if test "$ac_cv_atof_accept_inf" = "yes"; then 417 AC_DEFINE([HAVE_ATOF_ACCEPTS_INF], 1, [whether atof() accepts INF]) 418fi 419 420dnl 421dnl Check if HUGE_VAL == INF 422dnl 423AC_CACHE_CHECK(whether HUGE_VAL == INF, ac_cv_huge_val_inf,[ 424AC_TRY_RUN([ 425#include <math.h> 426#include <stdlib.h> 427 428#if HAVE_DECL_ISINF 429#define zend_isinf(a) isinf(a) 430#elif defined(INFINITY) 431/* Might not work, but is required by ISO C99 */ 432#define zend_isinf(a) (((a)==INFINITY || (a)==-INFINITY)?1:0) 433#elif defined(HAVE_FPCLASS) 434#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF)) 435#else 436#define zend_isinf(a) 0 437#endif 438 439int main(int argc, char** argv) 440{ 441 return zend_isinf(HUGE_VAL) ? 0 : 1; 442} 443],[ 444 ac_cv_huge_val_inf=yes 445],[ 446 ac_cv_huge_val_inf=no 447],[ 448 ac_cv_huge_val_inf=yes 449])]) 450dnl This is the most probable fallback so we assume yes in case of cross compile. 451if test "$ac_cv_huge_val_inf" = "yes"; then 452 AC_DEFINE([HAVE_HUGE_VAL_INF], 1, [whether HUGE_VAL == INF]) 453fi 454 455dnl 456dnl Check if HUGE_VAL + -HUGEVAL == NAN 457dnl 458AC_CACHE_CHECK(whether HUGE_VAL + -HUGEVAL == NAN, ac_cv_huge_val_nan,[ 459AC_TRY_RUN([ 460#include <math.h> 461#include <stdlib.h> 462 463#if HAVE_DECL_ISNAN 464#define zend_isnan(a) isnan(a) 465#elif defined(HAVE_FPCLASS) 466#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN)) 467#else 468#define zend_isnan(a) 0 469#endif 470 471int main(int argc, char** argv) 472{ 473#if defined(__sparc__) && !(__GNUC__ >= 3) 474 /* prevent bug #27830 */ 475 return 1; 476#else 477 return zend_isnan(HUGE_VAL + -HUGE_VAL) ? 0 : 1; 478#endif 479} 480],[ 481 ac_cv_huge_val_nan=yes 482],[ 483 ac_cv_huge_val_nan=no 484],[ 485 ac_cv_huge_val_nan=yes 486])]) 487dnl This is the most probable fallback so we assume yes in case of cross compile. 488if test "$ac_cv_huge_val_nan" = "yes"; then 489 AC_DEFINE([HAVE_HUGE_VAL_NAN], 1, [whether HUGE_VAL + -HUGEVAL == NAN]) 490fi 491 492dnl 493dnl Check for strptime() 494dnl 495AC_CACHE_CHECK(whether strptime() declaration fails, ac_cv_strptime_decl_fails,[ 496AC_TRY_COMPILE([ 497#include <time.h> 498],[ 499#ifndef HAVE_STRPTIME 500#error no strptime() on this platform 501#else 502/* use invalid strptime() declaration to see if it fails to compile */ 503int strptime(const char *s, const char *format, struct tm *tm); 504#endif 505],[ 506 ac_cv_strptime_decl_fails=no 507],[ 508 ac_cv_strptime_decl_fails=yes 509])]) 510if test "$ac_cv_strptime_decl_fails" = "yes"; then 511 AC_DEFINE([HAVE_STRPTIME_DECL_FAILS], 1, [whether strptime() declaration fails]) 512fi 513 514dnl 515dnl Check for i18n capabilities 516dnl 517AC_CHECK_HEADERS([wchar.h]) 518AC_CHECK_FUNCS([mblen]) 519AC_CHECK_FUNCS([mbrlen mbsinit],,,[ 520#ifdef HAVE_WCHAR_H 521# include <wchar.h> 522#endif 523]) 524AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],[ 525AC_TRY_COMPILE([ 526#ifdef HAVE_WCHAR_H 527# include <wchar.h> 528#endif 529],[ 530mbstate_t a; 531],[ 532 ac_cv_type_mbstate_t=yes 533],[ 534 ac_cv_type_mbstate_t=no 535])]) 536if test "$ac_cv_type_mbstate_t" = "yes"; then 537 AC_DEFINE([HAVE_MBSTATE_T], 1, [Define if your system has mbstate_t in wchar.h]) 538fi 539 540dnl 541dnl Check for atomic operation API availability in Solaris 542dnl 543AC_CHECK_HEADERS([atomic.h]) 544 545dnl 546dnl Check for arc4random on BSD systems 547dnl 548AC_CHECK_DECLS([arc4random_buf]) 549 550dnl 551dnl Setup extension sources 552dnl 553PHP_NEW_EXTENSION(standard, array.c base64.c basic_functions.c browscap.c crc32.c crypt.c \ 554 cyr_convert.c datetime.c dir.c dl.c dns.c exec.c file.c filestat.c \ 555 flock_compat.c formatted_print.c fsock.c head.c html.c image.c \ 556 info.c iptc.c lcg.c link.c mail.c math.c md5.c metaphone.c \ 557 microtime.c pack.c pageinfo.c quot_print.c rand.c mt_rand.c \ 558 soundex.c string.c scanf.c syslog.c type.c uniqid.c url.c \ 559 var.c versioning.c assert.c strnatcmp.c levenshtein.c \ 560 incomplete_class.c url_scanner_ex.c ftp_fopen_wrapper.c \ 561 http_fopen_wrapper.c php_fopen_wrapper.c credits.c css.c \ 562 var_unserializer.c ftok.c sha1.c user_filters.c uuencode.c \ 563 filters.c proc_open.c streamsfuncs.c http.c password.c \ 564 random.c,,, 565 -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) 566 567PHP_ADD_MAKEFILE_FRAGMENT 568PHP_INSTALL_HEADERS([ext/standard/]) 569