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