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_pwrite", 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_pread 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_pread", 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]) 1177 1178dnl 1179dnl PHP_PWRITE_TEST 1180dnl 1181AC_DEFUN([PHP_PWRITE_TEST],[ 1182 AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[ 1183 PHP_DOES_PWRITE_WORK 1184 if test "$ac_cv_pwrite" = "no"; then 1185 PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);]) 1186 if test "$ac_cv_pwrite" = "yes"; then 1187 ac_cv_pwrite=64 1188 fi 1189 fi 1190 ]) 1191 1192 if test "$ac_cv_pwrite" != "no"; then 1193 AC_DEFINE(HAVE_PWRITE, 1, [ ]) 1194 if test "$ac_cv_pwrite" = "64"; then 1195 AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default]) 1196 fi 1197 fi 1198]) 1199 1200dnl 1201dnl PHP_PREAD_TEST 1202dnl 1203AC_DEFUN([PHP_PREAD_TEST],[ 1204 AC_CACHE_CHECK(whether pread works,ac_cv_pread,[ 1205 PHP_DOES_PREAD_WORK 1206 if test "$ac_cv_pread" = "no"; then 1207 PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);]) 1208 if test "$ac_cv_pread" = "yes"; then 1209 ac_cv_pread=64 1210 fi 1211 fi 1212 ]) 1213 1214 if test "$ac_cv_pread" != "no"; then 1215 AC_DEFINE(HAVE_PREAD, 1, [ ]) 1216 if test "$ac_cv_pread" = "64"; then 1217 AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default]) 1218 fi 1219 fi 1220]) 1221 1222dnl 1223dnl PHP_MISSING_TIME_R_DECL 1224dnl 1225AC_DEFUN([PHP_MISSING_TIME_R_DECL],[ 1226AC_CHECK_DECL([localtime_r],, 1227 [AC_DEFINE([MISSING_LOCALTIME_R_DECL], [1], [Whether localtime_r is declared])], 1228 [#include <time.h>]) 1229AC_CHECK_DECL([gmtime_r],, 1230 [AC_DEFINE([MISSING_GMTIME_R_DECL], [1], [Whether gmtime_r is declared])], 1231 [#include <time.h>]) 1232AC_CHECK_DECL([asctime_r],, 1233 [AC_DEFINE([MISSING_ASCTIME_R_DECL], [1], [Whether asctime_r is declared])], 1234 [#include <time.h>]) 1235AC_CHECK_DECL([ctime_r],, 1236 [AC_DEFINE([MISSING_CTIME_R_DECL], [1], [Whether ctime_r is declared])], 1237 [#include <time.h>]) 1238AC_CHECK_DECL([strtok_r],, 1239 [AC_DEFINE([MISSING_STRTOK_R_DECL], [1], [Whether strtok_r is declared])], 1240 [#include <string.h>]) 1241]) 1242 1243dnl 1244dnl PHP_EBCDIC 1245dnl 1246AC_DEFUN([PHP_EBCDIC], [ 1247 AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[ 1248 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1249int main(void) { 1250 return (unsigned char)'A' != (unsigned char)0xC1; 1251} 1252]])],[ 1253 ac_cv_ebcdic=yes 1254],[ 1255 ac_cv_ebcdic=no 1256],[ 1257 ac_cv_ebcdic=no 1258])]) 1259 if test "$ac_cv_ebcdic" = "yes"; then 1260 AC_MSG_ERROR([PHP does not support EBCDIC targets]) 1261 fi 1262]) 1263 1264dnl 1265dnl PHP_BROKEN_GETCWD 1266dnl 1267dnl Some systems, notably Solaris, cause getcwd() or realpath to fail if a 1268dnl component of the path has execute but not read permissions. 1269dnl 1270AC_DEFUN([PHP_BROKEN_GETCWD],[ 1271 AC_MSG_CHECKING([for broken getcwd]) 1272 os=`uname -sr 2>/dev/null` 1273 case $os in 1274 SunOS*[)] 1275 AC_DEFINE(HAVE_BROKEN_GETCWD,1, [Define if system has broken getcwd]) 1276 AC_MSG_RESULT([yes]);; 1277 *[)] 1278 AC_MSG_RESULT([no]);; 1279 esac 1280]) 1281 1282dnl 1283dnl PHP_BROKEN_GCC_STRLEN_OPT 1284dnl 1285dnl Early releases of GCC 8 shipped with a strlen() optimization bug, so they 1286dnl didn't properly handle the `char val[1]` struct hack. See bug #76510. 1287dnl 1288AC_DEFUN([PHP_BROKEN_GCC_STRLEN_OPT], [ 1289 AC_CACHE_CHECK([for broken gcc optimize-strlen],ac_cv_have_broken_gcc_strlen_opt,[ 1290 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1291#include <stdlib.h> 1292#include <string.h> 1293#include <stdio.h> 1294struct s 1295{ 1296 int i; 1297 char c[1]; 1298}; 1299int main(void) 1300{ 1301 struct s *s = malloc(sizeof(struct s) + 3); 1302 s->i = 3; 1303 strcpy(s->c, "foo"); 1304 return strlen(s->c+1) == 2; 1305} 1306]])],[ 1307 ac_cv_have_broken_gcc_strlen_opt=yes 1308],[ 1309 ac_cv_have_broken_gcc_strlen_opt=no 1310],[ 1311 ac_cv_have_broken_gcc_strlen_opt=no 1312])]) 1313 if test "$ac_cv_have_broken_gcc_strlen_opt" = "yes"; then 1314 CFLAGS="$CFLAGS -fno-optimize-strlen" 1315 fi 1316]) 1317 1318dnl 1319dnl PHP_FOPENCOOKIE 1320dnl 1321dnl Check for cookie_io_functions_t type and fopencookie(). When using glibc, 1322dnl checks here require _GNU_SOURCE defined via AC_USE_SYSTEM_EXTENSIONS. Some 1323dnl glibc versions started using the off64_t in fopencookie seeker definition, 1324dnl which is in transition to use the POSIX standard off_t on 32-bit (with large 1325dnl file support enabled) and 64-bit. 1326dnl 1327AC_DEFUN([PHP_FOPENCOOKIE], 1328[AC_CHECK_TYPE([cookie_io_functions_t], [AC_CHECK_FUNCS([fopencookie])],, 1329 [#include <stdio.h>]) 1330dnl Check if glibc might use off64_t seeker definition. 1331AS_VAR_IF([ac_cv_func_fopencookie], [yes], 1332 [AC_CACHE_CHECK([whether fopencookie seeker uses off64_t], 1333 [php_cv_type_cookie_off64_t], 1334 [AC_RUN_IFELSE([AC_LANG_SOURCE([ 1335#include <stdio.h> 1336#include <stdlib.h> 1337 1338struct cookiedata { 1339 off64_t pos; 1340}; 1341 1342ssize_t reader(void *cookie, char *buffer, size_t size) 1343{ (void)cookie; (void)buffer; return size; } 1344ssize_t writer(void *cookie, const char *buffer, size_t size) 1345{ (void)cookie; (void)buffer; return size; } 1346int closer(void *cookie) 1347{ (void)cookie; return 0; } 1348int seeker(void *cookie, off64_t *position, int whence) 1349{ ((struct cookiedata*)cookie)->pos = *position; (void)whence; return 0; } 1350 1351cookie_io_functions_t funcs = {reader, writer, seeker, closer}; 1352 1353int main(void) { 1354 struct cookiedata g = { 0 }; 1355 FILE *fp = fopencookie(&g, "r", funcs); 1356 if (fp && fseek(fp, 8192, SEEK_SET) == 0 && g.pos == 8192) { 1357 return 0; 1358 } 1359 return 1; 1360} 1361])], 1362 [php_cv_type_cookie_off64_t=yes], 1363 [php_cv_type_cookie_off64_t=no], 1364 [AS_CASE([$host_alias], 1365 [*linux*], [php_cv_type_cookie_off64_t=yes], 1366 [php_cv_type_cookie_off64_t=no])] 1367 )]) 1368 AS_VAR_IF([php_cv_type_cookie_off64_t], [yes], 1369 [AC_DEFINE([COOKIE_SEEKER_USES_OFF64_T], [1], 1370 [Whether fopencookie seeker uses off64_t.])]) 1371]) 1372]) 1373 1374dnl ---------------------------------------------------------------------------- 1375dnl Library/function existence and build sanity checks. 1376dnl ---------------------------------------------------------------------------- 1377 1378dnl 1379dnl PHP_CHECK_LIBRARY(library, function [, action-found [, action-not-found [, extra-libs]]]) 1380dnl 1381dnl Wrapper for AC_CHECK_LIB. 1382dnl 1383AC_DEFUN([PHP_CHECK_LIBRARY], [ 1384 save_old_LDFLAGS=$LDFLAGS 1385 ac_stuff="$5" 1386 1387 save_ext_shared=$ext_shared 1388 ext_shared=yes 1389 PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS) 1390 AC_CHECK_LIB([$1],[$2],[ 1391 LDFLAGS=$save_old_LDFLAGS 1392 ext_shared=$save_ext_shared 1393 $3 1394 ],[ 1395 LDFLAGS=$save_old_LDFLAGS 1396 ext_shared=$save_ext_shared 1397 unset ac_cv_lib_$1[]_$2 1398 $4 1399 ])dnl 1400]) 1401 1402dnl 1403dnl PHP_CHECK_FRAMEWORK(framework, function [, action-found [, action-not-found ]]) 1404dnl 1405dnl El cheapo wrapper for AC_CHECK_LIB. 1406dnl 1407AC_DEFUN([PHP_CHECK_FRAMEWORK], [ 1408 save_old_LDFLAGS=$LDFLAGS 1409 LDFLAGS="-framework $1 $LDFLAGS" 1410 dnl Supplying "c" to AC_CHECK_LIB is technically cheating, but rewriting 1411 dnl AC_CHECK_LIB is overkill and this only affects the "checking.." output 1412 dnl anyway. 1413 AC_CHECK_LIB(c,[$2],[ 1414 LDFLAGS=$save_old_LDFLAGS 1415 $3 1416 ],[ 1417 LDFLAGS=$save_old_LDFLAGS 1418 $4 1419 ]) 1420]) 1421 1422dnl 1423dnl PHP_CHECK_FUNC_LIB(func, libs) 1424dnl 1425dnl This macro checks whether 'func' or '__func' exists in the specified 1426dnl library. Defines HAVE_func and HAVE_library if found and adds the library to 1427dnl LIBS. This should be called in the ACTION-IF-NOT-FOUND part of 1428dnl PHP_CHECK_FUNC. 1429dnl 1430dnl autoconf undefines the builtin "shift" :-( 1431dnl If possible, we use the builtin shift anyway, otherwise we use the ubercool 1432dnl definition that has been tested so far with FreeBSD/GNU m4. 1433dnl 1434ifdef([builtin],[builtin(define, phpshift, [builtin(shift, $@)])],[ 1435define([phpshift],[ifelse(index([$@],[,]),-1,,[substr([$@],incr(index([$@],[,])))])]) 1436]) 1437 1438dnl 1439dnl PHP_CHECK_FUNC_LIB 1440dnl 1441AC_DEFUN([PHP_CHECK_FUNC_LIB],[ 1442 ifelse($2,,:,[ 1443 unset ac_cv_lib_$2[]_$1 1444 unset ac_cv_lib_$2[]___$1 1445 unset found 1446 AC_CHECK_LIB($2, $1, [found=yes], [ 1447 AC_CHECK_LIB($2, __$1, [found=yes], [found=no]) 1448 ]) 1449 1450 if test "$found" = "yes"; then 1451 ac_libs=$LIBS 1452 LIBS="$LIBS -l$2" 1453 AC_RUN_IFELSE([AC_LANG_PROGRAM()],[found=yes],[found=no],[ 1454 dnl Cross compilation. 1455 found=yes 1456 ]) 1457 LIBS=$ac_libs 1458 fi 1459 1460 if test "$found" = "yes"; then 1461 PHP_ADD_LIBRARY($2) 1462 PHP_DEF_HAVE($1) 1463 PHP_DEF_HAVE(lib$2) 1464 ac_cv_func_$1=yes 1465 else 1466 PHP_CHECK_FUNC_LIB($1,phpshift(phpshift($@))) 1467 fi 1468 ]) 1469]) 1470 1471dnl 1472dnl PHP_CHECK_FUNC(func, ...) 1473dnl 1474dnl This macro checks whether 'func' or '__func' exists in the default libraries 1475dnl and as a fall back in the specified library. Defines HAVE_func and 1476dnl HAVE_library if found and adds the library to LIBS. 1477dnl 1478AC_DEFUN([PHP_CHECK_FUNC],[ 1479 unset ac_cv_func_$1 1480 unset ac_cv_func___$1 1481 unset found 1482 1483 AC_CHECK_FUNC($1, [found=yes],[ AC_CHECK_FUNC(__$1,[found=yes],[found=no]) ]) 1484 1485 case $found in 1486 yes[)] 1487 PHP_DEF_HAVE($1) 1488 ac_cv_func_$1=yes 1489 ;; 1490 ifelse($#,1,,[ 1491 *[)] PHP_CHECK_FUNC_LIB($@) ;; 1492 ]) 1493 esac 1494]) 1495 1496dnl 1497dnl PHP_TEST_BUILD(function, action-if-ok, action-if-not-ok [, extra-libs [, extra-source]]) 1498dnl 1499dnl This macro checks whether build works and given function exists. 1500dnl 1501AC_DEFUN([PHP_TEST_BUILD], [ 1502 old_LIBS=$LIBS 1503 LIBS="$4 $LIBS" 1504 AC_LINK_IFELSE([AC_LANG_SOURCE([[ 1505 $5 1506 char $1(void); 1507 int main(void) { 1508 $1(); 1509 return 0; 1510 } 1511 ]])],[ 1512 LIBS=$old_LIBS 1513 $2 1514 ],[ 1515 LIBS=$old_LIBS 1516 $3 1517 ]) 1518]) 1519 1520dnl ---------------------------------------------------------------------------- 1521dnl Platform characteristics checks. 1522dnl ---------------------------------------------------------------------------- 1523 1524dnl 1525dnl PHP_SHLIB_SUFFIX_NAMES 1526dnl 1527dnl Determines link library suffix SHLIB_SUFFIX_NAME which can be: .so, .sl or 1528dnl .dylib 1529dnl 1530dnl Determines shared library suffix SHLIB_DL_SUFFIX_NAME suffix can be: .so or 1531dnl .sl 1532dnl 1533AC_DEFUN([PHP_SHLIB_SUFFIX_NAMES],[ 1534 AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl 1535 PHP_SUBST_OLD(SHLIB_SUFFIX_NAME) 1536 PHP_SUBST_OLD(SHLIB_DL_SUFFIX_NAME) 1537 SHLIB_SUFFIX_NAME=so 1538 SHLIB_DL_SUFFIX_NAME=$SHLIB_SUFFIX_NAME 1539 case $host_alias in 1540 *hpux*[)] 1541 SHLIB_SUFFIX_NAME=sl 1542 SHLIB_DL_SUFFIX_NAME=sl 1543 ;; 1544 *darwin*[)] 1545 SHLIB_SUFFIX_NAME=dylib 1546 SHLIB_DL_SUFFIX_NAME=so 1547 ;; 1548 esac 1549]) 1550 1551dnl 1552dnl PHP_C_BIGENDIAN 1553dnl 1554dnl Replacement macro for AC_C_BIGENDIAN. 1555dnl 1556AC_DEFUN([PHP_C_BIGENDIAN], 1557[AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian_php, 1558 [ 1559 ac_cv_c_bigendian_php=unknown 1560 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1561int main(void) 1562{ 1563 short one = 1; 1564 char *cp = (char *)&one; 1565 1566 if (*cp == 0) { 1567 return(0); 1568 } else { 1569 return(1); 1570 } 1571} 1572 ]])], [ac_cv_c_bigendian_php=yes], [ac_cv_c_bigendian_php=no], [ac_cv_c_bigendian_php=unknown]) 1573 ]) 1574 if test $ac_cv_c_bigendian_php = yes; then 1575 AC_DEFINE(WORDS_BIGENDIAN, [], [Define if processor uses big-endian word]) 1576 fi 1577]) 1578 1579dnl ---------------------------------------------------------------------------- 1580dnl Checks for programs: PHP_PROG_<program>. 1581dnl ---------------------------------------------------------------------------- 1582 1583dnl 1584dnl PHP_PROG_SENDMAIL 1585dnl 1586dnl Search for the sendmail binary. 1587dnl 1588AC_DEFUN([PHP_PROG_SENDMAIL], [ 1589 PHP_ALT_PATH=/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib 1590 AC_PATH_PROG(PROG_SENDMAIL, sendmail, /usr/sbin/sendmail, $PATH:$PHP_ALT_PATH) 1591]) 1592 1593dnl 1594dnl PHP_PROG_AWK 1595dnl 1596dnl Some vendors force mawk before gawk; mawk is broken so we don't like that. 1597dnl 1598AC_DEFUN([PHP_PROG_AWK], [ 1599 AC_CHECK_PROGS(AWK, gawk nawk awk mawk, bork, /usr/xpg4/bin/:$PATH) 1600 case "$AWK" in 1601 *mawk) 1602 AC_MSG_WARN([mawk is known to have problems on some systems. You should install GNU awk]) 1603 ;; 1604 *gawk) 1605 ;; 1606 bork) 1607 AC_MSG_ERROR([Could not find awk; Install GNU awk]) 1608 ;; 1609 *) 1610 AC_MSG_CHECKING([if $AWK is broken]) 1611 if ! $AWK 'function foo() {}' >/dev/null 2>&1 ; then 1612 AC_MSG_RESULT([yes]) 1613 AC_MSG_ERROR([You should install GNU awk]) 1614 else 1615 AC_MSG_RESULT([no]) 1616 fi 1617 ;; 1618 esac 1619 PHP_SUBST(AWK) 1620]) 1621 1622dnl 1623dnl PHP_PROG_BISON([MIN-VERSION], [EXCLUDED-VERSION...]) 1624dnl 1625dnl Search for bison and optionally check if version is at least the minimum 1626dnl required version MIN-VERSION and doesn't match any of the blank separated 1627dnl list of excluded versions EXCLUDED-VERSION (for example "3.0 3.2"). 1628dnl 1629AC_DEFUN([PHP_PROG_BISON], [ 1630 AC_CHECK_PROG(YACC, bison, bison) 1631 1632 ifelse($1,,php_bison_required_version='',php_bison_required_version="$1") 1633 ifelse($2,,php_bison_excluded_versions='none',php_bison_excluded_versions="$2") 1634 1635 if test -n "$YACC"; then 1636 AC_MSG_CHECKING([for bison version]) 1637 1638 php_bison_version=$($YACC --version 2> /dev/null | grep 'GNU Bison' | cut -d ' ' -f 4 | tr -d a-z) 1639 if test -z "$php_bison_version"; then 1640 php_bison_version=0.0.0 1641 fi 1642 ac_IFS=$IFS; IFS="." 1643 set $php_bison_version 1644 IFS=$ac_IFS 1645 php_bison_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}` 1646 php_bison_branch="[$]1.[$]2" 1647 php_bison_check=ok 1648 1649 if test -z "$php_bison_required_version" && test -z "$php_bison_num"; then 1650 php_bison_check=invalid 1651 elif test -n "$php_bison_required_version"; then 1652 ac_IFS=$IFS; IFS="." 1653 set $php_bison_required_version 1654 IFS=$ac_IFS 1655 php_bison_required_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}` 1656 php_bison_required_version="$php_bison_required_version or later" 1657 1658 if test -z "$php_bison_num" || test "$php_bison_num" -lt "$php_bison_required_num"; then 1659 php_bison_check=invalid 1660 fi 1661 fi 1662 1663 for php_bison_check_version in $php_bison_excluded_versions; do 1664 if test "$php_bison_version" = "$php_bison_check_version" || test "$php_bison_branch" = "$php_bison_check_version"; then 1665 php_bison_check=invalid 1666 break 1667 fi 1668 done 1669 1670 if test "$php_bison_check" != "invalid"; then 1671 PHP_SUBST_OLD([YFLAGS], [-Wall]) 1672 AC_MSG_RESULT([$php_bison_version (ok)]) 1673 else 1674 AC_MSG_RESULT([$php_bison_version]) 1675 fi 1676 fi 1677 1678 case $php_bison_check in 1679 ""|invalid[)] 1680 if test ! -f "$abs_srcdir/Zend/zend_language_parser.h" || test ! -f "$abs_srcdir/Zend/zend_language_parser.c"; then 1681 AC_MSG_ERROR([bison $php_bison_required_version or newer is required to generate PHP parsers (excluded versions: $php_bison_excluded_versions).]) 1682 fi 1683 1684 YACC="exit 0;" 1685 ;; 1686 esac 1687 1688 PHP_SUBST(YACC) 1689]) 1690 1691dnl 1692dnl PHP_PROG_RE2C([min-version], [options]) 1693dnl 1694dnl Search for the re2c and optionally check if version is at least the minimum 1695dnl required version "min-version". The blank-or-newline-separated "options" are 1696dnl the re2c command-line flags substituted into a Makefile variable RE2C_FLAGS 1697dnl which can be added to all re2c invocations. 1698dnl 1699AC_DEFUN([PHP_PROG_RE2C],[ 1700 AC_CHECK_PROG(RE2C, re2c, re2c) 1701 1702 ifelse($1,,php_re2c_required_version='',php_re2c_required_version="$1") 1703 1704 if test -n "$RE2C"; then 1705 AC_MSG_CHECKING([for re2c version]) 1706 1707 php_re2c_version=$($RE2C --version | cut -d ' ' -f 2 2>/dev/null) 1708 if test -z "$php_re2c_version"; then 1709 php_re2c_version=0.0.0 1710 fi 1711 ac_IFS=$IFS; IFS="." 1712 set $php_re2c_version 1713 IFS=$ac_IFS 1714 php_re2c_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}` 1715 php_re2c_check=ok 1716 1717 if test -z "$php_re2c_required_version" && test -z "$php_re2c_num"; then 1718 php_re2c_check=invalid 1719 elif test -n "$php_re2c_required_version"; then 1720 ac_IFS=$IFS; IFS="." 1721 set $php_re2c_required_version 1722 IFS=$ac_IFS 1723 php_re2c_required_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}` 1724 php_re2c_required_version="$php_re2c_required_version or later" 1725 1726 if test -z "$php_re2c_num" || test "$php_re2c_num" -lt "$php_re2c_required_num"; then 1727 php_re2c_check=invalid 1728 fi 1729 fi 1730 1731 if test "$php_re2c_check" != "invalid"; then 1732 AC_MSG_RESULT([$php_re2c_version (ok)]) 1733 else 1734 AC_MSG_RESULT([$php_re2c_version (too old)]) 1735 fi 1736 fi 1737 1738 case $php_re2c_check in 1739 ""|invalid[)] 1740 if test ! -f "$abs_srcdir/Zend/zend_language_scanner.c"; then 1741 AC_MSG_ERROR([re2c $php_re2c_required_version or newer is required to generate PHP lexers.]) 1742 fi 1743 1744 RE2C="exit 0;" 1745 ;; 1746 esac 1747 1748 PHP_SUBST(RE2C) 1749 AS_VAR_SET([RE2C_FLAGS], [m4_normalize([$2])]) 1750 PHP_SUBST([RE2C_FLAGS]) 1751]) 1752 1753AC_DEFUN([PHP_PROG_PHP],[ 1754 AC_CHECK_PROG(PHP, php, php) 1755 1756 if test -n "$PHP"; then 1757 AC_MSG_CHECKING([for php version]) 1758 php_version=$($PHP -v | head -n1 | cut -d ' ' -f 2 | cut -d '-' -f 1) 1759 if test -z "$php_version"; then 1760 php_version=0.0.0 1761 fi 1762 ac_IFS=$IFS; IFS="." 1763 set $php_version 1764 IFS=$ac_IFS 1765 php_version_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}` 1766 dnl Minimum supported version for gen_stub.php is PHP 7.4. 1767 if test "$php_version_num" -lt 70400; then 1768 AC_MSG_RESULT([$php_version (too old)]) 1769 unset PHP 1770 else 1771 AC_MSG_RESULT([$php_version (ok)]) 1772 fi 1773 fi 1774 PHP_SUBST(PHP) 1775]) 1776 1777dnl ---------------------------------------------------------------------------- 1778dnl Common setup macros: PHP_SETUP_<what> 1779dnl ---------------------------------------------------------------------------- 1780 1781dnl 1782dnl PHP_SETUP_ICU([shared-add]) 1783dnl 1784dnl Common setup macro for ICU. 1785dnl 1786AC_DEFUN([PHP_SETUP_ICU],[ 1787 PKG_CHECK_MODULES([ICU], [icu-uc >= 50.1 icu-io icu-i18n]) 1788 1789 PHP_EVAL_INCLINE($ICU_CFLAGS) 1790 PHP_EVAL_LIBLINE($ICU_LIBS, $1) 1791 1792 ICU_CFLAGS="$ICU_CFLAGS -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1" 1793 ICU_CXXFLAGS="$ICU_CXXFLAGS -DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit" 1794 1795 AS_IF([$PKG_CONFIG icu-io --atleast-version=60], 1796 [ICU_CFLAGS="$ICU_CFLAGS -DU_HIDE_OBSOLETE_UTF_OLD_H=1"]) 1797]) 1798 1799dnl 1800dnl PHP_SETUP_OPENSSL(shared-add [, action-found]) 1801dnl 1802dnl Common setup macro for openssl. 1803dnl 1804AC_DEFUN([PHP_SETUP_OPENSSL],[ 1805 found_openssl=no 1806 1807 PKG_CHECK_MODULES([OPENSSL], [openssl >= 1.1.1], [found_openssl=yes]) 1808 1809 if test "$found_openssl" = "yes"; then 1810 PHP_EVAL_LIBLINE($OPENSSL_LIBS, $1) 1811 PHP_EVAL_INCLINE($OPENSSL_CFLAGS) 1812ifelse([$2],[],:,[$2]) 1813 fi 1814]) 1815 1816dnl 1817dnl PHP_SETUP_ICONV(shared-add [, action-found [, action-not-found]]) 1818dnl 1819dnl Common setup macro for iconv. 1820dnl 1821AC_DEFUN([PHP_SETUP_ICONV], [ 1822 found_iconv=no 1823 unset ICONV_DIR 1824 1825 dnl Check libc first if no path is provided in --with-iconv. 1826 if test "$PHP_ICONV" = "yes"; then 1827 dnl Reset LIBS temporarily as it may have already been included -liconv in. 1828 LIBS_save="$LIBS" 1829 LIBS= 1830 AC_CHECK_FUNC([iconv], [ 1831 found_iconv=yes 1832 ],[ 1833 AC_CHECK_FUNC([libiconv], [ 1834 AC_DEFINE(HAVE_LIBICONV, 1, [ ]) 1835 found_iconv=yes 1836 ]) 1837 ]) 1838 LIBS="$LIBS_save" 1839 fi 1840 1841 dnl Check external libs for iconv funcs. 1842 if test "$found_iconv" = "no"; then 1843 1844 for i in $PHP_ICONV /usr/local /usr; do 1845 if test -r $i/include/gnu-libiconv/iconv.h; then 1846 ICONV_DIR=$i 1847 ICONV_INCLUDE_DIR=$i/include/gnu-libiconv 1848 iconv_lib_name=iconv 1849 break 1850 elif test -r $i/include/iconv.h; then 1851 ICONV_DIR=$i 1852 ICONV_INCLUDE_DIR=$i/include 1853 iconv_lib_name=iconv 1854 break 1855 fi 1856 done 1857 1858 if test -z "$ICONV_DIR"; then 1859 AC_MSG_ERROR([Please specify the install prefix of iconv with --with-iconv=<DIR>]) 1860 fi 1861 1862 if test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.a || 1863 test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.$SHLIB_SUFFIX_NAME || 1864 test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.tbd 1865 then 1866 PHP_CHECK_LIBRARY($iconv_lib_name, libiconv, [ 1867 found_iconv=yes 1868 AC_DEFINE(HAVE_LIBICONV,1,[ ]) 1869 AC_DEFINE([ICONV_ALIASED_LIBICONV],1,[iconv() is aliased to libiconv() in -liconv]) 1870 ], [ 1871 PHP_CHECK_LIBRARY($iconv_lib_name, iconv, [ 1872 found_iconv=yes 1873 ], [], [ 1874 -L$ICONV_DIR/$PHP_LIBDIR 1875 ]) 1876 ], [ 1877 -L$ICONV_DIR/$PHP_LIBDIR 1878 ]) 1879 fi 1880 fi 1881 1882 if test "$found_iconv" = "yes"; then 1883 AC_DEFINE(HAVE_ICONV,1,[ ]) 1884 if test -n "$ICONV_DIR"; then 1885 PHP_ADD_LIBRARY_WITH_PATH($iconv_lib_name, $ICONV_DIR/$PHP_LIBDIR, $1) 1886 PHP_ADD_INCLUDE($ICONV_INCLUDE_DIR) 1887 fi 1888 $2 1889ifelse([$3],[],,[else $3]) 1890 fi 1891]) 1892 1893dnl 1894dnl PHP_SETUP_LIBXML(shared-add [, action-found]) 1895dnl 1896dnl Common setup macro for libxml. 1897dnl 1898AC_DEFUN([PHP_SETUP_LIBXML], [ 1899 PKG_CHECK_MODULES([LIBXML], [libxml-2.0 >= 2.9.0]) 1900 1901 PHP_EVAL_INCLINE($LIBXML_CFLAGS) 1902 PHP_EVAL_LIBLINE($LIBXML_LIBS, $1) 1903 1904 AC_DEFINE(HAVE_LIBXML, 1, [ ]) 1905 1906 $2 1907]) 1908 1909dnl 1910dnl PHP_SETUP_EXPAT([shared-add]) 1911dnl 1912dnl Common setup macro for expat. 1913dnl 1914AC_DEFUN([PHP_SETUP_EXPAT], [ 1915 PKG_CHECK_MODULES([EXPAT], [expat]) 1916 1917 PHP_EVAL_INCLINE($EXPAT_CFLAGS) 1918 PHP_EVAL_LIBLINE($EXPAT_LIBS, $1) 1919 1920 AC_DEFINE(HAVE_LIBEXPAT, 1, [ ]) 1921]) 1922 1923dnl 1924dnl PHP_SETUP_SQLITE([shared-add]) 1925dnl 1926dnl Common setup macro for SQLite library. 1927dnl 1928AC_DEFUN([PHP_SETUP_SQLITE], [ 1929PKG_CHECK_MODULES([SQLITE], [sqlite3 >= 3.7.7], [ 1930 PHP_EVAL_INCLINE([$SQLITE_CFLAGS]) 1931 PHP_EVAL_LIBLINE([$SQLITE_LIBS], [$1]) 1932]) 1933]) 1934 1935dnl 1936dnl PHP_SETUP_ZLIB(shared-add [, action-found, [action-not-found]]) 1937dnl 1938dnl Common setup macro for zlib library. If zlib is not found on the system, the 1939dnl default error by PKG_CHECK_MODULES is emitted, unless the action-not-found 1940dnl is given. 1941dnl 1942AC_DEFUN([PHP_SETUP_ZLIB], [dnl 1943PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.11], [dnl 1944 PHP_EVAL_INCLINE([$ZLIB_CFLAGS]) 1945 PHP_EVAL_LIBLINE([$ZLIB_LIBS], [$1]) 1946 $2], [$3])dnl 1947]) 1948 1949dnl 1950dnl PHP_SETUP_PGSQL([shared-add [, action-found [, action-not-found [, pgsql-dir]]]]) 1951dnl 1952dnl Common setup macro for PostgreSQL library (libpq). The optional "pgsql-dir" 1953dnl is the PostgreSQL base install directory or the path to pg_config. Support 1954dnl for pkg-config was introduced in PostgreSQL 9.3. If library can't be found 1955dnl with pkg-config, check falls back to pg_config. If libpq is not found, error 1956dnl is thrown, unless the "action-not-found" is given. 1957dnl 1958AC_DEFUN([PHP_SETUP_PGSQL], [dnl 1959found_pgsql=no 1960dnl Set PostgreSQL installation directory if given from the configure argument. 1961AS_CASE([$4], [yes], [pgsql_dir=""], [pgsql_dir=$4]) 1962AS_VAR_IF([pgsql_dir],, 1963 [PKG_CHECK_MODULES([PGSQL], [libpq >= 10.0], 1964 [found_pgsql=yes], 1965 [found_pgsql=no])]) 1966 1967AS_VAR_IF([found_pgsql], [no], [dnl 1968 AC_MSG_CHECKING([for pg_config]) 1969 for i in $pgsql_dir $pgsql_dir/bin /usr/local/pgsql/bin /usr/local/bin /usr/bin ""; do 1970 AS_IF([test -x $i/pg_config], [PG_CONFIG="$i/pg_config"; break;]) 1971 done 1972 1973 AS_VAR_IF([PG_CONFIG],, [dnl 1974 AC_MSG_RESULT([not found]) 1975 AS_VAR_IF([pgsql_dir],, 1976 [pgsql_search_paths="/usr /usr/local /usr/local/pgsql"], 1977 [pgsql_search_paths=$pgsql_dir]) 1978 1979 for i in $pgsql_search_paths; do 1980 for j in include include/pgsql include/postgres include/postgresql ""; do 1981 AS_IF([test -r "$i/$j/libpq-fe.h"], [PGSQL_INCLUDE=$i/$j]) 1982 done 1983 1984 for j in $PHP_LIBDIR lib $PHP_LIBDIR/pgsql $PHP_LIBDIR/postgres $PHP_LIBDIR/postgresql ""; do 1985 AS_IF([test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a"], 1986 [PGSQL_LIBDIR=$i/$j]) 1987 done 1988 done 1989 ], [dnl 1990 AC_MSG_RESULT([$PG_CONFIG]) 1991 PGSQL_INCLUDE=$($PG_CONFIG --includedir) 1992 PGSQL_LIBDIR=$($PG_CONFIG --libdir) 1993 ]) 1994 1995 AS_IF([test -n "$PGSQL_INCLUDE" && test -n "PGSQL_LIBDIR"], [ 1996 found_pgsql=yes 1997 PGSQL_CFLAGS="-I$PGSQL_INCLUDE" 1998 PGSQL_LIBS="-L$PGSQL_LIBDIR -lpq" 1999 ])dnl 2000]) 2001 2002AS_VAR_IF([found_pgsql], [yes], [dnl 2003 PHP_EVAL_INCLINE([$PGSQL_CFLAGS]) 2004 PHP_EVAL_LIBLINE([$PGSQL_LIBS], [$1]) 2005dnl PostgreSQL minimum version sanity check. 2006 PHP_CHECK_LIBRARY([pq], [PQencryptPasswordConn],, [AC_MSG_ERROR([m4_normalize([ 2007 PostgreSQL check failed: libpq 10.0 or later is required, please see 2008 config.log for details. 2009 ])])], 2010 [$PGSQL_LIBS]) 2011$2], 2012[m4_default([$3], [AC_MSG_ERROR([m4_normalize([ 2013 Cannot find libpq-fe.h or pq library (libpq). Please specify the correct 2014 PostgreSQL installation path with environment variables PGSQL_CFLAGS and 2015 PGSQL_LIBS or provide the PostgreSQL installation directory. 2016])])])]) 2017]) 2018 2019dnl ---------------------------------------------------------------------------- 2020dnl Misc. macros 2021dnl ---------------------------------------------------------------------------- 2022 2023dnl 2024dnl PHP_INSTALL_HEADERS(path [, file ...]) 2025dnl 2026dnl PHP header files to be installed. 2027dnl 2028AC_DEFUN([PHP_INSTALL_HEADERS],[ 2029 ifelse([$2],[],[ 2030 for header_file in $1; do 2031 PHP_RUN_ONCE(INSTALLHEADERS, $header_file, [ 2032 INSTALL_HEADERS="$INSTALL_HEADERS $header_file" 2033 ]) 2034 done 2035 ], [ 2036 header_path=$1 2037 for header_file in $2; do 2038 hp_hf="$header_path/$header_file" 2039 PHP_RUN_ONCE(INSTALLHEADERS, $hp_hf, [ 2040 INSTALL_HEADERS="$INSTALL_HEADERS $hp_hf" 2041 ]) 2042 done 2043 ]) 2044]) 2045 2046dnl 2047dnl PHP_AP_EXTRACT_VERSION(/path/httpd) 2048dnl 2049dnl This macro is used to get a comparable version for Apache. 2050dnl 2051AC_DEFUN([PHP_AP_EXTRACT_VERSION],[ 2052 ac_output=`$1 -v 2>&1 | grep version | $SED -e 's/Oracle-HTTP-//'` 2053 ac_IFS=$IFS 2054IFS="- /. 2055" 2056 set $ac_output 2057 IFS=$ac_IFS 2058 2059 APACHE_VERSION=`expr [$]4 \* 1000000 + [$]5 \* 1000 + [$]6` 2060]) 2061 2062dnl 2063dnl PHP_CONFIG_NICE(filename) 2064dnl 2065dnl This macro creates script file with given filename which includes the last 2066dnl configure command run by user. This file is named 'config.nice' in PHP. 2067dnl 2068AC_DEFUN([PHP_CONFIG_NICE],[ 2069 AC_REQUIRE([AC_PROG_EGREP]) 2070 AC_REQUIRE([AC_PROG_SED]) 2071 PHP_SUBST_OLD(EGREP) 2072 PHP_SUBST_OLD(SED) 2073 test -f $1 && mv $1 $1.old 2074 rm -f $1.old 2075 cat >$1<<EOF 2076#! /bin/sh 2077# 2078# Created by configure 2079 2080EOF 2081 2082 clean_configure_args=$ac_configure_args 2083 for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS EXTRA_LDFLAGS_PROGRAM LIBS CC CXX; do 2084 eval val=\$$var 2085 if test -n "$val"; then 2086 echo "$var='$val' \\" >> $1 2087 if test `expr "X$ac_configure_args" : ".*${var}.*"` != 0; then 2088 clean_configure_args=$(echo $clean_configure_args | sed -e "s#'$var=$val'##") 2089 fi 2090 fi 2091 done 2092 2093 echo "'[$]0' \\" >> $1 2094 if test `expr " [$]0" : " '.*"` = 0; then 2095 CONFIGURE_COMMAND="$CONFIGURE_COMMAND '[$]0'" 2096 else 2097 CONFIGURE_COMMAND="$CONFIGURE_COMMAND [$]0" 2098 fi 2099 CONFIGURE_ARGS="$clean_configure_args" 2100 while test "X$CONFIGURE_ARGS" != "X"; 2101 do 2102 if CURRENT_ARG=`expr "X$CONFIGURE_ARGS" : "X *\('[[^']]*'\)"` 2103 then 2104 CONFIGURE_ARGS=`expr "X$CONFIGURE_ARGS" : "X *'[[^']]*' \(.*\)"` 2105 elif CURRENT_ARG=`expr "X$CONFIGURE_ARGS" : "X *\([[^ ]]*\)"` 2106 then 2107 CONFIGURE_ARGS=`expr "X$CONFIGURE_ARGS" : "X *[[^ ]]* \(.*\)"` 2108 CURRENT_ARG="'$CURRENT_ARG'" 2109 else 2110 break 2111 fi 2112 AS_ECHO(["$CURRENT_ARG \\"]) >>$1 2113 CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS $CURRENT_ARG" 2114 done 2115 echo '"[$]@"' >> $1 2116 chmod +x $1 2117 CONFIGURE_COMMAND="$CONFIGURE_COMMAND $CONFIGURE_OPTIONS" 2118 AC_SUBST([CONFIGURE_COMMAND]) 2119 AC_SUBST([CONFIGURE_OPTIONS]) 2120]) 2121 2122dnl 2123dnl PHP_CHECK_PDO_INCLUDES([found [, not-found]]) 2124dnl 2125AC_DEFUN([PHP_CHECK_PDO_INCLUDES],[ 2126 AC_CACHE_CHECK([for PDO includes], pdo_cv_inc_path, [ 2127 if test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then 2128 pdo_cv_inc_path=$abs_srcdir/ext 2129 elif test -f $phpincludedir/ext/pdo/php_pdo_driver.h; then 2130 pdo_cv_inc_path=$phpincludedir/ext 2131 fi 2132 ]) 2133 if test -n "$pdo_cv_inc_path"; then 2134ifelse([$1],[],:,[$1]) 2135 else 2136ifelse([$2],[],[AC_MSG_ERROR([Cannot find php_pdo_driver.h.])],[$2]) 2137 fi 2138]) 2139 2140dnl 2141dnl PHP_DETECT_ICC 2142dnl 2143dnl Detect Intel C++ Compiler and unset $GCC if ICC found. 2144dnl 2145AC_DEFUN([PHP_DETECT_ICC], 2146[ 2147 ICC="no" 2148 AC_MSG_CHECKING([for icc]) 2149 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER], 2150 ICC="no" 2151 AC_MSG_RESULT([no]), 2152 ICC="yes" 2153 GCC="no" 2154 AC_MSG_RESULT([yes]) 2155 ) 2156]) 2157 2158dnl 2159dnl PHP_DETECT_SUNCC 2160dnl 2161dnl Detect if the systems default compiler is suncc. We also set some useful 2162dnl CFLAGS if the user didn't set any. 2163dnl 2164AC_DEFUN([PHP_DETECT_SUNCC],[ 2165 SUNCC="no" 2166 AC_MSG_CHECKING([for suncc]) 2167 AC_EGREP_CPP([^__SUNPRO_C], [__SUNPRO_C], 2168 SUNCC="no" 2169 AC_MSG_RESULT([no]), 2170 SUNCC="yes" 2171 GCC="no" 2172 test -n "$auto_cflags" && CFLAGS="-O -xs -xstrconst -zlazyload" 2173 GCC="" 2174 AC_MSG_RESULT([yes]) 2175 ) 2176]) 2177 2178dnl 2179dnl PHP_CRYPT_R_STYLE 2180dnl 2181dnl Detect the style of crypt_r() if any is available. 2182dnl See APR_CHECK_CRYPT_R_STYLE() for original version. 2183dnl 2184AC_DEFUN([PHP_CRYPT_R_STYLE], 2185[ 2186 AC_CACHE_CHECK([which data struct is used by crypt_r], php_cv_crypt_r_style,[ 2187 php_cv_crypt_r_style=none 2188 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2189#define _REENTRANT 1 2190#include <crypt.h> 2191]], [[ 2192CRYPTD buffer; 2193crypt_r("passwd", "hash", &buffer); 2194]])],[php_cv_crypt_r_style=cryptd],[]) 2195 2196 if test "$php_cv_crypt_r_style" = "none"; then 2197 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2198#define _REENTRANT 1 2199#include <crypt.h> 2200]],[[ 2201struct crypt_data buffer; 2202crypt_r("passwd", "hash", &buffer); 2203]])],[php_cv_crypt_r_style=struct_crypt_data],[]) 2204 fi 2205 2206 if test "$php_cv_crypt_r_style" = "none"; then 2207 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2208#define _REENTRANT 1 2209#ifndef _GNU_SOURCE 2210#define _GNU_SOURCE 2211#endif 2212#include <crypt.h> 2213]],[[ 2214struct crypt_data buffer; 2215crypt_r("passwd", "hash", &buffer); 2216]])],[php_cv_crypt_r_style=struct_crypt_data_gnu_source],[]) 2217 fi 2218 2219 if test "$php_cv_crypt_r_style" = "none"; then 2220 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2221#include <stdlib.h> 2222#include <unistd.h> 2223]],[[ 2224struct crypt_data buffer; 2225crypt_r("passwd", "hash", &buffer); 2226]])],[php_cv_crypt_r_style=struct_crypt_data],[]) 2227 fi 2228 ]) 2229 2230 if test "$php_cv_crypt_r_style" = "cryptd"; then 2231 AC_DEFINE(CRYPT_R_CRYPTD, 1, [Define if crypt_r has uses CRYPTD]) 2232 fi 2233 if test "$php_cv_crypt_r_style" = "struct_crypt_data" || test "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then 2234 AC_DEFINE(CRYPT_R_STRUCT_CRYPT_DATA, 1, [Define if crypt_r uses struct crypt_data]) 2235 fi 2236 if test "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then 2237 AC_DEFINE(CRYPT_R_GNU_SOURCE, 1, [Define if struct crypt_data requires _GNU_SOURCE]) 2238 fi 2239 if test "$php_cv_crypt_r_style" = "none"; then 2240 AC_MSG_ERROR([Unable to detect data struct used by crypt_r]) 2241 fi 2242]) 2243 2244dnl 2245dnl PHP_TEST_WRITE_STDOUT 2246dnl 2247AC_DEFUN([PHP_TEST_WRITE_STDOUT],[ 2248 AC_CACHE_CHECK(whether writing to stdout works,ac_cv_write_stdout,[ 2249 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 2250#ifdef HAVE_UNISTD_H 2251#include <unistd.h> 2252#endif 2253 2254#define TEXT "This is the test message -- " 2255 2256int main(void) 2257{ 2258 int n; 2259 2260 n = write(1, TEXT, sizeof(TEXT)-1); 2261 return (!(n == sizeof(TEXT)-1)); 2262} 2263 ]])],[ 2264 ac_cv_write_stdout=yes 2265 ],[ 2266 ac_cv_write_stdout=no 2267 ],[ 2268 case $host_alias in 2269 *linux*|*midipix) 2270 ac_cv_write_stdout=yes 2271 ;; 2272 *) 2273 ac_cv_write_stdout=no 2274 ;; 2275 esac 2276 ]) 2277 ]) 2278 if test "$ac_cv_write_stdout" = "yes"; then 2279 AC_DEFINE(PHP_WRITE_STDOUT, 1, [whether write(2) works]) 2280 fi 2281]) 2282 2283dnl 2284dnl PHP_INIT_DTRACE(providerdesc, header-file, sources [, module]) 2285dnl 2286AC_DEFUN([PHP_INIT_DTRACE], 2287[AC_CHECK_HEADER([sys/sdt.h],, 2288 [AC_MSG_ERROR([Cannot find sys/sdt.h which is required for DTrace support.])]) 2289 2290dnl Set paths properly when called from extension. 2291 case "$4" in 2292 ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir;; 2293 /*[)] ac_srcdir=`echo "$4"|cut -c 2-`"/"; ac_bdir=$ac_srcdir;; 2294 *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$4/";; 2295 esac 2296 2297dnl providerdesc. 2298 ac_provsrc=$1 2299 old_IFS=[$]IFS 2300 IFS=. 2301 set $ac_provsrc 2302 ac_provobj=[$]1 2303 IFS=$old_IFS 2304 2305dnl header-file. 2306 ac_hdrobj=$2 2307 2308dnl Add providerdesc.o or .lo into global objects when needed. 2309 case $host_alias in 2310 *freebsd*) 2311 PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.lo" 2312 PHP_LDFLAGS="$PHP_LDFLAGS -lelf" 2313 ;; 2314 *solaris*) 2315 PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.lo" 2316 ;; 2317 *linux*) 2318 PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.lo" 2319 ;; 2320 esac 2321 2322dnl DTrace objects. 2323 old_IFS=[$]IFS 2324 for ac_src in $3; do 2325 IFS=. 2326 set $ac_src 2327 ac_obj=[$]1 2328 IFS=$old_IFS 2329 2330 PHP_DTRACE_OBJS="[$]PHP_DTRACE_OBJS [$]ac_bdir[$]ac_obj.lo" 2331 done; 2332 2333 case [$]php_sapi_module in 2334 shared[)] 2335 for ac_lo in $PHP_DTRACE_OBJS; do 2336 dtrace_objs="[$]dtrace_objs `echo $ac_lo | $SED -e 's,\.lo$,.o,' -e 's#\(.*\)\/#\1\/.libs\/#'`" 2337 done; 2338 ;; 2339 *[)] 2340 dtrace_objs='$(PHP_DTRACE_OBJS:.lo=.o)' 2341 ;; 2342 esac 2343 2344dnl Generate Makefile.objects entries. The empty $ac_provsrc command stops an 2345dnl implicit circular dependency in GNU Make which causes the .d file to be 2346dnl overwritten (Bug 61268). 2347 cat>>Makefile.objects<<EOF 2348 2349$abs_srcdir/$ac_provsrc:; 2350 2351$ac_bdir[$]ac_hdrobj: $abs_srcdir/$ac_provsrc 2352 CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHP_,DTRACE_,g' \$[]@.bak > \$[]@ 2353 2354\$(PHP_DTRACE_OBJS): $ac_bdir[$]ac_hdrobj 2355 2356EOF 2357 2358 case $host_alias in 2359 *solaris*|*linux*|*freebsd*) 2360 dtrace_prov_name="`echo $ac_provsrc | $SED -e 's#\(.*\)\/##'`.o" 2361 dtrace_lib_dir="`echo $ac_bdir[$]ac_provsrc | $SED -e 's#\(.*\)/[^/]*#\1#'`/.libs" 2362 dtrace_d_obj="`echo $ac_bdir[$]ac_provsrc | $SED -e 's#\(.*\)/\([^/]*\)#\1/.libs/\2#'`.o" 2363 dtrace_nolib_objs='$(PHP_DTRACE_OBJS:.lo=.o)' 2364 for ac_lo in $PHP_DTRACE_OBJS; do 2365 dtrace_lib_objs="[$]dtrace_lib_objs `echo $ac_lo | $SED -e 's,\.lo$,.o,' -e 's#\(.*\)\/#\1\/.libs\/#'`" 2366 done; 2367 dnl Always attempt to create both PIC and non-PIC DTrace objects (Bug 63692) 2368 cat>>Makefile.objects<<EOF 2369$ac_bdir[$]ac_provsrc.lo: \$(PHP_DTRACE_OBJS) 2370 echo "[#] Generated by Makefile for libtool" > \$[]@ 2371 @test -d "$dtrace_lib_dir" || mkdir $dtrace_lib_dir 2372 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 [\\] 2373 echo "pic_object=['].libs/$dtrace_prov_name[']" >> \$[]@ [;\\] 2374 else [\\] 2375 echo "pic_object='none'" >> \$[]@ [;\\] 2376 fi 2377 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 [\\] 2378 echo "non_pic_object=[']$dtrace_prov_name[']" >> \$[]@ [;\\] 2379 else [\\] 2380 echo "non_pic_object='none'" >> \$[]@ [;\\] 2381 fi 2382 2383EOF 2384 2385 ;; 2386 *) 2387cat>>Makefile.objects<<EOF 2388$ac_bdir[$]ac_provsrc.o: \$(PHP_DTRACE_OBJS) 2389 CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $abs_srcdir/$ac_provsrc $dtrace_objs 2390 2391EOF 2392 ;; 2393 esac 2394 2395AC_DEFINE([HAVE_DTRACE], [1], [Define to 1 if DTrace support is enabled.]) 2396PHP_SUBST([PHP_DTRACE_OBJS]) 2397]) 2398 2399dnl 2400dnl PHP_CHECK_STDINT_TYPES 2401dnl 2402AC_DEFUN([PHP_CHECK_STDINT_TYPES], [ 2403 AC_CHECK_SIZEOF([int]) 2404 AC_CHECK_SIZEOF([long]) 2405 AC_CHECK_SIZEOF([long long]) 2406 AC_CHECK_SIZEOF([size_t]) 2407 AC_CHECK_SIZEOF([off_t]) 2408]) 2409 2410dnl 2411dnl PHP_CHECK_BUILTIN_EXPECT 2412dnl 2413AC_DEFUN([PHP_CHECK_BUILTIN_EXPECT], [ 2414 AC_MSG_CHECKING([for __builtin_expect]) 2415 2416 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2417 return __builtin_expect(1,1) ? 1 : 0; 2418 ]])], [ 2419 have_builtin_expect=1 2420 AC_MSG_RESULT([yes]) 2421 ], [ 2422 have_builtin_expect=0 2423 AC_MSG_RESULT([no]) 2424 ]) 2425 2426 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_EXPECT], [$have_builtin_expect], [Whether the compiler supports __builtin_expect]) 2427]) 2428 2429dnl 2430dnl PHP_CHECK_BUILTIN_UNREACHABLE 2431dnl 2432AC_DEFUN([PHP_CHECK_BUILTIN_UNREACHABLE], [ 2433 AC_MSG_CHECKING([for __builtin_unreachable]) 2434 2435 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2436 __builtin_unreachable(); 2437 ]])], [ 2438 have_builtin_unreachable=1 2439 AC_MSG_RESULT([yes]) 2440 ], [ 2441 have_builtin_unreachable=0 2442 AC_MSG_RESULT([no]) 2443 ]) 2444 2445 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_UNREACHABLE], [$have_builtin_unreachable], [Whether the compiler supports __builtin_unreachable]) 2446]) 2447 2448dnl 2449dnl PHP_CHECK_BUILTIN_CLZ 2450dnl 2451AC_DEFUN([PHP_CHECK_BUILTIN_CLZ], [ 2452 AC_MSG_CHECKING([for __builtin_clz]) 2453 2454 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2455 return __builtin_clz(1) ? 1 : 0; 2456 ]])], [ 2457 have_builtin_clz=1 2458 AC_MSG_RESULT([yes]) 2459 ], [ 2460 have_builtin_clz=0 2461 AC_MSG_RESULT([no]) 2462 ]) 2463 2464 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CLZ], [$have_builtin_clz], [Whether the compiler supports __builtin_clz]) 2465]) 2466 2467dnl 2468dnl PHP_CHECK_BUILTIN_CLZL 2469dnl 2470AC_DEFUN([PHP_CHECK_BUILTIN_CLZL], [ 2471 AC_MSG_CHECKING([for __builtin_clzl]) 2472 2473 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2474 return __builtin_clzl(1) ? 1 : 0; 2475 ]])], [ 2476 have_builtin_clzl=1 2477 AC_MSG_RESULT([yes]) 2478 ], [ 2479 have_builtin_clzl=0 2480 AC_MSG_RESULT([no]) 2481 ]) 2482 2483 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CLZL], [$have_builtin_clzl], [Whether the compiler supports __builtin_clzl]) 2484]) 2485 2486dnl 2487dnl PHP_CHECK_BUILTIN_CLZLL 2488dnl 2489AC_DEFUN([PHP_CHECK_BUILTIN_CLZLL], [ 2490 AC_MSG_CHECKING([for __builtin_clzll]) 2491 2492 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2493 return __builtin_clzll(1) ? 1 : 0; 2494 ]])], [ 2495 have_builtin_clzll=1 2496 AC_MSG_RESULT([yes]) 2497 ], [ 2498 have_builtin_clzll=0 2499 AC_MSG_RESULT([no]) 2500 ]) 2501 2502 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CLZLL], [$have_builtin_clzll], [Whether the compiler supports __builtin_clzll]) 2503]) 2504 2505dnl 2506dnl PHP_CHECK_BUILTIN_CTZL 2507dnl 2508AC_DEFUN([PHP_CHECK_BUILTIN_CTZL], [ 2509 AC_MSG_CHECKING([for __builtin_ctzl]) 2510 2511 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2512 return __builtin_ctzl(2L) ? 1 : 0; 2513 ]])], [ 2514 have_builtin_ctzl=1 2515 AC_MSG_RESULT([yes]) 2516 ], [ 2517 have_builtin_ctzl=0 2518 AC_MSG_RESULT([no]) 2519 ]) 2520 2521 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CTZL], [$have_builtin_ctzl], [Whether the compiler supports __builtin_ctzl]) 2522]) 2523 2524dnl 2525dnl PHP_CHECK_BUILTIN_CTZLL 2526dnl 2527AC_DEFUN([PHP_CHECK_BUILTIN_CTZLL], [ 2528 AC_MSG_CHECKING([for __builtin_ctzll]) 2529 2530 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2531 return __builtin_ctzll(2LL) ? 1 : 0; 2532 ]])], [ 2533 have_builtin_ctzll=1 2534 AC_MSG_RESULT([yes]) 2535 ], [ 2536 have_builtin_ctzll=0 2537 AC_MSG_RESULT([no]) 2538 ]) 2539 2540 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CTZLL], [$have_builtin_ctzll], [Whether the compiler supports __builtin_ctzll]) 2541]) 2542 2543dnl 2544dnl PHP_CHECK_BUILTIN_SMULL_OVERFLOW 2545dnl 2546AC_DEFUN([PHP_CHECK_BUILTIN_SMULL_OVERFLOW], [ 2547 AC_MSG_CHECKING([for __builtin_smull_overflow]) 2548 2549 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2550 long tmpvar; 2551 return __builtin_smull_overflow(3, 7, &tmpvar); 2552 ]])], [ 2553 have_builtin_smull_overflow=1 2554 AC_MSG_RESULT([yes]) 2555 ], [ 2556 have_builtin_smull_overflow=0 2557 AC_MSG_RESULT([no]) 2558 ]) 2559 2560 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SMULL_OVERFLOW], 2561 [$have_builtin_smull_overflow], [Whether the compiler supports __builtin_smull_overflow]) 2562]) 2563 2564dnl 2565dnl PHP_CHECK_BUILTIN_SMULLL_OVERFLOW 2566dnl 2567AC_DEFUN([PHP_CHECK_BUILTIN_SMULLL_OVERFLOW], [ 2568 AC_MSG_CHECKING([for __builtin_smulll_overflow]) 2569 2570 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2571 long long tmpvar; 2572 return __builtin_smulll_overflow(3, 7, &tmpvar); 2573 ]])], [ 2574 have_builtin_smulll_overflow=1 2575 AC_MSG_RESULT([yes]) 2576 ], [ 2577 have_builtin_smulll_overflow=0 2578 AC_MSG_RESULT([no]) 2579 ]) 2580 2581 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SMULLL_OVERFLOW], 2582 [$have_builtin_smulll_overflow], [Whether the compiler supports __builtin_smulll_overflow]) 2583]) 2584 2585dnl 2586dnl PHP_CHECK_BUILTIN_SADDL_OVERFLOW 2587dnl 2588AC_DEFUN([PHP_CHECK_BUILTIN_SADDL_OVERFLOW], [ 2589 AC_MSG_CHECKING([for __builtin_saddl_overflow]) 2590 2591 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2592 long tmpvar; 2593 return __builtin_saddl_overflow(3, 7, &tmpvar); 2594 ]])], [ 2595 have_builtin_saddl_overflow=1 2596 AC_MSG_RESULT([yes]) 2597 ], [ 2598 have_builtin_saddl_overflow=0 2599 AC_MSG_RESULT([no]) 2600 ]) 2601 2602 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SADDL_OVERFLOW], 2603 [$have_builtin_saddl_overflow], [Whether the compiler supports __builtin_saddl_overflow]) 2604]) 2605 2606dnl 2607dnl PHP_CHECK_BUILTIN_SADDLL_OVERFLOW 2608dnl 2609AC_DEFUN([PHP_CHECK_BUILTIN_SADDLL_OVERFLOW], [ 2610 AC_MSG_CHECKING([for __builtin_saddll_overflow]) 2611 2612 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2613 long long tmpvar; 2614 return __builtin_saddll_overflow(3, 7, &tmpvar); 2615 ]])], [ 2616 have_builtin_saddll_overflow=1 2617 AC_MSG_RESULT([yes]) 2618 ], [ 2619 have_builtin_saddll_overflow=0 2620 AC_MSG_RESULT([no]) 2621 ]) 2622 2623 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SADDLL_OVERFLOW], 2624 [$have_builtin_saddll_overflow], [Whether the compiler supports __builtin_saddll_overflow]) 2625]) 2626 2627dnl 2628dnl PHP_CHECK_BUILTIN_USUB_OVERFLOW 2629dnl 2630AC_DEFUN([PHP_CHECK_BUILTIN_USUB_OVERFLOW], [ 2631 AC_MSG_CHECKING([for __builtin_usub_overflow]) 2632 2633 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2634 unsigned int tmpvar; 2635 return __builtin_usub_overflow(3, 7, &tmpvar); 2636 ]])], [ 2637 have_builtin_usub_overflow=1 2638 AC_MSG_RESULT([yes]) 2639 ], [ 2640 have_builtin_usub_overflow=0 2641 AC_MSG_RESULT([no]) 2642 ]) 2643 2644 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_USUB_OVERFLOW], 2645 [$have_builtin_usub_overflow], [Whether the compiler supports __builtin_usub_overflow]) 2646]) 2647 2648dnl 2649dnl PHP_CHECK_BUILTIN_SSUBL_OVERFLOW 2650dnl 2651AC_DEFUN([PHP_CHECK_BUILTIN_SSUBL_OVERFLOW], [ 2652 AC_MSG_CHECKING([for __builtin_ssubl_overflow]) 2653 2654 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2655 long tmpvar; 2656 return __builtin_ssubl_overflow(3, 7, &tmpvar); 2657 ]])], [ 2658 have_builtin_ssubl_overflow=1 2659 AC_MSG_RESULT([yes]) 2660 ], [ 2661 have_builtin_ssubl_overflow=0 2662 AC_MSG_RESULT([no]) 2663 ]) 2664 2665 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SSUBL_OVERFLOW], 2666 [$have_builtin_ssubl_overflow], [Whether the compiler supports __builtin_ssubl_overflow]) 2667]) 2668 2669dnl 2670dnl PHP_CHECK_BUILTIN_SSUBLL_OVERFLOW 2671dnl 2672AC_DEFUN([PHP_CHECK_BUILTIN_SSUBLL_OVERFLOW], [ 2673 AC_MSG_CHECKING([for __builtin_ssubll_overflow]) 2674 2675 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2676 long long tmpvar; 2677 return __builtin_ssubll_overflow(3, 7, &tmpvar); 2678 ]])], [ 2679 have_builtin_ssubll_overflow=1 2680 AC_MSG_RESULT([yes]) 2681 ], [ 2682 have_builtin_ssubll_overflow=0 2683 AC_MSG_RESULT([no]) 2684 ]) 2685 2686 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SSUBLL_OVERFLOW], 2687 [$have_builtin_ssubll_overflow], [Whether the compiler supports __builtin_ssubll_overflow]) 2688]) 2689 2690dnl 2691dnl PHP_CHECK_BUILTIN_CPU_INIT 2692dnl 2693AC_DEFUN([PHP_CHECK_BUILTIN_CPU_INIT], [ 2694 AC_MSG_CHECKING([for __builtin_cpu_init]) 2695 2696 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2697 __builtin_cpu_init(); 2698 ]])], [ 2699 have_builtin_cpu_init=1 2700 AC_MSG_RESULT([yes]) 2701 ], [ 2702 have_builtin_cpu_init=0 2703 AC_MSG_RESULT([no]) 2704 ]) 2705 2706 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CPU_INIT], 2707 [$have_builtin_cpu_init], [Whether the compiler supports __builtin_cpu_init]) 2708]) 2709 2710dnl 2711dnl PHP_CHECK_BUILTIN_CPU_SUPPORTS 2712dnl 2713AC_DEFUN([PHP_CHECK_BUILTIN_CPU_SUPPORTS], [ 2714 AC_MSG_CHECKING([for __builtin_cpu_supports]) 2715 2716 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2717 return __builtin_cpu_supports("sse")? 1 : 0; 2718 ]])], [ 2719 have_builtin_cpu_supports=1 2720 AC_MSG_RESULT([yes]) 2721 ], [ 2722 have_builtin_cpu_supports=0 2723 AC_MSG_RESULT([no]) 2724 ]) 2725 2726 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CPU_SUPPORTS], 2727 [$have_builtin_cpu_supports], [Whether the compiler supports __builtin_cpu_supports]) 2728]) 2729 2730dnl 2731dnl PHP_CHECK_BUILTIN_FRAME_ADDRESS 2732dnl 2733AC_DEFUN([PHP_CHECK_BUILTIN_FRAME_ADDRESS], [ 2734 AC_MSG_CHECKING([for __builtin_frame_address]) 2735 2736 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 2737 return __builtin_frame_address(0) != (void*)0; 2738 ]])], [ 2739 have_builtin_frame_address=1 2740 AC_MSG_RESULT([yes]) 2741 ], [ 2742 have_builtin_frame_address=0 2743 AC_MSG_RESULT([no]) 2744 ]) 2745 2746 AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_FRAME_ADDRESS], 2747 [$have_builtin_frame_address], [Whether the compiler supports __builtin_frame_address]) 2748]) 2749 2750dnl 2751dnl PHP_PATCH_CONFIG_HEADERS([FILE]) 2752dnl 2753dnl PACKAGE_* symbols are automatically defined by Autoconf. When including 2754dnl configuration header, warnings about redefined symbols are emitted for such 2755dnl symbols if they are defined by multiple libraries. This disables all 2756dnl PACKAGE_* symbols in the generated configuration header template FILE. For 2757dnl example, main/php_config.h.in for PHP or config.h.in for PHP extensions. 2758dnl 2759AC_DEFUN([PHP_PATCH_CONFIG_HEADERS], [ 2760 AC_MSG_NOTICE([patching $1]) 2761 2762 $SED -e 's/^#undef PACKAGE_[^ ]*/\/\* & \*\//g' < $srcdir/$1 \ 2763 > $srcdir/$1.tmp && mv $srcdir/$1.tmp $srcdir/$1 2764]) 2765 2766dnl 2767dnl PHP_CHECK_AVX512_SUPPORTS 2768dnl 2769AC_DEFUN([PHP_CHECK_AVX512_SUPPORTS], [ 2770 AC_MSG_CHECKING([for avx512 supports in compiler]) 2771 save_CFLAGS="$CFLAGS" 2772 CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw $CFLAGS" 2773 2774 AC_LINK_IFELSE([AC_LANG_SOURCE([[ 2775 #include <immintrin.h> 2776 int main(void) { 2777 __m512i mask = _mm512_set1_epi32(0x1); 2778 char out[32]; 2779 _mm512_storeu_si512(out, _mm512_shuffle_epi8(mask, mask)); 2780 return 0; 2781 }]])], [ 2782 have_avx512_supports=1 2783 AC_MSG_RESULT([yes]) 2784 ], [ 2785 have_avx512_supports=0 2786 AC_MSG_RESULT([no]) 2787 ]) 2788 2789 CFLAGS="$save_CFLAGS" 2790 2791 AC_DEFINE_UNQUOTED([PHP_HAVE_AVX512_SUPPORTS], 2792 [$have_avx512_supports], [Whether the compiler supports AVX512]) 2793]) 2794 2795dnl 2796dnl PHP_CHECK_AVX512_VBMI_SUPPORTS 2797dnl 2798AC_DEFUN([PHP_CHECK_AVX512_VBMI_SUPPORTS], [ 2799 AC_MSG_CHECKING([for avx512 vbmi supports in compiler]) 2800 save_CFLAGS="$CFLAGS" 2801 CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw -mavx512vbmi $CFLAGS" 2802 AC_LINK_IFELSE([AC_LANG_SOURCE([[ 2803 #include <immintrin.h> 2804 int main(void) { 2805 __m512i mask = _mm512_set1_epi32(0x1); 2806 char out[32]; 2807 _mm512_storeu_si512(out, _mm512_permutexvar_epi8(mask, mask)); 2808 return 0; 2809 }]])], [ 2810 have_avx512_vbmi_supports=1 2811 AC_MSG_RESULT([yes]) 2812 ], [ 2813 have_avx512_vbmi_supports=0 2814 AC_MSG_RESULT([no]) 2815 ]) 2816 CFLAGS="$save_CFLAGS" 2817 AC_DEFINE_UNQUOTED([PHP_HAVE_AVX512_VBMI_SUPPORTS], 2818 [$have_avx512_vbmi_supports], [Whether the compiler supports AVX512 VBMI]) 2819]) 2820 2821dnl 2822dnl PHP_CHECK_VARIABLE_ATTRIBUTE(attribute) 2823dnl 2824dnl Check whether the compiler supports the GNU C variable attribute. 2825dnl 2826AC_DEFUN([PHP_CHECK_VARIABLE_ATTRIBUTE], 2827[AS_VAR_PUSHDEF([php_var], [php_cv_have_variable_attribute_$1]) 2828AC_CACHE_CHECK([for variable __attribute__(($1))], [php_var], 2829[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([m4_case([$1], 2830 [aligned], 2831 [unsigned char test[32] __attribute__(($1(__alignof__(int))));], 2832 [ 2833 m4_warn([syntax], [Unsupported variable attribute $1, the test may fail]) 2834 int var __attribute__(($1)); 2835 ])], 2836 [])], 2837dnl By default, compilers may not classify attribute warnings as errors 2838dnl (-Werror=attributes) when encountering an unknown attribute. Accept the 2839dnl attribute only if no warnings were generated. 2840 [AS_IF([test -s conftest.err], 2841 [AS_VAR_SET([php_var], [no])], 2842 [AS_VAR_SET([php_var], [yes])])], 2843 [AS_VAR_SET([php_var], [no])]) 2844]) 2845AS_VAR_IF([php_var], [yes], 2846 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_ATTRIBUTE_$1]), [1], 2847 [Define to 1 if the compiler supports the '$1' variable attribute.])]) 2848AS_VAR_POPDEF([php_var]) 2849]) 2850