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[21], answer[21+86]; 186 187 strcpy(salt,"\$6\$rasmuslerdorf\$"); 188 strcpy(answer, salt); 189 strcat(answer, "EeHCRjm0bljalWuALHSTs1NB9ipEiLEXLhYeXdOpx22gmlmVejnVXFhd84cEKbYxCo.XuUTrW.RLraeEnsvWs/"); 190 exit (strcmp((char *)crypt("rasmuslerdorf",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[21], answer[21+43]; 215 216 strcpy(salt,"\$5\$rasmuslerdorf\$"); 217 strcpy(answer, salt); 218 strcat(answer, "cFAm2puLCujQ9t.0CxiFIIvFi4JyQx5UncCt/xRIX23"); 219 exit (strcmp((char *)crypt("rasmuslerdorf",salt),answer)); 220 221#else 222 exit(0); 223#endif 224}],[ 225 ac_cv_crypt_sha256=yes 226],[ 227 ac_cv_crypt_sha256=no 228],[ 229 ac_cv_crypt_sha256=no 230])]) 231 232 233dnl 234dnl If one of them is missing, use our own implementation, portable code is then possible 235dnl 236if 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 237 238 dnl 239 dnl Check for __alignof__ support in the compiler 240 dnl 241 AC_CACHE_CHECK(whether the compiler supports __alignof__, ac_cv_alignof_exists,[ 242 AC_TRY_COMPILE([ 243 ],[ 244 int align = __alignof__(int); 245 ],[ 246 ac_cv_alignof_exists=yes 247 ],[ 248 ac_cv_alignof_exists=no 249 ])]) 250 if test "$ac_cv_alignof_exists" = "yes"; then 251 AC_DEFINE([HAVE_ALIGNOF], 1, [whether the compiler supports __alignof__]) 252 fi 253 254 dnl 255 dnl Check for __attribute__ ((__aligned__)) support in the compiler 256 dnl 257 AC_CACHE_CHECK(whether the compiler supports aligned attribute, ac_cv_attribute_aligned,[ 258 AC_TRY_COMPILE([ 259 ],[ 260 unsigned char test[32] __attribute__ ((__aligned__ (__alignof__ (int)))); 261 ],[ 262 ac_cv_attribute_aligned=yes 263 ],[ 264 ac_cv_attribute_aligned=no 265 ])]) 266 if test "$ac_cv_attribute_aligned" = "yes"; then 267 AC_DEFINE([HAVE_ATTRIBUTE_ALIGNED], 1, [whether the compiler supports __attribute__ ((__aligned__))]) 268 fi 269 270 271 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]) 272 AC_DEFINE_UNQUOTED(PHP_STD_DES_CRYPT, 1, [Whether the system supports standard DES salt]) 273 AC_DEFINE_UNQUOTED(PHP_BLOWFISH_CRYPT, 1, [Whether the system supports BlowFish salt]) 274 AC_DEFINE_UNQUOTED(PHP_EXT_DES_CRYPT, 1, [Whether the system supports extended DES salt]) 275 AC_DEFINE_UNQUOTED(PHP_MD5_CRYPT, 1, [Whether the system supports MD5 salt]) 276 AC_DEFINE_UNQUOTED(PHP_SHA512_CRYPT, 1, [Whether the system supports SHA512 salt]) 277 AC_DEFINE_UNQUOTED(PHP_SHA256_CRYPT, 1, [Whether the system supports SHA256 salt]) 278 279 PHP_ADD_SOURCES(PHP_EXT_DIR(standard), crypt_freesec.c crypt_blowfish.c crypt_sha512.c crypt_sha256.c php_crypt_r.c) 280else 281 if test "$ac_cv_crypt_des" = "yes"; then 282 ac_result=1 283 ac_crypt_des=1 284 else 285 ac_result=0 286 ac_crypt_des=0 287 fi 288 AC_DEFINE_UNQUOTED(PHP_STD_DES_CRYPT, $ac_result, [Whether the system supports standard DES salt]) 289 290 if test "$ac_cv_crypt_blowfish" = "yes"; then 291 ac_result=1 292 ac_crypt_blowfish=1 293 else 294 ac_result=0 295 ac_crypt_blowfish=0 296 fi 297 AC_DEFINE_UNQUOTED(PHP_BLOWFISH_CRYPT, $ac_result, [Whether the system supports BlowFish salt]) 298 299 if test "$ac_cv_crypt_ext_des" = "yes"; then 300 ac_result=1 301 ac_crypt_edes=1 302 else 303 ac_result=0 304 ac_crypt_edes=0 305 fi 306 AC_DEFINE_UNQUOTED(PHP_EXT_DES_CRYPT, $ac_result, [Whether the system supports extended DES salt]) 307 308 if test "$ac_cv_crypt_md5" = "yes"; then 309 ac_result=1 310 ac_crypt_md5=1 311 else 312 ac_result=0 313 ac_crypt_md5=0 314 fi 315 AC_DEFINE_UNQUOTED(PHP_MD5_CRYPT, $ac_result, [Whether the system supports MD5 salt]) 316 317 if test "$ac_cv_crypt_sha512" = "yes"; then 318 ac_result=1 319 ac_crypt_sha512=1 320 else 321 ac_result=0 322 ac_crypt_sha512=0 323 fi 324 AC_DEFINE_UNQUOTED(PHP_SHA512_CRYPT, $ac_result, [Whether the system supports SHA512 salt]) 325 326 if test "$ac_cv_crypt_sha256" = "yes"; then 327 ac_result=1 328 ac_crypt_sha256=1 329 else 330 ac_result=0 331 ac_crypt_sha256=0 332 fi 333 AC_DEFINE_UNQUOTED(PHP_SHA256_CRYPT, $ac_result, [Whether the system supports SHA256 salt]) 334 335 AC_DEFINE_UNQUOTED(PHP_USE_PHP_CRYPT_R, 0, [Whether PHP has to use its own crypt_r for blowfish, des and ext des]) 336fi 337 338dnl 339dnl Check for available functions 340dnl 341AC_CHECK_FUNCS(getcwd getwd asinh acosh atanh log1p hypot glob strfmon nice fpclass isinf isnan mempcpy strpncpy) 342AC_FUNC_FNMATCH 343 344dnl 345dnl Check if there is a support means of creating a new process 346dnl and defining which handles it receives 347dnl 348AC_CHECK_FUNCS(fork CreateProcess, [ 349 php_can_support_proc_open=yes 350 break 351],[ 352 php_can_support_proc_open=no 353]) 354AC_MSG_CHECKING([if your OS can spawn processes with inherited handles]) 355if test "$php_can_support_proc_open" = "yes"; then 356 AC_MSG_RESULT(yes) 357 AC_DEFINE(PHP_CAN_SUPPORT_PROC_OPEN,1, [Define if your system has fork/vfork/CreateProcess]) 358else 359 AC_MSG_RESULT(no) 360fi 361 362PHP_ENABLE_CHROOT_FUNC=no 363case "$PHP_SAPI" in 364 embed) 365 PHP_ENABLE_CHROOT_FUNC=yes 366 ;; 367 368 none) 369 for PROG in $PHP_BINARIES; do 370 case "$PROG" in 371 cgi|cli) 372 PHP_ENABLE_CHROOT_FUNC=yes 373 ;; 374 375 *) 376 PHP_ENABLE_CHROOT_FUNC=no 377 break 378 ;; 379 esac 380 done 381 ;; 382esac 383 384if test "$PHP_ENABLE_CHROOT_FUNC" = "yes"; then 385 AC_DEFINE(ENABLE_CHROOT_FUNC, 1, [Whether to enable chroot() function]) 386fi 387 388dnl 389dnl Detect library functions needed by php dns_xxx functions 390dnl ext/standard/php_dns.h will collect these in a single define: HAVE_FULL_DNS_FUNCS 391dnl 392PHP_CHECK_FUNC(res_nsearch, resolv, bind, socket) 393PHP_CHECK_FUNC(dns_search, resolv, bind, socket) 394PHP_CHECK_FUNC(dn_expand, resolv, bind, socket) 395PHP_CHECK_FUNC(dn_skipname, resolv, bind, socket) 396 397dnl 398dnl These are old deprecated functions 399dnl 400 401PHP_CHECK_FUNC(res_search, resolv, bind, socket) 402 403dnl 404dnl Check if atof() accepts NAN 405dnl 406AC_CACHE_CHECK(whether atof() accepts NAN, ac_cv_atof_accept_nan,[ 407AC_TRY_RUN([ 408#include <math.h> 409#include <stdlib.h> 410 411#ifdef HAVE_ISNAN 412#define zend_isnan(a) isnan(a) 413#elif defined(HAVE_FPCLASS) 414#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN)) 415#else 416#define zend_isnan(a) 0 417#endif 418 419int main(int argc, char** argv) 420{ 421 return zend_isnan(atof("NAN")) ? 0 : 1; 422} 423],[ 424 ac_cv_atof_accept_nan=yes 425],[ 426 ac_cv_atof_accept_nan=no 427],[ 428 ac_cv_atof_accept_nan=no 429])]) 430if test "$ac_cv_atof_accept_nan" = "yes"; then 431 AC_DEFINE([HAVE_ATOF_ACCEPTS_NAN], 1, [whether atof() accepts NAN]) 432fi 433 434dnl 435dnl Check if atof() accepts INF 436dnl 437AC_CACHE_CHECK(whether atof() accepts INF, ac_cv_atof_accept_inf,[ 438AC_TRY_RUN([ 439#include <math.h> 440#include <stdlib.h> 441 442#ifdef HAVE_ISINF 443#define zend_isinf(a) isinf(a) 444#elif defined(INFINITY) 445/* Might not work, but is required by ISO C99 */ 446#define zend_isinf(a) (((a)==INFINITY)?1:0) 447#elif defined(HAVE_FPCLASS) 448#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF)) 449#else 450#define zend_isinf(a) 0 451#endif 452 453int main(int argc, char** argv) 454{ 455 return zend_isinf(atof("INF")) && zend_isinf(atof("-INF")) ? 0 : 1; 456} 457],[ 458 ac_cv_atof_accept_inf=yes 459],[ 460 ac_cv_atof_accept_inf=no 461],[ 462 ac_cv_atof_accept_inf=no 463])]) 464if test "$ac_cv_atof_accept_inf" = "yes"; then 465 AC_DEFINE([HAVE_ATOF_ACCEPTS_INF], 1, [whether atof() accepts INF]) 466fi 467 468dnl 469dnl Check if HUGE_VAL == INF 470dnl 471AC_CACHE_CHECK(whether HUGE_VAL == INF, ac_cv_huge_val_inf,[ 472AC_TRY_RUN([ 473#include <math.h> 474#include <stdlib.h> 475 476#ifdef HAVE_ISINF 477#define zend_isinf(a) isinf(a) 478#elif defined(INFINITY) 479/* Might not work, but is required by ISO C99 */ 480#define zend_isinf(a) (((a)==INFINITY)?1:0) 481#elif defined(HAVE_FPCLASS) 482#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF)) 483#else 484#define zend_isinf(a) 0 485#endif 486 487int main(int argc, char** argv) 488{ 489 return zend_isinf(HUGE_VAL) ? 0 : 1; 490} 491],[ 492 ac_cv_huge_val_inf=yes 493],[ 494 ac_cv_huge_val_inf=no 495],[ 496 ac_cv_huge_val_inf=yes 497])]) 498dnl This is the most probable fallback so we assume yes in case of cross compile. 499if test "$ac_cv_huge_val_inf" = "yes"; then 500 AC_DEFINE([HAVE_HUGE_VAL_INF], 1, [whether HUGE_VAL == INF]) 501fi 502 503dnl 504dnl Check if HUGE_VAL + -HUGEVAL == NAN 505dnl 506AC_CACHE_CHECK(whether HUGE_VAL + -HUGEVAL == NAN, ac_cv_huge_val_nan,[ 507AC_TRY_RUN([ 508#include <math.h> 509#include <stdlib.h> 510 511#ifdef HAVE_ISNAN 512#define zend_isnan(a) isnan(a) 513#elif defined(HAVE_FPCLASS) 514#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN)) 515#else 516#define zend_isnan(a) 0 517#endif 518 519int main(int argc, char** argv) 520{ 521#if defined(__sparc__) && !(__GNUC__ >= 3) 522 /* prevent bug #27830 */ 523 return 1; 524#else 525 return zend_isnan(HUGE_VAL + -HUGE_VAL) ? 0 : 1; 526#endif 527} 528],[ 529 ac_cv_huge_val_nan=yes 530],[ 531 ac_cv_huge_val_nan=no 532],[ 533 ac_cv_huge_val_nan=yes 534])]) 535dnl This is the most probable fallback so we assume yes in case of cross compile. 536if test "$ac_cv_huge_val_nan" = "yes"; then 537 AC_DEFINE([HAVE_HUGE_VAL_NAN], 1, [whether HUGE_VAL + -HUGEVAL == NAN]) 538fi 539 540dnl 541dnl Check for strptime() 542dnl 543AC_CACHE_CHECK(whether strptime() declaration fails, ac_cv_strptime_decl_fails,[ 544AC_TRY_COMPILE([ 545#include <time.h> 546],[ 547#ifndef HAVE_STRPTIME 548#error no strptime() on this platform 549#else 550/* use invalid strptime() declaration to see if it fails to compile */ 551int strptime(const char *s, const char *format, struct tm *tm); 552#endif 553],[ 554 ac_cv_strptime_decl_fails=no 555],[ 556 ac_cv_strptime_decl_fails=yes 557])]) 558if test "$ac_cv_strptime_decl_fails" = "yes"; then 559 AC_DEFINE([HAVE_STRPTIME_DECL_FAILS], 1, [whether strptime() declaration fails]) 560fi 561 562dnl 563dnl Check for i18n capabilities 564dnl 565AC_CHECK_HEADERS([wchar.h]) 566AC_CHECK_FUNCS([mblen]) 567AC_CHECK_FUNCS([mbrlen mbsinit],,,[ 568#ifdef HAVE_WCHAR_H 569# include <wchar.h> 570#endif 571]) 572AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],[ 573AC_TRY_COMPILE([ 574#ifdef HAVE_WCHAR_H 575# include <wchar.h> 576#endif 577],[ 578int __tmp__() { mbstate_t a; } 579],[ 580 ac_cv_type_mbstate_t=yes 581],[ 582 ac_cv_type_mbstate_t=no 583])]) 584if test "$ac_cv_type_mbstate_t" = "yes"; then 585 AC_DEFINE([HAVE_MBSTATE_T], 1, [Define if your system has mbstate_t in wchar.h]) 586fi 587 588dnl 589dnl Check for atomic operation API availability in Solaris 590dnl 591AC_CHECK_HEADERS([atomic.h]) 592 593dnl 594dnl Setup extension sources 595dnl 596PHP_NEW_EXTENSION(standard, array.c base64.c basic_functions.c browscap.c crc32.c crypt.c \ 597 cyr_convert.c datetime.c dir.c dl.c dns.c exec.c file.c filestat.c \ 598 flock_compat.c formatted_print.c fsock.c head.c html.c image.c \ 599 info.c iptc.c lcg.c link.c mail.c math.c md5.c metaphone.c \ 600 microtime.c pack.c pageinfo.c quot_print.c rand.c \ 601 soundex.c string.c scanf.c syslog.c type.c uniqid.c url.c \ 602 var.c versioning.c assert.c strnatcmp.c levenshtein.c \ 603 incomplete_class.c url_scanner_ex.c ftp_fopen_wrapper.c \ 604 http_fopen_wrapper.c php_fopen_wrapper.c credits.c css.c \ 605 var_unserializer.c ftok.c sha1.c user_filters.c uuencode.c \ 606 filters.c proc_open.c streamsfuncs.c http.c password.c) 607 608PHP_ADD_MAKEFILE_FRAGMENT 609PHP_INSTALL_HEADERS([ext/standard/]) 610