1dnl 2dnl This file contains local autoconf functions. 3dnl 4 5dnl ------------------------------------------------------------------------- 6dnl Output stylize macros for configure (help/runtime) 7dnl ------------------------------------------------------------------------- 8 9dnl 10dnl PHP_HELP_SEPARATOR(title) 11dnl 12dnl Adds separator title into the configure --help display. 13dnl 14AC_DEFUN([PHP_HELP_SEPARATOR],[ 15AC_ARG_ENABLE([],[ 16$1 17],[]) 18]) 19 20dnl 21dnl PHP_CONFIGURE_PART(title) 22dnl 23dnl Adds separator title configure output (idea borrowed from mm) 24dnl 25AC_DEFUN([PHP_CONFIGURE_PART],[ 26 AC_MSG_RESULT() 27 AC_MSG_RESULT([${T_MD}$1${T_ME}]) 28]) 29 30dnl ------------------------------------------------------------------------- 31dnl Build system helper macros 32dnl ------------------------------------------------------------------------- 33 34dnl 35dnl PHP_DEF_HAVE(what) 36dnl 37dnl Generates 'AC_DEFINE(HAVE_WHAT, 1, [ ])' 38dnl 39AC_DEFUN([PHP_DEF_HAVE],[AC_DEFINE([HAVE_]translit($1,a-z_.-,A-Z___), 1, [ ])]) 40 41dnl 42dnl PHP_RUN_ONCE(namespace, variable, code) 43dnl 44dnl execute code, if variable is not set in namespace 45dnl 46AC_DEFUN([PHP_RUN_ONCE],[ 47 changequote({,}) 48 unique=`echo $2|$SED 's/[^a-zA-Z0-9]/_/g'` 49 changequote([,]) 50 cmd="echo $ac_n \"\$$1$unique$ac_c\"" 51 if test -n "$unique" && test "`eval $cmd`" = "" ; then 52 eval "$1$unique=set" 53 $3 54 fi 55]) 56 57dnl 58dnl PHP_EXPAND_PATH(path, variable) 59dnl 60dnl expands path to an absolute path and assigns it to variable 61dnl 62AC_DEFUN([PHP_EXPAND_PATH],[ 63 if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then 64 $2=$1 65 else 66 changequote({,}) 67 ep_dir=`echo $1|$SED 's%/*[^/][^/]*/*$%%'` 68 changequote([,]) 69 ep_realdir=`(cd "$ep_dir" && pwd)` 70 $2="$ep_realdir"/`basename "$1"` 71 fi 72]) 73 74dnl 75dnl PHP_DEFINE(WHAT [, value[, directory]]) 76dnl 77dnl Creates builddir/include/what.h and in there #define WHAT value 78dnl 79AC_DEFUN([PHP_DEFINE],[ 80 [echo "#define ]$1[]ifelse([$2],,[ 1],[ $2])[" > ]ifelse([$3],,[include],[$3])[/php_]translit($1,A-Z,a-z)[.h] 81]) 82 83dnl 84dnl PHP_SUBST(varname) 85dnl 86dnl Adds variable with it's value into Makefile, e.g.: 87dnl CC = gcc 88dnl 89AC_DEFUN([PHP_SUBST],[ 90 PHP_VAR_SUBST="$PHP_VAR_SUBST $1" 91]) 92 93dnl 94dnl PHP_SUBST_OLD(varname) 95dnl 96dnl Same as PHP_SUBST() but also substitutes all @VARNAME@ 97dnl instances in every file passed to AC_OUTPUT 98dnl 99AC_DEFUN([PHP_SUBST_OLD],[ 100 PHP_SUBST($1) 101 AC_SUBST($1) 102]) 103 104dnl 105dnl PHP_OUTPUT(file) 106dnl 107dnl Adds "file" to the list of files generated by AC_OUTPUT 108dnl This macro can be used several times. 109dnl 110AC_DEFUN([PHP_OUTPUT],[ 111 PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1" 112]) 113 114 115dnl ------------------------------------------------------------------------- 116dnl Build system base macros 117dnl ------------------------------------------------------------------------- 118 119dnl 120dnl PHP_CANONICAL_HOST_TARGET 121dnl 122AC_DEFUN([PHP_CANONICAL_HOST_TARGET],[ 123 AC_REQUIRE([AC_CANONICAL_HOST])dnl 124 AC_REQUIRE([AC_CANONICAL_TARGET])dnl 125 dnl Make sure we do not continue if host_alias is empty. 126 if test -z "$host_alias" && test -n "$host"; then 127 host_alias=$host 128 fi 129 if test -z "$host_alias"; then 130 AC_MSG_ERROR([host_alias is not set!]) 131 fi 132]) 133 134dnl 135dnl PHP_INIT_BUILD_SYSTEM 136dnl 137AC_DEFUN([PHP_INIT_BUILD_SYSTEM],[ 138AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl 139test -d include || $php_shtool mkdir include 140> Makefile.objects 141> Makefile.fragments 142dnl We need to play tricks here to avoid matching the grep line itself 143pattern=define 144$EGREP $pattern'.*include/php' $srcdir/configure|$SED 's/.*>//'|xargs touch 2>/dev/null 145]) 146 147dnl 148dnl PHP_GEN_GLOBAL_MAKEFILE 149dnl 150dnl Generates the global makefile. 151dnl 152AC_DEFUN([PHP_GEN_GLOBAL_MAKEFILE],[ 153 cat >Makefile <<EOF 154srcdir = $abs_srcdir 155builddir = $abs_builddir 156top_srcdir = $abs_srcdir 157top_builddir = $abs_builddir 158EOF 159 for i in $PHP_VAR_SUBST; do 160 eval echo "$i = \$$i" >> Makefile 161 done 162 163 cat $abs_srcdir/Makefile.global Makefile.fragments Makefile.objects >> Makefile 164]) 165 166dnl 167dnl PHP_ADD_MAKEFILE_FRAGMENT([srcfile [, ext_srcdir [, ext_builddir]]]) 168dnl 169dnl Processes a file called Makefile.frag in the source directory 170dnl of the most recently added extension. $(srcdir) and $(builddir) 171dnl are substituted with the proper paths. Can be used to supply 172dnl custom rules and/or additional targets. 173dnl 174AC_DEFUN([PHP_ADD_MAKEFILE_FRAGMENT],[ 175 ifelse($1,,src=$ext_srcdir/Makefile.frag,src=$1) 176 ifelse($2,,ac_srcdir=$ext_srcdir,ac_srcdir=$2) 177 ifelse($3,,ac_builddir=$ext_builddir,ac_builddir=$3) 178 test -f "$src" && $SED -e "s#\$(srcdir)#$ac_srcdir#g" -e "s#\$(builddir)#$ac_builddir#g" $src >> Makefile.fragments 179]) 180 181dnl 182dnl PHP_ADD_SOURCES(source-path, sources [, special-flags [, type]]) 183dnl 184dnl Adds sources which are located relative to source-path to the 185dnl array of type type. Sources are processed with optional 186dnl special-flags which are passed to the compiler. Sources 187dnl can be either written in C or C++ (filenames shall end in .c 188dnl or .cpp, respectively). 189dnl 190dnl Note: If source-path begins with a "/", the "/" is removed and 191dnl the path is interpreted relative to the top build-directory. 192dnl 193dnl which array to append to? 194AC_DEFUN([PHP_ADD_SOURCES],[ 195 PHP_ADD_SOURCES_X($1, $2, $3, ifelse($4,sapi,PHP_SAPI_OBJS,PHP_GLOBAL_OBJS)) 196]) 197 198dnl 199dnl _PHP_ASSIGN_BUILD_VARS(type) 200dnl internal, don't use 201AC_DEFUN([_PHP_ASSIGN_BUILD_VARS],[ 202ifelse($1,shared,[ 203 b_c_pre=$shared_c_pre 204 b_cxx_pre=$shared_cxx_pre 205 b_c_meta=$shared_c_meta 206 b_cxx_meta=$shared_cxx_meta 207 b_c_post=$shared_c_post 208 b_cxx_post=$shared_cxx_post 209],[ 210 b_c_pre=$php_c_pre 211 b_cxx_pre=$php_cxx_pre 212 b_c_meta=$php_c_meta 213 b_cxx_meta=$php_cxx_meta 214 b_c_post=$php_c_post 215 b_cxx_post=$php_cxx_post 216])dnl 217 b_lo=[$]$1_lo 218]) 219 220dnl 221dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared[, special-post-flags]]]]) 222dnl 223dnl Additional to PHP_ADD_SOURCES (see above), this lets you set the 224dnl name of the array target-var directly, as well as whether 225dnl shared objects will be built from the sources. 226dnl 227dnl Should not be used directly. 228dnl 229AC_DEFUN([PHP_ADD_SOURCES_X],[ 230dnl relative to source- or build-directory? 231dnl ac_srcdir/ac_bdir include trailing slash 232 case $1 in 233 ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir; ac_inc="-I. -I$abs_srcdir" ;; 234 /*[)] ac_srcdir=`echo "$1"|cut -c 2-`"/"; ac_bdir=$ac_srcdir; ac_inc="-I$ac_bdir -I$abs_srcdir/$ac_bdir" ;; 235 *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$1/"; ac_inc="-I$ac_bdir -I$ac_srcdir" ;; 236 esac 237 238dnl how to build .. shared or static? 239 ifelse($5,yes,_PHP_ASSIGN_BUILD_VARS(shared),_PHP_ASSIGN_BUILD_VARS(php)) 240 241dnl iterate over the sources 242 old_IFS=[$]IFS 243 for ac_src in $2; do 244 245dnl remove the suffix 246 IFS=. 247 set $ac_src 248 ac_obj=[$]1 249 IFS=$old_IFS 250 251dnl append to the array which has been dynamically chosen at m4 time 252 $4="[$]$4 [$]ac_bdir[$]ac_obj.lo" 253 254dnl choose the right compiler/flags/etc. for the source-file 255 case $ac_src in 256 *.c[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;; 257 *.s[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;; 258 *.S[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;; 259 *.cpp|*.cc|*.cxx[)] ac_comp="$b_cxx_pre $3 $ac_inc $b_cxx_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_cxx_post" ;; 260 esac 261 262dnl create a rule for the object/source combo 263 cat >>Makefile.objects<<EOF 264$ac_bdir[$]ac_obj.lo: $ac_srcdir[$]ac_src 265 $ac_comp 266EOF 267 done 268]) 269 270dnl ------------------------------------------------------------------------- 271dnl Compiler characteristics checks 272dnl ------------------------------------------------------------------------- 273 274dnl 275dnl PHP_TARGET_RDYNAMIC 276dnl 277dnl Checks whether -rdynamic is supported by the compiler. This 278dnl is necessary for some targets to populate the global symbol 279dnl table. Otherwise, dynamic modules would not be able to resolve 280dnl PHP-related symbols. 281dnl 282dnl If successful, adds -rdynamic to PHP_LDFLAGS. 283dnl 284AC_DEFUN([PHP_TARGET_RDYNAMIC],[ 285 if test -n "$GCC"; then 286 PHP_CHECK_GCC_ARG(-rdynamic, gcc_rdynamic=yes) 287 if test "$gcc_rdynamic" = "yes"; then 288 PHP_LDFLAGS="$PHP_LDFLAGS -rdynamic" 289 fi 290 fi 291]) 292 293dnl 294dnl PHP_RUNPATH_SWITCH 295dnl 296dnl Checks for -R, etc. switch 297dnl 298AC_DEFUN([PHP_RUNPATH_SWITCH],[ 299AC_MSG_CHECKING([if compiler supports -R]) 300AC_CACHE_VAL(php_cv_cc_dashr,[ 301 SAVE_LIBS=$LIBS 302 LIBS="-R /usr/$PHP_LIBDIR $LIBS" 303 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],[php_cv_cc_dashr=yes],[php_cv_cc_dashr=no]) 304 LIBS=$SAVE_LIBS]) 305AC_MSG_RESULT([$php_cv_cc_dashr]) 306if test $php_cv_cc_dashr = "yes"; then 307 ld_runpath_switch=-R 308else 309 AC_MSG_CHECKING([if compiler supports -Wl,-rpath,]) 310 AC_CACHE_VAL(php_cv_cc_rpath,[ 311 SAVE_LIBS=$LIBS 312 LIBS="-Wl,-rpath,/usr/$PHP_LIBDIR $LIBS" 313 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],[php_cv_cc_rpath=yes],[php_cv_cc_rpath=no]) 314 LIBS=$SAVE_LIBS]) 315 AC_MSG_RESULT([$php_cv_cc_rpath]) 316 if test $php_cv_cc_rpath = "yes"; then 317 ld_runpath_switch=-Wl,-rpath, 318 else 319 dnl something innocuous 320 ld_runpath_switch=-L 321 fi 322fi 323if test "$PHP_RPATH" = "no"; then 324 ld_runpath_switch= 325fi 326]) 327 328dnl 329dnl PHP_CHECK_GCC_ARG(arg, action-if-found, action-if-not-found) 330dnl 331AC_DEFUN([PHP_CHECK_GCC_ARG],[ 332 gcc_arg_name=[ac_cv_gcc_arg]translit($1,A-Z=-,a-z__) 333 AC_CACHE_CHECK([whether $CC supports $1], [ac_cv_gcc_arg]translit($1,A-Z=-,a-z__), [ 334 echo 'void somefunc() { };' > conftest.c 335 cmd='$CC $1 -c conftest.c' 336 if eval $cmd 2>&1 | $EGREP -e $1 >/dev/null ; then 337 ac_result=no 338 else 339 ac_result=yes 340 fi 341 eval $gcc_arg_name=$ac_result 342 rm -f conftest.* 343 ]) 344 if eval test "\$$gcc_arg_name" = "yes"; then 345 $2 346 else 347 : 348 $3 349 fi 350]) 351 352dnl 353dnl PHP_LIBGCC_LIBPATH(gcc) 354dnl 355dnl Stores the location of libgcc in libgcc_libpath 356dnl 357AC_DEFUN([PHP_LIBGCC_LIBPATH],[ 358 changequote({,}) 359 libgcc_libpath=`$1 --print-libgcc-file-name|$SED 's%/*[^/][^/]*$%%'` 360 changequote([,]) 361]) 362 363dnl ------------------------------------------------------------------------- 364dnl Macros to modify LIBS, INCLUDES, etc. variables 365dnl ------------------------------------------------------------------------- 366 367dnl 368dnl PHP_REMOVE_USR_LIB(NAME) 369dnl 370dnl Removes all -L/usr/$PHP_LIBDIR entries from variable NAME 371dnl 372AC_DEFUN([PHP_REMOVE_USR_LIB],[ 373 unset ac_new_flags 374 for i in [$]$1; do 375 case [$]i in 376 -L/usr/$PHP_LIBDIR|-L/usr/$PHP_LIBDIR/[)] ;; 377 *[)] ac_new_flags="[$]ac_new_flags [$]i" ;; 378 esac 379 done 380 $1=[$]ac_new_flags 381]) 382 383dnl 384dnl PHP_EVAL_LIBLINE(libline, SHARED-LIBADD) 385dnl 386dnl Use this macro, if you need to add libraries and or library search 387dnl paths to the PHP build system which are only given in compiler 388dnl notation. 389dnl 390AC_DEFUN([PHP_EVAL_LIBLINE],[ 391 for ac_i in $1; do 392 case $ac_i in 393 -pthread[)] 394 if test "$ext_shared" = "yes"; then 395 $2="[$]$2 -pthread" 396 else 397 PHP_RUN_ONCE(EXTRA_LDFLAGS, [$ac_i], [EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ac_i"]) 398 PHP_RUN_ONCE(EXTRA_LDFLAGS_PROGRAM, [$ac_i], 399 [EXTRA_LDFLAGS_PROGRAM="$EXTRA_LDFLAGS_PROGRAM $ac_i"]) 400 fi 401 ;; 402 -l*[)] 403 ac_ii=`echo $ac_i|cut -c 3-` 404 PHP_ADD_LIBRARY($ac_ii,1,$2) 405 ;; 406 -L*[)] 407 ac_ii=`echo $ac_i|cut -c 3-` 408 PHP_ADD_LIBPATH($ac_ii,$2) 409 ;; 410 esac 411 done 412]) 413 414dnl 415dnl PHP_EVAL_INCLINE(headerline) 416dnl 417dnl Use this macro, if you need to add header search paths to the PHP 418dnl build system which are only given in compiler notation. 419dnl 420AC_DEFUN([PHP_EVAL_INCLINE],[ 421 for ac_i in $1; do 422 case $ac_i in 423 -I*[)] 424 ac_ii=`echo $ac_i|cut -c 3-` 425 PHP_ADD_INCLUDE($ac_ii) 426 ;; 427 esac 428 done 429]) 430 431dnl internal, don't use 432AC_DEFUN([_PHP_ADD_LIBPATH_GLOBAL],[ 433 PHP_RUN_ONCE(LIBPATH, $1, [ 434 test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$1" 435 LDFLAGS="$LDFLAGS -L$1" 436 PHP_RPATHS="$PHP_RPATHS $1" 437 ]) 438])dnl 439dnl 440dnl 441dnl PHP_ADD_LIBPATH(path [, SHARED-LIBADD]) 442dnl 443dnl Adds a path to linkpath/runpath (LDFLAGS) 444dnl 445AC_DEFUN([PHP_ADD_LIBPATH],[ 446 if test "$1" != "/usr/$PHP_LIBDIR" && test "$1" != "/usr/lib"; then 447 PHP_EXPAND_PATH($1, ai_p) 448 ifelse([$2],,[ 449 _PHP_ADD_LIBPATH_GLOBAL([$ai_p]) 450 ],[ 451 if test "$ext_shared" = "yes"; then 452 $2="-L$ai_p [$]$2" 453 test -n "$ld_runpath_switch" && $2="$ld_runpath_switch$ai_p [$]$2" 454 else 455 _PHP_ADD_LIBPATH_GLOBAL([$ai_p]) 456 fi 457 ]) 458 fi 459]) 460 461dnl 462dnl PHP_UTILIZE_RPATHS() 463dnl 464dnl builds RPATHS/LDFLAGS from PHP_RPATHS 465dnl 466AC_DEFUN([PHP_UTILIZE_RPATHS],[ 467 OLD_RPATHS=$PHP_RPATHS 468 unset PHP_RPATHS 469 470 for i in $OLD_RPATHS; do 471dnl Can be passed to native cc/libtool 472 PHP_LDFLAGS="$PHP_LDFLAGS -L$i" 473dnl Libtool-specific 474 PHP_RPATHS="$PHP_RPATHS -R $i" 475dnl cc-specific 476 NATIVE_RPATHS="$NATIVE_RPATHS $ld_runpath_switch$i" 477 done 478 479 if test "$PHP_RPATH" = "no"; then 480 unset PHP_RPATHS 481 unset NATIVE_RPATHS 482 fi 483]) 484 485dnl 486dnl PHP_ADD_INCLUDE(path [,before]) 487dnl 488dnl add an include path. 489dnl if before is 1, add in the beginning of INCLUDES. 490dnl 491AC_DEFUN([PHP_ADD_INCLUDE],[ 492 if test "$1" != "/usr/include"; then 493 PHP_EXPAND_PATH($1, ai_p) 494 PHP_RUN_ONCE(INCLUDEPATH, $ai_p, [ 495 if test "$2"; then 496 INCLUDES="-I$ai_p $INCLUDES" 497 else 498 INCLUDES="$INCLUDES -I$ai_p" 499 fi 500 ]) 501 fi 502]) 503 504dnl internal, don't use 505AC_DEFUN([_PHP_X_ADD_LIBRARY],[dnl 506 ifelse([$2],,$3="-l$1 [$]$3", $3="[$]$3 -l$1") dnl 507])dnl 508dnl 509dnl internal, don't use 510AC_DEFUN([_PHP_ADD_LIBRARY_SKELETON],[ 511 case $1 in 512 c|c_r|pthread*[)] ;; 513 *[)] ifelse($3,,[ 514 _PHP_X_ADD_LIBRARY($1,$2,$5) 515 ],[ 516 if test "$ext_shared" = "yes"; then 517 _PHP_X_ADD_LIBRARY($1,$2,$3) 518 else 519 $4($1,$2) 520 fi 521 ]) ;; 522 esac 523])dnl 524dnl 525dnl 526dnl PHP_ADD_LIBRARY(library[, append[, shared-libadd]]) 527dnl 528dnl add a library to the link line 529dnl 530AC_DEFUN([PHP_ADD_LIBRARY],[ 531 _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY],[LIBS]) 532]) 533 534dnl 535dnl PHP_ADD_LIBRARY_DEFER(library[, append[, shared-libadd]]) 536dnl 537dnl add a library to the link line (deferred, not used during configure) 538dnl 539AC_DEFUN([PHP_ADD_LIBRARY_DEFER],[ 540 _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY_DEFER],[DLIBS]) 541]) 542 543dnl 544dnl PHP_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd]) 545dnl 546dnl add a library to the link line and path to linkpath/runpath. 547dnl if shared-libadd is not empty and $ext_shared is yes, 548dnl shared-libadd will be assigned the library information 549dnl 550AC_DEFUN([PHP_ADD_LIBRARY_WITH_PATH],[ 551ifelse($3,,[ 552 if test -n "$2"; then 553 PHP_ADD_LIBPATH($2) 554 fi 555 PHP_ADD_LIBRARY($1) 556],[ 557 if test "$ext_shared" = "yes"; then 558 $3="-l$1 [$]$3" 559 if test -n "$2"; then 560 PHP_ADD_LIBPATH($2,$3) 561 fi 562 else 563 PHP_ADD_LIBRARY_WITH_PATH($1,$2) 564 fi 565]) 566]) 567 568dnl 569dnl PHP_ADD_LIBRARY_DEFER_WITH_PATH(library, path[, shared-libadd]) 570dnl 571dnl add a library to the link line (deferred) 572dnl and path to linkpath/runpath (not deferred) 573dnl if shared-libadd is not empty and $ext_shared is yes, 574dnl shared-libadd will be assigned the library information 575dnl 576AC_DEFUN([PHP_ADD_LIBRARY_DEFER_WITH_PATH],[ 577ifelse($3,,[ 578 if test -n "$2"; then 579 PHP_ADD_LIBPATH($2) 580 fi 581 PHP_ADD_LIBRARY_DEFER($1) 582],[ 583 if test "$ext_shared" = "yes"; then 584 $3="-l$1 [$]$3" 585 if test -n "$2"; then 586 PHP_ADD_LIBPATH($2,$3) 587 fi 588 else 589 PHP_ADD_LIBRARY_DEFER_WITH_PATH($1,$2) 590 fi 591]) 592]) 593 594dnl 595dnl PHP_ADD_FRAMEWORK(framework [,before]) 596dnl 597dnl add a (Darwin / Mac OS X) framework to the link 598dnl line. if before is 1, the framework is added 599dnl to the beginning of the line. 600dnl 601AC_DEFUN([PHP_ADD_FRAMEWORK], [ 602 PHP_RUN_ONCE(FRAMEWORKS, $1, [ 603 if test "$2"; then 604 PHP_FRAMEWORKS="-framework $1 $PHP_FRAMEWORKS" 605 else 606 PHP_FRAMEWORKS="$PHP_FRAMEWORKS -framework $1" 607 fi 608 ]) 609]) 610 611dnl 612dnl PHP_ADD_FRAMEWORKPATH(path [,before]) 613dnl 614dnl add a (Darwin / Mac OS X) framework path to the link 615dnl and include lines. default paths include (but are 616dnl not limited to) /Local/Library/Frameworks and 617dnl /System/Library/Frameworks, so these don't need 618dnl to be specifically added. if before is 1, the 619dnl framework path is added to the beginning of the 620dnl relevant lines. 621dnl 622AC_DEFUN([PHP_ADD_FRAMEWORKPATH], [ 623 PHP_EXPAND_PATH($1, ai_p) 624 PHP_RUN_ONCE(FRAMEWORKPATH, $ai_p, [ 625 if test "$2"; then 626 PHP_FRAMEWORKPATH="-F$ai_p $PHP_FRAMEWORKPATH" 627 else 628 PHP_FRAMEWORKPATH="$PHP_FRAMEWORKPATH -F$ai_p" 629 fi 630 ]) 631]) 632 633dnl 634dnl PHP_ADD_FRAMEWORK_WITH_PATH(framework, path) 635dnl 636dnl Adds a (Darwin / Mac OS X) framework path and the 637dnl framework itself to the link and include lines. 638dnl 639AC_DEFUN([PHP_ADD_FRAMEWORK_WITH_PATH], [ 640 PHP_ADD_FRAMEWORKPATH($2) 641 PHP_ADD_FRAMEWORK($1) 642]) 643 644dnl 645dnl PHP_SET_LIBTOOL_VARIABLE(var) 646dnl 647dnl Set libtool variable 648dnl 649AC_DEFUN([PHP_SET_LIBTOOL_VARIABLE],[ 650 if test -z "$LIBTOOL"; then 651 LIBTOOL='$(SHELL) $(top_builddir)/libtool $1' 652 else 653 LIBTOOL="$LIBTOOL $1" 654 fi 655]) 656 657dnl ------------------------------------------------------------------------- 658dnl Wrapper macros for AC_ARG_WITH / AC_ARG_ENABLE 659dnl ------------------------------------------------------------------------- 660 661dnl PHP_ARG_ANALYZE_EX 662dnl internal 663AC_DEFUN([PHP_ARG_ANALYZE_EX],[ 664ext_output="yes, shared" 665ext_shared=yes 666case [$]$1 in 667shared,*[)] 668 $1=`echo "[$]$1"|$SED 's/^shared,//'` 669 ;; 670shared[)] 671 $1=yes 672 ;; 673no[)] 674 ext_output=no 675 ext_shared=no 676 ;; 677*[)] 678 ext_output=yes 679 ext_shared=no 680 ;; 681esac 682 683PHP_ALWAYS_SHARED([$1]) 684]) 685 686dnl PHP_ARG_ANALYZE 687dnl internal 688AC_DEFUN([PHP_ARG_ANALYZE],[ 689ifelse([$3],yes,[PHP_ARG_ANALYZE_EX([$1])],[ext_output=ifelse([$]$1,,no,[$]$1)]) 690ifelse([$2],,,[AC_MSG_RESULT([$ext_output])]) 691]) 692 693dnl 694dnl PHP_ARG_WITH(arg-name, check message, help text[, default-val[, extension-or-not]]) 695dnl Sets PHP_ARG_NAME either to the user value or to the default value. 696dnl default-val defaults to no. This will also set the variable ext_shared, 697dnl and will overwrite any previous variable of that name. 698dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run 699dnl the PHP_ARG_ANALYZE_EX. 700dnl 701AC_DEFUN([PHP_ARG_WITH],[ 702php_with_[]translit($1,A-Z0-9-,a-z0-9_)=ifelse($4,,no,$4) 703PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)]) 704]) 705 706dnl PHP_REAL_ARG_WITH 707dnl internal 708AC_DEFUN([PHP_REAL_ARG_WITH],[ 709ifelse([$2],,,[AC_MSG_CHECKING([$2])]) 710AC_ARG_WITH($1,[$3],$5=[$]withval, 711[ 712 $5=ifelse($4,,no,$4) 713 ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL]) 714]) 715PHP_ARG_ANALYZE($5,[$2],$6) 716]) 717 718dnl 719dnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val[, extension-or-not]]) 720dnl Sets PHP_ARG_NAME either to the user value or to the default value. 721dnl default-val defaults to no. This will also set the variable ext_shared, 722dnl and will overwrite any previous variable of that name. 723dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run 724dnl the PHP_ARG_ANALYZE_EX. 725dnl 726AC_DEFUN([PHP_ARG_ENABLE],[ 727php_enable_[]translit($1,A-Z0-9-,a-z0-9_)=ifelse($4,,no,$4) 728PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)]) 729]) 730 731dnl PHP_REAL_ARG_ENABLE 732dnl internal 733AC_DEFUN([PHP_REAL_ARG_ENABLE],[ 734ifelse([$2],,,[AC_MSG_CHECKING([$2])]) 735AC_ARG_ENABLE($1,[$3],$5=[$]enableval, 736[ 737 $5=ifelse($4,,no,$4) 738 ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL]) 739]) 740PHP_ARG_ANALYZE($5,[$2],$6) 741]) 742 743dnl ------------------------------------------------------------------------- 744dnl Build macros 745dnl ------------------------------------------------------------------------- 746 747dnl 748dnl PHP_BUILD_THREAD_SAFE 749dnl 750AC_DEFUN([PHP_BUILD_THREAD_SAFE],[ 751 enable_maintainer_zts=yes 752 if test "$pthreads_working" != "yes"; then 753 AC_MSG_ERROR([ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads.]) 754 fi 755]) 756 757dnl 758dnl PHP_REQUIRE_CXX 759dnl 760AC_DEFUN([PHP_REQUIRE_CXX],[ 761 if test -z "$php_cxx_done"; then 762 AC_PROG_CXX 763 AC_PROG_CXXCPP 764 PHP_ADD_LIBRARY(stdc++) 765 php_cxx_done=yes 766 fi 767]) 768 769dnl 770dnl PHP_BUILD_SHARED 771dnl 772AC_DEFUN([PHP_BUILD_SHARED],[ 773 PHP_BUILD_PROGRAM 774 OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la] 775 php_sapi_module=shared 776 777 php_c_pre=$shared_c_pre 778 php_c_meta=$shared_c_meta 779 php_c_post=$shared_c_post 780 php_cxx_pre=$shared_cxx_pre 781 php_cxx_meta=$shared_cxx_meta 782 php_cxx_post=$shared_cxx_post 783 php_lo=$shared_lo 784]) 785 786dnl 787dnl PHP_BUILD_STATIC 788dnl 789AC_DEFUN([PHP_BUILD_STATIC],[ 790 PHP_BUILD_PROGRAM 791 OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la] 792 php_sapi_module=static 793]) 794 795dnl 796dnl PHP_BUILD_BUNDLE 797dnl 798AC_DEFUN([PHP_BUILD_BUNDLE],[ 799 PHP_BUILD_PROGRAM 800 OVERALL_TARGET=libs/libphp[]$PHP_MAJOR_VERSION[.bundle] 801 php_sapi_module=static 802]) 803 804dnl 805dnl PHP_BUILD_PROGRAM 806dnl 807AC_DEFUN([PHP_BUILD_PROGRAM],[ 808 php_c_pre='$(LIBTOOL) --mode=compile $(CC)' 809 php_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS)' 810 php_c_post= 811 php_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)' 812 php_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS)' 813 php_cxx_post= 814 php_lo=lo 815 816 case $with_pic in 817 yes) pic_setting='-prefer-pic';; 818 no) pic_setting='-prefer-non-pic';; 819 esac 820 821 shared_c_pre='$(LIBTOOL) --mode=compile $(CC)' 822 shared_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) '$pic_setting 823 shared_c_post= 824 shared_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)' 825 shared_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) '$pic_setting 826 shared_cxx_post= 827 shared_lo=lo 828]) 829 830dnl 831dnl PHP_SHARED_MODULE(module-name, object-var, build-dir, cxx, zend_ext) 832dnl 833dnl Basically sets up the link-stage for building module-name 834dnl from object_var in build-dir. 835dnl 836AC_DEFUN([PHP_SHARED_MODULE],[ 837 install_modules="install-modules" 838 suffix=la 839 840 case $host_alias in 841 *aix*[)] 842 additional_flags="-Wl,-G" 843 ;; 844 esac 845 846 if test "x$5" = "xyes"; then 847 PHP_ZEND_EX="$PHP_ZEND_EX \$(phplibdir)/$1.$suffix" 848 else 849 PHP_MODULES="$PHP_MODULES \$(phplibdir)/$1.$suffix" 850 fi 851 PHP_SUBST($2) 852 cat >>Makefile.objects<<EOF 853\$(phplibdir)/$1.$suffix: $3/$1.$suffix 854 \$(LIBTOOL) --mode=install cp $3/$1.$suffix \$(phplibdir) 855 856$3/$1.$suffix: \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_DEPENDENCIES) 857 \$(LIBTOOL) --mode=link ifelse($4,,[\$(CC)],[\$(CXX)]) \$(COMMON_FLAGS) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(LDFLAGS) $additional_flags -o [\$]@ -export-dynamic -avoid-version -prefer-pic -module -rpath \$(phplibdir) \$(EXTRA_LDFLAGS) \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_LIBADD) 858 859EOF 860]) 861 862dnl 863dnl PHP_SELECT_SAPI(name, type[, sources [, extra-cflags [, build-target]]]) 864dnl 865dnl Selects the SAPI name and type (static, shared, bundle, program) 866dnl and optionally also the source-files for the SAPI-specific 867dnl objects. 868dnl 869AC_DEFUN([PHP_SELECT_SAPI],[ 870 if test "$2" = "program"; then 871 PHP_BINARIES="$PHP_BINARIES $1" 872 elif test "$PHP_SAPI" != "none"; then 873 AC_MSG_ERROR([ 874+--------------------------------------------------------------------+ 875| *** ATTENTION *** | 876| | 877| You've configured multiple SAPIs to be build. You can build only | 878| one SAPI module plus CGI, CLI and FPM binaries at the same time. | 879+--------------------------------------------------------------------+ 880]) 881 else 882 PHP_SAPI=$1 883 fi 884 885 PHP_ADD_BUILD_DIR([sapi/$1]) 886 887 PHP_INSTALLED_SAPIS="$PHP_INSTALLED_SAPIS $1" 888 889 ifelse($2,program,[ 890 PHP_BUILD_PROGRAM 891 install_binaries="install-binaries" 892 install_binary_targets="$install_binary_targets install-$1" 893 PHP_SUBST(PHP_[]translit($1,a-z0-9-,A-Z0-9_)[]_OBJS) 894 ifelse($3,,,[PHP_ADD_SOURCES_X([sapi/$1],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_)[]_OBJS)]) 895 ],[ 896 case "$2" in 897 static[)] PHP_BUILD_STATIC;; 898 shared[)] PHP_BUILD_SHARED;; 899 bundle[)] PHP_BUILD_BUNDLE;; 900 esac 901 install_sapi="install-sapi" 902 ifelse($3,,,[PHP_ADD_SOURCES([sapi/$1],[$3],[$4],[sapi])]) 903 ]) 904]) 905 906dnl deprecated 907AC_DEFUN([PHP_EXTENSION],[ 908 sources=`$AWK -f $abs_srcdir/build/scan_makefile_in.awk < []PHP_EXT_SRCDIR($1)[]/Makefile.in` 909 910 PHP_NEW_EXTENSION($1, $sources, $2, $3) 911 912 if test -r "$ext_srcdir/Makefile.frag"; then 913 PHP_ADD_MAKEFILE_FRAGMENT 914 fi 915]) 916 917AC_DEFUN([PHP_ADD_BUILD_DIR],[ 918 ifelse($2,,[ 919 BUILD_DIR="$BUILD_DIR $1" 920 ], [ 921 $php_shtool mkdir -p $1 922 ]) 923]) 924 925AC_DEFUN([PHP_GEN_BUILD_DIRS],[ 926 $php_shtool mkdir -p $BUILD_DIR 927]) 928 929dnl 930dnl PHP_NEW_EXTENSION(extname, sources [, shared [, sapi_class [, extra-cflags [, cxx [, zend_ext]]]]]) 931dnl 932dnl Includes an extension in the build. 933dnl 934dnl "extname" is the name of the extension. 935dnl "sources" is a list of files relative to the subdir which are used 936dnl to build the extension. 937dnl "shared" can be set to "shared" or "yes" to build the extension as 938dnl a dynamically loadable library. Optional parameter "sapi_class" can 939dnl be set to "cli" to mark extension build only with CLI or CGI sapi's. 940dnl "extra-cflags" are passed to the compiler, with 941dnl @ext_srcdir@ and @ext_builddir@ being substituted. 942dnl "cxx" can be used to indicate that a C++ shared module is desired. 943dnl "zend_ext" indicates a zend extension. 944AC_DEFUN([PHP_NEW_EXTENSION],[ 945 ext_builddir=[]PHP_EXT_BUILDDIR($1) 946 ext_srcdir=[]PHP_EXT_SRCDIR($1) 947 ext_dir=[]PHP_EXT_DIR($1) 948 949 ifelse($5,,ac_extra=,[ac_extra=`echo "$5"|$SED s#@ext_srcdir@#$ext_srcdir#g|$SED s#@ext_builddir@#$ext_builddir#g`]) 950 951 if test "$3" != "shared" && test "$3" != "yes" && test "$4" != "cli"; then 952dnl ---------------------------------------------- Static module 953 [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=no 954 PHP_ADD_SOURCES($ext_dir,$2,$ac_extra,) 955 EXT_STATIC="$EXT_STATIC $1;$ext_dir" 956 if test "$3" != "nocli"; then 957 EXT_CLI_STATIC="$EXT_CLI_STATIC $1;$ext_dir" 958 fi 959 else 960 if test "$3" = "shared" || test "$3" = "yes"; then 961dnl ---------------------------------------------- Shared module 962 [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=yes 963 PHP_ADD_SOURCES_X($ext_dir,$2,$ac_extra,shared_objects_$1,yes) 964 PHP_SHARED_MODULE($1,shared_objects_$1, $ext_builddir, $6, $7) 965 AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z_-,A-Z__), 1, Whether to build $1 as dynamic module) 966 fi 967 fi 968 969 if test "$3" != "shared" && test "$3" != "yes" && test "$4" = "cli"; then 970dnl ---------------------------------------------- CLI static module 971 [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=no 972 case "$PHP_SAPI" in 973 cgi|embed|phpdbg[)] 974 PHP_ADD_SOURCES($ext_dir,$2,$ac_extra,) 975 EXT_STATIC="$EXT_STATIC $1;$ext_dir" 976 ;; 977 *[)] 978 PHP_ADD_SOURCES($ext_dir,$2,$ac_extra,cli) 979 ;; 980 esac 981 EXT_CLI_STATIC="$EXT_CLI_STATIC $1;$ext_dir" 982 fi 983 PHP_ADD_BUILD_DIR($ext_builddir) 984 985dnl Set for phpize builds only 986dnl --------------------------- 987 if test "$ext_builddir" = "."; then 988 PHP_PECL_EXTENSION=$1 989 PHP_SUBST(PHP_PECL_EXTENSION) 990 fi 991]) 992 993dnl 994dnl PHP_WITH_SHARED 995dnl 996dnl Checks whether $withval is "shared" or starts with "shared,XXX" 997dnl and sets $shared to "yes" or "no", and removes "shared,?" stuff 998dnl from $withval. 999dnl 1000AC_DEFUN([PHP_WITH_SHARED],[ 1001 PHP_ARG_ANALYZE_EX(withval) 1002 shared=$ext_shared 1003 unset ext_shared ext_output 1004]) 1005 1006dnl 1007dnl PHP_ADD_EXTENSION_DEP(extname, depends [, depconf]) 1008dnl 1009dnl This macro is scanned by genif.sh when it builds the internal functions 1010dnl list, so that modules can be init'd in the correct order 1011dnl $1 = name of extension, $2 = extension upon which it depends 1012dnl $3 = optional: if true, it's ok for $2 to have not been configured 1013dnl default is false and should halt the build. 1014dnl To be effective, this macro must be invoked *after* PHP_NEW_EXTENSION. 1015dnl The extension on which it depends must also have been configured. 1016dnl See ADD_EXTENSION_DEP in win32 build 1017dnl 1018AC_DEFUN([PHP_ADD_EXTENSION_DEP], [ 1019 am_i_shared=$[PHP_]translit($1,a-z_-,A-Z__)[_SHARED] 1020 is_it_shared=$[PHP_]translit($2,a-z_-,A-Z__)[_SHARED] 1021 is_it_enabled=$[PHP_]translit($2,a-z_-,A-Z__) 1022 if test "$am_i_shared" = "no" && test "$is_it_shared" = "yes" ; then 1023 AC_MSG_ERROR([ 1024You've configured extension $1 to build statically, but it 1025depends on extension $2, which you've configured to build shared. 1026You either need to build $1 shared or build $2 statically for the 1027build to be successful. 1028]) 1029 fi 1030 if test "x$is_it_enabled" = "xno" && test "x$3" != "xtrue"; then 1031 AC_MSG_ERROR([ 1032You've configured extension $1, which depends on extension $2, 1033but you've either not enabled $2, or have disabled it. 1034]) 1035 fi 1036 dnl Some systems require that we link $2 to $1 when building 1037]) 1038 1039dnl ------------------------------------------------------------------------- 1040dnl Checks for structures, typedefs, broken functions, etc. 1041dnl ------------------------------------------------------------------------- 1042 1043dnl Internal helper macros 1044dnl 1045dnl _PHP_DEF_HAVE_FILE(what, filename) 1046AC_DEFUN([_PHP_DEF_HAVE_FILE], [ 1047 php_def_have_what=HAVE_[]`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz-' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_' ` 1048 echo "#define $php_def_have_what 1" >> $2 1049]) 1050dnl 1051dnl _PHP_CHECK_SIZEOF(type, cross-value, extra-headers [, found-action [, not-found-action]]) 1052dnl 1053AC_DEFUN([_PHP_CHECK_SIZEOF], [ 1054 php_cache_value=php_cv_sizeof_[]$1 1055 AC_CACHE_VAL(php_cv_sizeof_[]$1, [ 1056 old_LIBS=$LIBS 1057 LIBS= 1058 old_LDFLAGS=$LDFLAGS 1059 LDFLAGS= 1060 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h> 1061#if STDC_HEADERS 1062#include <stdlib.h> 1063#include <stddef.h> 1064#endif 1065#ifdef HAVE_INTTYPES_H 1066#include <inttypes.h> 1067#endif 1068#ifdef HAVE_UNISTD_H 1069#include <unistd.h> 1070#endif 1071$3 1072 1073int main() 1074{ 1075 FILE *fp = fopen("conftestval", "w"); 1076 if (!fp) return(1); 1077 fprintf(fp, "%d\n", sizeof($1)); 1078 return(0); 1079} 1080 ]])], [ 1081 eval $php_cache_value=`cat conftestval` 1082 ], [ 1083 eval $php_cache_value=0 1084 ], [ 1085 ifelse([$2],,[eval $php_cache_value=0], [eval $php_cache_value=$2]) 1086]) 1087 LDFLAGS=$old_LDFLAGS 1088 LIBS=$old_LIBS 1089]) 1090 if eval test "\$$php_cache_value" != "0"; then 1091ifelse([$4],[],:,[$4]) 1092ifelse([$5],[],,[else $5]) 1093 fi 1094]) 1095 1096dnl 1097dnl PHP_CHECK_SIZEOF(type, cross-value, extra-headers) 1098dnl 1099AC_DEFUN([PHP_CHECK_SIZEOF], [ 1100 AC_MSG_CHECKING([size of $1]) 1101 _PHP_CHECK_SIZEOF($1, $2, $3, [ 1102 AC_DEFINE_UNQUOTED([SIZEOF_]translit($1,a-z,A-Z_), [$]php_cv_sizeof_[]$1, [Size of $1]) 1103 AC_DEFINE_UNQUOTED([HAVE_]translit($1,a-z,A-Z_), 1, [Whether $1 is available]) 1104 ]) 1105 AC_MSG_RESULT([[$][php_cv_sizeof_]translit($1, ,_)]) 1106]) 1107 1108dnl 1109dnl PHP_CHECK_TYPES(type-list, include-file [, extra-headers]) 1110dnl 1111AC_DEFUN([PHP_CHECK_TYPES], [ 1112 for php_typename in $1; do 1113 AC_MSG_CHECKING([whether $php_typename exists]) 1114 _PHP_CHECK_SIZEOF($php_typename, 0, $3, [ 1115 _PHP_DEF_HAVE_FILE($php_typename, $2) 1116 AC_MSG_RESULT([yes]) 1117 ], [ 1118 AC_MSG_RESULT([no]) 1119 ]) 1120 done 1121]) 1122 1123dnl 1124dnl PHP_CHECK_IN_ADDR_T 1125dnl 1126AC_DEFUN([PHP_CHECK_IN_ADDR_T], [ 1127dnl AIX keeps in_addr_t in /usr/include/netinet/in.h 1128AC_MSG_CHECKING([for in_addr_t]) 1129AC_CACHE_VAL(ac_cv_type_in_addr_t, 1130[AC_EGREP_CPP(dnl 1131changequote(<<,>>)dnl 1132<<in_addr_t[^a-zA-Z_0-9]>>dnl 1133changequote([,]), [#include <sys/types.h> 1134#if STDC_HEADERS 1135#include <stdlib.h> 1136#include <stddef.h> 1137#endif 1138#ifdef HAVE_NETINET_IN_H 1139#include <netinet/in.h> 1140#endif], ac_cv_type_in_addr_t=yes, ac_cv_type_in_addr_t=no)])dnl 1141AC_MSG_RESULT([$ac_cv_type_in_addr_t]) 1142if test $ac_cv_type_in_addr_t = no; then 1143 AC_DEFINE(in_addr_t, u_int, [ ]) 1144fi 1145]) 1146 1147dnl 1148dnl PHP_TIME_R_TYPE 1149dnl 1150dnl Check type of reentrant time-related functions 1151dnl Type can be: irix, hpux or POSIX 1152dnl 1153AC_DEFUN([PHP_TIME_R_TYPE],[ 1154AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[ 1155AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1156#include <time.h> 1157 1158main() { 1159char buf[27]; 1160struct tm t; 1161time_t old = 0; 1162int r, s; 1163 1164s = gmtime_r(&old, &t); 1165r = (int) asctime_r(&t, buf, 26); 1166if (r == s && s == 0) return (0); 1167return (1); 1168} 1169]])],[ 1170 ac_cv_time_r_type=hpux 1171],[ 1172 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1173#include <time.h> 1174main() { 1175 struct tm t, *s; 1176 time_t old = 0; 1177 char buf[27], *p; 1178 1179 s = gmtime_r(&old, &t); 1180 p = asctime_r(&t, buf, 26); 1181 if (p == buf && s == &t) return (0); 1182 return (1); 1183} 1184 ]])],[ 1185 ac_cv_time_r_type=irix 1186 ],[ 1187 ac_cv_time_r_type=POSIX 1188 ],[ 1189 ac_cv_time_r_type=POSIX 1190 ]) 1191],[ 1192 ac_cv_time_r_type=POSIX 1193]) 1194]) 1195 case $ac_cv_time_r_type in 1196 hpux[)] AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;; 1197 irix[)] AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;; 1198 esac 1199]) 1200 1201dnl 1202dnl PHP_DOES_PWRITE_WORK 1203dnl internal 1204AC_DEFUN([PHP_DOES_PWRITE_WORK],[ 1205 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1206#include <sys/types.h> 1207#include <sys/stat.h> 1208#include <fcntl.h> 1209#include <unistd.h> 1210#include <errno.h> 1211$1 1212 int main() { 1213 int fd = open("conftest_in", O_WRONLY|O_CREAT, 0600); 1214 1215 if (fd < 0) return 1; 1216 if (pwrite(fd, "text", 4, 0) != 4) return 1; 1217 /* Linux glibc breakage until 2.2.5 */ 1218 if (pwrite(fd, "text", 4, -1) != -1 || errno != EINVAL) return 1; 1219 return 0; 1220 } 1221 1222 ]])],[ 1223 ac_cv_pwrite=yes 1224 ],[ 1225 ac_cv_pwrite=no 1226 ],[ 1227 ac_cv_pwrite=no 1228 ]) 1229]) 1230 1231dnl PHP_DOES_PREAD_WORK 1232dnl internal 1233AC_DEFUN([PHP_DOES_PREAD_WORK],[ 1234 echo test > conftest_in 1235 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1236#include <sys/types.h> 1237#include <sys/stat.h> 1238#include <fcntl.h> 1239#include <unistd.h> 1240#include <errno.h> 1241$1 1242 int main() { 1243 char buf[3]; 1244 int fd = open("conftest_in", O_RDONLY); 1245 if (fd < 0) return 1; 1246 if (pread(fd, buf, 2, 0) != 2) return 1; 1247 /* Linux glibc breakage until 2.2.5 */ 1248 if (pread(fd, buf, 2, -1) != -1 || errno != EINVAL) return 1; 1249 return 0; 1250 } 1251 ]])],[ 1252 ac_cv_pread=yes 1253 ],[ 1254 ac_cv_pread=no 1255 ],[ 1256 ac_cv_pread=no 1257 ]) 1258 rm -f conftest_in 1259]) 1260 1261dnl 1262dnl PHP_PWRITE_TEST 1263dnl 1264AC_DEFUN([PHP_PWRITE_TEST],[ 1265 AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[ 1266 PHP_DOES_PWRITE_WORK 1267 if test "$ac_cv_pwrite" = "no"; then 1268 PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);]) 1269 if test "$ac_cv_pwrite" = "yes"; then 1270 ac_cv_pwrite=64 1271 fi 1272 fi 1273 ]) 1274 1275 if test "$ac_cv_pwrite" != "no"; then 1276 AC_DEFINE(HAVE_PWRITE, 1, [ ]) 1277 if test "$ac_cv_pwrite" = "64"; then 1278 AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default]) 1279 fi 1280 fi 1281]) 1282 1283dnl 1284dnl PHP_PREAD_TEST 1285dnl 1286AC_DEFUN([PHP_PREAD_TEST],[ 1287 AC_CACHE_CHECK(whether pread works,ac_cv_pread,[ 1288 PHP_DOES_PREAD_WORK 1289 if test "$ac_cv_pread" = "no"; then 1290 PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);]) 1291 if test "$ac_cv_pread" = "yes"; then 1292 ac_cv_pread=64 1293 fi 1294 fi 1295 ]) 1296 1297 if test "$ac_cv_pread" != "no"; then 1298 AC_DEFINE(HAVE_PREAD, 1, [ ]) 1299 if test "$ac_cv_pread" = "64"; then 1300 AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default]) 1301 fi 1302 fi 1303]) 1304 1305dnl 1306dnl PHP_MISSING_TIME_R_DECL 1307dnl 1308AC_DEFUN([PHP_MISSING_TIME_R_DECL],[ 1309 AC_MSG_CHECKING([for missing declarations of reentrant functions]) 1310 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct tm *(*func)() = localtime_r]])],[ 1311 : 1312 ],[ 1313 AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared]) 1314 ]) 1315 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct tm *(*func)() = gmtime_r]])],[ 1316 : 1317 ],[ 1318 AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared]) 1319 ]) 1320 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[char *(*func)() = asctime_r]])],[ 1321 : 1322 ],[ 1323 AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared]) 1324 ]) 1325 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[char *(*func)() = ctime_r]])],[ 1326 : 1327 ],[ 1328 AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared]) 1329 ]) 1330 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string.h>]], [[char *(*func)() = strtok_r]])],[ 1331 : 1332 ],[ 1333 AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared]) 1334 ]) 1335 AC_MSG_RESULT([done]) 1336]) 1337 1338dnl 1339dnl PHP_READDIR_R_TYPE 1340dnl 1341AC_DEFUN([PHP_READDIR_R_TYPE],[ 1342 dnl HAVE_READDIR_R is also defined by libmysql 1343 AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no) 1344 if test "$ac_cv_func_readdir_r" = "yes"; then 1345 AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[ 1346 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1347#define _REENTRANT 1348#include <sys/types.h> 1349#include <dirent.h> 1350#include <unistd.h> 1351 1352#ifndef PATH_MAX 1353#define PATH_MAX 1024 1354#endif 1355 1356int main() { 1357 DIR *dir; 1358 char entry[sizeof(struct dirent)+PATH_MAX]; 1359 struct dirent *pentry = (struct dirent *) &entry; 1360 1361 dir = opendir("/"); 1362 if (!dir) 1363 return 1; 1364 if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0) { 1365 close(dir); 1366 return 0; 1367 } 1368 close(dir); 1369 return 1; 1370} 1371 ]])],[ 1372 ac_cv_what_readdir_r=POSIX 1373 ],[ 1374 AC_PREPROC_IFELSE([ 1375 AC_LANG_SOURCE([[ 1376#define _REENTRANT 1377#include <sys/types.h> 1378#include <dirent.h> 1379int readdir_r(DIR *, struct dirent *); 1380 ]])],[ 1381 ac_cv_what_readdir_r=old-style 1382 ],[ 1383 ac_cv_what_readdir_r=none 1384 ]) 1385 ],[ 1386 ac_cv_what_readdir_r=none 1387 ]) 1388 ]) 1389 case $ac_cv_what_readdir_r in 1390 POSIX) 1391 AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);; 1392 old-style) 1393 AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);; 1394 esac 1395 fi 1396]) 1397 1398dnl 1399dnl PHP_TM_GMTOFF 1400dnl 1401AC_DEFUN([PHP_TM_GMTOFF],[ 1402AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff, 1403[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 1404#include <$ac_cv_struct_tm>]], [[struct tm tm; tm.tm_gmtoff;]])], 1405 [ac_cv_struct_tm_gmtoff=yes], [ac_cv_struct_tm_gmtoff=no])]) 1406 1407if test "$ac_cv_struct_tm_gmtoff" = yes; then 1408 AC_DEFINE(HAVE_TM_GMTOFF,1,[whether you have tm_gmtoff in struct tm]) 1409fi 1410]) 1411 1412dnl 1413dnl PHP_STRUCT_FLOCK 1414dnl 1415AC_DEFUN([PHP_STRUCT_FLOCK],[ 1416AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock, 1417 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1418#include <unistd.h> 1419#include <fcntl.h> 1420 ]], [[struct flock x;]])],[ 1421 ac_cv_struct_flock=yes 1422 ],[ 1423 ac_cv_struct_flock=no 1424 ]) 1425) 1426if test "$ac_cv_struct_flock" = "yes" ; then 1427 AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock]) 1428fi 1429]) 1430 1431dnl 1432dnl PHP_SOCKLEN_T 1433dnl 1434AC_DEFUN([PHP_SOCKLEN_T],[ 1435AC_CACHE_CHECK(for socklen_t,ac_cv_socklen_t, 1436 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1437#include <sys/types.h> 1438#include <sys/socket.h> 1439]],[[ 1440socklen_t x; 1441]])],[ 1442 ac_cv_socklen_t=yes 1443],[ 1444 ac_cv_socklen_t=no 1445])) 1446if test "$ac_cv_socklen_t" = "yes"; then 1447 AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t]) 1448fi 1449]) 1450 1451dnl 1452dnl PHP_MISSING_FCLOSE_DECL 1453dnl 1454dnl See if we have broken header files like SunOS has. 1455dnl 1456AC_DEFUN([PHP_MISSING_FCLOSE_DECL],[ 1457 AC_MSG_CHECKING([for fclose declaration]) 1458 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[int (*func)() = fclose]])],[ 1459 AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ]) 1460 AC_MSG_RESULT([ok]) 1461 ],[ 1462 AC_DEFINE(MISSING_FCLOSE_DECL,1,[ ]) 1463 AC_MSG_RESULT([missing]) 1464 ]) 1465]) 1466 1467dnl 1468dnl PHP_AC_BROKEN_SPRINTF 1469dnl 1470dnl Check for broken sprintf(), C99 conformance 1471dnl 1472AC_DEFUN([PHP_AC_BROKEN_SPRINTF],[ 1473 AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[ 1474 AC_RUN_IFELSE([AC_LANG_SOURCE([[main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }]])],[ 1475 ac_cv_broken_sprintf=no 1476 ],[ 1477 ac_cv_broken_sprintf=yes 1478 ],[ 1479 ac_cv_broken_sprintf=no 1480 ]) 1481 ]) 1482 if test "$ac_cv_broken_sprintf" = "yes"; then 1483 AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [Whether sprintf is C99 conform]) 1484 else 1485 AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [Whether sprintf is C99 conform]) 1486 fi 1487]) 1488 1489dnl 1490dnl PHP_AC_BROKEN_SNPRINTF 1491dnl 1492dnl Check for broken snprintf(), C99 conformance 1493dnl 1494AC_DEFUN([PHP_AC_BROKEN_SNPRINTF],[ 1495 AC_CACHE_CHECK(whether snprintf is broken, ac_cv_broken_snprintf,[ 1496 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1497#define NULL (0L) 1498main() { 1499 char buf[20]; 1500 int res = 0; 1501 res = res || (snprintf(buf, 2, "marcus") != 6); 1502 res = res || (buf[1] != '\0'); 1503 /* Implementations may consider this as an encoding error */ 1504 snprintf(buf, 0, "boerger"); 1505 /* However, they MUST ignore the pointer */ 1506 res = res || (buf[0] != 'm'); 1507 res = res || (snprintf(NULL, 0, "boerger") != 7); 1508 res = res || (snprintf(buf, sizeof(buf), "%f", 0.12345678) != 8); 1509 exit(res); 1510} 1511 ]])],[ 1512 ac_cv_broken_snprintf=no 1513 ],[ 1514 ac_cv_broken_snprintf=yes 1515 ],[ 1516 ac_cv_broken_snprintf=no 1517 ]) 1518 ]) 1519 if test "$ac_cv_broken_snprintf" = "yes"; then 1520 AC_DEFINE(PHP_BROKEN_SNPRINTF, 1, [Whether snprintf is C99 conform]) 1521 else 1522 AC_DEFINE(PHP_BROKEN_SNPRINTF, 0, [Whether snprintf is C99 conform]) 1523 fi 1524]) 1525 1526dnl 1527dnl PHP_SOLARIS_PIC_WEIRDNESS 1528dnl 1529dnl Solaris requires main code to be position independent in order 1530dnl to let shared objects find symbols. Weird. Ugly. 1531dnl 1532dnl Must be run after all --with-NN options that let the user 1533dnl choose dynamic extensions, and after the gcc test. 1534dnl 1535AC_DEFUN([PHP_SOLARIS_PIC_WEIRDNESS],[ 1536 AC_MSG_CHECKING([whether -fPIC is required]) 1537 if test -n "$EXT_SHARED"; then 1538 os=`uname -sr 2>/dev/null` 1539 case $os in 1540 "SunOS 5.6"|"SunOS 5.7"[)] 1541 case $CC in 1542 gcc*|egcs*) 1543 CFLAGS="$CFLAGS -fPIC";; 1544 *[)] 1545 CFLAGS="$CFLAGS -fpic";; 1546 esac 1547 AC_MSG_RESULT([yes]);; 1548 *[)] 1549 AC_MSG_RESULT([no]);; 1550 esac 1551 else 1552 AC_MSG_RESULT([no]) 1553 fi 1554]) 1555 1556dnl 1557dnl PHP_SYS_LFS 1558dnl 1559dnl The problem is that the default compilation flags in Solaris 2.6 won't 1560dnl let programs access large files; you need to tell the compiler that 1561dnl you actually want your programs to work on large files. For more 1562dnl details about this brain damage please see: 1563dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html 1564dnl 1565dnl Written by Paul Eggert <eggert@twinsun.com>. 1566dnl 1567AC_DEFUN([PHP_SYS_LFS], 1568[dnl 1569 # If available, prefer support for large files unless the user specified 1570 # one of the CPPFLAGS, LDFLAGS, or LIBS variables. 1571 AC_MSG_CHECKING([whether large file support needs explicit enabling]) 1572 ac_getconfs='' 1573 ac_result=yes 1574 ac_set='' 1575 ac_shellvars='CPPFLAGS LDFLAGS LIBS' 1576 for ac_shellvar in $ac_shellvars; do 1577 case $ac_shellvar in 1578 CPPFLAGS[)] ac_lfsvar=LFS_CFLAGS ;; 1579 *[)] ac_lfsvar=LFS_$ac_shellvar ;; 1580 esac 1581 eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar 1582 (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; } 1583 ac_getconf=`getconf $ac_lfsvar` 1584 ac_getconfs=$ac_getconfs$ac_getconf 1585 eval ac_test_$ac_shellvar=\$ac_getconf 1586 done 1587 case "$ac_result$ac_getconfs" in 1588 yes[)] ac_result=no ;; 1589 esac 1590 case "$ac_result$ac_set" in 1591 yes?*[)] ac_result="yes, but $ac_set is already set, so use its settings" 1592 esac 1593 AC_MSG_RESULT([$ac_result]) 1594 case $ac_result in 1595 yes[)] 1596 for ac_shellvar in $ac_shellvars; do 1597 eval $ac_shellvar=\$ac_test_$ac_shellvar 1598 done ;; 1599 esac 1600]) 1601 1602dnl 1603dnl PHP_SOCKADDR_CHECKS 1604dnl 1605AC_DEFUN([PHP_SOCKADDR_CHECKS], [ 1606 dnl Check for struct sockaddr_storage exists 1607 AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_sockaddr_storage, 1608 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 1609#include <sys/socket.h>]], 1610 [[struct sockaddr_storage s; s]])], 1611 [ac_cv_sockaddr_storage=yes], [ac_cv_sockaddr_storage=no]) 1612 ]) 1613 if test "$ac_cv_sockaddr_storage" = "yes"; then 1614 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [Whether you have struct sockaddr_storage]) 1615 fi 1616 dnl Check if field sa_len exists in struct sockaddr 1617 AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[ 1618 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 1619#include <sys/socket.h>]], [[static struct sockaddr sa; int n = (int) sa.sa_len; return n;]])], 1620 [ac_cv_sockaddr_sa_len=yes], [ac_cv_sockaddr_sa_len=no]) 1621 ]) 1622 if test "$ac_cv_sockaddr_sa_len" = "yes"; then 1623 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has field sa_len]) 1624 fi 1625]) 1626 1627dnl 1628dnl PHP_DECLARED_TIMEZONE 1629dnl 1630AC_DEFUN([PHP_DECLARED_TIMEZONE],[ 1631 AC_CACHE_CHECK(for declared timezone, ac_cv_declared_timezone,[ 1632 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1633#include <sys/types.h> 1634#include <time.h> 1635#ifdef HAVE_SYS_TIME_H 1636#include <sys/time.h> 1637#endif 1638]],[[ 1639 time_t foo = (time_t) timezone; 1640]])],[ 1641 ac_cv_declared_timezone=yes 1642],[ 1643 ac_cv_declared_timezone=no 1644])]) 1645 if test "$ac_cv_declared_timezone" = "yes"; then 1646 AC_DEFINE(HAVE_DECLARED_TIMEZONE, 1, [Whether system headers declare timezone]) 1647 fi 1648]) 1649 1650dnl 1651dnl PHP_EBCDIC 1652dnl 1653AC_DEFUN([PHP_EBCDIC], [ 1654 AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[ 1655 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1656int main(void) { 1657 return (unsigned char)'A' != (unsigned char)0xC1; 1658} 1659]])],[ 1660 ac_cv_ebcdic=yes 1661],[ 1662 ac_cv_ebcdic=no 1663],[ 1664 ac_cv_ebcdic=no 1665])]) 1666 if test "$ac_cv_ebcdic" = "yes"; then 1667 AC_DEFINE(CHARSET_EBCDIC,1, [Define if system uses EBCDIC]) 1668 fi 1669]) 1670 1671dnl 1672dnl PHP_BROKEN_GETCWD 1673dnl 1674dnl Some systems, notably Solaris, cause getcwd() or realpath to fail if a 1675dnl component of the path has execute but not read permissions 1676dnl 1677AC_DEFUN([PHP_BROKEN_GETCWD],[ 1678 AC_MSG_CHECKING([for broken getcwd]) 1679 os=`uname -sr 2>/dev/null` 1680 case $os in 1681 SunOS*[)] 1682 AC_DEFINE(HAVE_BROKEN_GETCWD,1, [Define if system has broken getcwd]) 1683 AC_MSG_RESULT([yes]);; 1684 *[)] 1685 AC_MSG_RESULT([no]);; 1686 esac 1687]) 1688 1689dnl 1690dnl PHP_BROKEN_GLIBC_FOPEN_APPEND 1691dnl 1692AC_DEFUN([PHP_BROKEN_GLIBC_FOPEN_APPEND], [ 1693 AC_MSG_CHECKING([for broken libc stdio]) 1694 AC_CACHE_VAL(_cv_have_broken_glibc_fopen_append,[ 1695 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1696#include <stdio.h> 1697#include <unistd.h> 1698int main(int argc, char *argv[]) 1699{ 1700 FILE *fp; 1701 long position; 1702 char *filename = tmpnam(NULL); 1703 1704 fp = fopen(filename, "w"); 1705 if (fp == NULL) { 1706 perror("fopen"); 1707 return 2; 1708 } 1709 fputs("foobar", fp); 1710 fclose(fp); 1711 1712 fp = fopen(filename, "a+"); 1713 position = ftell(fp); 1714 fclose(fp); 1715 unlink(filename); 1716 if (position == 0) 1717 return 1; 1718 return 0; 1719} 1720]])], 1721[_cv_have_broken_glibc_fopen_append=no], 1722[_cv_have_broken_glibc_fopen_append=yes], 1723[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1724#include <features.h> 1725]], [[ 1726#if !__GLIBC_PREREQ(2,2) 1727choke me 1728#endif 1729]])], 1730[_cv_have_broken_glibc_fopen_append=yes], 1731[_cv_have_broken_glibc_fopen_append=no]) 1732])]) 1733 1734 if test "$_cv_have_broken_glibc_fopen_append" = "yes"; then 1735 AC_MSG_RESULT(yes) 1736 AC_DEFINE(HAVE_BROKEN_GLIBC_FOPEN_APPEND,1, [Define if your glibc borks on fopen with mode a+]) 1737 else 1738 AC_MSG_RESULT(no) 1739 fi 1740]) 1741 1742dnl 1743dnl PHP_BROKEN_GCC_STRLEN_OPT 1744dnl 1745dnl Early releases of GCC 8 shipped with a strlen() optimization bug, so they 1746dnl didn't properly handle the `char val[1]` struct hack. See bug #76510. 1747dnl 1748AC_DEFUN([PHP_BROKEN_GCC_STRLEN_OPT], [ 1749 AC_CACHE_CHECK([for broken gcc optimize-strlen],ac_cv_have_broken_gcc_strlen_opt,[ 1750 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1751#include <stdlib.h> 1752#include <string.h> 1753#include <stdio.h> 1754struct s 1755{ 1756 int i; 1757 char c[1]; 1758}; 1759int main() 1760{ 1761 struct s *s = malloc(sizeof(struct s) + 3); 1762 s->i = 3; 1763 strcpy(s->c, "foo"); 1764 return strlen(s->c+1) == 2; 1765} 1766]])],[ 1767 ac_cv_have_broken_gcc_strlen_opt=yes 1768],[ 1769 ac_cv_have_broken_gcc_strlen_opt=no 1770],[ 1771 ac_cv_have_broken_gcc_strlen_opt=no 1772])]) 1773 if test "$ac_cv_have_broken_gcc_strlen_opt" = "yes"; then 1774 CFLAGS="$CFLAGS -fno-optimize-strlen" 1775 fi 1776]) 1777 1778dnl 1779dnl PHP_FOPENCOOKIE 1780dnl 1781AC_DEFUN([PHP_FOPENCOOKIE], [ 1782 AC_CHECK_FUNC(fopencookie, [have_glibc_fopencookie=yes]) 1783 1784 if test "$have_glibc_fopencookie" = "yes"; then 1785dnl this comes in two flavors: 1786dnl newer glibcs (since 2.1.2 ? ) 1787dnl have a type called cookie_io_functions_t 1788AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1789#define _GNU_SOURCE 1790#include <stdio.h> 1791]], [[cookie_io_functions_t cookie;]])],[have_cookie_io_functions_t=yes],[]) 1792 1793 if test "$have_cookie_io_functions_t" = "yes"; then 1794 cookie_io_functions_t=cookie_io_functions_t 1795 have_fopen_cookie=yes 1796 1797dnl even newer glibcs have a different seeker definition... 1798AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1799#define _GNU_SOURCE 1800#include <stdio.h> 1801 1802struct cookiedata { 1803 __off64_t pos; 1804}; 1805 1806__ssize_t reader(void *cookie, char *buffer, size_t size) 1807{ return size; } 1808__ssize_t writer(void *cookie, const char *buffer, size_t size) 1809{ return size; } 1810int closer(void *cookie) 1811{ return 0; } 1812int seeker(void *cookie, __off64_t *position, int whence) 1813{ ((struct cookiedata*)cookie)->pos = *position; return 0; } 1814 1815cookie_io_functions_t funcs = {reader, writer, seeker, closer}; 1816 1817int main() { 1818 struct cookiedata g = { 0 }; 1819 FILE *fp = fopencookie(&g, "r", funcs); 1820 1821 if (fp && fseek(fp, 8192, SEEK_SET) == 0 && g.pos == 8192) 1822 return 0; 1823 return 1; 1824} 1825 1826]])], [ 1827 cookie_io_functions_use_off64_t=yes 1828], [ 1829 cookie_io_functions_use_off64_t=no 1830], [ 1831 cookie_io_functions_use_off64_t=no 1832]) 1833 1834 else 1835 1836dnl older glibc versions (up to 2.1.2 ?) 1837dnl call it _IO_cookie_io_functions_t 1838AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1839#define _GNU_SOURCE 1840#include <stdio.h> 1841]], [[_IO_cookie_io_functions_t cookie;]])], [have_IO_cookie_io_functions_t=yes], []) 1842 if test "$have_cookie_io_functions_t" = "yes" ; then 1843 cookie_io_functions_t=_IO_cookie_io_functions_t 1844 have_fopen_cookie=yes 1845 fi 1846 fi 1847 1848 if test "$have_fopen_cookie" = "yes" ; then 1849 AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ]) 1850 AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ]) 1851 if test "$cookie_io_functions_use_off64_t" = "yes" ; then 1852 AC_DEFINE(COOKIE_SEEKER_USES_OFF64_T, 1, [ ]) 1853 fi 1854 fi 1855 fi 1856]) 1857 1858dnl ------------------------------------------------------------------------- 1859dnl Library/function existence and build sanity checks 1860dnl ------------------------------------------------------------------------- 1861 1862dnl 1863dnl PHP_CHECK_LIBRARY(library, function [, action-found [, action-not-found [, extra-libs]]]) 1864dnl 1865dnl Wrapper for AC_CHECK_LIB 1866dnl 1867AC_DEFUN([PHP_CHECK_LIBRARY], [ 1868 save_old_LDFLAGS=$LDFLAGS 1869 ac_stuff="$5" 1870 1871 save_ext_shared=$ext_shared 1872 ext_shared=yes 1873 PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS) 1874 AC_CHECK_LIB([$1],[$2],[ 1875 LDFLAGS=$save_old_LDFLAGS 1876 ext_shared=$save_ext_shared 1877 $3 1878 ],[ 1879 LDFLAGS=$save_old_LDFLAGS 1880 ext_shared=$save_ext_shared 1881 unset ac_cv_lib_$1[]_$2 1882 $4 1883 ])dnl 1884]) 1885 1886dnl 1887dnl PHP_CHECK_FRAMEWORK(framework, function [, action-found [, action-not-found ]]) 1888dnl 1889dnl El cheapo wrapper for AC_CHECK_LIB 1890dnl 1891AC_DEFUN([PHP_CHECK_FRAMEWORK], [ 1892 save_old_LDFLAGS=$LDFLAGS 1893 LDFLAGS="-framework $1 $LDFLAGS" 1894 dnl supplying "c" to AC_CHECK_LIB is technically cheating, but 1895 dnl rewriting AC_CHECK_LIB is overkill and this only affects 1896 dnl the "checking.." output anyway. 1897 AC_CHECK_LIB(c,[$2],[ 1898 LDFLAGS=$save_old_LDFLAGS 1899 $3 1900 ],[ 1901 LDFLAGS=$save_old_LDFLAGS 1902 $4 1903 ]) 1904]) 1905 1906dnl 1907dnl PHP_CHECK_FUNC_LIB(func, libs) 1908dnl 1909dnl This macro checks whether 'func' or '__func' exists 1910dnl in the specified library. 1911dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS. 1912dnl This should be called in the ACTION-IF-NOT-FOUND part of PHP_CHECK_FUNC 1913dnl 1914dnl 1915dnl autoconf undefines the builtin "shift" :-( 1916dnl If possible, we use the builtin shift anyway, otherwise we use 1917dnl the ubercool definition I have tested so far with FreeBSD/GNU m4 1918ifdef([builtin],[builtin(define, phpshift, [builtin(shift, $@)])],[ 1919define([phpshift],[ifelse(index([$@],[,]),-1,,[substr([$@],incr(index([$@],[,])))])]) 1920]) 1921dnl 1922AC_DEFUN([PHP_CHECK_FUNC_LIB],[ 1923 ifelse($2,,:,[ 1924 unset ac_cv_lib_$2[]_$1 1925 unset ac_cv_lib_$2[]___$1 1926 unset found 1927 AC_CHECK_LIB($2, $1, [found=yes], [ 1928 AC_CHECK_LIB($2, __$1, [found=yes], [found=no]) 1929 ]) 1930 1931 if test "$found" = "yes"; then 1932 ac_libs=$LIBS 1933 LIBS="$LIBS -l$2" 1934 AC_RUN_IFELSE([AC_LANG_SOURCE([[main() { return (0); }]])],[found=yes],[found=no],[found=no]) 1935 LIBS=$ac_libs 1936 fi 1937 1938 if test "$found" = "yes"; then 1939 PHP_ADD_LIBRARY($2) 1940 PHP_DEF_HAVE($1) 1941 PHP_DEF_HAVE(lib$2) 1942 ac_cv_func_$1=yes 1943 else 1944 PHP_CHECK_FUNC_LIB($1,phpshift(phpshift($@))) 1945 fi 1946 ]) 1947]) 1948 1949dnl 1950dnl PHP_CHECK_FUNC(func, ...) 1951dnl 1952dnl This macro checks whether 'func' or '__func' exists 1953dnl in the default libraries and as a fall back in the specified library. 1954dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS. 1955dnl 1956AC_DEFUN([PHP_CHECK_FUNC],[ 1957 unset ac_cv_func_$1 1958 unset ac_cv_func___$1 1959 unset found 1960 1961 AC_CHECK_FUNC($1, [found=yes],[ AC_CHECK_FUNC(__$1,[found=yes],[found=no]) ]) 1962 1963 case $found in 1964 yes[)] 1965 PHP_DEF_HAVE($1) 1966 ac_cv_func_$1=yes 1967 ;; 1968 ifelse($#,1,,[ 1969 *[)] PHP_CHECK_FUNC_LIB($@) ;; 1970 ]) 1971 esac 1972]) 1973 1974dnl 1975dnl PHP_TEST_BUILD(function, action-if-ok, action-if-not-ok [, extra-libs [, extra-source]]) 1976dnl 1977dnl This macro checks whether build works and given function exists. 1978dnl 1979AC_DEFUN([PHP_TEST_BUILD], [ 1980 old_LIBS=$LIBS 1981 LIBS="$4 $LIBS" 1982 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1983 $5 1984 char $1(); 1985 int main() { 1986 $1(); 1987 return 0; 1988 } 1989 ]])],[ 1990 LIBS=$old_LIBS 1991 $2 1992 ],[ 1993 LIBS=$old_LIBS 1994 $3 1995 ],[ 1996 LIBS=$old_LIBS 1997 ]) 1998]) 1999 2000dnl ------------------------------------------------------------------------- 2001dnl Platform characteristics checks 2002dnl ------------------------------------------------------------------------- 2003 2004dnl 2005dnl PHP_SHLIB_SUFFIX_NAMES 2006dnl 2007dnl Determines link library suffix SHLIB_SUFFIX_NAME 2008dnl which can be: .so, .sl or .dylib 2009dnl 2010dnl Determines shared library suffix SHLIB_DL_SUFFIX_NAME 2011dnl suffix can be: .so or .sl 2012dnl 2013AC_DEFUN([PHP_SHLIB_SUFFIX_NAMES],[ 2014 AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl 2015 PHP_SUBST_OLD(SHLIB_SUFFIX_NAME) 2016 PHP_SUBST_OLD(SHLIB_DL_SUFFIX_NAME) 2017 SHLIB_SUFFIX_NAME=so 2018 SHLIB_DL_SUFFIX_NAME=$SHLIB_SUFFIX_NAME 2019 case $host_alias in 2020 *hpux*[)] 2021 SHLIB_SUFFIX_NAME=sl 2022 SHLIB_DL_SUFFIX_NAME=sl 2023 ;; 2024 *darwin*[)] 2025 SHLIB_SUFFIX_NAME=dylib 2026 SHLIB_DL_SUFFIX_NAME=so 2027 ;; 2028 esac 2029]) 2030 2031dnl 2032dnl PHP_CHECK_64BIT([do if 32], [do if 64]) 2033dnl 2034dnl This macro is used to detect if we're at 64-bit platform or not. 2035dnl It could be useful for those external libs, that have different precompiled 2036dnl versions in different directories. 2037dnl 2038AC_DEFUN([PHP_CHECK_64BIT],[ 2039 AC_CHECK_SIZEOF(long int, 4) 2040 AC_MSG_CHECKING([checking if we're at 64-bit platform]) 2041 if test "$ac_cv_sizeof_long_int" = "4" ; then 2042 AC_MSG_RESULT([no]) 2043 $1 2044 else 2045 AC_MSG_RESULT([yes]) 2046 $2 2047 fi 2048]) 2049 2050dnl 2051dnl PHP_C_BIGENDIAN 2052dnl 2053dnl Replacement macro for AC_C_BIGENDIAN 2054dnl 2055AC_DEFUN([PHP_C_BIGENDIAN], 2056[AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian_php, 2057 [ 2058 ac_cv_c_bigendian_php=unknown 2059 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 2060int main(void) 2061{ 2062 short one = 1; 2063 char *cp = (char *)&one; 2064 2065 if (*cp == 0) { 2066 return(0); 2067 } else { 2068 return(1); 2069 } 2070} 2071 ]])], [ac_cv_c_bigendian_php=yes], [ac_cv_c_bigendian_php=no], [ac_cv_c_bigendian_php=unknown]) 2072 ]) 2073 if test $ac_cv_c_bigendian_php = yes; then 2074 AC_DEFINE(WORDS_BIGENDIAN, [], [Define if processor uses big-endian word]) 2075 fi 2076]) 2077 2078dnl ------------------------------------------------------------------------- 2079dnl Checks for programs: PHP_PROG_<program> 2080dnl ------------------------------------------------------------------------- 2081 2082dnl 2083dnl PHP_PROG_SENDMAIL 2084dnl 2085dnl Search for the sendmail binary 2086dnl 2087AC_DEFUN([PHP_PROG_SENDMAIL], [ 2088 PHP_ALT_PATH=/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib 2089 AC_PATH_PROG(PROG_SENDMAIL, sendmail, /usr/sbin/sendmail, $PATH:$PHP_ALT_PATH) 2090 PHP_SUBST(PROG_SENDMAIL) 2091]) 2092 2093dnl 2094dnl PHP_PROG_AWK 2095dnl 2096dnl Some vendors force mawk before gawk; mawk is broken so we don't like that 2097dnl 2098AC_DEFUN([PHP_PROG_AWK], [ 2099 AC_CHECK_PROGS(AWK, gawk nawk awk mawk, bork, /usr/xpg4/bin/:$PATH) 2100 case "$AWK" in 2101 *mawk) 2102 AC_MSG_WARN([mawk is known to have problems on some systems. You should install GNU awk]) 2103 ;; 2104 *gawk) 2105 ;; 2106 bork) 2107 AC_MSG_ERROR([Could not find awk; Install GNU awk]) 2108 ;; 2109 *) 2110 AC_MSG_CHECKING([if $AWK is broken]) 2111 if ! $AWK 'function foo() {}' >/dev/null 2>&1 ; then 2112 AC_MSG_RESULT([yes]) 2113 AC_MSG_ERROR([You should install GNU awk]) 2114 else 2115 AC_MSG_RESULT([no]) 2116 fi 2117 ;; 2118 esac 2119 PHP_SUBST(AWK) 2120]) 2121 2122dnl 2123dnl PHP_PROG_BISON 2124dnl 2125dnl Search for bison and check it's version 2126dnl 2127AC_DEFUN([PHP_PROG_BISON], [ 2128 AC_PROG_YACC 2129 LIBZEND_BISON_CHECK 2130 PHP_SUBST(YACC) 2131]) 2132 2133dnl 2134dnl PHP_PROG_RE2C 2135dnl 2136dnl Search for the re2c binary and check the version 2137dnl 2138AC_DEFUN([PHP_PROG_RE2C],[ 2139 AC_CHECK_PROG(RE2C, re2c, re2c) 2140 if test -n "$RE2C"; then 2141 AC_CACHE_CHECK([for re2c version], php_cv_re2c_version, [ 2142 re2c_vernum=`$RE2C --vernum 2>/dev/null` 2143 if test -z "$re2c_vernum" || test "$re2c_vernum" -lt "1304"; then 2144 php_cv_re2c_version=invalid 2145 else 2146 php_cv_re2c_version="`$RE2C --version | cut -d ' ' -f 2 2>/dev/null` (ok)" 2147 fi 2148 ]) 2149 fi 2150 case $php_cv_re2c_version in 2151 ""|invalid[)] 2152 AC_MSG_WARN([You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.]) 2153 RE2C="exit 0;" 2154 ;; 2155 esac 2156 PHP_SUBST(RE2C) 2157]) 2158 2159dnl ------------------------------------------------------------------------- 2160dnl Common setup macros: PHP_SETUP_<what> 2161dnl ------------------------------------------------------------------------- 2162 2163dnl 2164dnl PHP_SETUP_ICU([shared-add]) 2165dnl 2166dnl Common setup macro for ICU 2167dnl 2168AC_DEFUN([PHP_SETUP_ICU],[ 2169 PHP_ARG_WITH(icu-dir,, 2170 [ --with-icu-dir=DIR Specify where ICU libraries and headers can be found], DEFAULT, no) 2171 2172 if test "$PHP_ICU_DIR" = "no"; then 2173 PHP_ICU_DIR=DEFAULT 2174 fi 2175 2176 AC_MSG_CHECKING([for location of ICU headers and libraries]) 2177 found_icu=no 2178 2179 dnl First try to find pkg-config 2180 if test -z "$PKG_CONFIG"; then 2181 AC_PATH_PROG(PKG_CONFIG, pkg-config, no) 2182 fi 2183 2184 dnl If pkg-config is found try using it 2185 if test "$PHP_ICU_DIR" = "DEFAULT" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists icu-uc icu-io icu-i18n; then 2186 if $PKG_CONFIG --atleast-version=4.0 icu-uc; then 2187 found_icu=yes 2188 icu_version_full=`$PKG_CONFIG --modversion icu-uc` 2189 ac_IFS=$IFS 2190 IFS="." 2191 set $icu_version_full 2192 IFS=$ac_IFS 2193 icu_version=`expr [$]1 \* 1000 + [$]2` 2194 AC_MSG_RESULT([found $icu_version_full]) 2195 2196 ICU_LIBS=`$PKG_CONFIG --libs icu-uc icu-io icu-i18n` 2197 ICU_INCS=`$PKG_CONFIG --cflags-only-I icu-uc icu-io icu-i18n` 2198 ICU_CXXFLAGS=`$PKG_CONFIG --variable=CXXFLAGS icu-uc` 2199 ICU_CXXFLAGS="$ICU_CXXFLAGS -DU_USING_ICU_NAMESPACE=1" 2200 2201 AC_MSG_RESULT([found $ICU_VERSION]) 2202 2203 PHP_EVAL_LIBLINE($ICU_LIBS, $1) 2204 PHP_EVAL_INCLINE($ICU_INCS) 2205 else 2206 AC_MSG_ERROR([ICU version 4.0 or later required.]) 2207 fi 2208 fi 2209 2210 dnl If pkg-config fails for some reason, revert to the old method 2211 if test "$found_icu" = "no"; then 2212 if test "$PHP_ICU_DIR" = "DEFAULT"; then 2213 dnl Try to find icu-config 2214 AC_PATH_PROG(ICU_CONFIG, icu-config, no, [$PATH:/usr/local/bin]) 2215 else 2216 ICU_CONFIG="$PHP_ICU_DIR/bin/icu-config" 2217 fi 2218 2219 dnl Trust icu-config to know better what the install prefix is.. 2220 icu_install_prefix=`$ICU_CONFIG --prefix 2> /dev/null` 2221 if test "$?" != "0" || test -z "$icu_install_prefix"; then 2222 AC_MSG_RESULT([not found]) 2223 AC_MSG_ERROR([Unable to detect ICU prefix or $ICU_CONFIG failed. Please verify ICU install prefix and make sure icu-config works.]) 2224 else 2225 AC_MSG_RESULT([$icu_install_prefix]) 2226 2227 dnl Check ICU version 2228 AC_MSG_CHECKING([for ICU 4.0 or greater]) 2229 icu_version_full=`$ICU_CONFIG --version` 2230 ac_IFS=$IFS 2231 IFS="." 2232 set $icu_version_full 2233 IFS=$ac_IFS 2234 icu_version=`expr [$]1 \* 1000 + [$]2` 2235 AC_MSG_RESULT([found $icu_version_full]) 2236 2237 if test "$icu_version" -lt "4000"; then 2238 AC_MSG_ERROR([ICU version 4.0 or later is required]) 2239 fi 2240 2241 ICU_VERSION=$icu_version 2242 ICU_INCS=`$ICU_CONFIG --cppflags-searchpath` 2243 ICU_LIBS=`$ICU_CONFIG --ldflags --ldflags-icuio` 2244 PHP_EVAL_INCLINE($ICU_INCS) 2245 PHP_EVAL_LIBLINE($ICU_LIBS, $1) 2246 2247 ICU_CXXFLAGS=`$ICU_CONFIG --cxxflags` 2248 if test "$icu_version" -ge "49000"; then 2249 ICU_CXXFLAGS="$ICU_CXXFLAGS -DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit" 2250 ICU_CFLAGS="-DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1" 2251 fi 2252 if test "$icu_version" -ge "60000"; then 2253 ICU_CFLAGS="$ICU_CFLAGS -DU_HIDE_OBSOLETE_UTF_OLD_H=1" 2254 fi 2255 fi 2256 fi 2257 2258 ICU_CFLAGS="$ICU_CFLAGS -DU_DEFINE_FALSE_AND_TRUE=1" 2259]) 2260 2261dnl 2262dnl PHP_SETUP_KERBEROS(shared-add [, action-found [, action-not-found]]) 2263dnl 2264dnl Common setup macro for kerberos 2265dnl 2266AC_DEFUN([PHP_SETUP_KERBEROS],[ 2267 found_kerberos=no 2268 unset KERBEROS_CFLAGS 2269 unset KERBEROS_LIBS 2270 2271 dnl First try to find krb5-config 2272 if test -z "$KRB5_CONFIG"; then 2273 AC_PATH_PROG(KRB5_CONFIG, krb5-config, no, [$PATH:/usr/kerberos/bin:/usr/local/bin]) 2274 fi 2275 2276 dnl If krb5-config is found try using it 2277 if test "$PHP_KERBEROS" != "no" && test -x "$KRB5_CONFIG"; then 2278 KERBEROS_LIBS=`$KRB5_CONFIG --libs gssapi` 2279 KERBEROS_CFLAGS=`$KRB5_CONFIG --cflags gssapi` 2280 2281 if test -n "$KERBEROS_LIBS"; then 2282 found_kerberos=yes 2283 PHP_EVAL_LIBLINE($KERBEROS_LIBS, $1) 2284 PHP_EVAL_INCLINE($KERBEROS_CFLAGS) 2285 fi 2286 fi 2287 2288 dnl If still not found use old skool method 2289 if test "$found_kerberos" = "no"; then 2290 2291 if test "$PHP_KERBEROS" = "yes"; then 2292 PHP_KERBEROS="/usr/kerberos /usr/local /usr" 2293 fi 2294 2295 for i in $PHP_KERBEROS; do 2296 if test -f $i/$PHP_LIBDIR/libkrb5.a || test -f $i/$PHP_LIBDIR/libkrb5.$SHLIB_SUFFIX_NAME; then 2297 PHP_KERBEROS_DIR=$i 2298 break 2299 fi 2300 done 2301 2302 if test "$PHP_KERBEROS_DIR"; then 2303 found_kerberos=yes 2304 PHP_ADD_LIBPATH($PHP_KERBEROS_DIR/$PHP_LIBDIR, $1) 2305 PHP_ADD_LIBRARY(gssapi_krb5, 1, $1) 2306 PHP_ADD_LIBRARY(krb5, 1, $1) 2307 PHP_ADD_LIBRARY(k5crypto, 1, $1) 2308 PHP_ADD_LIBRARY(com_err, 1, $1) 2309 PHP_ADD_INCLUDE($PHP_KERBEROS_DIR/include) 2310 fi 2311 fi 2312 2313 if test "$found_kerberos" = "yes"; then 2314ifelse([$2],[],:,[$2]) 2315ifelse([$3],[],,[else $3]) 2316 fi 2317]) 2318 2319dnl 2320dnl PHP_SETUP_OPENSSL(shared-add [, action-found [, action-not-found]]) 2321dnl 2322dnl Common setup macro for openssl 2323dnl 2324AC_DEFUN([PHP_SETUP_OPENSSL],[ 2325 found_openssl=no 2326 unset OPENSSL_INCDIR 2327 unset OPENSSL_LIBDIR 2328 2329 dnl Empty variable means 'no' 2330 test -z "$PHP_OPENSSL" && PHP_OPENSSL=no 2331 test -z "$PHP_IMAP_SSL" && PHP_IMAP_SSL=no 2332 2333 dnl Fallbacks for different configure options 2334 if test "$PHP_OPENSSL" != "no"; then 2335 PHP_OPENSSL_DIR=$PHP_OPENSSL 2336 elif test "$PHP_IMAP_SSL" != "no"; then 2337 PHP_OPENSSL_DIR=$PHP_IMAP_SSL 2338 fi 2339 2340 dnl First try to find pkg-config 2341 if test -z "$PKG_CONFIG"; then 2342 AC_PATH_PROG(PKG_CONFIG, pkg-config, no) 2343 fi 2344 2345 dnl If pkg-config is found try using it 2346 if test "$PHP_OPENSSL_DIR" = "yes" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists openssl; then 2347 if $PKG_CONFIG --atleast-version=1.0.1 openssl; then 2348 found_openssl=yes 2349 OPENSSL_LIBS=`$PKG_CONFIG --libs openssl` 2350 OPENSSL_INCS=`$PKG_CONFIG --cflags-only-I openssl` 2351 OPENSSL_INCDIR=`$PKG_CONFIG --variable=includedir openssl` 2352 else 2353 AC_MSG_ERROR([OpenSSL version 1.0.1 or greater required.]) 2354 fi 2355 2356 if test -n "$OPENSSL_LIBS"; then 2357 PHP_EVAL_LIBLINE($OPENSSL_LIBS, $1) 2358 fi 2359 if test -n "$OPENSSL_INCS"; then 2360 PHP_EVAL_INCLINE($OPENSSL_INCS) 2361 fi 2362 fi 2363 2364 dnl If pkg-config fails for some reason, revert to the old method 2365 if test "$found_openssl" = "no"; then 2366 2367 if test "$PHP_OPENSSL_DIR" = "yes"; then 2368 PHP_OPENSSL_DIR="/usr/local/ssl /usr/local /usr /usr/local/openssl" 2369 fi 2370 2371 for i in $PHP_OPENSSL_DIR; do 2372 if test -r $i/include/openssl/evp.h; then 2373 OPENSSL_INCDIR=$i/include 2374 fi 2375 if test -r $i/$PHP_LIBDIR/libssl.a -o -r $i/$PHP_LIBDIR/libssl.$SHLIB_SUFFIX_NAME; then 2376 OPENSSL_LIBDIR=$i/$PHP_LIBDIR 2377 fi 2378 test -n "$OPENSSL_INCDIR" && test -n "$OPENSSL_LIBDIR" && break 2379 done 2380 2381 if test -z "$OPENSSL_INCDIR"; then 2382 AC_MSG_ERROR([Cannot find OpenSSL's <evp.h>]) 2383 fi 2384 2385 if test -z "$OPENSSL_LIBDIR"; then 2386 AC_MSG_ERROR([Cannot find OpenSSL's libraries]) 2387 fi 2388 2389 old_CPPFLAGS=$CPPFLAGS 2390 CPPFLAGS=-I$OPENSSL_INCDIR 2391 AC_MSG_CHECKING([for OpenSSL version]) 2392 AC_EGREP_CPP(yes,[ 2393#include <openssl/opensslv.h> 2394#if OPENSSL_VERSION_NUMBER >= 0x10001001L 2395 yes 2396#endif 2397 ],[ 2398 AC_MSG_RESULT([>= 1.0.1]) 2399 ],[ 2400 AC_MSG_ERROR([OpenSSL version 1.0.1 or greater required.]) 2401 ]) 2402 CPPFLAGS=$old_CPPFLAGS 2403 2404 PHP_ADD_INCLUDE($OPENSSL_INCDIR) 2405 2406 PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [ 2407 PHP_ADD_LIBRARY(crypto,,$1) 2408 ],[ 2409 AC_MSG_ERROR([libcrypto not found!]) 2410 ],[ 2411 -L$OPENSSL_LIBDIR 2412 ]) 2413 2414 old_LIBS=$LIBS 2415 LIBS="$LIBS -lcrypto" 2416 PHP_CHECK_LIBRARY(ssl, SSL_CTX_set_ssl_version, [ 2417 found_openssl=yes 2418 ],[ 2419 AC_MSG_ERROR([libssl not found!]) 2420 ],[ 2421 -L$OPENSSL_LIBDIR 2422 ]) 2423 LIBS=$old_LIBS 2424 PHP_ADD_LIBRARY(ssl,,$1) 2425 PHP_ADD_LIBRARY(crypto,,$1) 2426 2427 PHP_ADD_LIBPATH($OPENSSL_LIBDIR, $1) 2428 fi 2429 2430 if test "$found_openssl" = "yes"; then 2431 dnl For apache 1.3.x static build 2432 OPENSSL_INCDIR_OPT=-I$OPENSSL_INCDIR 2433 AC_SUBST(OPENSSL_INCDIR_OPT) 2434 2435ifelse([$2],[],:,[$2]) 2436ifelse([$3],[],,[else $3]) 2437 fi 2438]) 2439 2440dnl 2441dnl PHP_SETUP_ICONV(shared-add [, action-found [, action-not-found]]) 2442dnl 2443dnl Common setup macro for iconv 2444dnl 2445AC_DEFUN([PHP_SETUP_ICONV], [ 2446 found_iconv=no 2447 unset ICONV_DIR 2448 2449 # Create the directories for a VPATH build: 2450 $php_shtool mkdir -p ext/iconv 2451 2452 echo > ext/iconv/php_have_bsd_iconv.h 2453 echo > ext/iconv/php_have_ibm_iconv.h 2454 echo > ext/iconv/php_have_glibc_iconv.h 2455 echo > ext/iconv/php_have_libiconv.h 2456 echo > ext/iconv/php_have_iconv.h 2457 echo > ext/iconv/php_php_iconv_impl.h 2458 echo > ext/iconv/php_iconv_aliased_libiconv.h 2459 echo > ext/iconv/php_php_iconv_h_path.h 2460 echo > ext/iconv/php_iconv_supports_errno.h 2461 2462 dnl 2463 dnl Check libc first if no path is provided in --with-iconv 2464 dnl 2465 2466 if test "$PHP_ICONV" = "yes"; then 2467 dnl Reset LIBS temporarily as it may have already been included 2468 dnl -liconv in. 2469 LIBS_save="$LIBS" 2470 LIBS= 2471 AC_CHECK_FUNC(iconv, [ 2472 found_iconv=yes 2473 ],[ 2474 AC_CHECK_FUNC(libiconv,[ 2475 PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv]) 2476 AC_DEFINE(HAVE_LIBICONV, 1, [ ]) 2477 found_iconv=yes 2478 ]) 2479 ]) 2480 LIBS="$LIBS_save" 2481 fi 2482 2483 dnl 2484 dnl Check external libs for iconv funcs 2485 dnl 2486 if test "$found_iconv" = "no"; then 2487 2488 for i in $PHP_ICONV /usr/local /usr; do 2489 if test -r $i/include/giconv.h; then 2490 AC_DEFINE(HAVE_GICONV_H, 1, [ ]) 2491 ICONV_DIR=$i 2492 iconv_lib_name=giconv 2493 break 2494 elif test -r $i/include/iconv.h; then 2495 ICONV_DIR=$i 2496 iconv_lib_name=iconv 2497 break 2498 fi 2499 done 2500 2501 if test -z "$ICONV_DIR"; then 2502 AC_MSG_ERROR([Please specify the install prefix of iconv with --with-iconv=<DIR>]) 2503 fi 2504 2505 if test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.a || 2506 test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.$SHLIB_SUFFIX_NAME 2507 then 2508 PHP_CHECK_LIBRARY($iconv_lib_name, libiconv, [ 2509 found_iconv=yes 2510 PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv]) 2511 AC_DEFINE(HAVE_LIBICONV,1,[ ]) 2512 PHP_DEFINE([ICONV_ALIASED_LIBICONV],1,[ext/iconv]) 2513 AC_DEFINE([ICONV_ALIASED_LIBICONV],1,[iconv() is aliased to libiconv() in -liconv]) 2514 ], [ 2515 PHP_CHECK_LIBRARY($iconv_lib_name, iconv, [ 2516 found_iconv=yes 2517 ], [], [ 2518 -L$ICONV_DIR/$PHP_LIBDIR 2519 ]) 2520 ], [ 2521 -L$ICONV_DIR/$PHP_LIBDIR 2522 ]) 2523 fi 2524 fi 2525 2526 if test "$found_iconv" = "yes"; then 2527 PHP_DEFINE(HAVE_ICONV,1,[ext/iconv]) 2528 AC_DEFINE(HAVE_ICONV,1,[ ]) 2529 if test -n "$ICONV_DIR"; then 2530 PHP_ADD_LIBRARY_WITH_PATH($iconv_lib_name, $ICONV_DIR/$PHP_LIBDIR, $1) 2531 PHP_ADD_INCLUDE($ICONV_DIR/include) 2532 fi 2533 $2 2534ifelse([$3],[],,[else $3]) 2535 fi 2536]) 2537 2538dnl 2539dnl PHP_SETUP_LIBXML(shared-add [, action-found [, action-not-found]]) 2540dnl 2541dnl Common setup macro for libxml 2542dnl 2543AC_DEFUN([PHP_SETUP_LIBXML], [ 2544 found_libxml=no 2545 2546 dnl First try to find xml2-config 2547 AC_CACHE_CHECK([for xml2-config path], ac_cv_php_xml2_config_path, 2548 [ 2549 for i in $PHP_LIBXML_DIR /usr/local /usr; do 2550 if test -x "$i/bin/xml2-config"; then 2551 ac_cv_php_xml2_config_path="$i/bin/xml2-config" 2552 break 2553 fi 2554 done 2555 ]) 2556 2557 if test -x "$ac_cv_php_xml2_config_path"; then 2558 XML2_CONFIG="$ac_cv_php_xml2_config_path" 2559 libxml_full_version=`$XML2_CONFIG --version` 2560 ac_IFS=$IFS 2561 IFS="." 2562 set $libxml_full_version 2563 IFS=$ac_IFS 2564 LIBXML_VERSION=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3` 2565 if test "$LIBXML_VERSION" -ge "2006011"; then 2566 found_libxml=yes 2567 LIBXML_LIBS=`$XML2_CONFIG --libs` 2568 LIBXML_INCS=`$XML2_CONFIG --cflags` 2569 else 2570 AC_MSG_ERROR([libxml2 version 2.6.11 or greater required.]) 2571 fi 2572 fi 2573 2574 dnl If xml2-config fails, try pkg-config 2575 if test "$found_libxml" = "no"; then 2576 if test -z "$PKG_CONFIG"; then 2577 AC_PATH_PROG(PKG_CONFIG, pkg-config, no) 2578 fi 2579 2580 dnl If pkg-config is found try using it 2581 if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libxml-2.0; then 2582 if $PKG_CONFIG --atleast-version=2.6.11 libxml-2.0; then 2583 found_libxml=yes 2584 LIBXML_LIBS=`$PKG_CONFIG --libs libxml-2.0` 2585 LIBXML_INCS=`$PKG_CONFIG --cflags-only-I libxml-2.0` 2586 else 2587 AC_MSG_ERROR([libxml2 version 2.6.11 or greater required.]) 2588 fi 2589 fi 2590 fi 2591 2592 if test "$found_libxml" = "yes"; then 2593 PHP_EVAL_LIBLINE($LIBXML_LIBS, $1) 2594 PHP_EVAL_INCLINE($LIBXML_INCS) 2595 2596 dnl Check that build works with given libs 2597 AC_CACHE_CHECK(whether libxml build works, php_cv_libxml_build_works, [ 2598 PHP_TEST_BUILD(xmlInitParser, 2599 [ 2600 php_cv_libxml_build_works=yes 2601 ], [ 2602 AC_MSG_RESULT(no) 2603 AC_MSG_ERROR([build test failed. Please check the config.log for details.]) 2604 ], [ 2605 [$]$1 2606 ]) 2607 ]) 2608 if test "$php_cv_libxml_build_works" = "yes"; then 2609 AC_DEFINE(HAVE_LIBXML, 1, [ ]) 2610 fi 2611 $2 2612ifelse([$3],[],,[else $3]) 2613 fi 2614]) 2615 2616dnl ------------------------------------------------------------------------- 2617dnl Misc. macros 2618dnl ------------------------------------------------------------------------- 2619 2620dnl 2621dnl PHP_INSTALL_HEADERS(path [, file ...]) 2622dnl 2623dnl PHP header files to be installed 2624dnl 2625AC_DEFUN([PHP_INSTALL_HEADERS],[ 2626 ifelse([$2],[],[ 2627 for header_file in $1; do 2628 PHP_RUN_ONCE(INSTALLHEADERS, $header_file, [ 2629 INSTALL_HEADERS="$INSTALL_HEADERS $header_file" 2630 ]) 2631 done 2632 ], [ 2633 header_path=$1 2634 for header_file in $2; do 2635 hp_hf="$header_path/$header_file" 2636 PHP_RUN_ONCE(INSTALLHEADERS, $hp_hf, [ 2637 INSTALL_HEADERS="$INSTALL_HEADERS $hp_hf" 2638 ]) 2639 done 2640 ]) 2641]) 2642 2643dnl 2644dnl PHP_AP_EXTRACT_VERSION(/path/httpd) 2645dnl 2646dnl This macro is used to get a comparable 2647dnl version for apache1/2. 2648dnl 2649AC_DEFUN([PHP_AP_EXTRACT_VERSION],[ 2650 ac_output=`$1 -v 2>&1 | grep version | $SED -e 's/Oracle-HTTP-//'` 2651 ac_IFS=$IFS 2652IFS="- /. 2653" 2654 set $ac_output 2655 IFS=$ac_IFS 2656 2657 APACHE_VERSION=`expr [$]4 \* 1000000 + [$]5 \* 1000 + [$]6` 2658]) 2659 2660dnl 2661dnl PHP_DEBUG_MACRO(filename) 2662dnl 2663AC_DEFUN([PHP_DEBUG_MACRO],[ 2664 DEBUG_LOG=$1 2665 cat >$1 <<X 2666CONFIGURE: $CONFIGURE_COMMAND 2667CC: $CC 2668CFLAGS: $CFLAGS 2669CPPFLAGS: $CPPFLAGS 2670CXX: $CXX 2671CXXFLAGS: $CXXFLAGS 2672INCLUDES: $INCLUDES 2673LDFLAGS: $LDFLAGS 2674LIBS: $LIBS 2675DLIBS: $DLIBS 2676SAPI: $PHP_SAPI 2677PHP_RPATHS: $PHP_RPATHS 2678uname -a: `uname -a` 2679 2680X 2681 cat >conftest.$ac_ext <<X 2682main() 2683{ 2684 exit(0); 2685} 2686X 2687 (eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1 2688 rm -fr conftest* 2689]) 2690 2691dnl 2692dnl PHP_CONFIG_NICE(filename) 2693dnl 2694dnl Generates the config.nice file 2695dnl 2696AC_DEFUN([PHP_CONFIG_NICE],[ 2697 AC_REQUIRE([AC_PROG_EGREP]) 2698 AC_REQUIRE([LT_AC_PROG_SED]) 2699 PHP_SUBST_OLD(EGREP) 2700 PHP_SUBST_OLD(SED) 2701 test -f $1 && mv $1 $1.old 2702 rm -f $1.old 2703 cat >$1<<EOF 2704#! /bin/sh 2705# 2706# Created by configure 2707 2708EOF 2709 2710 clean_configure_args=$ac_configure_args 2711 for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS EXTRA_LDFLAGS_PROGRAM LIBS CC CXX; do 2712 eval val=\$$var 2713 if test -n "$val"; then 2714 echo "$var='$val' \\" >> $1 2715 if test `expr "X$ac_configure_args" : ".*${var}.*"` != 0; then 2716 clean_configure_args=$(echo $clean_configure_args | sed -e "s#'$var=$val'##") 2717 fi 2718 fi 2719 done 2720 2721 echo "'[$]0' \\" >> $1 2722 if test `expr " [$]0" : " '.*"` = 0; then 2723 CONFIGURE_COMMAND="$CONFIGURE_COMMAND '[$]0'" 2724 else 2725 CONFIGURE_COMMAND="$CONFIGURE_COMMAND [$]0" 2726 fi 2727 CONFIGURE_ARGS="$clean_configure_args" 2728 while test "X$CONFIGURE_ARGS" != "X"; 2729 do 2730 if CURRENT_ARG=`expr "X$CONFIGURE_ARGS" : "X *\('[[^']]*'\)"` 2731 then 2732 CONFIGURE_ARGS=`expr "X$CONFIGURE_ARGS" : "X *'[[^']]*' \(.*\)"` 2733 elif CURRENT_ARG=`expr "X$CONFIGURE_ARGS" : "X *\([[^ ]]*\)"` 2734 then 2735 CONFIGURE_ARGS=`expr "X$CONFIGURE_ARGS" : "X *[[^ ]]* \(.*\)"` 2736 CURRENT_ARG="'$CURRENT_ARG'" 2737 else 2738 break 2739 fi 2740 $as_echo "$CURRENT_ARG \\" >>$1 2741 CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS $CURRENT_ARG" 2742 done 2743 echo '"[$]@"' >> $1 2744 chmod +x $1 2745 CONFIGURE_COMMAND="$CONFIGURE_COMMAND $CONFIGURE_OPTIONS" 2746 PHP_SUBST_OLD(CONFIGURE_COMMAND) 2747 PHP_SUBST_OLD(CONFIGURE_OPTIONS) 2748]) 2749 2750dnl 2751dnl PHP_CHECK_CONFIGURE_OPTIONS 2752dnl 2753AC_DEFUN([PHP_CHECK_CONFIGURE_OPTIONS],[ 2754 for arg in $ac_configure_args; do 2755 case $arg in 2756 --with-*[)] 2757 arg_name="`echo [$]arg | $SED -e 's/--with-/with-/g' -e 's/=.*//g'`" 2758 ;; 2759 --without-*[)] 2760 arg_name="`echo [$]arg | $SED -e 's/--without-/with-/g' -e 's/=.*//g'`" 2761 ;; 2762 --enable-*[)] 2763 arg_name="`echo [$]arg | $SED -e 's/--enable-/enable-/g' -e 's/=.*//g'`" 2764 ;; 2765 --disable-*[)] 2766 arg_name="`echo [$]arg | $SED -e 's/--disable-/enable-/g' -e 's/=.*//g'`" 2767 ;; 2768 *[)] 2769 continue 2770 ;; 2771 esac 2772 case $arg_name in 2773 # Allow --disable-all / --enable-all 2774 enable-all[)];; 2775 2776 # Allow certain libtool options 2777 enable-libtool-lock | with-pic | with-tags | enable-shared | enable-static | enable-fast-install | with-gnu-ld[)];; 2778 2779 # Allow certain TSRM options 2780 with-tsrm-pth | with-tsrm-st | with-tsrm-pthreads [)];; 2781 2782 # Allow certain Zend options 2783 with-zend-vm | enable-maintainer-zts | enable-inline-optimization[)];; 2784 2785 # All the rest must be set using the PHP_ARG_* macros 2786 # PHP_ARG_* macros set php_enable_<arg_name> or php_with_<arg_name> 2787 *[)] 2788 # Options that exist before PHP 6 2789 if test "$PHP_MAJOR_VERSION" -lt "6"; then 2790 case $arg_name in 2791 enable-zend-multibyte[)] continue;; 2792 esac 2793 fi 2794 2795 is_arg_set=php_[]`echo [$]arg_name | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ-' 'abcdefghijklmnopqrstuvwxyz_'` 2796 if eval test "x\$$is_arg_set" = "x"; then 2797 PHP_UNKNOWN_CONFIGURE_OPTIONS="$PHP_UNKNOWN_CONFIGURE_OPTIONS 2798[$]arg" 2799 fi 2800 ;; 2801 esac 2802 done 2803]) 2804 2805dnl 2806dnl PHP_CHECK_PDO_INCLUDES([found [, not-found]]) 2807dnl 2808AC_DEFUN([PHP_CHECK_PDO_INCLUDES],[ 2809 AC_CACHE_CHECK([for PDO includes], pdo_cv_inc_path, [ 2810 AC_MSG_CHECKING([for PDO includes]) 2811 if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then 2812 pdo_cv_inc_path=$abs_srcdir/ext 2813 elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then 2814 pdo_cv_inc_path=$abs_srcdir/ext 2815 elif test -f $phpincludedir/ext/pdo/php_pdo_driver.h; then 2816 pdo_cv_inc_path=$phpincludedir/ext 2817 fi 2818 ]) 2819 if test -n "$pdo_cv_inc_path"; then 2820ifelse([$1],[],:,[$1]) 2821 else 2822ifelse([$2],[],[AC_MSG_ERROR([Cannot find php_pdo_driver.h.])],[$2]) 2823 fi 2824]) 2825 2826dnl 2827dnl PHP_DETECT_ICC 2828dnl Detect Intel C++ Compiler and unset $GCC if ICC found 2829AC_DEFUN([PHP_DETECT_ICC], 2830[ 2831 ICC="no" 2832 AC_MSG_CHECKING([for icc]) 2833 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER], 2834 ICC="no" 2835 AC_MSG_RESULT([no]), 2836 ICC="yes" 2837 GCC="no" 2838 AC_MSG_RESULT([yes]) 2839 ) 2840]) 2841 2842dnl PHP_DETECT_SUNCC 2843dnl Detect if the systems default compiler is suncc. 2844dnl We also set some useful CFLAGS if the user didn't set any 2845AC_DEFUN([PHP_DETECT_SUNCC],[ 2846 SUNCC="no" 2847 AC_MSG_CHECKING([for suncc]) 2848 AC_EGREP_CPP([^__SUNPRO_C], [__SUNPRO_C], 2849 SUNCC="no" 2850 AC_MSG_RESULT([no]), 2851 SUNCC="yes" 2852 GCC="no" 2853 test -n "$auto_cflags" && CFLAGS="-O -xs -xstrconst -zlazyload" 2854 GCC="" 2855 AC_MSG_RESULT([yes]) 2856 ) 2857]) 2858 2859dnl 2860dnl PHP_CRYPT_R_STYLE 2861dnl detect the style of crypt_r() is any is available 2862dnl see APR_CHECK_CRYPT_R_STYLE() for original version 2863dnl 2864AC_DEFUN([PHP_CRYPT_R_STYLE], 2865[ 2866 AC_CACHE_CHECK([which data struct is used by crypt_r], php_cv_crypt_r_style,[ 2867 php_cv_crypt_r_style=none 2868 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2869#define _REENTRANT 1 2870#include <crypt.h> 2871]], [[ 2872CRYPTD buffer; 2873crypt_r("passwd", "hash", &buffer); 2874]])],[php_cv_crypt_r_style=cryptd],[]) 2875 2876 if test "$php_cv_crypt_r_style" = "none"; then 2877 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2878#define _REENTRANT 1 2879#include <crypt.h> 2880]],[[ 2881struct crypt_data buffer; 2882crypt_r("passwd", "hash", &buffer); 2883]])],[php_cv_crypt_r_style=struct_crypt_data],[]) 2884 fi 2885 2886 if test "$php_cv_crypt_r_style" = "none"; then 2887 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2888#define _REENTRANT 1 2889#define _GNU_SOURCE 2890#include <crypt.h> 2891]],[[ 2892struct crypt_data buffer; 2893crypt_r("passwd", "hash", &buffer); 2894]])],[php_cv_crypt_r_style=struct_crypt_data_gnu_source],[]) 2895 fi 2896 ]) 2897 2898 if test "$php_cv_crypt_r_style" = "cryptd"; then 2899 AC_DEFINE(CRYPT_R_CRYPTD, 1, [Define if crypt_r has uses CRYPTD]) 2900 fi 2901 if test "$php_cv_crypt_r_style" = "struct_crypt_data" -o "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then 2902 AC_DEFINE(CRYPT_R_STRUCT_CRYPT_DATA, 1, [Define if crypt_r uses struct crypt_data]) 2903 fi 2904 if test "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then 2905 AC_DEFINE(CRYPT_R_GNU_SOURCE, 1, [Define if struct crypt_data requires _GNU_SOURCE]) 2906 fi 2907 if test "$php_cv_crypt_r_style" = "none"; then 2908 AC_MSG_ERROR([Unable to detect data struct used by crypt_r]) 2909 fi 2910]) 2911 2912dnl 2913dnl PHP_TEST_WRITE_STDOUT 2914dnl 2915AC_DEFUN([PHP_TEST_WRITE_STDOUT],[ 2916 AC_CACHE_CHECK(whether writing to stdout works,ac_cv_write_stdout,[ 2917 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 2918#ifdef HAVE_UNISTD_H 2919#include <unistd.h> 2920#endif 2921 2922#define TEXT "This is the test message -- " 2923 2924main() 2925{ 2926 int n; 2927 2928 n = write(1, TEXT, sizeof(TEXT)-1); 2929 return (!(n == sizeof(TEXT)-1)); 2930} 2931 ]])],[ 2932 ac_cv_write_stdout=yes 2933 ],[ 2934 ac_cv_write_stdout=no 2935 ],[ 2936 ac_cv_write_stdout=no 2937 ]) 2938 ]) 2939 if test "$ac_cv_write_stdout" = "yes"; then 2940 AC_DEFINE(PHP_WRITE_STDOUT, 1, [whether write(2) works]) 2941 fi 2942]) 2943 2944dnl 2945dnl PHP_INIT_DTRACE(providerdesc, header-file, sources [, module]) 2946dnl 2947AC_DEFUN([PHP_INIT_DTRACE],[ 2948dnl Set paths properly when called from extension 2949 case "$4" in 2950 ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir;; 2951 /*[)] ac_srcdir=`echo "$4"|cut -c 2-`"/"; ac_bdir=$ac_srcdir;; 2952 *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$4/";; 2953 esac 2954 2955dnl providerdesc 2956 ac_provsrc=$1 2957 old_IFS=[$]IFS 2958 IFS=. 2959 set $ac_provsrc 2960 ac_provobj=[$]1 2961 IFS=$old_IFS 2962 2963dnl header-file 2964 ac_hdrobj=$2 2965 2966dnl Add providerdesc.o or .lo into global objects when needed 2967 case $host_alias in 2968 *freebsd*) 2969 PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.o" 2970 PHP_LDFLAGS="$PHP_LDFLAGS -lelf" 2971 ;; 2972 *solaris*) 2973 PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.lo" 2974 ;; 2975 *linux*) 2976 PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.lo" 2977 ;; 2978 esac 2979 2980dnl DTrace objects 2981 old_IFS=[$]IFS 2982 for ac_src in $3; do 2983 IFS=. 2984 set $ac_src 2985 ac_obj=[$]1 2986 IFS=$old_IFS 2987 2988 PHP_DTRACE_OBJS="[$]PHP_DTRACE_OBJS [$]ac_bdir[$]ac_obj.lo" 2989 done; 2990 2991 case [$]php_sapi_module in 2992 shared[)] 2993 for ac_lo in $PHP_DTRACE_OBJS; do 2994 dtrace_objs="[$]dtrace_objs `echo $ac_lo | $SED -e 's,\.lo$,.o,' -e 's#\(.*\)\/#\1\/.libs\/#'`" 2995 done; 2996 ;; 2997 *[)] 2998 dtrace_objs='$(PHP_DTRACE_OBJS:.lo=.o)' 2999 ;; 3000 esac 3001 3002dnl Generate Makefile.objects entries 3003dnl The empty $ac_provsrc command stops an implicit circular dependency 3004dnl in GNU Make which causes the .d file to be overwritten (Bug 61268) 3005 cat>>Makefile.objects<<EOF 3006 3007$abs_srcdir/$ac_provsrc:; 3008 3009$ac_bdir[$]ac_hdrobj: $abs_srcdir/$ac_provsrc 3010 CFLAGS="\$(CFLAGS_CLEAN)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHP_,DTRACE_,g' \$[]@.bak > \$[]@ 3011 3012\$(PHP_DTRACE_OBJS): $ac_bdir[$]ac_hdrobj 3013 3014EOF 3015 3016 case $host_alias in 3017 *solaris*|*linux*) 3018 dtrace_prov_name="`echo $ac_provsrc | $SED -e 's#\(.*\)\/##'`.o" 3019 dtrace_lib_dir="`echo $ac_bdir[$]ac_provsrc | $SED -e 's#\(.*\)/[^/]*#\1#'`/.libs" 3020 dtrace_d_obj="`echo $ac_bdir[$]ac_provsrc | $SED -e 's#\(.*\)/\([^/]*\)#\1/.libs/\2#'`.o" 3021 dtrace_nolib_objs='$(PHP_DTRACE_OBJS:.lo=.o)' 3022 for ac_lo in $PHP_DTRACE_OBJS; do 3023 dtrace_lib_objs="[$]dtrace_lib_objs `echo $ac_lo | $SED -e 's,\.lo$,.o,' -e 's#\(.*\)\/#\1\/.libs\/#'`" 3024 done; 3025dnl Always attempt to create both PIC and non-PIC DTrace objects (Bug 63692) 3026 cat>>Makefile.objects<<EOF 3027$ac_bdir[$]ac_provsrc.lo: \$(PHP_DTRACE_OBJS) 3028 echo "[#] Generated by Makefile for libtool" > \$[]@ 3029 @test -d "$dtrace_lib_dir" || mkdir $dtrace_lib_dir 3030 if CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o $dtrace_d_obj -s $abs_srcdir/$ac_provsrc $dtrace_lib_objs 2> /dev/null && test -f "$dtrace_d_obj"; then [\\] 3031 echo "pic_object=['].libs/$dtrace_prov_name[']" >> \$[]@ [;\\] 3032 else [\\] 3033 echo "pic_object='none'" >> \$[]@ [;\\] 3034 fi 3035 if CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o $ac_bdir[$]ac_provsrc.o -s $abs_srcdir/$ac_provsrc $dtrace_nolib_objs 2> /dev/null && test -f "$ac_bdir[$]ac_provsrc.o"; then [\\] 3036 echo "non_pic_object=[']$dtrace_prov_name[']" >> \$[]@ [;\\] 3037 else [\\] 3038 echo "non_pic_object='none'" >> \$[]@ [;\\] 3039 fi 3040 3041EOF 3042 3043 ;; 3044 *) 3045cat>>Makefile.objects<<EOF 3046$ac_bdir[$]ac_provsrc.o: \$(PHP_DTRACE_OBJS) 3047 CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $abs_srcdir/$ac_provsrc $dtrace_objs 3048 3049EOF 3050 ;; 3051 esac 3052]) 3053 3054dnl 3055dnl PHP_CHECK_STDINT_TYPES 3056dnl 3057AC_DEFUN([PHP_CHECK_STDINT_TYPES], [ 3058 AC_CHECK_SIZEOF([short], 2) 3059 AC_CHECK_SIZEOF([int], 4) 3060 AC_CHECK_SIZEOF([long], 4) 3061 AC_CHECK_SIZEOF([long long], 8) 3062 AC_CHECK_TYPES([int8, int16, int32, int64, int8_t, int16_t, int32_t, int64_t, uint8, uint16, uint32, uint64, uint8_t, uint16_t, uint32_t, uint64_t, u_int8_t, u_int16_t, u_int32_t, u_int64_t], [], [], [ 3063#if HAVE_STDINT_H 3064# include <stdint.h> 3065#endif 3066#if HAVE_SYS_TYPES_H 3067# include <sys/types.h> 3068#endif 3069 ]) 3070 AC_DEFINE([PHP_HAVE_STDINT_TYPES], [1], [Checked for stdint types]) 3071]) 3072 3073dnl PHP_CHECK_BUILTIN_EXPECT 3074AC_DEFUN([PHP_CHECK_BUILTIN_EXPECT], [ 3075 AC_MSG_CHECKING([for __builtin_expect]) 3076 3077 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 3078 return __builtin_expect(1,1) ? 1 : 0; 3079 ]])], [ 3080 have_builtin_expect=1 3081 AC_MSG_RESULT([yes]) 3082 ], [ 3083 have_builtin_expect=0 3084 AC_MSG_RESULT([no]) 3085 ]) 3086 3087 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_EXPECT], [$have_builtin_expect], [Whether the compiler supports __builtin_expect]) 3088 3089]) 3090 3091dnl PHP_CHECK_BUILTIN_CLZ 3092AC_DEFUN([PHP_CHECK_BUILTIN_CLZ], [ 3093 AC_MSG_CHECKING([for __builtin_clz]) 3094 3095 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 3096 return __builtin_clz(1) ? 1 : 0; 3097 ]])], [ 3098 have_builtin_clz=1 3099 AC_MSG_RESULT([yes]) 3100 ], [ 3101 have_builtin_clz=0 3102 AC_MSG_RESULT([no]) 3103 ]) 3104 3105 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CLZ], [$have_builtin_clz], [Whether the compiler supports __builtin_clz]) 3106 3107]) 3108 3109dnl PHP_CHECK_BUILTIN_CTZL 3110AC_DEFUN([PHP_CHECK_BUILTIN_CTZL], [ 3111 AC_MSG_CHECKING([for __builtin_ctzl]) 3112 3113 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 3114 return __builtin_ctzl(2L) ? 1 : 0; 3115 ]])], [ 3116 have_builtin_ctzl=1 3117 AC_MSG_RESULT([yes]) 3118 ], [ 3119 have_builtin_ctzl=0 3120 AC_MSG_RESULT([no]) 3121 ]) 3122 3123 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CTZL], [$have_builtin_ctzl], [Whether the compiler supports __builtin_ctzl]) 3124 3125]) 3126 3127dnl PHP_CHECK_BUILTIN_CTZLL 3128AC_DEFUN([PHP_CHECK_BUILTIN_CTZLL], [ 3129 AC_MSG_CHECKING([for __builtin_ctzll]) 3130 3131 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 3132 return __builtin_ctzll(2LL) ? 1 : 0; 3133 ]])], [ 3134 have_builtin_ctzll=1 3135 AC_MSG_RESULT([yes]) 3136 ], [ 3137 have_builtin_ctzll=0 3138 AC_MSG_RESULT([no]) 3139 ]) 3140 3141 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CTZLL], [$have_builtin_ctzll], [Whether the compiler supports __builtin_ctzll]) 3142 3143]) 3144 3145dnl PHP_CHECK_BUILTIN_SMULL_OVERFLOW 3146AC_DEFUN([PHP_CHECK_BUILTIN_SMULL_OVERFLOW], [ 3147 AC_MSG_CHECKING([for __builtin_smull_overflow]) 3148 3149 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 3150 long tmpvar; 3151 return __builtin_smull_overflow(3, 7, &tmpvar); 3152 ]])], [ 3153 have_builtin_smull_overflow=1 3154 AC_MSG_RESULT([yes]) 3155 ], [ 3156 have_builtin_smull_overflow=0 3157 AC_MSG_RESULT([no]) 3158 ]) 3159 3160 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SMULL_OVERFLOW], 3161 [$have_builtin_smull_overflow], [Whether the compiler supports __builtin_smull_overflow]) 3162 3163]) 3164 3165dnl PHP_CHECK_BUILTIN_SMULLL_OVERFLOW 3166AC_DEFUN([PHP_CHECK_BUILTIN_SMULLL_OVERFLOW], [ 3167 AC_MSG_CHECKING([for __builtin_smulll_overflow]) 3168 3169 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 3170 long long tmpvar; 3171 return __builtin_smulll_overflow(3, 7, &tmpvar); 3172 ]])], [ 3173 have_builtin_smulll_overflow=1 3174 AC_MSG_RESULT([yes]) 3175 ], [ 3176 have_builtin_smulll_overflow=0 3177 AC_MSG_RESULT([no]) 3178 ]) 3179 3180 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SMULLL_OVERFLOW], 3181 [$have_builtin_smulll_overflow], [Whether the compiler supports __builtin_smulll_overflow]) 3182 3183]) 3184 3185dnl PHP_CHECK_BUILTIN_SADDL_OVERFLOW 3186AC_DEFUN([PHP_CHECK_BUILTIN_SADDL_OVERFLOW], [ 3187 AC_MSG_CHECKING([for __builtin_saddl_overflow]) 3188 3189 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 3190 long tmpvar; 3191 return __builtin_saddl_overflow(3, 7, &tmpvar); 3192 ]])], [ 3193 have_builtin_saddl_overflow=1 3194 AC_MSG_RESULT([yes]) 3195 ], [ 3196 have_builtin_saddl_overflow=0 3197 AC_MSG_RESULT([no]) 3198 ]) 3199 3200 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SADDL_OVERFLOW], 3201 [$have_builtin_saddl_overflow], [Whether the compiler supports __builtin_saddl_overflow]) 3202 3203]) 3204 3205dnl PHP_CHECK_BUILTIN_SADDLL_OVERFLOW 3206AC_DEFUN([PHP_CHECK_BUILTIN_SADDLL_OVERFLOW], [ 3207 AC_MSG_CHECKING([for __builtin_saddll_overflow]) 3208 3209 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 3210 long long tmpvar; 3211 return __builtin_saddll_overflow(3, 7, &tmpvar); 3212 ]])], [ 3213 have_builtin_saddll_overflow=1 3214 AC_MSG_RESULT([yes]) 3215 ], [ 3216 have_builtin_saddll_overflow=0 3217 AC_MSG_RESULT([no]) 3218 ]) 3219 3220 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SADDLL_OVERFLOW], 3221 [$have_builtin_saddll_overflow], [Whether the compiler supports __builtin_saddll_overflow]) 3222 3223]) 3224 3225dnl PHP_CHECK_BUILTIN_SSUBL_OVERFLOW 3226AC_DEFUN([PHP_CHECK_BUILTIN_SSUBL_OVERFLOW], [ 3227 AC_MSG_CHECKING([for __builtin_ssubl_overflow]) 3228 3229 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 3230 long tmpvar; 3231 return __builtin_ssubl_overflow(3, 7, &tmpvar); 3232 ]])], [ 3233 have_builtin_ssubl_overflow=1 3234 AC_MSG_RESULT([yes]) 3235 ], [ 3236 have_builtin_ssubl_overflow=0 3237 AC_MSG_RESULT([no]) 3238 ]) 3239 3240 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SSUBL_OVERFLOW], 3241 [$have_builtin_ssubl_overflow], [Whether the compiler supports __builtin_ssubl_overflow]) 3242 3243]) 3244 3245dnl PHP_CHECK_BUILTIN_SSUBLL_OVERFLOW 3246AC_DEFUN([PHP_CHECK_BUILTIN_SSUBLL_OVERFLOW], [ 3247 AC_MSG_CHECKING([for __builtin_ssubll_overflow]) 3248 3249 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 3250 long long tmpvar; 3251 return __builtin_ssubll_overflow(3, 7, &tmpvar); 3252 ]])], [ 3253 have_builtin_ssubll_overflow=1 3254 AC_MSG_RESULT([yes]) 3255 ], [ 3256 have_builtin_ssubll_overflow=0 3257 AC_MSG_RESULT([no]) 3258 ]) 3259 3260 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SSUBLL_OVERFLOW], 3261 [$have_builtin_ssubll_overflow], [Whether the compiler supports __builtin_ssubll_overflow]) 3262 3263]) 3264 3265dnl PHP_CHECK_BUILTIN_CPU_INIT 3266AC_DEFUN([PHP_CHECK_BUILTIN_CPU_INIT], [ 3267 AC_MSG_CHECKING([for __builtin_cpu_init]) 3268 3269 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 3270 return __builtin_cpu_init()? 1 : 0; 3271 ]])], [ 3272 have_builtin_cpu_init=1 3273 AC_MSG_RESULT([yes]) 3274 ], [ 3275 have_builtin_cpu_init=0 3276 AC_MSG_RESULT([no]) 3277 ]) 3278 3279 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CPU_INIT], 3280 [$have_builtin_cpu_init], [Whether the compiler supports __builtin_cpu_init]) 3281 3282]) 3283 3284dnl PHP_CHECK_BUILTIN_CPU_SUPPORTS 3285AC_DEFUN([PHP_CHECK_BUILTIN_CPU_SUPPORTS], [ 3286 AC_MSG_CHECKING([for __builtin_cpu_supports]) 3287 3288 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 3289 return __builtin_cpu_supports("sse")? 1 : 0; 3290 ]])], [ 3291 have_builtin_cpu_supports=1 3292 AC_MSG_RESULT([yes]) 3293 ], [ 3294 have_builtin_cpu_supports=0 3295 AC_MSG_RESULT([no]) 3296 ]) 3297 3298 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CPU_SUPPORTS], 3299 [$have_builtin_cpu_supports], [Whether the compiler supports __builtin_cpu_supports]) 3300]) 3301 3302dnl PHP_CHECK_CPU_SUPPORTS 3303AC_DEFUN([PHP_CHECK_CPU_SUPPORTS], [ 3304 AC_REQUIRE([PHP_CHECK_BUILTIN_CPU_INIT]) 3305 AC_REQUIRE([PHP_CHECK_BUILTIN_CPU_SUPPORTS]) 3306 have_ext_instructions=0 3307 if test $have_builtin_cpu_supports = 1; then 3308 AC_MSG_CHECKING([for $1 instructions supports]) 3309 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 3310int main() { 3311 return __builtin_cpu_supports("$1")? 0 : 1; 3312} 3313 ]])], [ 3314 have_ext_instructions=1 3315 AC_MSG_RESULT([yes]) 3316 ], [ 3317 AC_MSG_RESULT([no]) 3318 ], [AC_MSG_RESULT([no])]) 3319 fi 3320 AC_DEFINE_UNQUOTED(AS_TR_CPP([PHP_HAVE_$1_INSTRUCTIONS]), 3321 [$have_ext_instructions], [Whether the compiler supports $1 instructions]) 3322]) 3323 3324dnl Load the AX_CHECK_COMPILE_FLAG macro from the autoconf archive. 3325m4_include([build/ax_check_compile_flag.m4]) 3326 3327m4_include([build/ax_gcc_func_attribute.m4]) 3328