1dnl This file contains local autoconf macros. 2 3dnl ---------------------------------------------------------------------------- 4dnl Output stylize macros for configure (help/runtime). 5dnl ---------------------------------------------------------------------------- 6 7dnl 8dnl PHP_HELP_SEPARATOR(title) 9dnl 10dnl Adds separator title into the configure --help display. 11dnl 12AC_DEFUN([PHP_HELP_SEPARATOR],[ 13AC_ARG_ENABLE([],[ 14$1 15],[]) 16]) 17 18dnl 19dnl PHP_CONFIGURE_PART(title) 20dnl 21dnl Adds separator title configure output (idea borrowed from mm). 22dnl 23AC_DEFUN([PHP_CONFIGURE_PART],[ 24 AC_MSG_RESULT() 25 AC_MSG_RESULT([${T_MD}$1${T_ME}]) 26]) 27 28dnl ---------------------------------------------------------------------------- 29dnl Build system helper macros. 30dnl ---------------------------------------------------------------------------- 31 32dnl 33dnl PHP_DEF_HAVE(what) 34dnl 35dnl Generates 'AC_DEFINE(HAVE_WHAT, 1, [ ])'. 36dnl 37AC_DEFUN([PHP_DEF_HAVE],[AC_DEFINE([HAVE_]translit($1,a-z_.-,A-Z___), 1, [ ])]) 38 39dnl 40dnl PHP_RUN_ONCE(namespace, variable, code) 41dnl 42dnl Execute code, if variable is not set in namespace. 43dnl 44AC_DEFUN([PHP_RUN_ONCE],[ 45 changequote({,}) 46 unique=`echo $2|$SED 's/[^a-zA-Z0-9]/_/g'` 47 changequote([,]) 48 cmd="echo $ac_n \"\$$1$unique$ac_c\"" 49 if test -n "$unique" && test "`eval $cmd`" = "" ; then 50 eval "$1$unique=set" 51 $3 52 fi 53]) 54 55dnl 56dnl PHP_EXPAND_PATH(path, variable) 57dnl 58dnl Expands path to an absolute path and assigns it to variable. 59dnl 60AC_DEFUN([PHP_EXPAND_PATH],[ 61 if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then 62 $2=$1 63 else 64 changequote({,}) 65 ep_dir=`echo $1|$SED 's%/*[^/][^/]*/*$%%'` 66 changequote([,]) 67 ep_realdir=`(cd "$ep_dir" && pwd)` 68 $2="$ep_realdir"/`basename "$1"` 69 fi 70]) 71 72dnl 73dnl PHP_SUBST(varname) 74dnl 75dnl Adds variable with its value into Makefile, e.g.: 76dnl CC = gcc 77dnl 78AC_DEFUN([PHP_SUBST],[ 79 PHP_VAR_SUBST="$PHP_VAR_SUBST $1" 80]) 81 82dnl 83dnl PHP_SUBST_OLD(varname, [VALUE]) 84dnl 85dnl Same as PHP_SUBST() but also substitutes all @VARNAME@ instances in every 86dnl file passed to AC_OUTPUT. 87dnl 88AC_DEFUN([PHP_SUBST_OLD],[ 89 AC_SUBST($@) 90 PHP_SUBST([$1]) 91]) 92 93dnl 94dnl PHP_OUTPUT(file) 95dnl 96dnl Adds "file" to the list of files generated by AC_OUTPUT. This macro can be 97dnl used several times. 98dnl 99AC_DEFUN([PHP_OUTPUT],[ 100 PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1" 101]) 102 103dnl ---------------------------------------------------------------------------- 104dnl Build system base macros. 105dnl ---------------------------------------------------------------------------- 106 107dnl 108dnl PHP_CANONICAL_HOST_TARGET 109dnl 110AC_DEFUN([PHP_CANONICAL_HOST_TARGET],[ 111 AC_REQUIRE([AC_CANONICAL_HOST])dnl 112 AC_REQUIRE([AC_CANONICAL_TARGET])dnl 113 dnl Make sure we do not continue if host_alias is empty. 114 if test -z "$host_alias" && test -n "$host"; then 115 host_alias=$host 116 fi 117 if test -z "$host_alias"; then 118 AC_MSG_ERROR([host_alias is not set! Make sure to run config.guess]) 119 fi 120]) 121 122dnl 123dnl PHP_INIT_BUILD_SYSTEM 124dnl 125dnl Creates build directories and Makefile placeholders. 126dnl 127AC_DEFUN([PHP_INIT_BUILD_SYSTEM],[ 128AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl 129> Makefile.objects 130> Makefile.fragments 131dnl Run at the end of the configuration, before creating the config.status. 132AC_CONFIG_COMMANDS_PRE( 133[dnl Directory for storing shared objects of extensions. 134PHP_ADD_BUILD_DIR([modules]) 135phplibdir="$(pwd)/modules" 136PHP_SUBST([phplibdir]) 137PHP_GEN_BUILD_DIRS 138PHP_GEN_GLOBAL_MAKEFILE 139])dnl 140]) 141 142dnl 143dnl PHP_GEN_GLOBAL_MAKEFILE 144dnl 145dnl Generates the global makefile. 146dnl 147AC_DEFUN([PHP_GEN_GLOBAL_MAKEFILE],[ 148 AC_MSG_NOTICE([creating Makefile]) 149 cat >Makefile <<EOF 150srcdir = $abs_srcdir 151builddir = $abs_builddir 152top_srcdir = $abs_srcdir 153top_builddir = $abs_builddir 154EOF 155 for i in $PHP_VAR_SUBST; do 156 eval echo "$i = \$$i" >> Makefile 157 done 158 159 cat $abs_srcdir/build/Makefile.global Makefile.fragments Makefile.objects >> Makefile 160]) 161 162dnl 163dnl PHP_ADD_MAKEFILE_FRAGMENT([srcfile [, ext_srcdir [, ext_builddir]]]) 164dnl 165dnl Processes a file called Makefile.frag in the source directory of the most 166dnl recently added extension. $(srcdir) and $(builddir) are substituted with the 167dnl proper paths. Can be used to supply custom rules and/or additional targets. 168dnl 169AC_DEFUN([PHP_ADD_MAKEFILE_FRAGMENT],[ 170 ifelse($1,,src=$ext_srcdir/Makefile.frag,src=$1) 171 ifelse($2,,ac_srcdir=$ext_srcdir,ac_srcdir=$2) 172 ifelse($3,,ac_builddir=$ext_builddir,ac_builddir=$3) 173 test -f "$src" && $SED -e "s#\$(srcdir)#$ac_srcdir#g" -e "s#\$(builddir)#$ac_builddir#g" $src >> Makefile.fragments 174]) 175 176dnl 177dnl PHP_ADD_SOURCES(source-path, sources [, special-flags [, type]]) 178dnl 179dnl Adds sources which are located relative to source-path to the array of type 180dnl type. Sources are processed with optional special-flags which are passed to 181dnl the compiler. Sources can be either written in C or C++ (filenames shall end 182dnl in .c or .cpp, respectively). 183dnl 184dnl Note: If source-path begins with a "/", the "/" is removed and the path is 185dnl interpreted relative to the top build-directory. 186dnl 187dnl Which array to append to? 188dnl 189AC_DEFUN([PHP_ADD_SOURCES],[ 190 PHP_ADD_SOURCES_X($1, $2, $3, ifelse($4,sapi,PHP_SAPI_OBJS,PHP_GLOBAL_OBJS)) 191]) 192 193dnl 194dnl _PHP_ASSIGN_BUILD_VARS(type) 195dnl 196dnl Internal, don't use. 197dnl 198AC_DEFUN([_PHP_ASSIGN_BUILD_VARS],[ 199ifelse($1,shared,[ 200 b_c_pre=$shared_c_pre 201 b_cxx_pre=$shared_cxx_pre 202 b_c_meta=$shared_c_meta 203 b_cxx_meta=$shared_cxx_meta 204 b_c_post=$shared_c_post 205 b_cxx_post=$shared_cxx_post 206],[ 207 b_c_pre=$php_c_pre 208 b_cxx_pre=$php_cxx_pre 209 b_c_meta=$php_c_meta 210 b_cxx_meta=$php_cxx_meta 211 b_c_post=$php_c_post 212 b_cxx_post=$php_cxx_post 213])dnl 214 b_lo=[$]$1_lo 215]) 216 217dnl 218dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared]]]) 219dnl 220dnl Additional to PHP_ADD_SOURCES (see above), this lets you set the name of the 221dnl array target-var directly, as well as whether shared objects will be built 222dnl from the sources. Should not be used directly. 223dnl 224AC_DEFUN([PHP_ADD_SOURCES_X],[ 225dnl Relative to source- or build-directory? 226dnl ac_srcdir/ac_bdir include trailing slash 227 case $1 in 228 ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir; ac_inc="-I. -I$abs_srcdir" ;; 229 /*[)] ac_srcdir=`echo "$1"|cut -c 2-`"/"; ac_bdir=$ac_srcdir; ac_inc="-I$ac_bdir -I$abs_srcdir/$ac_bdir" ;; 230 *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$1/"; ac_inc="-I$ac_bdir -I$ac_srcdir" ;; 231 esac 232 233dnl how to build .. shared or static? 234 ifelse($5,yes,_PHP_ASSIGN_BUILD_VARS(shared),_PHP_ASSIGN_BUILD_VARS(php)) 235 236dnl Iterate over the sources. 237 old_IFS=[$]IFS 238 for ac_src in $2; do 239 240dnl Remove the suffix. 241 IFS=. 242 set $ac_src 243 ac_obj=[$]1 244 IFS=$old_IFS 245 246dnl Append to the array which has been dynamically chosen at m4 time. 247 $4="[$]$4 [$]ac_bdir[$]ac_obj.lo" 248 249dnl Choose the right compiler/flags/etc. for the source-file. 250 case $ac_src in 251 *.c[)] ac_comp="$b_c_pre $ac_inc $b_c_meta $3 -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $b_c_post" ;; 252 *.s[)] ac_comp="$b_c_pre $ac_inc $b_c_meta $3 -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $b_c_post" ;; 253 *.S[)] ac_comp="$b_c_pre $ac_inc $b_c_meta $3 -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $b_c_post" ;; 254 *.cpp|*.cc|*.cxx[)] ac_comp="$b_cxx_pre $ac_inc $b_cxx_meta $3 -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $b_cxx_post" ;; 255 esac 256 257dnl Generate Makefiles with dependencies 258 ac_comp="$ac_comp -MMD -MF $ac_bdir$ac_obj.dep -MT $ac_bdir[$]ac_obj.lo" 259 260dnl Create a rule for the object/source combo. 261 cat >>Makefile.objects<<EOF 262-include $ac_bdir[$]ac_obj.dep 263$ac_bdir[$]ac_obj.lo: $ac_srcdir[$]ac_src 264 $ac_comp 265EOF 266 done 267]) 268 269dnl ---------------------------------------------------------------------------- 270dnl Compiler characteristics checks. 271dnl ---------------------------------------------------------------------------- 272 273dnl 274dnl PHP_RUNPATH_SWITCH 275dnl 276dnl Checks for -R, etc. switch. 277dnl 278AC_DEFUN([PHP_RUNPATH_SWITCH],[ 279AC_MSG_CHECKING([if compiler supports -Wl,-rpath,]) 280AC_CACHE_VAL(php_cv_cc_rpath,[ 281 SAVE_LIBS=$LIBS 282 LIBS="-Wl,-rpath,/usr/$PHP_LIBDIR $LIBS" 283 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],[php_cv_cc_rpath=yes],[php_cv_cc_rpath=no]) 284 LIBS=$SAVE_LIBS]) 285AC_MSG_RESULT([$php_cv_cc_rpath]) 286if test $php_cv_cc_rpath = "yes"; then 287 ld_runpath_switch=-Wl,-rpath, 288else 289 AC_MSG_CHECKING([if compiler supports -R]) 290 AC_CACHE_VAL(php_cv_cc_dashr,[ 291 SAVE_LIBS=$LIBS 292 LIBS="-R /usr/$PHP_LIBDIR $LIBS" 293 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],[php_cv_cc_dashr=yes],[php_cv_cc_dashr=no]) 294 LIBS=$SAVE_LIBS]) 295 AC_MSG_RESULT([$php_cv_cc_dashr]) 296 if test $php_cv_cc_dashr = "yes"; then 297 ld_runpath_switch=-R 298 else 299 dnl Something innocuous. 300 ld_runpath_switch=-L 301 fi 302fi 303if test "$PHP_RPATH" = "no"; then 304 ld_runpath_switch= 305fi 306]) 307 308dnl 309dnl PHP_LIBGCC_LIBPATH(gcc) 310dnl 311dnl Stores the location of libgcc in libgcc_libpath. 312dnl 313AC_DEFUN([PHP_LIBGCC_LIBPATH],[ 314 changequote({,}) 315 libgcc_libpath=`$1 --print-libgcc-file-name|$SED 's%/*[^/][^/]*$%%'` 316 changequote([,]) 317]) 318 319dnl ---------------------------------------------------------------------------- 320dnl Macros to modify LIBS, INCLUDES, etc. variables. 321dnl ---------------------------------------------------------------------------- 322 323dnl 324dnl PHP_REMOVE_USR_LIB(NAME) 325dnl 326dnl Removes all -L/usr/$PHP_LIBDIR entries from variable NAME. 327dnl 328AC_DEFUN([PHP_REMOVE_USR_LIB],[ 329 unset ac_new_flags 330 for i in [$]$1; do 331 case [$]i in 332 -L/usr/$PHP_LIBDIR|-L/usr/$PHP_LIBDIR/[)] ;; 333 *[)] ac_new_flags="[$]ac_new_flags [$]i" ;; 334 esac 335 done 336 $1=[$]ac_new_flags 337]) 338 339dnl 340dnl PHP_EVAL_LIBLINE(libline, SHARED-LIBADD) 341dnl 342dnl Use this macro, if you need to add libraries and or library search paths to 343dnl the PHP build system which are only given in compiler notation. 344dnl 345AC_DEFUN([PHP_EVAL_LIBLINE],[ 346 for ac_i in $1; do 347 case $ac_i in 348 -pthread[)] 349 if test "$ext_shared" = "yes"; then 350 $2="[$]$2 -pthread" 351 else 352 PHP_RUN_ONCE(EXTRA_LDFLAGS, [$ac_i], [EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ac_i"]) 353 PHP_RUN_ONCE(EXTRA_LDFLAGS_PROGRAM, [$ac_i], 354 [EXTRA_LDFLAGS_PROGRAM="$EXTRA_LDFLAGS_PROGRAM $ac_i"]) 355 fi 356 ;; 357 -l*[)] 358 ac_ii=`echo $ac_i|cut -c 3-` 359 PHP_ADD_LIBRARY($ac_ii,1,$2) 360 ;; 361 -L*[)] 362 ac_ii=`echo $ac_i|cut -c 3-` 363 PHP_ADD_LIBPATH($ac_ii,$2) 364 ;; 365 esac 366 done 367]) 368 369dnl 370dnl PHP_EVAL_INCLINE(headerline) 371dnl 372dnl Use this macro, if you need to add header search paths to the PHP build 373dnl system which are only given in compiler notation. 374dnl 375AC_DEFUN([PHP_EVAL_INCLINE],[ 376 for ac_i in $1; do 377 case $ac_i in 378 -I*[)] 379 ac_ii=`echo $ac_i|cut -c 3-` 380 PHP_ADD_INCLUDE($ac_ii) 381 ;; 382 esac 383 done 384]) 385 386dnl 387dnl _PHP_ADD_LIBPATH_GLOBAL(variable) 388dnl 389dnl Internal, don't use. 390dnl 391AC_DEFUN([_PHP_ADD_LIBPATH_GLOBAL],[ 392 PHP_RUN_ONCE(LIBPATH, $1, [ 393 test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$1" 394 LDFLAGS="$LDFLAGS -L$1" 395 PHP_RPATHS="$PHP_RPATHS $1" 396 ]) 397]) 398 399dnl 400dnl PHP_ADD_LIBPATH(path [, SHARED-LIBADD]) 401dnl 402dnl Adds a path to linkpath/runpath (LDFLAGS). 403dnl 404AC_DEFUN([PHP_ADD_LIBPATH],[ 405 if test "$1" != "/usr/$PHP_LIBDIR" && test "$1" != "/usr/lib"; then 406 PHP_EXPAND_PATH($1, ai_p) 407 ifelse([$2],,[ 408 _PHP_ADD_LIBPATH_GLOBAL([$ai_p]) 409 ],[ 410 if test "$ext_shared" = "yes"; then 411 $2="-L$ai_p [$]$2" 412 test -n "$ld_runpath_switch" && $2="$ld_runpath_switch$ai_p [$]$2" 413 else 414 _PHP_ADD_LIBPATH_GLOBAL([$ai_p]) 415 fi 416 ]) 417 fi 418]) 419 420dnl 421dnl PHP_UTILIZE_RPATHS() 422dnl 423dnl Builds RPATHS/LDFLAGS from PHP_RPATHS. 424dnl 425AC_DEFUN([PHP_UTILIZE_RPATHS],[ 426 OLD_RPATHS=$PHP_RPATHS 427 unset PHP_RPATHS 428 429 for i in $OLD_RPATHS; do 430 dnl Can be passed to native cc/libtool 431 PHP_LDFLAGS="$PHP_LDFLAGS -L$i" 432 dnl Libtool-specific 433 PHP_RPATHS="$PHP_RPATHS -R $i" 434 dnl cc-specific 435 NATIVE_RPATHS="$NATIVE_RPATHS $ld_runpath_switch$i" 436 done 437 438 if test "$PHP_RPATH" = "no"; then 439 unset PHP_RPATHS 440 unset NATIVE_RPATHS 441 fi 442]) 443 444dnl 445dnl PHP_ADD_INCLUDE(path [,before]) 446dnl 447dnl Add an include path. If before is 1, add in the beginning of INCLUDES. 448dnl 449AC_DEFUN([PHP_ADD_INCLUDE],[ 450 if test "$1" != "/usr/include"; then 451 PHP_EXPAND_PATH($1, ai_p) 452 PHP_RUN_ONCE(INCLUDEPATH, $ai_p, [ 453 if test "$2"; then 454 INCLUDES="-I$ai_p $INCLUDES" 455 else 456 INCLUDES="$INCLUDES -I$ai_p" 457 fi 458 ]) 459 fi 460]) 461 462dnl 463dnl _PHP_X_ADD_LIBRARY 464dnl 465dnl Internal, don't use. 466dnl 467AC_DEFUN([_PHP_X_ADD_LIBRARY],[dnl 468 ifelse([$2],,$3="-l$1 [$]$3", $3="[$]$3 -l$1") dnl 469]) 470 471dnl 472dnl _PHP_ADD_LIBRARY_SKELETON 473dnl 474dnl Internal, don't use. 475dnl 476AC_DEFUN([_PHP_ADD_LIBRARY_SKELETON],[ 477 case $1 in 478 c|c_r[)] ;; 479 *[)] ifelse($3,,[ 480 _PHP_X_ADD_LIBRARY($1,$2,$5) 481 ],[ 482 if test "$ext_shared" = "yes"; then 483 _PHP_X_ADD_LIBRARY($1,$2,$3) 484 else 485 $4($1,$2) 486 fi 487 ]) ;; 488 esac 489]) 490 491dnl 492dnl PHP_ADD_LIBRARY(library[, append[, shared-libadd]]) 493dnl 494dnl Add a library to the link line. 495dnl 496AC_DEFUN([PHP_ADD_LIBRARY],[ 497 _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY],[LIBS]) 498]) 499 500dnl 501dnl PHP_ADD_LIBRARY_DEFER(library[, append[, shared-libadd]]) 502dnl 503dnl Add a library to the link line (deferred, not used during configure). 504dnl 505AC_DEFUN([PHP_ADD_LIBRARY_DEFER],[ 506 _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY_DEFER],[DLIBS]) 507]) 508 509dnl 510dnl PHP_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd]) 511dnl 512dnl Add a library to the link line and path to linkpath/runpath. If 513dnl shared-libadd is not empty and $ext_shared is yes, shared-libadd will be 514dnl assigned the library information. 515dnl 516AC_DEFUN([PHP_ADD_LIBRARY_WITH_PATH],[ 517ifelse($3,,[ 518 if test -n "$2"; then 519 PHP_ADD_LIBPATH($2) 520 fi 521 PHP_ADD_LIBRARY($1) 522],[ 523 if test "$ext_shared" = "yes"; then 524 $3="-l$1 [$]$3" 525 if test -n "$2"; then 526 PHP_ADD_LIBPATH($2,$3) 527 fi 528 else 529 PHP_ADD_LIBRARY_WITH_PATH($1,$2) 530 fi 531]) 532]) 533 534dnl 535dnl PHP_ADD_LIBRARY_DEFER_WITH_PATH(library, path[, shared-libadd]) 536dnl 537dnl Add a library to the link line (deferred) and path to linkpath/runpath (not 538dnl deferred). If shared-libadd is not empty and $ext_shared is yes, 539dnl shared-libadd will be assigned the library information. 540dnl 541AC_DEFUN([PHP_ADD_LIBRARY_DEFER_WITH_PATH],[ 542ifelse($3,,[ 543 if test -n "$2"; then 544 PHP_ADD_LIBPATH($2) 545 fi 546 PHP_ADD_LIBRARY_DEFER($1) 547],[ 548 if test "$ext_shared" = "yes"; then 549 $3="-l$1 [$]$3" 550 if test -n "$2"; then 551 PHP_ADD_LIBPATH($2,$3) 552 fi 553 else 554 PHP_ADD_LIBRARY_DEFER_WITH_PATH($1,$2) 555 fi 556]) 557]) 558 559dnl 560dnl PHP_ADD_FRAMEWORK(framework [,before]) 561dnl 562dnl Add a (Darwin / Mac OS X) framework to the link line. If before is 1, the 563dnl framework is added to the beginning of the line. 564dnl 565AC_DEFUN([PHP_ADD_FRAMEWORK], [ 566 PHP_RUN_ONCE(FRAMEWORKS, $1, [ 567 if test "$2"; then 568 PHP_FRAMEWORKS="-framework $1 $PHP_FRAMEWORKS" 569 else 570 PHP_FRAMEWORKS="$PHP_FRAMEWORKS -framework $1" 571 fi 572 ]) 573]) 574 575dnl 576dnl PHP_ADD_FRAMEWORKPATH(path [,before]) 577dnl 578dnl Add a (Darwin / Mac OS X) framework path to the link and include lines. 579dnl Default paths include (but are not limited to) /Local/Library/Frameworks and 580dnl /System/Library/Frameworks, so these don't need to be specifically added. If 581dnl before is 1, the framework path is added to the beginning of the relevant 582dnl lines. 583dnl 584AC_DEFUN([PHP_ADD_FRAMEWORKPATH], [ 585 PHP_EXPAND_PATH($1, ai_p) 586 PHP_RUN_ONCE(FRAMEWORKPATH, $ai_p, [ 587 if test "$2"; then 588 PHP_FRAMEWORKPATH="-F$ai_p $PHP_FRAMEWORKPATH" 589 else 590 PHP_FRAMEWORKPATH="$PHP_FRAMEWORKPATH -F$ai_p" 591 fi 592 ]) 593]) 594 595dnl 596dnl PHP_ADD_FRAMEWORK_WITH_PATH(framework, path) 597dnl 598dnl Adds a (Darwin / Mac OS X) framework path and the framework itself to the 599dnl link and include lines. 600dnl 601AC_DEFUN([PHP_ADD_FRAMEWORK_WITH_PATH], [ 602 PHP_ADD_FRAMEWORKPATH($2) 603 PHP_ADD_FRAMEWORK($1) 604]) 605 606dnl 607dnl PHP_SET_LIBTOOL_VARIABLE(var) 608dnl 609dnl Set libtool variable. 610dnl 611AC_DEFUN([PHP_SET_LIBTOOL_VARIABLE],[ 612 if test -z "$LIBTOOL"; then 613 LIBTOOL='$(SHELL) $(top_builddir)/libtool $1' 614 else 615 LIBTOOL="$LIBTOOL $1" 616 fi 617]) 618 619dnl ---------------------------------------------------------------------------- 620dnl Wrapper macros for AC_ARG_WITH / AC_ARG_ENABLE 621dnl ---------------------------------------------------------------------------- 622 623dnl 624dnl PHP_ARG_ANALYZE_EX 625dnl 626dnl Internal. 627dnl 628AC_DEFUN([PHP_ARG_ANALYZE_EX],[ 629ext_output="yes, shared" 630ext_shared=yes 631case [$]$1 in 632shared,*[)] 633 $1=`echo "[$]$1"|$SED 's/^shared,//'` 634 ;; 635shared[)] 636 $1=yes 637 ;; 638no[)] 639 ext_output=no 640 ext_shared=no 641 ;; 642*[)] 643 ext_output=yes 644 ext_shared=no 645 ;; 646esac 647 648PHP_ALWAYS_SHARED([$1]) 649]) 650 651dnl 652dnl PHP_ARG_ANALYZE 653dnl 654dnl Internal. 655dnl 656AC_DEFUN([PHP_ARG_ANALYZE],[ 657ifelse([$3],yes,[PHP_ARG_ANALYZE_EX([$1])],[ext_output=ifelse([$]$1,,no,[$]$1)]) 658ifelse([$2],,,[AC_MSG_RESULT([$ext_output])]) 659]) 660 661dnl 662dnl PHP_ARG_WITH(arg-name, check message, help text[, default-val[, extension-or-not]]) 663dnl 664dnl Sets PHP_ARG_NAME either to the user value or to the default value. 665dnl default-val defaults to no. This will also set the variable ext_shared, and 666dnl will overwrite any previous variable of that name. If extension-or-not is 667dnl yes (default), then do the ENABLE_ALL check and run the PHP_ARG_ANALYZE_EX. 668dnl 669AC_DEFUN([PHP_ARG_WITH],[ 670php_with_[]translit($1,A-Z0-9-,a-z0-9_)=ifelse($4,,no,$4) 671PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)]) 672]) 673 674dnl 675dnl PHP_REAL_ARG_WITH 676dnl 677dnl Internal. 678dnl 679AC_DEFUN([PHP_REAL_ARG_WITH],[ 680ifelse([$2],,,[AC_MSG_CHECKING([$2])]) 681AC_ARG_WITH($1,[$3],$5=[$]withval, 682[ 683 $5=ifelse($4,,no,$4) 684 ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL]) 685]) 686PHP_ARG_ANALYZE($5,[$2],$6) 687]) 688 689dnl 690dnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val[, extension-or-not]]) 691dnl 692dnl Sets PHP_ARG_NAME either to the user value or to the default value. 693dnl default-val defaults to no. This will also set the variable ext_shared, and 694dnl will overwrite any previous variable of that name. If extension-or-not is 695dnl yes (default), then do the ENABLE_ALL check and run the PHP_ARG_ANALYZE_EX. 696dnl 697AC_DEFUN([PHP_ARG_ENABLE],[ 698php_enable_[]translit($1,A-Z0-9-,a-z0-9_)=ifelse($4,,no,$4) 699PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)]) 700]) 701 702dnl 703dnl PHP_REAL_ARG_ENABLE 704dnl 705dnl Internal. 706dnl 707AC_DEFUN([PHP_REAL_ARG_ENABLE],[ 708ifelse([$2],,,[AC_MSG_CHECKING([$2])]) 709AC_ARG_ENABLE($1,[$3],$5=[$]enableval, 710[ 711 $5=ifelse($4,,no,$4) 712 ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL]) 713]) 714PHP_ARG_ANALYZE($5,[$2],$6) 715]) 716 717dnl ---------------------------------------------------------------------------- 718dnl Build macros 719dnl ---------------------------------------------------------------------------- 720 721dnl 722dnl PHP_BUILD_THREAD_SAFE 723dnl 724AC_DEFUN([PHP_BUILD_THREAD_SAFE],[ 725 enable_zts=yes 726 if test "$pthreads_working" != "yes"; then 727 AC_MSG_ERROR([ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads.]) 728 fi 729]) 730 731dnl 732dnl PHP_REQUIRE_CXX 733dnl 734AC_DEFUN([PHP_REQUIRE_CXX],[ 735 if test -z "$php_cxx_done"; then 736 AC_PROG_CXX 737 AC_PROG_CXXCPP 738 PHP_ADD_LIBRARY(stdc++) 739 php_cxx_done=yes 740 fi 741]) 742 743dnl 744dnl PHP_BUILD_SHARED 745dnl 746AC_DEFUN([PHP_BUILD_SHARED],[ 747 PHP_BUILD_PROGRAM 748 OVERALL_TARGET=libphp.la 749 php_sapi_module=shared 750 751 php_c_pre=$shared_c_pre 752 php_c_meta=$shared_c_meta 753 php_c_post=$shared_c_post 754 php_cxx_pre=$shared_cxx_pre 755 php_cxx_meta=$shared_cxx_meta 756 php_cxx_post=$shared_cxx_post 757 php_lo=$shared_lo 758]) 759 760dnl 761dnl PHP_BUILD_STATIC 762dnl 763AC_DEFUN([PHP_BUILD_STATIC],[ 764 PHP_BUILD_PROGRAM 765 OVERALL_TARGET=libphp.la 766 php_sapi_module=static 767]) 768 769dnl 770dnl PHP_BUILD_BUNDLE 771dnl 772AC_DEFUN([PHP_BUILD_BUNDLE],[ 773 PHP_BUILD_PROGRAM 774 OVERALL_TARGET=libs/libphp.bundle 775 php_sapi_module=static 776]) 777 778dnl 779dnl PHP_BUILD_PROGRAM 780dnl 781AC_DEFUN([PHP_BUILD_PROGRAM],[ 782 php_c_pre='$(LIBTOOL) --tag=CC --mode=compile $(CC)' 783 php_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS)' 784 php_c_post= 785 php_cxx_pre='$(LIBTOOL) --tag=CXX --mode=compile $(CXX)' 786 php_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS)' 787 php_cxx_post= 788 php_lo=lo 789 790 case $with_pic in 791 yes) pic_setting='-prefer-pic';; 792 no) pic_setting='-prefer-non-pic';; 793 esac 794 795 shared_c_pre='$(LIBTOOL) --tag=CC --mode=compile $(CC)' 796 shared_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) '$pic_setting 797 shared_c_post= 798 shared_cxx_pre='$(LIBTOOL) --tag=CXX --mode=compile $(CXX)' 799 shared_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) '$pic_setting 800 shared_cxx_post= 801 shared_lo=lo 802]) 803 804dnl 805dnl PHP_SHARED_MODULE(module-name, object-var, build-dir, cxx, zend_ext) 806dnl 807dnl Basically sets up the link-stage for building module-name from object_var in 808dnl build-dir. 809dnl 810AC_DEFUN([PHP_SHARED_MODULE],[ 811 install_modules="install-modules" 812 suffix=la 813 814 case $host_alias in 815 *aix*[)] 816 additional_flags="-Wl,-G" 817 ;; 818 esac 819 820 if test "x$5" = "xyes"; then 821 PHP_ZEND_EX="$PHP_ZEND_EX \$(phplibdir)/$1.$suffix" 822 else 823 PHP_MODULES="$PHP_MODULES \$(phplibdir)/$1.$suffix" 824 fi 825 PHP_SUBST($2) 826 cat >>Makefile.objects<<EOF 827\$(phplibdir)/$1.$suffix: $3/$1.$suffix 828 \$(LIBTOOL) --tag=ifelse($4,,CC,CXX) --mode=install cp $3/$1.$suffix \$(phplibdir) 829 830$3/$1.$suffix: \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_DEPENDENCIES) 831 \$(LIBTOOL) --tag=ifelse($4,,CC,CXX) --mode=link ifelse($4,,[\$(CC)],[\$(CXX)]) -shared \$(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) 832 833EOF 834]) 835 836dnl 837dnl PHP_SELECT_SAPI(name, type[, sources [, extra-cflags [, build-target]]]) 838dnl 839dnl Selects the SAPI name and type (static, shared, bundle, program) and 840dnl optionally also the source-files for the SAPI-specific objects. 841dnl 842AC_DEFUN([PHP_SELECT_SAPI],[ 843 if test "$2" = "program"; then 844 PHP_BINARIES="$PHP_BINARIES $1" 845 elif test "$PHP_SAPI" != "none"; then 846 AC_MSG_ERROR([ 847+--------------------------------------------------------------------+ 848| *** ATTENTION *** | 849| | 850| You've configured multiple SAPIs to be built. You can build only | 851| one SAPI module plus CGI, CLI and FPM binaries at the same time. | 852+--------------------------------------------------------------------+ 853]) 854 else 855 PHP_SAPI=$1 856 fi 857 858 PHP_ADD_BUILD_DIR([sapi/$1]) 859 860 PHP_INSTALLED_SAPIS="$PHP_INSTALLED_SAPIS $1" 861 862 ifelse($2,program,[ 863 PHP_BUILD_PROGRAM 864 install_binaries="install-binaries" 865 install_binary_targets="$install_binary_targets install-$1" 866 PHP_SUBST(PHP_[]translit($1,a-z0-9-,A-Z0-9_)[]_OBJS) 867 ifelse($3,,,[PHP_ADD_SOURCES_X([sapi/$1],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_)[]_OBJS)]) 868 ],[ 869 case "$2" in 870 static[)] PHP_BUILD_STATIC;; 871 shared[)] PHP_BUILD_SHARED;; 872 bundle[)] PHP_BUILD_BUNDLE;; 873 esac 874 install_sapi="install-sapi" 875 ifelse($3,,,[PHP_ADD_SOURCES([sapi/$1],[$3],[$4],[sapi])]) 876 ]) 877]) 878 879dnl 880dnl PHP_ADD_BUILD_DIR(dirs [, create]) 881dnl 882dnl Add build directories and directories required for the out-of-source builds. 883dnl When "create" is given, the provided "dirs" are created immediately upon 884dnl macro invocation, instead of deferring it to the PHP_GEN_BUILD_DIRS. 885dnl 886AC_DEFUN([PHP_ADD_BUILD_DIR],[ 887 ifelse($2,,[ 888 BUILD_DIR="$BUILD_DIR $1" 889 ], [ 890 $php_shtool mkdir -p $1 891 ]) 892]) 893 894dnl 895dnl PHP_GEN_BUILD_DIRS 896dnl 897AC_DEFUN([PHP_GEN_BUILD_DIRS],[ 898 AC_MSG_NOTICE([creating build directories]) 899 $php_shtool mkdir -p $BUILD_DIR 900]) 901 902dnl 903dnl PHP_NEW_EXTENSION(extname, sources [, shared [, sapi_class [, extra-cflags [, cxx [, zend_ext]]]]]) 904dnl 905dnl Includes an extension in the build. 906dnl 907dnl "extname" is the name of the extension. 908dnl "sources" is a list of files relative to the subdir which are used to build 909dnl the extension. 910dnl "shared" can be set to "shared" or "yes" to build the extension as a 911dnl dynamically loadable library. Optional parameter "sapi_class" can be set to 912dnl "cli" to mark extension build only with CLI or CGI sapi's. "extra-cflags" 913dnl are passed to the compiler, with @ext_srcdir@ and @ext_builddir@ being 914dnl substituted. 915dnl "cxx" can be used to indicate that a C++ shared module is desired. 916dnl "zend_ext" indicates a zend extension. 917AC_DEFUN([PHP_NEW_EXTENSION],[ 918 ext_builddir=[]PHP_EXT_BUILDDIR($1) 919 ext_srcdir=[]PHP_EXT_SRCDIR($1) 920 ext_dir=[]PHP_EXT_DIR($1) 921 922 ifelse($5,,ac_extra=,[ac_extra=`echo "$5"|$SED s#@ext_srcdir@#$ext_srcdir#g|$SED s#@ext_builddir@#$ext_builddir#g`]) 923 924 if test "$3" != "shared" && test "$3" != "yes" && test "$4" != "cli"; then 925dnl ---------------------------------------------- Static module 926 [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=no 927 PHP_ADD_SOURCES($ext_dir,$2,$ac_extra,) 928 EXT_STATIC="$EXT_STATIC $1;$ext_dir" 929 if test "$3" != "nocli"; then 930 EXT_CLI_STATIC="$EXT_CLI_STATIC $1;$ext_dir" 931 fi 932 else 933 if test "$3" = "shared" || test "$3" = "yes"; then 934dnl ---------------------------------------------- Shared module 935 [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=yes 936 PHP_ADD_SOURCES_X($ext_dir,$2,$ac_extra -DZEND_COMPILE_DL_EXT=1,shared_objects_$1,yes) 937 PHP_SHARED_MODULE($1,shared_objects_$1, $ext_builddir, $6, $7) 938 AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z_-,A-Z__), 1, Whether to build $1 as dynamic module) 939 fi 940 fi 941 942 if test "$3" != "shared" && test "$3" != "yes" && test "$4" = "cli"; then 943dnl ---------------------------------------------- CLI static module 944 [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=no 945 case "$PHP_SAPI" in 946 cgi|embed|phpdbg[)] 947 PHP_ADD_SOURCES($ext_dir,$2,$ac_extra,) 948 EXT_STATIC="$EXT_STATIC $1;$ext_dir" 949 ;; 950 *[)] 951 PHP_ADD_SOURCES($ext_dir,$2,$ac_extra,cli) 952 ;; 953 esac 954 EXT_CLI_STATIC="$EXT_CLI_STATIC $1;$ext_dir" 955 fi 956 PHP_ADD_BUILD_DIR($ext_builddir) 957 958dnl Set for phpize builds only. 959dnl --------------------------- 960 if test "$ext_builddir" = "."; then 961 PHP_PECL_EXTENSION=$1 962 PHP_SUBST(PHP_PECL_EXTENSION) 963 fi 964]) 965 966dnl 967dnl PHP_ADD_EXTENSION_DEP(extname, depends [, depconf]) 968dnl 969dnl This macro is scanned by genif.sh when it builds the internal functions 970dnl list, so that modules can be init'd in the correct order 971dnl $1 = name of extension, $2 = extension upon which it depends 972dnl $3 = optional: if true, it's ok for $2 to have not been configured default 973dnl is false and should halt the build. To be effective, this macro must be 974dnl invoked *after* PHP_NEW_EXTENSION. The extension on which it depends must 975dnl also have been configured. See ADD_EXTENSION_DEP in win32 build. 976dnl 977AC_DEFUN([PHP_ADD_EXTENSION_DEP], [ 978 am_i_shared=$[PHP_]translit($1,a-z_-,A-Z__)[_SHARED] 979 is_it_shared=$[PHP_]translit($2,a-z_-,A-Z__)[_SHARED] 980 is_it_enabled=$[PHP_]translit($2,a-z_-,A-Z__) 981 if test "$am_i_shared" = "no" && test "$is_it_shared" = "yes" ; then 982 AC_MSG_ERROR([ 983You've configured extension $1 to build statically, but it 984depends on extension $2, which you've configured to build shared. 985You either need to build $1 shared or build $2 statically for the 986build to be successful. 987]) 988 fi 989 if test "x$is_it_enabled" = "xno" && test "x$3" != "xtrue"; then 990 AC_MSG_ERROR([ 991You've configured extension $1, which depends on extension $2, 992but you've either not enabled $2, or have disabled it. 993]) 994 fi 995 dnl Some systems require that we link $2 to $1 when building. 996]) 997 998dnl ---------------------------------------------------------------------------- 999dnl Checks for structures, typedefs, broken functions, etc. 1000dnl ---------------------------------------------------------------------------- 1001 1002dnl 1003dnl _PHP_CHECK_SIZEOF(type, cross-value, extra-headers [, found-action [, not-found-action]]) 1004dnl 1005dnl Internal helper macro. 1006dnl 1007AC_DEFUN([_PHP_CHECK_SIZEOF], [ 1008 php_cache_value=php_cv_sizeof_[]$1 1009 AC_CACHE_VAL(php_cv_sizeof_[]$1, [ 1010 old_LIBS=$LIBS 1011 LIBS= 1012 old_LDFLAGS=$LDFLAGS 1013 LDFLAGS= 1014 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h> 1015#include <stdlib.h> 1016#include <stddef.h> 1017#include <inttypes.h> 1018#ifdef HAVE_UNISTD_H 1019#include <unistd.h> 1020#endif 1021$3 1022 1023int main(void) 1024{ 1025 FILE *fp = fopen("conftestval", "w"); 1026 if (!fp) return(1); 1027 fprintf(fp, "%d\n", sizeof($1)); 1028 return(0); 1029} 1030 ]])], [ 1031 eval $php_cache_value=`cat conftestval` 1032 ], [ 1033 eval $php_cache_value=0 1034 ], [ 1035 ifelse([$2],,[eval $php_cache_value=0], [eval $php_cache_value=$2]) 1036]) 1037 LDFLAGS=$old_LDFLAGS 1038 LIBS=$old_LIBS 1039]) 1040 if eval test "\$$php_cache_value" != "0"; then 1041ifelse([$4],[],:,[$4]) 1042ifelse([$5],[],,[else $5]) 1043 fi 1044]) 1045 1046dnl 1047dnl PHP_CHECK_SIZEOF(type, cross-value, extra-headers) 1048dnl 1049AC_DEFUN([PHP_CHECK_SIZEOF], [ 1050 AC_MSG_CHECKING([size of $1]) 1051 _PHP_CHECK_SIZEOF($1, $2, $3, [ 1052 AC_DEFINE_UNQUOTED([SIZEOF_]translit($1,a-z,A-Z_), [$]php_cv_sizeof_[]$1, [Size of $1]) 1053 AC_DEFINE_UNQUOTED([HAVE_]translit($1,a-z,A-Z_), 1, [Whether $1 is available]) 1054 ]) 1055 AC_MSG_RESULT([[$][php_cv_sizeof_]translit($1, ,_)]) 1056]) 1057 1058dnl 1059dnl PHP_TIME_R_TYPE 1060dnl 1061dnl Check type of reentrant time-related functions. Type can be: irix, hpux or 1062dnl POSIX. 1063dnl 1064AC_DEFUN([PHP_TIME_R_TYPE],[ 1065AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[ 1066AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1067#include <time.h> 1068 1069int main(void) { 1070char buf[27]; 1071struct tm t; 1072time_t old = 0; 1073int r, s; 1074 1075s = gmtime_r(&old, &t); 1076r = (int) asctime_r(&t, buf, 26); 1077if (r == s && s == 0) return (0); 1078return (1); 1079} 1080]])],[ 1081 ac_cv_time_r_type=hpux 1082],[ 1083 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1084#include <time.h> 1085int main(void) { 1086 struct tm t, *s; 1087 time_t old = 0; 1088 char buf[27], *p; 1089 1090 s = gmtime_r(&old, &t); 1091 p = asctime_r(&t, buf, 26); 1092 if (p == buf && s == &t) return (0); 1093 return (1); 1094} 1095 ]])],[ 1096 ac_cv_time_r_type=irix 1097 ],[ 1098 ac_cv_time_r_type=POSIX 1099 ],[ 1100 ac_cv_time_r_type=POSIX 1101 ]) 1102],[ 1103 ac_cv_time_r_type=POSIX 1104]) 1105]) 1106 case $ac_cv_time_r_type in 1107 hpux[)] AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;; 1108 irix[)] AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;; 1109 esac 1110]) 1111 1112dnl 1113dnl PHP_DOES_PWRITE_WORK 1114dnl 1115dnl Internal. 1116dnl 1117AC_DEFUN([PHP_DOES_PWRITE_WORK],[ 1118 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1119#include <sys/types.h> 1120#include <sys/stat.h> 1121#include <fcntl.h> 1122#include <unistd.h> 1123#include <errno.h> 1124#include <stdlib.h> 1125$1 1126 int main(void) { 1127 int fd = open("conftest_in", O_WRONLY|O_CREAT, 0600); 1128 1129 if (fd < 0) return 1; 1130 if (pwrite(fd, "text", 4, 0) != 4) return 1; 1131 /* Linux glibc breakage until 2.2.5 */ 1132 if (pwrite(fd, "text", 4, -1) != -1 || errno != EINVAL) return 1; 1133 return 0; 1134 } 1135 1136 ]])],[ 1137 ac_cv_pwrite=yes 1138 ],[ 1139 ac_cv_pwrite=no 1140 ],[ 1141 ac_cv_pwrite=no 1142 ]) 1143]) 1144 1145dnl 1146dnl PHP_DOES_PREAD_WORK 1147dnl 1148dnl Internal. 1149dnl 1150AC_DEFUN([PHP_DOES_PREAD_WORK],[ 1151 echo test > conftest_in 1152 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1153#include <sys/types.h> 1154#include <sys/stat.h> 1155#include <fcntl.h> 1156#include <unistd.h> 1157#include <errno.h> 1158#include <stdlib.h> 1159$1 1160 int main(void) { 1161 char buf[3]; 1162 int fd = open("conftest_in", O_RDONLY); 1163 if (fd < 0) return 1; 1164 if (pread(fd, buf, 2, 0) != 2) return 1; 1165 /* Linux glibc breakage until 2.2.5 */ 1166 if (pread(fd, buf, 2, -1) != -1 || errno != EINVAL) return 1; 1167 return 0; 1168 } 1169 ]])],[ 1170 ac_cv_pread=yes 1171 ],[ 1172 ac_cv_pread=no 1173 ],[ 1174 ac_cv_pread=no 1175 ]) 1176 rm -f conftest_in 1177]) 1178 1179dnl 1180dnl PHP_PWRITE_TEST 1181dnl 1182AC_DEFUN([PHP_PWRITE_TEST],[ 1183 AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[ 1184 PHP_DOES_PWRITE_WORK 1185 if test "$ac_cv_pwrite" = "no"; then 1186 PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);]) 1187 if test "$ac_cv_pwrite" = "yes"; then 1188 ac_cv_pwrite=64 1189 fi 1190 fi 1191 ]) 1192 1193 if test "$ac_cv_pwrite" != "no"; then 1194 AC_DEFINE(HAVE_PWRITE, 1, [ ]) 1195 if test "$ac_cv_pwrite" = "64"; then 1196 AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default]) 1197 fi 1198 fi 1199]) 1200 1201dnl 1202dnl PHP_PREAD_TEST 1203dnl 1204AC_DEFUN([PHP_PREAD_TEST],[ 1205 AC_CACHE_CHECK(whether pread works,ac_cv_pread,[ 1206 PHP_DOES_PREAD_WORK 1207 if test "$ac_cv_pread" = "no"; then 1208 PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);]) 1209 if test "$ac_cv_pread" = "yes"; then 1210 ac_cv_pread=64 1211 fi 1212 fi 1213 ]) 1214 1215 if test "$ac_cv_pread" != "no"; then 1216 AC_DEFINE(HAVE_PREAD, 1, [ ]) 1217 if test "$ac_cv_pread" = "64"; then 1218 AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default]) 1219 fi 1220 fi 1221]) 1222 1223dnl 1224dnl PHP_MISSING_TIME_R_DECL 1225dnl 1226AC_DEFUN([PHP_MISSING_TIME_R_DECL],[ 1227 AC_MSG_CHECKING([for missing declarations of reentrant functions]) 1228 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct tm *(*func)(void) = localtime_r]])],[ 1229 : 1230 ],[ 1231 AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared]) 1232 ]) 1233 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct tm *(*func)(void) = gmtime_r]])],[ 1234 : 1235 ],[ 1236 AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared]) 1237 ]) 1238 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[char *(*func)(void) = asctime_r]])],[ 1239 : 1240 ],[ 1241 AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared]) 1242 ]) 1243 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[char *(*func)(void) = ctime_r]])],[ 1244 : 1245 ],[ 1246 AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared]) 1247 ]) 1248 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string.h>]], [[char *(*func)(void) = strtok_r]])],[ 1249 : 1250 ],[ 1251 AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared]) 1252 ]) 1253 AC_MSG_RESULT([done]) 1254]) 1255 1256dnl 1257dnl PHP_EBCDIC 1258dnl 1259AC_DEFUN([PHP_EBCDIC], [ 1260 AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[ 1261 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1262int main(void) { 1263 return (unsigned char)'A' != (unsigned char)0xC1; 1264} 1265]])],[ 1266 ac_cv_ebcdic=yes 1267],[ 1268 ac_cv_ebcdic=no 1269],[ 1270 ac_cv_ebcdic=no 1271])]) 1272 if test "$ac_cv_ebcdic" = "yes"; then 1273 AC_MSG_ERROR([PHP does not support EBCDIC targets]) 1274 fi 1275]) 1276 1277dnl 1278dnl PHP_BROKEN_GETCWD 1279dnl 1280dnl Some systems, notably Solaris, cause getcwd() or realpath to fail if a 1281dnl component of the path has execute but not read permissions. 1282dnl 1283AC_DEFUN([PHP_BROKEN_GETCWD],[ 1284 AC_MSG_CHECKING([for broken getcwd]) 1285 os=`uname -sr 2>/dev/null` 1286 case $os in 1287 SunOS*[)] 1288 AC_DEFINE(HAVE_BROKEN_GETCWD,1, [Define if system has broken getcwd]) 1289 AC_MSG_RESULT([yes]);; 1290 *[)] 1291 AC_MSG_RESULT([no]);; 1292 esac 1293]) 1294 1295dnl 1296dnl PHP_BROKEN_GCC_STRLEN_OPT 1297dnl 1298dnl Early releases of GCC 8 shipped with a strlen() optimization bug, so they 1299dnl didn't properly handle the `char val[1]` struct hack. See bug #76510. 1300dnl 1301AC_DEFUN([PHP_BROKEN_GCC_STRLEN_OPT], [ 1302 AC_CACHE_CHECK([for broken gcc optimize-strlen],ac_cv_have_broken_gcc_strlen_opt,[ 1303 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1304#include <stdlib.h> 1305#include <string.h> 1306#include <stdio.h> 1307struct s 1308{ 1309 int i; 1310 char c[1]; 1311}; 1312int main(void) 1313{ 1314 struct s *s = malloc(sizeof(struct s) + 3); 1315 s->i = 3; 1316 strcpy(s->c, "foo"); 1317 return strlen(s->c+1) == 2; 1318} 1319]])],[ 1320 ac_cv_have_broken_gcc_strlen_opt=yes 1321],[ 1322 ac_cv_have_broken_gcc_strlen_opt=no 1323],[ 1324 ac_cv_have_broken_gcc_strlen_opt=no 1325])]) 1326 if test "$ac_cv_have_broken_gcc_strlen_opt" = "yes"; then 1327 CFLAGS="$CFLAGS -fno-optimize-strlen" 1328 fi 1329]) 1330 1331dnl 1332dnl PHP_FOPENCOOKIE 1333dnl 1334AC_DEFUN([PHP_FOPENCOOKIE], [ 1335 AC_CHECK_FUNC(fopencookie, [have_glibc_fopencookie=yes]) 1336 1337 if test "$have_glibc_fopencookie" = "yes"; then 1338dnl glibcs (since 2.1.2?) have a type called cookie_io_functions_t. 1339AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1340#ifndef _GNU_SOURCE 1341#define _GNU_SOURCE 1342#endif 1343#include <stdio.h> 1344]], [[cookie_io_functions_t cookie;]])],[have_cookie_io_functions_t=yes],[]) 1345 1346 if test "$have_cookie_io_functions_t" = "yes"; then 1347dnl Newer glibcs have a different seeker definition. 1348AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1349#ifndef _GNU_SOURCE 1350#define _GNU_SOURCE 1351#endif 1352#include <stdio.h> 1353#include <stdlib.h> 1354 1355struct cookiedata { 1356 off64_t pos; 1357}; 1358 1359ssize_t reader(void *cookie, char *buffer, size_t size) 1360{ return size; } 1361ssize_t writer(void *cookie, const char *buffer, size_t size) 1362{ return size; } 1363int closer(void *cookie) 1364{ return 0; } 1365int seeker(void *cookie, off64_t *position, int whence) 1366{ ((struct cookiedata*)cookie)->pos = *position; return 0; } 1367 1368cookie_io_functions_t funcs = {reader, writer, seeker, closer}; 1369 1370int main(void) { 1371 struct cookiedata g = { 0 }; 1372 FILE *fp = fopencookie(&g, "r", funcs); 1373 1374 if (fp && fseek(fp, 8192, SEEK_SET) == 0 && g.pos == 8192) 1375 return 0; 1376 return 1; 1377} 1378 1379]])], [ 1380 cookie_io_functions_use_off64_t=yes 1381], [ 1382 cookie_io_functions_use_off64_t=no 1383], [ 1384 dnl Cross compilation. 1385 case $host_alias in 1386 *linux*) 1387 cookie_io_functions_use_off64_t=yes 1388 ;; 1389 *) 1390 cookie_io_functions_use_off64_t=no 1391 ;; 1392 esac 1393]) 1394 1395 AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ]) 1396 1397 if test "$cookie_io_functions_use_off64_t" = "yes" ; then 1398 AC_DEFINE(COOKIE_SEEKER_USES_OFF64_T, 1, [ ]) 1399 fi 1400 fi 1401 fi 1402]) 1403 1404dnl ---------------------------------------------------------------------------- 1405dnl Library/function existence and build sanity checks. 1406dnl ---------------------------------------------------------------------------- 1407 1408dnl 1409dnl PHP_CHECK_LIBRARY(library, function [, action-found [, action-not-found [, extra-libs]]]) 1410dnl 1411dnl Wrapper for AC_CHECK_LIB. 1412dnl 1413AC_DEFUN([PHP_CHECK_LIBRARY], [ 1414 save_old_LDFLAGS=$LDFLAGS 1415 ac_stuff="$5" 1416 1417 save_ext_shared=$ext_shared 1418 ext_shared=yes 1419 PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS) 1420 AC_CHECK_LIB([$1],[$2],[ 1421 LDFLAGS=$save_old_LDFLAGS 1422 ext_shared=$save_ext_shared 1423 $3 1424 ],[ 1425 LDFLAGS=$save_old_LDFLAGS 1426 ext_shared=$save_ext_shared 1427 unset ac_cv_lib_$1[]_$2 1428 $4 1429 ])dnl 1430]) 1431 1432dnl 1433dnl PHP_CHECK_FRAMEWORK(framework, function [, action-found [, action-not-found ]]) 1434dnl 1435dnl El cheapo wrapper for AC_CHECK_LIB. 1436dnl 1437AC_DEFUN([PHP_CHECK_FRAMEWORK], [ 1438 save_old_LDFLAGS=$LDFLAGS 1439 LDFLAGS="-framework $1 $LDFLAGS" 1440 dnl Supplying "c" to AC_CHECK_LIB is technically cheating, but rewriting 1441 dnl AC_CHECK_LIB is overkill and this only affects the "checking.." output 1442 dnl anyway. 1443 AC_CHECK_LIB(c,[$2],[ 1444 LDFLAGS=$save_old_LDFLAGS 1445 $3 1446 ],[ 1447 LDFLAGS=$save_old_LDFLAGS 1448 $4 1449 ]) 1450]) 1451 1452dnl 1453dnl PHP_CHECK_FUNC_LIB(func, libs) 1454dnl 1455dnl This macro checks whether 'func' or '__func' exists in the specified 1456dnl library. Defines HAVE_func and HAVE_library if found and adds the library to 1457dnl LIBS. This should be called in the ACTION-IF-NOT-FOUND part of 1458dnl PHP_CHECK_FUNC. 1459dnl 1460dnl autoconf undefines the builtin "shift" :-( 1461dnl If possible, we use the builtin shift anyway, otherwise we use the ubercool 1462dnl definition that has been tested so far with FreeBSD/GNU m4. 1463dnl 1464ifdef([builtin],[builtin(define, phpshift, [builtin(shift, $@)])],[ 1465define([phpshift],[ifelse(index([$@],[,]),-1,,[substr([$@],incr(index([$@],[,])))])]) 1466]) 1467 1468dnl 1469dnl PHP_CHECK_FUNC_LIB 1470dnl 1471AC_DEFUN([PHP_CHECK_FUNC_LIB],[ 1472 ifelse($2,,:,[ 1473 unset ac_cv_lib_$2[]_$1 1474 unset ac_cv_lib_$2[]___$1 1475 unset found 1476 AC_CHECK_LIB($2, $1, [found=yes], [ 1477 AC_CHECK_LIB($2, __$1, [found=yes], [found=no]) 1478 ]) 1479 1480 if test "$found" = "yes"; then 1481 ac_libs=$LIBS 1482 LIBS="$LIBS -l$2" 1483 AC_RUN_IFELSE([AC_LANG_PROGRAM()],[found=yes],[found=no],[ 1484 dnl Cross compilation. 1485 found=yes 1486 ]) 1487 LIBS=$ac_libs 1488 fi 1489 1490 if test "$found" = "yes"; then 1491 PHP_ADD_LIBRARY($2) 1492 PHP_DEF_HAVE($1) 1493 PHP_DEF_HAVE(lib$2) 1494 ac_cv_func_$1=yes 1495 else 1496 PHP_CHECK_FUNC_LIB($1,phpshift(phpshift($@))) 1497 fi 1498 ]) 1499]) 1500 1501dnl 1502dnl PHP_CHECK_FUNC(func, ...) 1503dnl 1504dnl This macro checks whether 'func' or '__func' exists in the default libraries 1505dnl and as a fall back in the specified library. Defines HAVE_func and 1506dnl HAVE_library if found and adds the library to LIBS. 1507dnl 1508AC_DEFUN([PHP_CHECK_FUNC],[ 1509 unset ac_cv_func_$1 1510 unset ac_cv_func___$1 1511 unset found 1512 1513 AC_CHECK_FUNC($1, [found=yes],[ AC_CHECK_FUNC(__$1,[found=yes],[found=no]) ]) 1514 1515 case $found in 1516 yes[)] 1517 PHP_DEF_HAVE($1) 1518 ac_cv_func_$1=yes 1519 ;; 1520 ifelse($#,1,,[ 1521 *[)] PHP_CHECK_FUNC_LIB($@) ;; 1522 ]) 1523 esac 1524]) 1525 1526dnl 1527dnl PHP_TEST_BUILD(function, action-if-ok, action-if-not-ok [, extra-libs [, extra-source]]) 1528dnl 1529dnl This macro checks whether build works and given function exists. 1530dnl 1531AC_DEFUN([PHP_TEST_BUILD], [ 1532 old_LIBS=$LIBS 1533 LIBS="$4 $LIBS" 1534 AC_LINK_IFELSE([AC_LANG_SOURCE([[ 1535 $5 1536 char $1(void); 1537 int main(void) { 1538 $1(); 1539 return 0; 1540 } 1541 ]])],[ 1542 LIBS=$old_LIBS 1543 $2 1544 ],[ 1545 LIBS=$old_LIBS 1546 $3 1547 ]) 1548]) 1549 1550dnl ---------------------------------------------------------------------------- 1551dnl Platform characteristics checks. 1552dnl ---------------------------------------------------------------------------- 1553 1554dnl 1555dnl PHP_SHLIB_SUFFIX_NAMES 1556dnl 1557dnl Determines link library suffix SHLIB_SUFFIX_NAME which can be: .so, .sl or 1558dnl .dylib 1559dnl 1560dnl Determines shared library suffix SHLIB_DL_SUFFIX_NAME suffix can be: .so or 1561dnl .sl 1562dnl 1563AC_DEFUN([PHP_SHLIB_SUFFIX_NAMES],[ 1564 AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl 1565 PHP_SUBST_OLD(SHLIB_SUFFIX_NAME) 1566 PHP_SUBST_OLD(SHLIB_DL_SUFFIX_NAME) 1567 SHLIB_SUFFIX_NAME=so 1568 SHLIB_DL_SUFFIX_NAME=$SHLIB_SUFFIX_NAME 1569 case $host_alias in 1570 *hpux*[)] 1571 SHLIB_SUFFIX_NAME=sl 1572 SHLIB_DL_SUFFIX_NAME=sl 1573 ;; 1574 *darwin*[)] 1575 SHLIB_SUFFIX_NAME=dylib 1576 SHLIB_DL_SUFFIX_NAME=so 1577 ;; 1578 esac 1579]) 1580 1581dnl 1582dnl PHP_C_BIGENDIAN 1583dnl 1584dnl Replacement macro for AC_C_BIGENDIAN. 1585dnl 1586AC_DEFUN([PHP_C_BIGENDIAN], 1587[AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian_php, 1588 [ 1589 ac_cv_c_bigendian_php=unknown 1590 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1591int main(void) 1592{ 1593 short one = 1; 1594 char *cp = (char *)&one; 1595 1596 if (*cp == 0) { 1597 return(0); 1598 } else { 1599 return(1); 1600 } 1601} 1602 ]])], [ac_cv_c_bigendian_php=yes], [ac_cv_c_bigendian_php=no], [ac_cv_c_bigendian_php=unknown]) 1603 ]) 1604 if test $ac_cv_c_bigendian_php = yes; then 1605 AC_DEFINE(WORDS_BIGENDIAN, [], [Define if processor uses big-endian word]) 1606 fi 1607]) 1608 1609dnl ---------------------------------------------------------------------------- 1610dnl Checks for programs: PHP_PROG_<program>. 1611dnl ---------------------------------------------------------------------------- 1612 1613dnl 1614dnl PHP_PROG_SENDMAIL 1615dnl 1616dnl Search for the sendmail binary. 1617dnl 1618AC_DEFUN([PHP_PROG_SENDMAIL], [ 1619 PHP_ALT_PATH=/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib 1620 AC_PATH_PROG(PROG_SENDMAIL, sendmail, /usr/sbin/sendmail, $PATH:$PHP_ALT_PATH) 1621 PHP_SUBST(PROG_SENDMAIL) 1622]) 1623 1624dnl 1625dnl PHP_PROG_AWK 1626dnl 1627dnl Some vendors force mawk before gawk; mawk is broken so we don't like that. 1628dnl 1629AC_DEFUN([PHP_PROG_AWK], [ 1630 AC_CHECK_PROGS(AWK, gawk nawk awk mawk, bork, /usr/xpg4/bin/:$PATH) 1631 case "$AWK" in 1632 *mawk) 1633 AC_MSG_WARN([mawk is known to have problems on some systems. You should install GNU awk]) 1634 ;; 1635 *gawk) 1636 ;; 1637 bork) 1638 AC_MSG_ERROR([Could not find awk; Install GNU awk]) 1639 ;; 1640 *) 1641 AC_MSG_CHECKING([if $AWK is broken]) 1642 if ! $AWK 'function foo() {}' >/dev/null 2>&1 ; then 1643 AC_MSG_RESULT([yes]) 1644 AC_MSG_ERROR([You should install GNU awk]) 1645 else 1646 AC_MSG_RESULT([no]) 1647 fi 1648 ;; 1649 esac 1650 PHP_SUBST(AWK) 1651]) 1652 1653dnl 1654dnl PHP_PROG_BISON([MIN-VERSION], [EXCLUDED-VERSION...]) 1655dnl 1656dnl Search for bison and optionally check if version is at least the minimum 1657dnl required version MIN-VERSION and doesn't match any of the blank separated 1658dnl list of excluded versions EXCLUDED-VERSION (for example "3.0 3.2"). 1659dnl 1660AC_DEFUN([PHP_PROG_BISON], [ 1661 AC_CHECK_PROG(YACC, bison, bison) 1662 1663 ifelse($1,,php_bison_required_version='',php_bison_required_version="$1") 1664 ifelse($2,,php_bison_excluded_versions='none',php_bison_excluded_versions="$2") 1665 1666 if test -n "$YACC"; then 1667 AC_MSG_CHECKING([for bison version]) 1668 1669 php_bison_version=$($YACC --version 2> /dev/null | grep 'GNU Bison' | cut -d ' ' -f 4 | tr -d a-z) 1670 if test -z "$php_bison_version"; then 1671 php_bison_version=0.0.0 1672 fi 1673 ac_IFS=$IFS; IFS="." 1674 set $php_bison_version 1675 IFS=$ac_IFS 1676 php_bison_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}` 1677 php_bison_branch="[$]1.[$]2" 1678 php_bison_check=ok 1679 1680 if test -z "$php_bison_required_version" && test -z "$php_bison_num"; then 1681 php_bison_check=invalid 1682 elif test -n "$php_bison_required_version"; then 1683 ac_IFS=$IFS; IFS="." 1684 set $php_bison_required_version 1685 IFS=$ac_IFS 1686 php_bison_required_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}` 1687 php_bison_required_version="$php_bison_required_version or later" 1688 1689 if test -z "$php_bison_num" || test "$php_bison_num" -lt "$php_bison_required_num"; then 1690 php_bison_check=invalid 1691 fi 1692 fi 1693 1694 for php_bison_check_version in $php_bison_excluded_versions; do 1695 if test "$php_bison_version" = "$php_bison_check_version" || test "$php_bison_branch" = "$php_bison_check_version"; then 1696 php_bison_check=invalid 1697 break 1698 fi 1699 done 1700 1701 if test "$php_bison_check" != "invalid"; then 1702 PHP_SUBST_OLD([YFLAGS], [-Wall]) 1703 AC_MSG_RESULT([$php_bison_version (ok)]) 1704 else 1705 AC_MSG_RESULT([$php_bison_version]) 1706 fi 1707 fi 1708 1709 case $php_bison_check in 1710 ""|invalid[)] 1711 if test ! -f "$abs_srcdir/Zend/zend_language_parser.h" || test ! -f "$abs_srcdir/Zend/zend_language_parser.c"; then 1712 AC_MSG_ERROR([bison $php_bison_required_version or newer is required to generate PHP parsers (excluded versions: $php_bison_excluded_versions).]) 1713 fi 1714 1715 YACC="exit 0;" 1716 ;; 1717 esac 1718 1719 PHP_SUBST(YACC) 1720]) 1721 1722dnl 1723dnl PHP_PROG_RE2C([MIN-VERSION]) 1724dnl 1725dnl Search for the re2c and optionally check if version is at least the minimum 1726dnl required version MIN-VERSION. 1727dnl 1728AC_DEFUN([PHP_PROG_RE2C],[ 1729 AC_CHECK_PROG(RE2C, re2c, re2c) 1730 1731 ifelse($1,,php_re2c_required_version='',php_re2c_required_version="$1") 1732 1733 if test -n "$RE2C"; then 1734 AC_MSG_CHECKING([for re2c version]) 1735 1736 php_re2c_version=$($RE2C --version | cut -d ' ' -f 2 2>/dev/null) 1737 if test -z "$php_re2c_version"; then 1738 php_re2c_version=0.0.0 1739 fi 1740 ac_IFS=$IFS; IFS="." 1741 set $php_re2c_version 1742 IFS=$ac_IFS 1743 php_re2c_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}` 1744 php_re2c_check=ok 1745 1746 if test -z "$php_re2c_required_version" && test -z "$php_re2c_num"; then 1747 php_re2c_check=invalid 1748 elif test -n "$php_re2c_required_version"; then 1749 ac_IFS=$IFS; IFS="." 1750 set $php_re2c_required_version 1751 IFS=$ac_IFS 1752 php_re2c_required_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}` 1753 php_re2c_required_version="$php_re2c_required_version or later" 1754 1755 if test -z "$php_re2c_num" || test "$php_re2c_num" -lt "$php_re2c_required_num"; then 1756 php_re2c_check=invalid 1757 fi 1758 fi 1759 1760 if test "$php_re2c_check" != "invalid"; then 1761 AC_MSG_RESULT([$php_re2c_version (ok)]) 1762 else 1763 AC_MSG_RESULT([$php_re2c_version (too old)]) 1764 fi 1765 fi 1766 1767 case $php_re2c_check in 1768 ""|invalid[)] 1769 if test ! -f "$abs_srcdir/Zend/zend_language_scanner.c"; then 1770 AC_MSG_ERROR([re2c $php_re2c_required_version or newer is required to generate PHP lexers.]) 1771 fi 1772 1773 RE2C="exit 0;" 1774 ;; 1775 esac 1776 1777 PHP_SUBST(RE2C) 1778]) 1779 1780AC_DEFUN([PHP_PROG_PHP],[ 1781 AC_CHECK_PROG(PHP, php, php) 1782 1783 if test -n "$PHP"; then 1784 AC_MSG_CHECKING([for php version]) 1785 php_version=$($PHP -v | head -n1 | cut -d ' ' -f 2 | cut -d '-' -f 1) 1786 if test -z "$php_version"; then 1787 php_version=0.0.0 1788 fi 1789 ac_IFS=$IFS; IFS="." 1790 set $php_version 1791 IFS=$ac_IFS 1792 php_version_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}` 1793 dnl Minimum supported version for gen_stub.php is PHP 7.4. 1794 if test "$php_version_num" -lt 70400; then 1795 AC_MSG_RESULT([$php_version (too old)]) 1796 unset PHP 1797 else 1798 AC_MSG_RESULT([$php_version (ok)]) 1799 fi 1800 fi 1801 PHP_SUBST(PHP) 1802]) 1803 1804dnl ---------------------------------------------------------------------------- 1805dnl Common setup macros: PHP_SETUP_<what> 1806dnl ---------------------------------------------------------------------------- 1807 1808dnl 1809dnl PHP_SETUP_ICU([shared-add]) 1810dnl 1811dnl Common setup macro for ICU. 1812dnl 1813AC_DEFUN([PHP_SETUP_ICU],[ 1814 PKG_CHECK_MODULES([ICU], [icu-uc >= 50.1 icu-io icu-i18n]) 1815 1816 PHP_EVAL_INCLINE($ICU_CFLAGS) 1817 PHP_EVAL_LIBLINE($ICU_LIBS, $1) 1818 1819 ICU_CFLAGS="$ICU_CFLAGS -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1" 1820 ICU_CXXFLAGS="$ICU_CXXFLAGS -DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit" 1821 1822 if test "$PKG_CONFIG icu-io --atleast-version=60"; then 1823 ICU_CFLAGS="$ICU_CFLAGS -DU_HIDE_OBSOLETE_UTF_OLD_H=1" 1824 fi 1825]) 1826 1827dnl 1828dnl PHP_SETUP_OPENSSL(shared-add [, action-found [, action-not-found]]) 1829dnl 1830dnl Common setup macro for openssl. 1831dnl 1832AC_DEFUN([PHP_SETUP_OPENSSL],[ 1833 found_openssl=no 1834 1835 PKG_CHECK_MODULES([OPENSSL], [openssl >= 1.1.1], [found_openssl=yes]) 1836 1837 if test "$found_openssl" = "yes"; then 1838 PHP_EVAL_LIBLINE($OPENSSL_LIBS, $1) 1839 PHP_EVAL_INCLINE($OPENSSL_CFLAGS) 1840ifelse([$2],[],:,[$2]) 1841ifelse([$3],[],,[else $3]) 1842 fi 1843]) 1844 1845dnl 1846dnl PHP_SETUP_ICONV(shared-add [, action-found [, action-not-found]]) 1847dnl 1848dnl Common setup macro for iconv. 1849dnl 1850AC_DEFUN([PHP_SETUP_ICONV], [ 1851 found_iconv=no 1852 unset ICONV_DIR 1853 1854 dnl Check libc first if no path is provided in --with-iconv. 1855 if test "$PHP_ICONV" = "yes"; then 1856 dnl Reset LIBS temporarily as it may have already been included -liconv in. 1857 LIBS_save="$LIBS" 1858 LIBS= 1859 AC_CHECK_FUNC(iconv, [ 1860 found_iconv=yes 1861 ],[ 1862 AC_CHECK_FUNC(libiconv,[ 1863 AC_DEFINE(HAVE_LIBICONV, 1, [ ]) 1864 found_iconv=yes 1865 ]) 1866 ]) 1867 LIBS="$LIBS_save" 1868 fi 1869 1870 dnl Check external libs for iconv funcs. 1871 if test "$found_iconv" = "no"; then 1872 1873 for i in $PHP_ICONV /usr/local /usr; do 1874 if test -r $i/include/gnu-libiconv/iconv.h; then 1875 ICONV_DIR=$i 1876 ICONV_INCLUDE_DIR=$i/include/gnu-libiconv 1877 iconv_lib_name=iconv 1878 break 1879 elif test -r $i/include/iconv.h; then 1880 ICONV_DIR=$i 1881 ICONV_INCLUDE_DIR=$i/include 1882 iconv_lib_name=iconv 1883 break 1884 fi 1885 done 1886 1887 if test -z "$ICONV_DIR"; then 1888 AC_MSG_ERROR([Please specify the install prefix of iconv with --with-iconv=<DIR>]) 1889 fi 1890 1891 if test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.a || 1892 test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.$SHLIB_SUFFIX_NAME || 1893 test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.tbd 1894 then 1895 PHP_CHECK_LIBRARY($iconv_lib_name, libiconv, [ 1896 found_iconv=yes 1897 AC_DEFINE(HAVE_LIBICONV,1,[ ]) 1898 AC_DEFINE([ICONV_ALIASED_LIBICONV],1,[iconv() is aliased to libiconv() in -liconv]) 1899 ], [ 1900 PHP_CHECK_LIBRARY($iconv_lib_name, iconv, [ 1901 found_iconv=yes 1902 ], [], [ 1903 -L$ICONV_DIR/$PHP_LIBDIR 1904 ]) 1905 ], [ 1906 -L$ICONV_DIR/$PHP_LIBDIR 1907 ]) 1908 fi 1909 fi 1910 1911 if test "$found_iconv" = "yes"; then 1912 AC_DEFINE(HAVE_ICONV,1,[ ]) 1913 if test -n "$ICONV_DIR"; then 1914 PHP_ADD_LIBRARY_WITH_PATH($iconv_lib_name, $ICONV_DIR/$PHP_LIBDIR, $1) 1915 PHP_ADD_INCLUDE($ICONV_INCLUDE_DIR) 1916 fi 1917 $2 1918ifelse([$3],[],,[else $3]) 1919 fi 1920]) 1921 1922dnl 1923dnl PHP_SETUP_LIBXML(shared-add [, action-found]) 1924dnl 1925dnl Common setup macro for libxml. 1926dnl 1927AC_DEFUN([PHP_SETUP_LIBXML], [ 1928 PKG_CHECK_MODULES([LIBXML], [libxml-2.0 >= 2.9.0]) 1929 1930 PHP_EVAL_INCLINE($LIBXML_CFLAGS) 1931 PHP_EVAL_LIBLINE($LIBXML_LIBS, $1) 1932 1933 AC_DEFINE(HAVE_LIBXML, 1, [ ]) 1934 1935 $2 1936]) 1937 1938dnl 1939dnl PHP_SETUP_EXPAT([shared-add]) 1940dnl 1941dnl Common setup macro for expat. 1942dnl 1943AC_DEFUN([PHP_SETUP_EXPAT], [ 1944 PKG_CHECK_MODULES([EXPAT], [expat]) 1945 1946 PHP_EVAL_INCLINE($EXPAT_CFLAGS) 1947 PHP_EVAL_LIBLINE($EXPAT_LIBS, $1) 1948 1949 AC_DEFINE(HAVE_LIBEXPAT, 1, [ ]) 1950]) 1951 1952dnl ---------------------------------------------------------------------------- 1953dnl Misc. macros 1954dnl ---------------------------------------------------------------------------- 1955 1956dnl 1957dnl PHP_INSTALL_HEADERS(path [, file ...]) 1958dnl 1959dnl PHP header files to be installed. 1960dnl 1961AC_DEFUN([PHP_INSTALL_HEADERS],[ 1962 ifelse([$2],[],[ 1963 for header_file in $1; do 1964 PHP_RUN_ONCE(INSTALLHEADERS, $header_file, [ 1965 INSTALL_HEADERS="$INSTALL_HEADERS $header_file" 1966 ]) 1967 done 1968 ], [ 1969 header_path=$1 1970 for header_file in $2; do 1971 hp_hf="$header_path/$header_file" 1972 PHP_RUN_ONCE(INSTALLHEADERS, $hp_hf, [ 1973 INSTALL_HEADERS="$INSTALL_HEADERS $hp_hf" 1974 ]) 1975 done 1976 ]) 1977]) 1978 1979dnl 1980dnl PHP_AP_EXTRACT_VERSION(/path/httpd) 1981dnl 1982dnl This macro is used to get a comparable version for Apache. 1983dnl 1984AC_DEFUN([PHP_AP_EXTRACT_VERSION],[ 1985 ac_output=`$1 -v 2>&1 | grep version | $SED -e 's/Oracle-HTTP-//'` 1986 ac_IFS=$IFS 1987IFS="- /. 1988" 1989 set $ac_output 1990 IFS=$ac_IFS 1991 1992 APACHE_VERSION=`expr [$]4 \* 1000000 + [$]5 \* 1000 + [$]6` 1993]) 1994 1995dnl 1996dnl PHP_CONFIG_NICE(filename) 1997dnl 1998dnl This macro creates script file with given filename which includes the last 1999dnl configure command run by user. This file is named 'config.nice' in PHP. 2000dnl 2001AC_DEFUN([PHP_CONFIG_NICE],[ 2002 AC_REQUIRE([AC_PROG_EGREP]) 2003 AC_REQUIRE([AC_PROG_SED]) 2004 PHP_SUBST_OLD(EGREP) 2005 PHP_SUBST_OLD(SED) 2006 test -f $1 && mv $1 $1.old 2007 rm -f $1.old 2008 cat >$1<<EOF 2009#! /bin/sh 2010# 2011# Created by configure 2012 2013EOF 2014 2015 clean_configure_args=$ac_configure_args 2016 for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS EXTRA_LDFLAGS_PROGRAM LIBS CC CXX; do 2017 eval val=\$$var 2018 if test -n "$val"; then 2019 echo "$var='$val' \\" >> $1 2020 if test `expr "X$ac_configure_args" : ".*${var}.*"` != 0; then 2021 clean_configure_args=$(echo $clean_configure_args | sed -e "s#'$var=$val'##") 2022 fi 2023 fi 2024 done 2025 2026 echo "'[$]0' \\" >> $1 2027 if test `expr " [$]0" : " '.*"` = 0; then 2028 CONFIGURE_COMMAND="$CONFIGURE_COMMAND '[$]0'" 2029 else 2030 CONFIGURE_COMMAND="$CONFIGURE_COMMAND [$]0" 2031 fi 2032 CONFIGURE_ARGS="$clean_configure_args" 2033 while test "X$CONFIGURE_ARGS" != "X"; 2034 do 2035 if CURRENT_ARG=`expr "X$CONFIGURE_ARGS" : "X *\('[[^']]*'\)"` 2036 then 2037 CONFIGURE_ARGS=`expr "X$CONFIGURE_ARGS" : "X *'[[^']]*' \(.*\)"` 2038 elif CURRENT_ARG=`expr "X$CONFIGURE_ARGS" : "X *\([[^ ]]*\)"` 2039 then 2040 CONFIGURE_ARGS=`expr "X$CONFIGURE_ARGS" : "X *[[^ ]]* \(.*\)"` 2041 CURRENT_ARG="'$CURRENT_ARG'" 2042 else 2043 break 2044 fi 2045 AS_ECHO(["$CURRENT_ARG \\"]) >>$1 2046 CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS $CURRENT_ARG" 2047 done 2048 echo '"[$]@"' >> $1 2049 chmod +x $1 2050 CONFIGURE_COMMAND="$CONFIGURE_COMMAND $CONFIGURE_OPTIONS" 2051 PHP_SUBST_OLD(CONFIGURE_COMMAND) 2052 PHP_SUBST_OLD(CONFIGURE_OPTIONS) 2053]) 2054 2055dnl 2056dnl PHP_CHECK_PDO_INCLUDES([found [, not-found]]) 2057dnl 2058AC_DEFUN([PHP_CHECK_PDO_INCLUDES],[ 2059 AC_CACHE_CHECK([for PDO includes], pdo_cv_inc_path, [ 2060 if test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then 2061 pdo_cv_inc_path=$abs_srcdir/ext 2062 elif test -f $phpincludedir/ext/pdo/php_pdo_driver.h; then 2063 pdo_cv_inc_path=$phpincludedir/ext 2064 fi 2065 ]) 2066 if test -n "$pdo_cv_inc_path"; then 2067ifelse([$1],[],:,[$1]) 2068 else 2069ifelse([$2],[],[AC_MSG_ERROR([Cannot find php_pdo_driver.h.])],[$2]) 2070 fi 2071]) 2072 2073dnl 2074dnl PHP_DETECT_ICC 2075dnl 2076dnl Detect Intel C++ Compiler and unset $GCC if ICC found. 2077dnl 2078AC_DEFUN([PHP_DETECT_ICC], 2079[ 2080 ICC="no" 2081 AC_MSG_CHECKING([for icc]) 2082 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER], 2083 ICC="no" 2084 AC_MSG_RESULT([no]), 2085 ICC="yes" 2086 GCC="no" 2087 AC_MSG_RESULT([yes]) 2088 ) 2089]) 2090 2091dnl 2092dnl PHP_DETECT_SUNCC 2093dnl 2094dnl Detect if the systems default compiler is suncc. We also set some useful 2095dnl CFLAGS if the user didn't set any. 2096dnl 2097AC_DEFUN([PHP_DETECT_SUNCC],[ 2098 SUNCC="no" 2099 AC_MSG_CHECKING([for suncc]) 2100 AC_EGREP_CPP([^__SUNPRO_C], [__SUNPRO_C], 2101 SUNCC="no" 2102 AC_MSG_RESULT([no]), 2103 SUNCC="yes" 2104 GCC="no" 2105 test -n "$auto_cflags" && CFLAGS="-O -xs -xstrconst -zlazyload" 2106 GCC="" 2107 AC_MSG_RESULT([yes]) 2108 ) 2109]) 2110 2111dnl 2112dnl PHP_CRYPT_R_STYLE 2113dnl 2114dnl Detect the style of crypt_r() if any is available. 2115dnl See APR_CHECK_CRYPT_R_STYLE() for original version. 2116dnl 2117AC_DEFUN([PHP_CRYPT_R_STYLE], 2118[ 2119 AC_CACHE_CHECK([which data struct is used by crypt_r], php_cv_crypt_r_style,[ 2120 php_cv_crypt_r_style=none 2121 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2122#define _REENTRANT 1 2123#include <crypt.h> 2124]], [[ 2125CRYPTD buffer; 2126crypt_r("passwd", "hash", &buffer); 2127]])],[php_cv_crypt_r_style=cryptd],[]) 2128 2129 if test "$php_cv_crypt_r_style" = "none"; then 2130 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2131#define _REENTRANT 1 2132#include <crypt.h> 2133]],[[ 2134struct crypt_data buffer; 2135crypt_r("passwd", "hash", &buffer); 2136]])],[php_cv_crypt_r_style=struct_crypt_data],[]) 2137 fi 2138 2139 if test "$php_cv_crypt_r_style" = "none"; then 2140 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2141#define _REENTRANT 1 2142#ifndef _GNU_SOURCE 2143#define _GNU_SOURCE 2144#endif 2145#include <crypt.h> 2146]],[[ 2147struct crypt_data buffer; 2148crypt_r("passwd", "hash", &buffer); 2149]])],[php_cv_crypt_r_style=struct_crypt_data_gnu_source],[]) 2150 fi 2151 2152 if test "$php_cv_crypt_r_style" = "none"; then 2153 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2154#include <stdlib.h> 2155#include <unistd.h> 2156]],[[ 2157struct crypt_data buffer; 2158crypt_r("passwd", "hash", &buffer); 2159]])],[php_cv_crypt_r_style=struct_crypt_data],[]) 2160 fi 2161 ]) 2162 2163 if test "$php_cv_crypt_r_style" = "cryptd"; then 2164 AC_DEFINE(CRYPT_R_CRYPTD, 1, [Define if crypt_r has uses CRYPTD]) 2165 fi 2166 if test "$php_cv_crypt_r_style" = "struct_crypt_data" || test "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then 2167 AC_DEFINE(CRYPT_R_STRUCT_CRYPT_DATA, 1, [Define if crypt_r uses struct crypt_data]) 2168 fi 2169 if test "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then 2170 AC_DEFINE(CRYPT_R_GNU_SOURCE, 1, [Define if struct crypt_data requires _GNU_SOURCE]) 2171 fi 2172 if test "$php_cv_crypt_r_style" = "none"; then 2173 AC_MSG_ERROR([Unable to detect data struct used by crypt_r]) 2174 fi 2175]) 2176 2177dnl 2178dnl PHP_TEST_WRITE_STDOUT 2179dnl 2180AC_DEFUN([PHP_TEST_WRITE_STDOUT],[ 2181 AC_CACHE_CHECK(whether writing to stdout works,ac_cv_write_stdout,[ 2182 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 2183#ifdef HAVE_UNISTD_H 2184#include <unistd.h> 2185#endif 2186 2187#define TEXT "This is the test message -- " 2188 2189int main(void) 2190{ 2191 int n; 2192 2193 n = write(1, TEXT, sizeof(TEXT)-1); 2194 return (!(n == sizeof(TEXT)-1)); 2195} 2196 ]])],[ 2197 ac_cv_write_stdout=yes 2198 ],[ 2199 ac_cv_write_stdout=no 2200 ],[ 2201 case $host_alias in 2202 *linux*|*midipix) 2203 ac_cv_write_stdout=yes 2204 ;; 2205 *) 2206 ac_cv_write_stdout=no 2207 ;; 2208 esac 2209 ]) 2210 ]) 2211 if test "$ac_cv_write_stdout" = "yes"; then 2212 AC_DEFINE(PHP_WRITE_STDOUT, 1, [whether write(2) works]) 2213 fi 2214]) 2215 2216dnl 2217dnl PHP_INIT_DTRACE(providerdesc, header-file, sources [, module]) 2218dnl 2219AC_DEFUN([PHP_INIT_DTRACE],[ 2220dnl Set paths properly when called from extension. 2221 case "$4" in 2222 ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir;; 2223 /*[)] ac_srcdir=`echo "$4"|cut -c 2-`"/"; ac_bdir=$ac_srcdir;; 2224 *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$4/";; 2225 esac 2226 2227dnl providerdesc. 2228 ac_provsrc=$1 2229 old_IFS=[$]IFS 2230 IFS=. 2231 set $ac_provsrc 2232 ac_provobj=[$]1 2233 IFS=$old_IFS 2234 2235dnl header-file. 2236 ac_hdrobj=$2 2237 2238dnl Add providerdesc.o or .lo into global objects when needed. 2239 case $host_alias in 2240 *freebsd*) 2241 PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.lo" 2242 PHP_LDFLAGS="$PHP_LDFLAGS -lelf" 2243 ;; 2244 *solaris*) 2245 PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.lo" 2246 ;; 2247 *linux*) 2248 PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.lo" 2249 ;; 2250 esac 2251 2252dnl DTrace objects. 2253 old_IFS=[$]IFS 2254 for ac_src in $3; do 2255 IFS=. 2256 set $ac_src 2257 ac_obj=[$]1 2258 IFS=$old_IFS 2259 2260 PHP_DTRACE_OBJS="[$]PHP_DTRACE_OBJS [$]ac_bdir[$]ac_obj.lo" 2261 done; 2262 2263 case [$]php_sapi_module in 2264 shared[)] 2265 for ac_lo in $PHP_DTRACE_OBJS; do 2266 dtrace_objs="[$]dtrace_objs `echo $ac_lo | $SED -e 's,\.lo$,.o,' -e 's#\(.*\)\/#\1\/.libs\/#'`" 2267 done; 2268 ;; 2269 *[)] 2270 dtrace_objs='$(PHP_DTRACE_OBJS:.lo=.o)' 2271 ;; 2272 esac 2273 2274dnl Generate Makefile.objects entries. The empty $ac_provsrc command stops an 2275dnl implicit circular dependency in GNU Make which causes the .d file to be 2276dnl overwritten (Bug 61268). 2277 cat>>Makefile.objects<<EOF 2278 2279$abs_srcdir/$ac_provsrc:; 2280 2281$ac_bdir[$]ac_hdrobj: $abs_srcdir/$ac_provsrc 2282 CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHP_,DTRACE_,g' \$[]@.bak > \$[]@ 2283 2284\$(PHP_DTRACE_OBJS): $ac_bdir[$]ac_hdrobj 2285 2286EOF 2287 2288 case $host_alias in 2289 *solaris*|*linux*|*freebsd*) 2290 dtrace_prov_name="`echo $ac_provsrc | $SED -e 's#\(.*\)\/##'`.o" 2291 dtrace_lib_dir="`echo $ac_bdir[$]ac_provsrc | $SED -e 's#\(.*\)/[^/]*#\1#'`/.libs" 2292 dtrace_d_obj="`echo $ac_bdir[$]ac_provsrc | $SED -e 's#\(.*\)/\([^/]*\)#\1/.libs/\2#'`.o" 2293 dtrace_nolib_objs='$(PHP_DTRACE_OBJS:.lo=.o)' 2294 for ac_lo in $PHP_DTRACE_OBJS; do 2295 dtrace_lib_objs="[$]dtrace_lib_objs `echo $ac_lo | $SED -e 's,\.lo$,.o,' -e 's#\(.*\)\/#\1\/.libs\/#'`" 2296 done; 2297 dnl Always attempt to create both PIC and non-PIC DTrace objects (Bug 63692) 2298 cat>>Makefile.objects<<EOF 2299$ac_bdir[$]ac_provsrc.lo: \$(PHP_DTRACE_OBJS) 2300 echo "[#] Generated by Makefile for libtool" > \$[]@ 2301 @test -d "$dtrace_lib_dir" || mkdir $dtrace_lib_dir 2302 if CC="\$(CC)" 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 [\\] 2303 echo "pic_object=['].libs/$dtrace_prov_name[']" >> \$[]@ [;\\] 2304 else [\\] 2305 echo "pic_object='none'" >> \$[]@ [;\\] 2306 fi 2307 if CC="\$(CC)" 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 [\\] 2308 echo "non_pic_object=[']$dtrace_prov_name[']" >> \$[]@ [;\\] 2309 else [\\] 2310 echo "non_pic_object='none'" >> \$[]@ [;\\] 2311 fi 2312 2313EOF 2314 2315 ;; 2316 *) 2317cat>>Makefile.objects<<EOF 2318$ac_bdir[$]ac_provsrc.o: \$(PHP_DTRACE_OBJS) 2319 CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $abs_srcdir/$ac_provsrc $dtrace_objs 2320 2321EOF 2322 ;; 2323 esac 2324]) 2325 2326dnl 2327dnl PHP_CHECK_STDINT_TYPES 2328dnl 2329AC_DEFUN([PHP_CHECK_STDINT_TYPES], [ 2330 AC_CHECK_SIZEOF([int]) 2331 AC_CHECK_SIZEOF([long]) 2332 AC_CHECK_SIZEOF([long long]) 2333 AC_CHECK_SIZEOF([size_t]) 2334 AC_CHECK_SIZEOF([off_t]) 2335]) 2336 2337dnl 2338dnl PHP_CHECK_BUILTIN_EXPECT 2339dnl 2340AC_DEFUN([PHP_CHECK_BUILTIN_EXPECT], [ 2341 AC_MSG_CHECKING([for __builtin_expect]) 2342 2343 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2344 return __builtin_expect(1,1) ? 1 : 0; 2345 ]])], [ 2346 have_builtin_expect=1 2347 AC_MSG_RESULT([yes]) 2348 ], [ 2349 have_builtin_expect=0 2350 AC_MSG_RESULT([no]) 2351 ]) 2352 2353 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_EXPECT], [$have_builtin_expect], [Whether the compiler supports __builtin_expect]) 2354]) 2355 2356dnl 2357dnl PHP_CHECK_BUILTIN_UNREACHABLE 2358dnl 2359AC_DEFUN([PHP_CHECK_BUILTIN_UNREACHABLE], [ 2360 AC_MSG_CHECKING([for __builtin_unreachable]) 2361 2362 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2363 __builtin_unreachable(); 2364 ]])], [ 2365 have_builtin_unreachable=1 2366 AC_MSG_RESULT([yes]) 2367 ], [ 2368 have_builtin_unreachable=0 2369 AC_MSG_RESULT([no]) 2370 ]) 2371 2372 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_UNREACHABLE], [$have_builtin_unreachable], [Whether the compiler supports __builtin_unreachable]) 2373]) 2374 2375dnl 2376dnl PHP_CHECK_BUILTIN_CLZ 2377dnl 2378AC_DEFUN([PHP_CHECK_BUILTIN_CLZ], [ 2379 AC_MSG_CHECKING([for __builtin_clz]) 2380 2381 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2382 return __builtin_clz(1) ? 1 : 0; 2383 ]])], [ 2384 have_builtin_clz=1 2385 AC_MSG_RESULT([yes]) 2386 ], [ 2387 have_builtin_clz=0 2388 AC_MSG_RESULT([no]) 2389 ]) 2390 2391 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CLZ], [$have_builtin_clz], [Whether the compiler supports __builtin_clz]) 2392]) 2393 2394dnl 2395dnl PHP_CHECK_BUILTIN_CLZL 2396dnl 2397AC_DEFUN([PHP_CHECK_BUILTIN_CLZL], [ 2398 AC_MSG_CHECKING([for __builtin_clzl]) 2399 2400 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2401 return __builtin_clzl(1) ? 1 : 0; 2402 ]])], [ 2403 have_builtin_clzl=1 2404 AC_MSG_RESULT([yes]) 2405 ], [ 2406 have_builtin_clzl=0 2407 AC_MSG_RESULT([no]) 2408 ]) 2409 2410 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CLZL], [$have_builtin_clzl], [Whether the compiler supports __builtin_clzl]) 2411]) 2412 2413dnl 2414dnl PHP_CHECK_BUILTIN_CLZLL 2415dnl 2416AC_DEFUN([PHP_CHECK_BUILTIN_CLZLL], [ 2417 AC_MSG_CHECKING([for __builtin_clzll]) 2418 2419 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2420 return __builtin_clzll(1) ? 1 : 0; 2421 ]])], [ 2422 have_builtin_clzll=1 2423 AC_MSG_RESULT([yes]) 2424 ], [ 2425 have_builtin_clzll=0 2426 AC_MSG_RESULT([no]) 2427 ]) 2428 2429 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CLZLL], [$have_builtin_clzll], [Whether the compiler supports __builtin_clzll]) 2430]) 2431 2432dnl 2433dnl PHP_CHECK_BUILTIN_CTZL 2434dnl 2435AC_DEFUN([PHP_CHECK_BUILTIN_CTZL], [ 2436 AC_MSG_CHECKING([for __builtin_ctzl]) 2437 2438 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2439 return __builtin_ctzl(2L) ? 1 : 0; 2440 ]])], [ 2441 have_builtin_ctzl=1 2442 AC_MSG_RESULT([yes]) 2443 ], [ 2444 have_builtin_ctzl=0 2445 AC_MSG_RESULT([no]) 2446 ]) 2447 2448 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CTZL], [$have_builtin_ctzl], [Whether the compiler supports __builtin_ctzl]) 2449]) 2450 2451dnl 2452dnl PHP_CHECK_BUILTIN_CTZLL 2453dnl 2454AC_DEFUN([PHP_CHECK_BUILTIN_CTZLL], [ 2455 AC_MSG_CHECKING([for __builtin_ctzll]) 2456 2457 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2458 return __builtin_ctzll(2LL) ? 1 : 0; 2459 ]])], [ 2460 have_builtin_ctzll=1 2461 AC_MSG_RESULT([yes]) 2462 ], [ 2463 have_builtin_ctzll=0 2464 AC_MSG_RESULT([no]) 2465 ]) 2466 2467 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CTZLL], [$have_builtin_ctzll], [Whether the compiler supports __builtin_ctzll]) 2468]) 2469 2470dnl 2471dnl PHP_CHECK_BUILTIN_SMULL_OVERFLOW 2472dnl 2473AC_DEFUN([PHP_CHECK_BUILTIN_SMULL_OVERFLOW], [ 2474 AC_MSG_CHECKING([for __builtin_smull_overflow]) 2475 2476 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2477 long tmpvar; 2478 return __builtin_smull_overflow(3, 7, &tmpvar); 2479 ]])], [ 2480 have_builtin_smull_overflow=1 2481 AC_MSG_RESULT([yes]) 2482 ], [ 2483 have_builtin_smull_overflow=0 2484 AC_MSG_RESULT([no]) 2485 ]) 2486 2487 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SMULL_OVERFLOW], 2488 [$have_builtin_smull_overflow], [Whether the compiler supports __builtin_smull_overflow]) 2489]) 2490 2491dnl 2492dnl PHP_CHECK_BUILTIN_SMULLL_OVERFLOW 2493dnl 2494AC_DEFUN([PHP_CHECK_BUILTIN_SMULLL_OVERFLOW], [ 2495 AC_MSG_CHECKING([for __builtin_smulll_overflow]) 2496 2497 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2498 long long tmpvar; 2499 return __builtin_smulll_overflow(3, 7, &tmpvar); 2500 ]])], [ 2501 have_builtin_smulll_overflow=1 2502 AC_MSG_RESULT([yes]) 2503 ], [ 2504 have_builtin_smulll_overflow=0 2505 AC_MSG_RESULT([no]) 2506 ]) 2507 2508 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SMULLL_OVERFLOW], 2509 [$have_builtin_smulll_overflow], [Whether the compiler supports __builtin_smulll_overflow]) 2510]) 2511 2512dnl 2513dnl PHP_CHECK_BUILTIN_SADDL_OVERFLOW 2514dnl 2515AC_DEFUN([PHP_CHECK_BUILTIN_SADDL_OVERFLOW], [ 2516 AC_MSG_CHECKING([for __builtin_saddl_overflow]) 2517 2518 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2519 long tmpvar; 2520 return __builtin_saddl_overflow(3, 7, &tmpvar); 2521 ]])], [ 2522 have_builtin_saddl_overflow=1 2523 AC_MSG_RESULT([yes]) 2524 ], [ 2525 have_builtin_saddl_overflow=0 2526 AC_MSG_RESULT([no]) 2527 ]) 2528 2529 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SADDL_OVERFLOW], 2530 [$have_builtin_saddl_overflow], [Whether the compiler supports __builtin_saddl_overflow]) 2531]) 2532 2533dnl 2534dnl PHP_CHECK_BUILTIN_SADDLL_OVERFLOW 2535dnl 2536AC_DEFUN([PHP_CHECK_BUILTIN_SADDLL_OVERFLOW], [ 2537 AC_MSG_CHECKING([for __builtin_saddll_overflow]) 2538 2539 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2540 long long tmpvar; 2541 return __builtin_saddll_overflow(3, 7, &tmpvar); 2542 ]])], [ 2543 have_builtin_saddll_overflow=1 2544 AC_MSG_RESULT([yes]) 2545 ], [ 2546 have_builtin_saddll_overflow=0 2547 AC_MSG_RESULT([no]) 2548 ]) 2549 2550 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SADDLL_OVERFLOW], 2551 [$have_builtin_saddll_overflow], [Whether the compiler supports __builtin_saddll_overflow]) 2552]) 2553 2554dnl 2555dnl PHP_CHECK_BUILTIN_USUB_OVERFLOW 2556dnl 2557AC_DEFUN([PHP_CHECK_BUILTIN_USUB_OVERFLOW], [ 2558 AC_MSG_CHECKING([for __builtin_usub_overflow]) 2559 2560 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2561 unsigned int tmpvar; 2562 return __builtin_usub_overflow(3, 7, &tmpvar); 2563 ]])], [ 2564 have_builtin_usub_overflow=1 2565 AC_MSG_RESULT([yes]) 2566 ], [ 2567 have_builtin_usub_overflow=0 2568 AC_MSG_RESULT([no]) 2569 ]) 2570 2571 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_USUB_OVERFLOW], 2572 [$have_builtin_usub_overflow], [Whether the compiler supports __builtin_usub_overflow]) 2573]) 2574 2575dnl 2576dnl PHP_CHECK_BUILTIN_SSUBL_OVERFLOW 2577dnl 2578AC_DEFUN([PHP_CHECK_BUILTIN_SSUBL_OVERFLOW], [ 2579 AC_MSG_CHECKING([for __builtin_ssubl_overflow]) 2580 2581 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2582 long tmpvar; 2583 return __builtin_ssubl_overflow(3, 7, &tmpvar); 2584 ]])], [ 2585 have_builtin_ssubl_overflow=1 2586 AC_MSG_RESULT([yes]) 2587 ], [ 2588 have_builtin_ssubl_overflow=0 2589 AC_MSG_RESULT([no]) 2590 ]) 2591 2592 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SSUBL_OVERFLOW], 2593 [$have_builtin_ssubl_overflow], [Whether the compiler supports __builtin_ssubl_overflow]) 2594]) 2595 2596dnl 2597dnl PHP_CHECK_BUILTIN_SSUBLL_OVERFLOW 2598dnl 2599AC_DEFUN([PHP_CHECK_BUILTIN_SSUBLL_OVERFLOW], [ 2600 AC_MSG_CHECKING([for __builtin_ssubll_overflow]) 2601 2602 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2603 long long tmpvar; 2604 return __builtin_ssubll_overflow(3, 7, &tmpvar); 2605 ]])], [ 2606 have_builtin_ssubll_overflow=1 2607 AC_MSG_RESULT([yes]) 2608 ], [ 2609 have_builtin_ssubll_overflow=0 2610 AC_MSG_RESULT([no]) 2611 ]) 2612 2613 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SSUBLL_OVERFLOW], 2614 [$have_builtin_ssubll_overflow], [Whether the compiler supports __builtin_ssubll_overflow]) 2615]) 2616 2617dnl 2618dnl PHP_CHECK_BUILTIN_CPU_INIT 2619dnl 2620AC_DEFUN([PHP_CHECK_BUILTIN_CPU_INIT], [ 2621 AC_MSG_CHECKING([for __builtin_cpu_init]) 2622 2623 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2624 __builtin_cpu_init(); 2625 ]])], [ 2626 have_builtin_cpu_init=1 2627 AC_MSG_RESULT([yes]) 2628 ], [ 2629 have_builtin_cpu_init=0 2630 AC_MSG_RESULT([no]) 2631 ]) 2632 2633 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CPU_INIT], 2634 [$have_builtin_cpu_init], [Whether the compiler supports __builtin_cpu_init]) 2635]) 2636 2637dnl 2638dnl PHP_CHECK_BUILTIN_CPU_SUPPORTS 2639dnl 2640AC_DEFUN([PHP_CHECK_BUILTIN_CPU_SUPPORTS], [ 2641 AC_MSG_CHECKING([for __builtin_cpu_supports]) 2642 2643 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2644 return __builtin_cpu_supports("sse")? 1 : 0; 2645 ]])], [ 2646 have_builtin_cpu_supports=1 2647 AC_MSG_RESULT([yes]) 2648 ], [ 2649 have_builtin_cpu_supports=0 2650 AC_MSG_RESULT([no]) 2651 ]) 2652 2653 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CPU_SUPPORTS], 2654 [$have_builtin_cpu_supports], [Whether the compiler supports __builtin_cpu_supports]) 2655]) 2656 2657dnl 2658dnl PHP_CHECK_BUILTIN_FRAME_ADDRESS 2659dnl 2660AC_DEFUN([PHP_CHECK_BUILTIN_FRAME_ADDRESS], [ 2661 AC_MSG_CHECKING([for __builtin_frame_address]) 2662 2663 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2664 return __builtin_frame_address(0) != (void*)0; 2665 ]])], [ 2666 have_builtin_frame_address=1 2667 AC_MSG_RESULT([yes]) 2668 ], [ 2669 have_builtin_frame_address=0 2670 AC_MSG_RESULT([no]) 2671 ]) 2672 2673 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_FRAME_ADDRESS], 2674 [$have_builtin_frame_address], [Whether the compiler supports __builtin_frame_address]) 2675]) 2676 2677dnl 2678dnl PHP_PATCH_CONFIG_HEADERS([FILE]) 2679dnl 2680dnl PACKAGE_* symbols are automatically defined by Autoconf. When including 2681dnl configuration header, warnings about redefined symbols are emitted for such 2682dnl symbols if they are defined by multiple libraries. This disables all 2683dnl PACKAGE_* symbols in the generated configuration header template FILE. For 2684dnl example, main/php_config.h.in for PHP or config.h.in for PHP extensions. 2685dnl 2686AC_DEFUN([PHP_PATCH_CONFIG_HEADERS], [ 2687 AC_MSG_NOTICE([patching $1]) 2688 2689 $SED -e 's/^#undef PACKAGE_[^ ]*/\/\* & \*\//g' < $srcdir/$1 \ 2690 > $srcdir/$1.tmp && mv $srcdir/$1.tmp $srcdir/$1 2691]) 2692 2693dnl 2694dnl PHP_CHECK_AVX512_SUPPORTS 2695dnl 2696AC_DEFUN([PHP_CHECK_AVX512_SUPPORTS], [ 2697 AC_MSG_CHECKING([for avx512 supports in compiler]) 2698 save_CFLAGS="$CFLAGS" 2699 CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw $CFLAGS" 2700 2701 AC_LINK_IFELSE([AC_LANG_SOURCE([[ 2702 #include <immintrin.h> 2703 int main(void) { 2704 __m512i mask = _mm512_set1_epi32(0x1); 2705 char out[32]; 2706 _mm512_storeu_si512(out, _mm512_shuffle_epi8(mask, mask)); 2707 return 0; 2708 }]])], [ 2709 have_avx512_supports=1 2710 AC_MSG_RESULT([yes]) 2711 ], [ 2712 have_avx512_supports=0 2713 AC_MSG_RESULT([no]) 2714 ]) 2715 2716 CFLAGS="$save_CFLAGS" 2717 2718 AC_DEFINE_UNQUOTED([PHP_HAVE_AVX512_SUPPORTS], 2719 [$have_avx512_supports], [Whether the compiler supports AVX512]) 2720]) 2721 2722dnl 2723dnl PHP_CHECK_AVX512_VBMI_SUPPORTS 2724dnl 2725AC_DEFUN([PHP_CHECK_AVX512_VBMI_SUPPORTS], [ 2726 AC_MSG_CHECKING([for avx512 vbmi supports in compiler]) 2727 save_CFLAGS="$CFLAGS" 2728 CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw -mavx512vbmi $CFLAGS" 2729 AC_LINK_IFELSE([AC_LANG_SOURCE([[ 2730 #include <immintrin.h> 2731 int main(void) { 2732 __m512i mask = _mm512_set1_epi32(0x1); 2733 char out[32]; 2734 _mm512_storeu_si512(out, _mm512_permutexvar_epi8(mask, mask)); 2735 return 0; 2736 }]])], [ 2737 have_avx512_vbmi_supports=1 2738 AC_MSG_RESULT([yes]) 2739 ], [ 2740 have_avx512_vbmi_supports=0 2741 AC_MSG_RESULT([no]) 2742 ]) 2743 CFLAGS="$save_CFLAGS" 2744 AC_DEFINE_UNQUOTED([PHP_HAVE_AVX512_VBMI_SUPPORTS], 2745 [$have_avx512_vbmi_supports], [Whether the compiler supports AVX512 VBMI]) 2746]) 2747