1dnl 2dnl Check if flush should be called explicitly after buffered io 3dnl 4AC_CACHE_CHECK([whether flush should be called explicitly after a buffered io], ac_cv_flush_io,[ 5AC_RUN_IFELSE([AC_LANG_SOURCE([[ 6#include <stdio.h> 7#include <stdlib.h> 8#include <string.h> 9#include <unistd.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_RUN_IFELSE([AC_LANG_SOURCE([[ 64#include <string.h> 65 66#if HAVE_UNISTD_H 67#include <unistd.h> 68#endif 69 70#if HAVE_CRYPT_H 71#include <crypt.h> 72#endif 73 74int main() { 75#if HAVE_CRYPT 76 char *encrypted = crypt("rasmuslerdorf","rl"); 77 return !encrypted || strcmp(encrypted,"rl.3StKT.4T8M"); 78#else 79 return 1; 80#endif 81}]])],[ 82 ac_cv_crypt_des=yes 83],[ 84 ac_cv_crypt_des=no 85],[ 86 ac_cv_crypt_des=yes 87])]) 88 89AC_CACHE_CHECK(for extended DES crypt, ac_cv_crypt_ext_des,[ 90 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 91#include <string.h> 92 93#if HAVE_UNISTD_H 94#include <unistd.h> 95#endif 96 97#if HAVE_CRYPT_H 98#include <crypt.h> 99#endif 100 101int main() { 102#if HAVE_CRYPT 103 char *encrypted = crypt("rasmuslerdorf","_J9..rasm"); 104 return !encrypted || strcmp(encrypted,"_J9..rasmBYk8r9AiWNc"); 105#else 106 return 1; 107#endif 108}]])],[ 109 ac_cv_crypt_ext_des=yes 110],[ 111 ac_cv_crypt_ext_des=no 112],[ 113 ac_cv_crypt_ext_des=no 114])]) 115 116AC_CACHE_CHECK(for MD5 crypt, ac_cv_crypt_md5,[ 117AC_RUN_IFELSE([AC_LANG_SOURCE([[ 118#include <string.h> 119 120#if HAVE_UNISTD_H 121#include <unistd.h> 122#endif 123 124#if HAVE_CRYPT_H 125#include <crypt.h> 126#endif 127 128int main() { 129#if HAVE_CRYPT 130 char salt[15], answer[40]; 131 char *encrypted; 132 133 salt[0]='$'; salt[1]='1'; salt[2]='$'; 134 salt[3]='r'; salt[4]='a'; salt[5]='s'; 135 salt[6]='m'; salt[7]='u'; salt[8]='s'; 136 salt[9]='l'; salt[10]='e'; salt[11]='$'; 137 salt[12]='\0'; 138 strcpy(answer,salt); 139 strcat(answer,"rISCgZzpwk3UhDidwXvin0"); 140 encrypted = crypt("rasmuslerdorf",salt); 141 return !encrypted || strcmp(encrypted,answer); 142#else 143 return 1; 144#endif 145}]])],[ 146 ac_cv_crypt_md5=yes 147],[ 148 ac_cv_crypt_md5=no 149],[ 150 ac_cv_crypt_md5=no 151])]) 152 153AC_CACHE_CHECK(for Blowfish crypt, ac_cv_crypt_blowfish,[ 154AC_RUN_IFELSE([AC_LANG_SOURCE([[ 155#include <string.h> 156 157#if HAVE_UNISTD_H 158#include <unistd.h> 159#endif 160 161#if HAVE_CRYPT_H 162#include <crypt.h> 163#endif 164 165int main() { 166#if HAVE_CRYPT 167 char salt[30], answer[70]; 168 char *encrypted; 169 170 salt[0]='$'; salt[1]='2'; salt[2]='a'; salt[3]='$'; salt[4]='0'; salt[5]='7'; salt[6]='$'; salt[7]='\0'; 171 strcat(salt,"rasmuslerd............"); 172 strcpy(answer,salt); 173 strcpy(&answer[29],"nIdrcHdxcUxWomQX9j6kvERCFjTg7Ra"); 174 encrypted = crypt("rasmuslerdorf",salt); 175 return !encrypted || strcmp(encrypted,answer); 176#else 177 return 1; 178#endif 179}]])],[ 180 ac_cv_crypt_blowfish=yes 181],[ 182 ac_cv_crypt_blowfish=no 183],[ 184 ac_cv_crypt_blowfish=no 185])]) 186 187AC_CACHE_CHECK(for SHA512 crypt, ac_cv_crypt_sha512,[ 188AC_RUN_IFELSE([AC_LANG_SOURCE([[ 189#include <string.h> 190 191#if HAVE_UNISTD_H 192#include <unistd.h> 193#endif 194 195#if HAVE_CRYPT_H 196#include <crypt.h> 197#endif 198 199int main() { 200#if HAVE_CRYPT 201 char salt[21], answer[21+86]; 202 char *encrypted; 203 204 strcpy(salt,"\$6\$rasmuslerdorf\$"); 205 strcpy(answer, salt); 206 strcat(answer, "EeHCRjm0bljalWuALHSTs1NB9ipEiLEXLhYeXdOpx22gmlmVejnVXFhd84cEKbYxCo.XuUTrW.RLraeEnsvWs/"); 207 encrypted = crypt("rasmuslerdorf",salt); 208 return !encrypted || strcmp(encrypted,answer); 209#else 210 return 1; 211#endif 212}]])],[ 213 ac_cv_crypt_sha512=yes 214],[ 215 ac_cv_crypt_sha512=no 216],[ 217 ac_cv_crypt_sha512=no 218])]) 219 220AC_CACHE_CHECK(for SHA256 crypt, ac_cv_crypt_sha256,[ 221AC_RUN_IFELSE([AC_LANG_SOURCE([[ 222#include <string.h> 223 224#if HAVE_UNISTD_H 225#include <unistd.h> 226#endif 227 228#if HAVE_CRYPT_H 229#include <crypt.h> 230#endif 231 232int main() { 233#if HAVE_CRYPT 234 char salt[21], answer[21+43]; 235 char *encrypted; 236 237 strcpy(salt,"\$5\$rasmuslerdorf\$"); 238 strcpy(answer, salt); 239 strcat(answer, "cFAm2puLCujQ9t.0CxiFIIvFi4JyQx5UncCt/xRIX23"); 240 encrypted = crypt("rasmuslerdorf",salt); 241 return !encrypted || strcmp(encrypted,answer); 242#else 243 return 1; 244#endif 245}]])],[ 246 ac_cv_crypt_sha256=yes 247],[ 248 ac_cv_crypt_sha256=no 249],[ 250 ac_cv_crypt_sha256=no 251])]) 252 253 254dnl 255dnl If one of them is missing, use our own implementation, portable code is then possible 256dnl 257if 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 258 259 dnl 260 dnl Check for __alignof__ support in the compiler 261 dnl 262 AC_CACHE_CHECK(whether the compiler supports __alignof__, ac_cv_alignof_exists,[ 263 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 264 ]],[[ 265 int align = __alignof__(int); 266 ]])],[ 267 ac_cv_alignof_exists=yes 268 ],[ 269 ac_cv_alignof_exists=no 270 ])]) 271 if test "$ac_cv_alignof_exists" = "yes"; then 272 AC_DEFINE([HAVE_ALIGNOF], 1, [whether the compiler supports __alignof__]) 273 fi 274 275 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]) 276 277 PHP_ADD_SOURCES(PHP_EXT_DIR(standard), crypt_freesec.c crypt_blowfish.c crypt_sha512.c crypt_sha256.c php_crypt_r.c) 278else 279 AC_DEFINE_UNQUOTED(PHP_USE_PHP_CRYPT_R, 0, [Whether PHP has to use its own crypt_r for blowfish, des and ext des]) 280fi 281 282dnl 283dnl Check for __attribute__ ((__aligned__)) support in the compiler 284dnl 285AC_CACHE_CHECK(whether the compiler supports aligned attribute, ac_cv_attribute_aligned,[ 286AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 287]],[[ 288 unsigned char test[32] __attribute__ ((__aligned__ (__alignof__ (int)))); 289]])],[ 290 ac_cv_attribute_aligned=yes 291],[ 292 ac_cv_attribute_aligned=no 293])]) 294if test "$ac_cv_attribute_aligned" = "yes"; then 295 AC_DEFINE([HAVE_ATTRIBUTE_ALIGNED], 1, [whether the compiler supports __attribute__ ((__aligned__))]) 296fi 297 298dnl 299dnl Check for available functions 300dnl 301dnl log2 could be used to improve the log function, however it requires C99. The 302dnl check for log2 should be turned on, as soon as we support C99. 303AC_CHECK_FUNCS(asinh acosh atanh log1p hypot) 304AC_FUNC_FNMATCH 305 306dnl 307dnl Check if there is a support means of creating a new process and defining 308dnl which handles it receives 309dnl 310AC_CHECK_FUNCS(fork CreateProcess, [ 311 php_can_support_proc_open=yes 312 break 313],[ 314 php_can_support_proc_open=no 315]) 316AC_MSG_CHECKING([if your OS can spawn processes with inherited handles]) 317if test "$php_can_support_proc_open" = "yes"; then 318 AC_MSG_RESULT(yes) 319 AC_DEFINE(PHP_CAN_SUPPORT_PROC_OPEN,1, [Define if your system has fork/vfork/CreateProcess]) 320else 321 AC_MSG_RESULT(no) 322fi 323 324PHP_ENABLE_CHROOT_FUNC=no 325case "$PHP_SAPI" in 326 embed) 327 PHP_ENABLE_CHROOT_FUNC=yes 328 ;; 329 330 none) 331 for PROG in $PHP_BINARIES; do 332 case "$PROG" in 333 cgi|cli|phpdbg) 334 PHP_ENABLE_CHROOT_FUNC=yes 335 ;; 336 337 *) 338 PHP_ENABLE_CHROOT_FUNC=no 339 break 340 ;; 341 esac 342 done 343 ;; 344esac 345 346if test "$PHP_ENABLE_CHROOT_FUNC" = "yes"; then 347 AC_DEFINE(ENABLE_CHROOT_FUNC, 1, [Whether to enable chroot() function]) 348fi 349 350dnl 351dnl Detect library functions needed by php dns_xxx functions 352dnl ext/standard/php_dns.h will collect these in a single define 353dnl HAVE_FULL_DNS_FUNCS 354dnl 355PHP_CHECK_FUNC(res_nsearch, resolv, bind, socket) 356PHP_CHECK_FUNC(res_ndestroy, resolv, bind, socket) 357PHP_CHECK_FUNC(dns_search, resolv, bind, socket) 358PHP_CHECK_FUNC(dn_expand, resolv, bind, socket) 359PHP_CHECK_FUNC(dn_skipname, resolv, bind, socket) 360 361dnl 362dnl These are old deprecated functions 363dnl 364 365PHP_CHECK_FUNC(res_search, resolv, bind, socket) 366 367dnl 368dnl Check for strptime() 369dnl 370AC_CACHE_CHECK(whether strptime() declaration fails, ac_cv_strptime_decl_fails,[ 371AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 372#include <time.h> 373]],[[ 374#ifndef HAVE_STRPTIME 375#error no strptime() on this platform 376#else 377/* use invalid strptime() declaration to see if it fails to compile */ 378int strptime(const char *s, const char *format, struct tm *tm); 379#endif 380]])],[ 381 ac_cv_strptime_decl_fails=no 382],[ 383 ac_cv_strptime_decl_fails=yes 384])]) 385if test "$ac_cv_strptime_decl_fails" = "yes"; then 386 AC_DEFINE([HAVE_STRPTIME_DECL_FAILS], 1, [whether strptime() declaration fails]) 387fi 388 389dnl 390dnl Check for i18n capabilities 391dnl 392AC_CHECK_HEADERS([wchar.h]) 393AC_CHECK_FUNCS([mblen]) 394AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],[ 395AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 396#ifdef HAVE_WCHAR_H 397# include <wchar.h> 398#endif 399]],[[ 400mbstate_t a; 401]])],[ 402 ac_cv_type_mbstate_t=yes 403],[ 404 ac_cv_type_mbstate_t=no 405])]) 406if test "$ac_cv_type_mbstate_t" = "yes"; then 407 AC_DEFINE([HAVE_MBSTATE_T], 1, [Define if your system has mbstate_t in wchar.h]) 408fi 409 410dnl 411dnl Check for atomic operation API availability in Solaris 412dnl 413AC_CHECK_HEADERS([atomic.h]) 414 415dnl 416dnl Check for arc4random on BSD systems 417dnl 418AC_CHECK_DECLS([arc4random_buf]) 419 420dnl 421dnl Check for argon2 422dnl 423PHP_ARG_WITH([password-argon2], 424 [for Argon2 support], 425 [AS_HELP_STRING([[--with-password-argon2[=DIR]]], 426 [Include Argon2 support in password_*. DIR is the Argon2 shared library 427 path])]) 428 429if test "$PHP_PASSWORD_ARGON2" != "no"; then 430 AC_MSG_CHECKING([for Argon2 library]) 431 for i in $PHP_PASSWORD_ARGON2 /usr /usr/local ; do 432 if test -r $i/include/argon2.h; then 433 ARGON2_DIR=$i; 434 AC_MSG_RESULT(found in $i) 435 break 436 fi 437 done 438 439 if test -z "$ARGON2_DIR"; then 440 AC_MSG_RESULT([not found]) 441 AC_MSG_ERROR([Please ensure the argon2 header and library are installed]) 442 fi 443 444 PHP_ADD_LIBRARY_WITH_PATH(argon2, $ARGON2_DIR/$PHP_LIBDIR) 445 PHP_ADD_INCLUDE($ARGON2_DIR/include) 446 447 AC_CHECK_LIB(argon2, argon2id_hash_raw, [ 448 LIBS="$LIBS -largon2" 449 AC_DEFINE(HAVE_ARGON2LIB, 1, [ Define to 1 if you have the <argon2.h> header file ]) 450 ], [ 451 AC_MSG_ERROR([Problem with libargon2.(a|so). Please verify that Argon2 header and libraries >= 20161029 are installed]) 452 ]) 453fi 454 455dnl 456dnl net_get_interfaces 457dnl 458AC_CHECK_HEADERS([net/if.h],[], [], 459[ 460 #ifdef HAVE_SYS_SOCKET_H 461 #include <sys/socket.h> 462 #endif 463 #include <net/if.h> 464]) 465AC_MSG_CHECKING([for usable getifaddrs]) 466AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 467 #include <sys/types.h> 468 #include <ifaddrs.h> 469]],[[ 470 struct ifaddrs *interfaces; 471 if (!getifaddrs(&interfaces)) { 472 freeifaddrs(interfaces); 473 } 474]])], [ac_have_getifaddrs=yes], [ac_have_getifaddrs=no]) 475if test "$ac_have_getifaddrs" = "yes" ; then 476 AC_DEFINE(HAVE_GETIFADDRS, 1, [whether getifaddrs is present and usable]) 477 AC_MSG_RESULT(yes) 478else 479 AC_MSG_RESULT(no) 480fi 481 482dnl 483dnl Setup extension sources 484dnl 485PHP_NEW_EXTENSION(standard, array.c base64.c basic_functions.c browscap.c crc32.c crypt.c \ 486 cyr_convert.c datetime.c dir.c dl.c dns.c exec.c file.c filestat.c \ 487 flock_compat.c formatted_print.c fsock.c head.c html.c image.c \ 488 info.c iptc.c lcg.c link.c mail.c math.c md5.c metaphone.c \ 489 microtime.c pack.c pageinfo.c quot_print.c rand.c mt_rand.c \ 490 soundex.c string.c scanf.c syslog.c type.c uniqid.c url.c \ 491 var.c versioning.c assert.c strnatcmp.c levenshtein.c \ 492 incomplete_class.c url_scanner_ex.c ftp_fopen_wrapper.c \ 493 http_fopen_wrapper.c php_fopen_wrapper.c credits.c css.c \ 494 var_unserializer.c ftok.c sha1.c user_filters.c uuencode.c \ 495 filters.c proc_open.c streamsfuncs.c http.c password.c \ 496 random.c net.c hrtime.c,,, 497 -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) 498 499PHP_ADD_MAKEFILE_FRAGMENT 500PHP_INSTALL_HEADERS([ext/standard/]) 501