A hint: This file contains one or more very long lines, so maybe it is better readable using the pure text view mode that shows the contents as wrapped lines within the browser window.
1 dnl $Id: acinclude.m4,v 1.271.2.22 2005/07/25 22:31:07 helly Exp $ -*- autoconf -*- 2 dnl 3 dnl This file contains local autoconf functions. 4 5 dnl PHP_ADD_MAKEFILE_FRAGMENT([srcfile[, ext_srcdir[, ext_builddir]]]) 6 dnl 7 dnl Processes a file called Makefile.frag in the source directory 8 dnl of the most recently added extension. $(srcdir) and $(builddir) 9 dnl are substituted with the proper paths. Can be used to supply 10 dnl custom rules and/or additional targets. 11 dnl 12 AC_DEFUN([PHP_ADD_MAKEFILE_FRAGMENT],[ 13 ifelse($1,,src=$ext_srcdir/Makefile.frag,src=$1) 14 ifelse($2,,ac_srcdir=$ext_srcdir,ac_srcdir=$2) 15 ifelse($3,,ac_builddir=$ext_builddir,ac_builddir=$3) 16 sed -e "s#\$(srcdir)#$ac_srcdir#g" -e "s#\$(builddir)#$ac_builddir#g" $src >> Makefile.fragments 17 ]) 18 19 AC_DEFUN([PHP_PROG_RE2C],[ 20 AC_CHECK_PROG(RE2C, re2c, re2c, [exit 0;]) 21 ]) 22 23 24 dnl PHP_DEFINE(WHAT[, value[, directory]]) 25 dnl 26 dnl Creates builddir/include/what.h and in there #define WHAT value 27 dnl 28 AC_DEFUN([PHP_DEFINE],[ 29 [echo "#define ]$1[]ifelse([$2],,[ 1],[ $2])[" > ]ifelse([$3],,[include],[$3])[/php_]translit($1,A-Z,a-z)[.h] 30 ]) 31 32 dnl PHP_CANONICAL_HOST 33 dnl 34 AC_DEFUN([PHP_CANONICAL_HOST],[ 35 AC_REQUIRE([AC_CANONICAL_HOST])dnl 36 dnl Make sure we do not continue if host_alias is empty. 37 if test -z "$host_alias" && test -n "$host"; then 38 host_alias=$host 39 fi 40 if test -z "$host_alias"; then 41 AC_MSG_ERROR([host_alias is not set!]) 42 fi 43 ]) 44 45 dnl PHP_INIT_BUILD_SYSTEM 46 dnl 47 AC_DEFUN([PHP_INIT_BUILD_SYSTEM],[ 48 AC_REQUIRE([PHP_CANONICAL_HOST])dnl 49 test -d include || mkdir include 50 > Makefile.objects 51 > Makefile.fragments 52 dnl We need to play tricks here to avoid matching the grep line itself 53 pattern=define 54 egrep $pattern'.*include/php' $srcdir/configure|sed 's/.*>//'|xargs touch 2>/dev/null 55 ]) 56 57 dnl PHP_GEN_GLOBAL_MAKEFILE 58 dnl 59 dnl Generates the global makefile. 60 dnl 61 AC_DEFUN([PHP_GEN_GLOBAL_MAKEFILE],[ 62 cat >Makefile <<EOF 63 srcdir = $abs_srcdir 64 builddir = $abs_builddir 65 top_srcdir = $abs_srcdir 66 top_builddir = $abs_builddir 67 EOF 68 for i in $PHP_VAR_SUBST; do 69 eval echo "$i = \$$i" >> Makefile 70 done 71 72 cat $abs_srcdir/Makefile.global Makefile.fragments Makefile.objects >> Makefile 73 ]) 74 75 dnl PHP_ADD_SOURCES(source-path, sources[, special-flags[, type]]) 76 dnl 77 dnl Adds sources which are located relative to source-path to the 78 dnl array of type type. Sources are processed with optional 79 dnl special-flags which are passed to the compiler. Sources 80 dnl can be either written in C or C++ (filenames shall end in .c 81 dnl or .cpp, respectively). 82 dnl 83 dnl Note: If source-path begins with a "/", the "/" is removed and 84 dnl the path is interpreted relative to the top build-directory. 85 dnl 86 dnl which array to append to? 87 AC_DEFUN([PHP_ADD_SOURCES],[ 88 PHP_ADD_SOURCES_X($1, $2, $3, ifelse($4,cli,PHP_CLI_OBJS,ifelse($4,sapi,PHP_SAPI_OBJS,PHP_GLOBAL_OBJS))) 89 ]) 90 dnl 91 dnl _PHP_ASSIGN_BUILD_VARS(type) 92 dnl internal, don't use 93 AC_DEFUN([_PHP_ASSIGN_BUILD_VARS],[ 94 ifelse($1,shared,[ 95 b_c_pre=$shared_c_pre 96 b_cxx_pre=$shared_cxx_pre 97 b_c_meta=$shared_c_meta 98 b_cxx_meta=$shared_cxx_meta 99 b_c_post=$shared_c_post 100 b_cxx_post=$shared_cxx_post 101 ],[ 102 b_c_pre=$php_c_pre 103 b_cxx_pre=$php_cxx_pre 104 b_c_meta=$php_c_meta 105 b_cxx_meta=$php_cxx_meta 106 b_c_post=$php_c_post 107 b_cxx_post=$php_cxx_post 108 ])dnl 109 b_lo=[$]$1_lo 110 ]) 111 112 dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared[, special-post-flags]]]]) 113 dnl 114 dnl Additional to PHP_ADD_SOURCES (see above), this lets you set the 115 dnl name of the array target-var directly, as well as whether 116 dnl shared objects will be built from the sources. Should not be 117 dnl used directly. 118 dnl 119 AC_DEFUN([PHP_ADD_SOURCES_X],[ 120 dnl relative to source- or build-directory? 121 dnl ac_srcdir/ac_bdir include trailing slash 122 case $1 in 123 ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir; ac_inc="-I. -I$abs_srcdir" ;; 124 /*[)] ac_srcdir=`echo "$1"|cut -c 2-`"/"; ac_bdir=$ac_srcdir; ac_inc="-I$ac_bdir -I$abs_srcdir/$ac_bdir" ;; 125 *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$1/"; ac_inc="-I$ac_bdir -I$ac_srcdir" ;; 126 esac 127 128 dnl how to build .. shared or static? 129 ifelse($5,yes,_PHP_ASSIGN_BUILD_VARS(shared),_PHP_ASSIGN_BUILD_VARS(php)) 130 131 dnl iterate over the sources 132 old_IFS=[$]IFS 133 for ac_src in $2; do 134 135 dnl remove the suffix 136 IFS=. 137 set $ac_src 138 ac_obj=[$]1 139 IFS=$old_IFS 140 141 dnl append to the array which has been dynamically chosen at m4 time 142 $4="[$]$4 [$]ac_bdir[$]ac_obj.lo" 143 144 dnl choose the right compiler/flags/etc. for the source-file 145 case $ac_src in 146 *.c[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;; 147 *.s[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;; 148 *.S[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;; 149 *.cpp|*.cc[)] ac_comp="$b_cxx_pre $3 $ac_inc $b_cxx_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_cxx_post" ;; 150 esac 151 152 dnl create a rule for the object/source combo 153 cat >>Makefile.objects<<EOF 154 $ac_bdir[$]ac_obj.lo: $ac_srcdir[$]ac_src 155 $ac_comp 156 EOF 157 done 158 ]) 159 160 dnl 161 dnl Separator into the configure --help display. 162 dnl 163 AC_DEFUN([PHP_HELP_SEPARATOR],[ 164 AC_ARG_ENABLE([],[ 165 $1 166 ],[]) 167 ]) 168 169 dnl 170 dnl PHP_TARGET_RDYNAMIC 171 dnl 172 dnl Checks whether -rdynamic is supported by the compiler. This 173 dnl is necessary for some targets to populate the global symbol 174 dnl table. Otherwise, dynamic modules would not be able to resolve 175 dnl PHP-related symbols. 176 dnl 177 dnl If successful, adds -rdynamic to PHP_LDFLAGS. 178 dnl 179 AC_DEFUN([PHP_TARGET_RDYNAMIC],[ 180 if test -n "$GCC"; then 181 dnl we should use a PHP-specific macro here 182 TSRM_CHECK_GCC_ARG(-rdynamic, gcc_rdynamic=yes) 183 if test "$gcc_rdynamic" = "yes"; then 184 PHP_LDFLAGS="$PHP_LDFLAGS -rdynamic" 185 fi 186 fi 187 ]) 188 189 AC_DEFUN([PHP_REMOVE_USR_LIB],[ 190 unset ac_new_flags 191 for i in [$]$1; do 192 case [$]i in 193 -L/usr/lib|-L/usr/lib/[)] ;; 194 *[)] ac_new_flags="[$]ac_new_flags [$]i" ;; 195 esac 196 done 197 $1=[$]ac_new_flags 198 ]) 199 200 dnl PHP_EVAL_LIBLINE(LINE, SHARED-LIBADD) 201 dnl 202 dnl Use this macro, if you need to add libraries and or library search 203 dnl paths to the PHP build system which are only given in compiler 204 dnl notation. 205 dnl 206 AC_DEFUN([PHP_EVAL_LIBLINE],[ 207 for ac_i in $1; do 208 case $ac_i in 209 -l*[)] 210 ac_ii=`echo $ac_i|cut -c 3-` 211 PHP_ADD_LIBRARY($ac_ii,1,$2) 212 ;; 213 -L*[)] 214 ac_ii=`echo $ac_i|cut -c 3-` 215 PHP_ADD_LIBPATH($ac_ii,$2) 216 ;; 217 esac 218 done 219 ]) 220 221 dnl PHP_EVAL_INCLINE(LINE) 222 dnl 223 dnl Use this macro, if you need to add header search paths to the PHP 224 dnl build system which are only given in compiler notation. 225 dnl 226 AC_DEFUN([PHP_EVAL_INCLINE],[ 227 for ac_i in $1; do 228 case $ac_i in 229 -I*[)] 230 ac_ii=`echo $ac_i|cut -c 3-` 231 PHP_ADD_INCLUDE($ac_ii) 232 ;; 233 esac 234 done 235 ]) 236 237 AC_DEFUN([PHP_READDIR_R_TYPE],[ 238 dnl HAVE_READDIR_R is also defined by libmysql 239 AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no) 240 if test "$ac_cv_func_readdir_r" = "yes"; then 241 AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[ 242 AC_TRY_RUN([ 243 #define _REENTRANT 244 #include <sys/types.h> 245 #include <dirent.h> 246 247 #ifndef PATH_MAX 248 #define PATH_MAX 1024 249 #endif 250 251 main() { 252 DIR *dir; 253 char entry[sizeof(struct dirent)+PATH_MAX]; 254 struct dirent *pentry = (struct dirent *) &entry; 255 256 dir = opendir("/"); 257 if (!dir) 258 exit(1); 259 if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0) 260 exit(0); 261 exit(1); 262 } 263 ],[ 264 ac_cv_what_readdir_r=POSIX 265 ],[ 266 AC_TRY_CPP([ 267 #define _REENTRANT 268 #include <sys/types.h> 269 #include <dirent.h> 270 int readdir_r(DIR *, struct dirent *); 271 ],[ 272 ac_cv_what_readdir_r=old-style 273 ],[ 274 ac_cv_what_readdir_r=none 275 ]) 276 ],[ 277 ac_cv_what_readdir_r=none 278 ]) 279 ]) 280 case $ac_cv_what_readdir_r in 281 POSIX) 282 AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);; 283 old-style) 284 AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);; 285 esac 286 fi 287 ]) 288 289 AC_DEFUN([PHP_SHLIB_SUFFIX_NAME],[ 290 AC_REQUIRE([PHP_CANONICAL_HOST])dnl 291 PHP_SUBST(SHLIB_SUFFIX_NAME) 292 SHLIB_SUFFIX_NAME=so 293 case $host_alias in 294 *hpux*[)] 295 SHLIB_SUFFIX_NAME=sl 296 ;; 297 *darwin*[)] 298 SHLIB_SUFFIX_NAME=dylib 299 ;; 300 esac 301 ]) 302 303 AC_DEFUN([PHP_DEBUG_MACRO],[ 304 DEBUG_LOG=$1 305 cat >$1 <<X 306 CONFIGURE: $CONFIGURE_COMMAND 307 CC: $CC 308 CFLAGS: $CFLAGS 309 CPPFLAGS: $CPPFLAGS 310 CXX: $CXX 311 CXXFLAGS: $CXXFLAGS 312 INCLUDES: $INCLUDES 313 LDFLAGS: $LDFLAGS 314 LIBS: $LIBS 315 DLIBS: $DLIBS 316 SAPI: $PHP_SAPI 317 PHP_RPATHS: $PHP_RPATHS 318 uname -a: `uname -a` 319 320 X 321 cat >conftest.$ac_ext <<X 322 main() 323 { 324 exit(0); 325 } 326 X 327 (eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1 328 rm -fr conftest* 329 ]) 330 331 AC_DEFUN([PHP_DOES_PWRITE_WORK],[ 332 AC_TRY_RUN([ 333 #include <sys/types.h> 334 #include <sys/stat.h> 335 #include <fcntl.h> 336 #include <unistd.h> 337 #include <errno.h> 338 $1 339 main() { 340 int fd = open("conftest_in", O_WRONLY|O_CREAT, 0600); 341 342 if (fd < 0) exit(1); 343 if (pwrite(fd, "text", 4, 0) != 4) exit(1); 344 /* Linux glibc breakage until 2.2.5 */ 345 if (pwrite(fd, "text", 4, -1) != -1 || errno != EINVAL) exit(1); 346 exit(0); 347 } 348 349 ],[ 350 ac_cv_pwrite=yes 351 ],[ 352 ac_cv_pwrite=no 353 ],[ 354 ac_cv_pwrite=no 355 ]) 356 ]) 357 358 AC_DEFUN([PHP_DOES_PREAD_WORK],[ 359 echo test > conftest_in 360 AC_TRY_RUN([ 361 #include <sys/types.h> 362 #include <sys/stat.h> 363 #include <fcntl.h> 364 #include <unistd.h> 365 #include <errno.h> 366 $1 367 main() { 368 char buf[3]; 369 int fd = open("conftest_in", O_RDONLY); 370 if (fd < 0) exit(1); 371 if (pread(fd, buf, 2, 0) != 2) exit(1); 372 /* Linux glibc breakage until 2.2.5 */ 373 if (pread(fd, buf, 2, -1) != -1 || errno != EINVAL) exit(1); 374 exit(0); 375 } 376 ],[ 377 ac_cv_pread=yes 378 ],[ 379 ac_cv_pread=no 380 ],[ 381 ac_cv_pread=no 382 ]) 383 rm -f conftest_in 384 ]) 385 386 AC_DEFUN([PHP_PWRITE_TEST],[ 387 AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[ 388 PHP_DOES_PWRITE_WORK 389 if test "$ac_cv_pwrite" = "no"; then 390 PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);]) 391 if test "$ac_cv_pwrite" = "yes"; then 392 ac_cv_pwrite=64 393 fi 394 fi 395 ]) 396 397 if test "$ac_cv_pwrite" != "no"; then 398 AC_DEFINE(HAVE_PWRITE, 1, [ ]) 399 if test "$ac_cv_pwrite" = "64"; then 400 AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default]) 401 fi 402 fi 403 ]) 404 405 AC_DEFUN([PHP_PREAD_TEST],[ 406 AC_CACHE_CHECK(whether pread works,ac_cv_pread,[ 407 PHP_DOES_PREAD_WORK 408 if test "$ac_cv_pread" = "no"; then 409 PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);]) 410 if test "$ac_cv_pread" = "yes"; then 411 ac_cv_pread=64 412 fi 413 fi 414 ]) 415 416 if test "$ac_cv_pread" != "no"; then 417 AC_DEFINE(HAVE_PREAD, 1, [ ]) 418 if test "$ac_cv_pread" = "64"; then 419 AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default]) 420 fi 421 fi 422 ]) 423 424 AC_DEFUN([PHP_MISSING_TIME_R_DECL],[ 425 AC_MSG_CHECKING([for missing declarations of reentrant functions]) 426 AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = localtime_r],[ 427 : 428 ],[ 429 AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared]) 430 ]) 431 AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = gmtime_r],[ 432 : 433 ],[ 434 AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared]) 435 ]) 436 AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = asctime_r],[ 437 : 438 ],[ 439 AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared]) 440 ]) 441 AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = ctime_r],[ 442 : 443 ],[ 444 AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared]) 445 ]) 446 AC_TRY_COMPILE([#include <string.h>],[char *(*func)() = strtok_r],[ 447 : 448 ],[ 449 AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared]) 450 ]) 451 AC_MSG_RESULT([done]) 452 ]) 453 454 dnl 455 dnl PHP_LIBGCC_LIBPATH(gcc) 456 dnl Stores the location of libgcc in libgcc_libpath 457 dnl 458 AC_DEFUN([PHP_LIBGCC_LIBPATH],[ 459 changequote({,}) 460 libgcc_libpath=`$1 --print-libgcc-file-name|sed 's%/*[^/][^/]*$%%'` 461 changequote([,]) 462 ]) 463 464 AC_DEFUN([PHP_ARG_ANALYZE_EX],[ 465 ext_output="yes, shared" 466 ext_shared=yes 467 case [$]$1 in 468 shared,*[)] 469 $1=`echo "[$]$1"|sed 's/^shared,//'` 470 ;; 471 shared[)] 472 $1=yes 473 ;; 474 no[)] 475 ext_output=no 476 ext_shared=no 477 ;; 478 *[)] 479 ext_output=yes 480 ext_shared=no 481 ;; 482 esac 483 484 PHP_ALWAYS_SHARED([$1]) 485 ]) 486 487 AC_DEFUN([PHP_ARG_ANALYZE],[ 488 ifelse([$3],yes,[PHP_ARG_ANALYZE_EX([$1])],[ext_output=ifelse([$]$1,,no,[$]$1)]) 489 ifelse([$2],,,[AC_MSG_RESULT([$ext_output])]) 490 ]) 491 492 dnl 493 dnl PHP_ARG_WITH(arg-name, check message, help text[, default-val[, extension-or-not]]) 494 dnl Sets PHP_ARG_NAME either to the user value or to the default value. 495 dnl default-val defaults to no. This will also set the variable ext_shared, 496 dnl and will overwrite any previous variable of that name. 497 dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run 498 dnl the PHP_ARG_ANALYZE_EX. 499 dnl 500 AC_DEFUN([PHP_ARG_WITH],[ 501 PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)]) 502 ]) 503 504 AC_DEFUN([PHP_REAL_ARG_WITH],[ 505 ifelse([$2],,,[AC_MSG_CHECKING([$2])]) 506 AC_ARG_WITH($1,[$3],$5=[$]withval, 507 [ 508 $5=ifelse($4,,no,$4) 509 510 if test "$PHP_ENABLE_ALL" && test "$6" = "yes"; then 511 $5=$PHP_ENABLE_ALL 512 fi 513 ]) 514 PHP_ARG_ANALYZE($5,[$2],$6) 515 ]) 516 517 dnl 518 dnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val[, extension-or-not]]) 519 dnl Sets PHP_ARG_NAME either to the user value or to the default value. 520 dnl default-val defaults to no. This will also set the variable ext_shared, 521 dnl and will overwrite any previous variable of that name. 522 dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run 523 dnl the PHP_ARG_ANALYZE_EX. 524 dnl 525 AC_DEFUN([PHP_ARG_ENABLE],[ 526 PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z-,A-Z_),[ifelse($5,,yes,$5)]) 527 ]) 528 529 AC_DEFUN([PHP_REAL_ARG_ENABLE],[ 530 ifelse([$2],,,[AC_MSG_CHECKING([$2])]) 531 AC_ARG_ENABLE($1,[$3],$5=[$]enableval, 532 [ 533 $5=ifelse($4,,no,$4) 534 535 if test "$PHP_ENABLE_ALL" && test "$6" = "yes"; then 536 $5=$PHP_ENABLE_ALL 537 fi 538 ]) 539 PHP_ARG_ANALYZE($5,[$2],$6) 540 ]) 541 542 AC_DEFUN([PHP_MODULE_PTR],[ 543 EXTRA_MODULE_PTRS="$EXTRA_MODULE_PTRS $1," 544 ]) 545 546 AC_DEFUN([PHP_CONFIG_NICE],[ 547 test -f $1 && mv $1 $1.old 548 rm -f $1.old 549 cat >$1<<EOF 550 #! /bin/sh 551 # 552 # Created by configure 553 554 EOF 555 556 for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS LIBS CC CXX; do 557 eval val=\$$var 558 if test -n "$val"; then 559 echo "$var='$val' \\" >> $1 560 fi 561 done 562 563 for arg in [$]0 "[$]@"; do 564 echo "'[$]arg' \\" >> $1 565 done 566 echo '"[$]@"' >> $1 567 chmod +x $1 568 ]) 569 570 AC_DEFUN([PHP_TIME_R_TYPE],[ 571 AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[ 572 AC_TRY_RUN([ 573 #include <time.h> 574 575 main() { 576 char buf[27]; 577 struct tm t; 578 time_t old = 0; 579 int r, s; 580 581 s = gmtime_r(&old, &t); 582 r = (int) asctime_r(&t, buf, 26); 583 if (r == s && s == 0) return (0); 584 return (1); 585 } 586 ],[ 587 ac_cv_time_r_type=hpux 588 ],[ 589 AC_TRY_RUN([ 590 #include <time.h> 591 main() { 592 struct tm t, *s; 593 time_t old = 0; 594 char buf[27], *p; 595 596 s = gmtime_r(&old, &t); 597 p = asctime_r(&t, buf, 26); 598 if (p == buf && s == &t) return (0); 599 return (1); 600 } 601 ],[ 602 ac_cv_time_r_type=irix 603 ],[ 604 ac_cv_time_r_type=POSIX 605 ]) 606 ],[ 607 ac_cv_time_r_type=POSIX 608 ]) 609 ]) 610 case $ac_cv_time_r_type in 611 hpux[)] AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;; 612 irix[)] AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;; 613 esac 614 ]) 615 616 AC_DEFUN([PHP_SUBST],[ 617 PHP_VAR_SUBST="$PHP_VAR_SUBST $1" 618 ]) 619 620 AC_DEFUN([PHP_SUBST_OLD],[ 621 PHP_SUBST($1) 622 AC_SUBST($1) 623 ]) 624 625 AC_DEFUN([PHP_TM_GMTOFF],[ 626 AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff, 627 [AC_TRY_COMPILE([#include <sys/types.h> 628 #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;], 629 ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)]) 630 631 if test "$ac_cv_struct_tm_gmtoff" = yes; then 632 AC_DEFINE(HAVE_TM_GMTOFF,1,[whether you have tm_gmtoff in struct tm]) 633 fi 634 ]) 635 636 dnl PHP_CONFIGURE_PART(MESSAGE) 637 dnl Idea borrowed from mm 638 AC_DEFUN([PHP_CONFIGURE_PART],[ 639 AC_MSG_RESULT() 640 AC_MSG_RESULT([${T_MD}$1${T_ME}]) 641 ]) 642 643 AC_DEFUN([PHP_PROG_SENDMAIL],[ 644 PHP_ALT_PATH=/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib 645 AC_PATH_PROG(PROG_SENDMAIL, sendmail,[], $PATH:$PHP_ALT_PATH) 646 if test -n "$PROG_SENDMAIL"; then 647 AC_DEFINE(HAVE_SENDMAIL,1,[whether you have sendmail]) 648 fi 649 ]) 650 651 AC_DEFUN([PHP_RUNPATH_SWITCH],[ 652 dnl check for -R, etc. switch 653 AC_MSG_CHECKING([if compiler supports -R]) 654 AC_CACHE_VAL(php_cv_cc_dashr,[ 655 SAVE_LIBS=$LIBS 656 LIBS="-R /usr/lib $LIBS" 657 AC_TRY_LINK([], [], php_cv_cc_dashr=yes, php_cv_cc_dashr=no) 658 LIBS=$SAVE_LIBS]) 659 AC_MSG_RESULT([$php_cv_cc_dashr]) 660 if test $php_cv_cc_dashr = "yes"; then 661 ld_runpath_switch=-R 662 else 663 AC_MSG_CHECKING([if compiler supports -Wl,-rpath,]) 664 AC_CACHE_VAL(php_cv_cc_rpath,[ 665 SAVE_LIBS=$LIBS 666 LIBS="-Wl,-rpath,/usr/lib $LIBS" 667 AC_TRY_LINK([], [], php_cv_cc_rpath=yes, php_cv_cc_rpath=no) 668 LIBS=$SAVE_LIBS]) 669 AC_MSG_RESULT([$php_cv_cc_rpath]) 670 if test $php_cv_cc_rpath = "yes"; then 671 ld_runpath_switch=-Wl,-rpath, 672 else 673 dnl something innocuous 674 ld_runpath_switch=-L 675 fi 676 fi 677 ]) 678 679 AC_DEFUN([PHP_STRUCT_FLOCK],[ 680 AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock, 681 AC_TRY_COMPILE([ 682 #include <unistd.h> 683 #include <fcntl.h> 684 ], 685 [struct flock x;], 686 [ 687 ac_cv_struct_flock=yes 688 ],[ 689 ac_cv_struct_flock=no 690 ]) 691 ) 692 if test "$ac_cv_struct_flock" = "yes" ; then 693 AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock]) 694 fi 695 ]) 696 697 AC_DEFUN([PHP_SOCKLEN_T],[ 698 AC_CACHE_CHECK(for socklen_t,ac_cv_socklen_t, 699 AC_TRY_COMPILE([ 700 #include <sys/types.h> 701 #include <sys/socket.h> 702 ],[ 703 socklen_t x; 704 ],[ 705 ac_cv_socklen_t=yes 706 ],[ 707 ac_cv_socklen_t=no 708 ])) 709 if test "$ac_cv_socklen_t" = "yes"; then 710 AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t]) 711 fi 712 ]) 713 714 dnl 715 dnl PHP_SET_SYM_FILE(path) 716 dnl 717 dnl set the path of the file which contains the symbol export list 718 dnl 719 AC_DEFUN([PHP_SET_SYM_FILE], 720 [ 721 PHP_SYM_FILE=$1 722 ]) 723 724 dnl 725 dnl PHP_BUILD_THREAD_SAFE 726 dnl 727 AC_DEFUN([PHP_BUILD_THREAD_SAFE],[ 728 enable_maintainer_zts=yes 729 if test "$pthreads_working" != "yes"; then 730 AC_MSG_ERROR([ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads.]) 731 fi 732 ]) 733 734 AC_DEFUN([PHP_REQUIRE_CXX],[ 735 if test -z "$php_cxx_done"; then 736 AC_PROG_CXX 737 AC_PROG_CXXCPP 738 php_cxx_done=yes 739 fi 740 ]) 741 742 dnl 743 dnl PHP_BUILD_SHARED 744 dnl 745 AC_DEFUN([PHP_BUILD_SHARED],[ 746 PHP_BUILD_PROGRAM 747 OVERALL_TARGET=libphp5.la 748 php_build_target=shared 749 750 php_c_pre=$shared_c_pre 751 php_c_meta=$shared_c_meta 752 php_c_post=$shared_c_post 753 php_cxx_pre=$shared_cxx_pre 754 php_cxx_meta=$shared_cxx_meta 755 php_cxx_post=$shared_cxx_post 756 php_lo=$shared_lo 757 ]) 758 759 dnl 760 dnl PHP_BUILD_STATIC 761 dnl 762 AC_DEFUN([PHP_BUILD_STATIC],[ 763 PHP_BUILD_PROGRAM 764 OVERALL_TARGET=libphp5.la 765 php_build_target=static 766 ]) 767 768 dnl 769 dnl PHP_BUILD_BUNDLE 770 dnl 771 AC_DEFUN([PHP_BUILD_BUNDLE],[ 772 PHP_BUILD_PROGRAM 773 OVERALL_TARGET=libs/libphp5.bundle 774 php_build_target=static 775 ]) 776 777 dnl 778 dnl PHP_BUILD_PROGRAM 779 dnl 780 AC_DEFUN([PHP_BUILD_PROGRAM],[ 781 OVERALL_TARGET=[]ifelse($1,,php,$1) 782 php_c_pre='$(CC)' 783 php_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS)' 784 php_c_post=' && echo > $[@]' 785 php_cxx_pre='$(CXX)' 786 php_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS)' 787 php_cxx_post=' && echo > $[@]' 788 php_lo=o 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) --mode=compile $(CC)' 796 shared_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) '$pic_setting 797 shared_c_post= 798 shared_cxx_pre='$(LIBTOOL) --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 php_build_target=program 804 ]) 805 806 dnl 807 dnl PHP_RUN_ONCE(namespace, variable, code) 808 dnl 809 dnl execute code, if variable is not set in namespace 810 dnl 811 AC_DEFUN([PHP_RUN_ONCE],[ 812 changequote({,}) 813 unique=`echo $2|sed 's/[^a-zA-Z0-9]/_/g'` 814 changequote([,]) 815 cmd="echo $ac_n \"\$$1$unique$ac_c\"" 816 if test -n "$unique" && test "`eval $cmd`" = "" ; then 817 eval "$1$unique=set" 818 $3 819 fi 820 ]) 821 822 dnl 823 dnl PHP_EXPAND_PATH(path, variable) 824 dnl 825 dnl expands path to an absolute path and assigns it to variable 826 dnl 827 AC_DEFUN([PHP_EXPAND_PATH],[ 828 if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then 829 $2=$1 830 else 831 changequote({,}) 832 ep_dir="`echo $1|sed 's%/*[^/][^/]*/*$%%'`" 833 changequote([,]) 834 ep_realdir="`(cd \"$ep_dir\" && pwd)`" 835 $2="$ep_realdir/`basename \"$1\"`" 836 fi 837 ]) 838 dnl 839 dnl internal, don't use 840 AC_DEFUN([_PHP_ADD_LIBPATH_GLOBAL],[ 841 PHP_RUN_ONCE(LIBPATH, $1, [ 842 test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$1" 843 LDFLAGS="$LDFLAGS -L$1" 844 PHP_RPATHS="$PHP_RPATHS $1" 845 ]) 846 ])dnl 847 dnl 848 dnl 849 dnl 850 dnl PHP_ADD_LIBPATH(path[, shared-libadd]) 851 dnl 852 dnl add a library to linkpath/runpath 853 dnl 854 AC_DEFUN([PHP_ADD_LIBPATH],[ 855 if test "$1" != "/usr/lib"; then 856 PHP_EXPAND_PATH($1, ai_p) 857 ifelse([$2],,[ 858 _PHP_ADD_LIBPATH_GLOBAL([$ai_p]) 859 ],[ 860 if test "$ext_shared" = "yes"; then 861 $2="$ld_runpath_switch$ai_p -L$ai_p [$]$2" 862 else 863 _PHP_ADD_LIBPATH_GLOBAL([$ai_p]) 864 fi 865 ]) 866 fi 867 ]) 868 869 dnl 870 dnl PHP_UTILIZE_RPATHS() 871 dnl 872 dnl builds RPATHS/LDFLAGS from PHP_RPATHS 873 dnl 874 AC_DEFUN([PHP_UTILIZE_RPATHS],[ 875 OLD_RPATHS=$PHP_RPATHS 876 unset PHP_RPATHS 877 878 for i in $OLD_RPATHS; do 879 dnl Can be passed to native cc/libtool 880 PHP_LDFLAGS="$PHP_LDFLAGS -L$i" 881 dnl Libtool-specific 882 PHP_RPATHS="$PHP_RPATHS -R $i" 883 dnl cc-specific 884 NATIVE_RPATHS="$NATIVE_RPATHS $ld_runpath_switch$i" 885 done 886 887 if test "$PHP_RPATH" = "no"; then 888 unset PHP_RPATHS 889 unset NATIVE_RPATHS 890 fi 891 ]) 892 893 dnl 894 dnl PHP_ADD_INCLUDE(path [,before]) 895 dnl 896 dnl add an include path. 897 dnl if before is 1, add in the beginning of INCLUDES. 898 dnl 899 AC_DEFUN([PHP_ADD_INCLUDE],[ 900 if test "$1" != "/usr/include"; then 901 PHP_EXPAND_PATH($1, ai_p) 902 PHP_RUN_ONCE(INCLUDEPATH, $ai_p, [ 903 if test "$2"; then 904 INCLUDES="-I$ai_p $INCLUDES" 905 else 906 INCLUDES="$INCLUDES -I$ai_p" 907 fi 908 ]) 909 fi 910 ]) 911 dnl 912 dnl internal, don't use 913 AC_DEFUN([_PHP_X_ADD_LIBRARY],[dnl 914 ifelse([$2],,$3="-l$1 [$]$3", $3="[$]$3 -l$1") dnl 915 ])dnl 916 dnl 917 dnl internal, don't use 918 AC_DEFUN([_PHP_ADD_LIBRARY_SKELETON],[ 919 case $1 in 920 c|c_r|pthread*[)] ;; 921 *[)] ifelse($3,,[ 922 _PHP_X_ADD_LIBRARY($1,$2,$5) 923 ],[ 924 if test "$ext_shared" = "yes"; then 925 _PHP_X_ADD_LIBRARY($1,$2,$3) 926 else 927 $4($1,$2) 928 fi 929 ]) ;; 930 esac 931 ])dnl 932 dnl 933 dnl 934 dnl 935 dnl PHP_ADD_LIBRARY(library[, append[, shared-libadd]]) 936 dnl 937 dnl add a library to the link line 938 dnl 939 AC_DEFUN([PHP_ADD_LIBRARY],[ 940 _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY],[LIBS]) 941 ]) 942 943 dnl 944 dnl PHP_ADD_LIBRARY_DEFER(library[, append[, shared-libadd]]) 945 dnl 946 dnl add a library to the link line (deferred) 947 dnl 948 AC_DEFUN([PHP_ADD_LIBRARY_DEFER],[ 949 _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY_DEFER],[DLIBS]) 950 ]) 951 952 dnl 953 dnl PHP_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd]) 954 dnl 955 dnl add a library to the link line and path to linkpath/runpath. 956 dnl if shared-libadd is not empty and $ext_shared is yes, 957 dnl shared-libadd will be assigned the library information 958 dnl 959 AC_DEFUN([PHP_ADD_LIBRARY_WITH_PATH],[ 960 ifelse($3,,[ 961 if test -n "$2"; then 962 PHP_ADD_LIBPATH($2) 963 fi 964 PHP_ADD_LIBRARY($1) 965 ],[ 966 if test "$ext_shared" = "yes"; then 967 $3="-l$1 [$]$3" 968 if test -n "$2"; then 969 PHP_ADD_LIBPATH($2,$3) 970 fi 971 else 972 PHP_ADD_LIBRARY_WITH_PATH($1,$2) 973 fi 974 ]) 975 ]) 976 977 dnl 978 dnl PHP_ADD_LIBRARY_DEFER_WITH_PATH(library, path[, shared-libadd]) 979 dnl 980 dnl add a library to the link line (deferred) 981 dnl and path to linkpath/runpath (not deferred) 982 dnl if shared-libadd is not empty and $ext_shared is yes, 983 dnl shared-libadd will be assigned the library information 984 dnl 985 AC_DEFUN([PHP_ADD_LIBRARY_DEFER_WITH_PATH],[ 986 ifelse($3,,[ 987 if test -n "$2"; then 988 PHP_ADD_LIBPATH($2) 989 fi 990 PHP_ADD_LIBRARY_DEFER($1) 991 ],[ 992 if test "$ext_shared" = "yes"; then 993 $3="-l$1 [$]$3" 994 if test -n "$2"; then 995 PHP_ADD_LIBPATH($2,$3) 996 fi 997 else 998 PHP_ADD_LIBRARY_DEFER_WITH_PATH($1,$2) 999 fi 1000 ]) 1001 ]) 1002 1003 dnl 1004 dnl PHP_ADD_FRAMEWORK(framework [,before]) 1005 dnl 1006 dnl add a (Darwin / Mac OS X) framework to the link 1007 dnl line. if before is 1, the framework is added 1008 dnl to the beginning of the line. 1009 1010 AC_DEFUN([PHP_ADD_FRAMEWORK], [ 1011 PHP_RUN_ONCE(FRAMEWORKS, $1, [ 1012 if test "$2"; then 1013 PHP_FRAMEWORKS="-framework $1 $PHP_FRAMEWORKS" 1014 else 1015 PHP_FRAMEWORKS="$PHP_FRAMEWORKS -framework $1" 1016 fi 1017 ]) 1018 ]) 1019 1020 dnl 1021 dnl PHP_ADD_FRAMEWORKPATH(path [,before]) 1022 dnl 1023 dnl add a (Darwin / Mac OS X) framework path to the link 1024 dnl and include lines. default paths include (but are 1025 dnl not limited to) /Local/Library/Frameworks and 1026 dnl /System/Library/Frameworks, so these don't need 1027 dnl to be specifically added. if before is 1, the 1028 dnl framework path is added to the beginning of the 1029 dnl relevant lines. 1030 1031 AC_DEFUN([PHP_ADD_FRAMEWORKPATH], [ 1032 PHP_EXPAND_PATH($1, ai_p) 1033 PHP_RUN_ONCE(FRAMEWORKPATH, $ai_p, [ 1034 if test "$2"; then 1035 PHP_FRAMEWORKPATH="-F$ai_p $PHP_FRAMEWORKPATH" 1036 else 1037 PHP_FRAMEWORKPATH="$PHP_FRAMEWORKPATH -F$ai_p" 1038 fi 1039 ]) 1040 ]) 1041 1042 dnl 1043 dnl PHP_ADD_FRAMEWORK_WITH_PATH(framework, path) 1044 dnl 1045 dnl add a (Darwin / Mac OS X) framework path and the 1046 dnl framework itself to the link and include lines. 1047 AC_DEFUN([PHP_ADD_FRAMEWORK_WITH_PATH], [ 1048 PHP_ADD_FRAMEWORKPATH($2) 1049 PHP_ADD_FRAMEWORK($1) 1050 ]) 1051 1052 dnl 1053 dnl Set libtool variable 1054 dnl 1055 AC_DEFUN([PHP_SET_LIBTOOL_VARIABLE],[ 1056 if test -z "$LIBTOOL"; then 1057 LIBTOOL='$(SHELL) $(top_builddir)/libtool $1' 1058 else 1059 LIBTOOL="$LIBTOOL $1" 1060 fi 1061 ]) 1062 1063 dnl 1064 dnl Check for cc option 1065 dnl 1066 AC_DEFUN([PHP_CHECK_CC_OPTION],[ 1067 echo "main(){return 0;}" > conftest.$ac_ext 1068 opt=$1 1069 changequote({,}) 1070 var=`echo $opt|sed 's/[^a-zA-Z0-9]/_/g'` 1071 changequote([,]) 1072 AC_MSG_CHECKING([if compiler supports -$1 really]) 1073 ac_php_compile="${CC-cc} -$opt -o conftest $CFLAGS $CPPFLAGS conftest.$ac_ext 2>&1" 1074 if eval $ac_php_compile 2>&1 | egrep "$opt" > /dev/null 2>&1 ; then 1075 eval php_cc_$var=no 1076 AC_MSG_RESULT([no]) 1077 else 1078 if eval ./conftest 2>/dev/null ; then 1079 eval php_cc_$var=yes 1080 AC_MSG_RESULT([yes]) 1081 else 1082 eval php_cc_$var=no 1083 AC_MSG_RESULT([no]) 1084 fi 1085 fi 1086 rm -rf conftest* 1087 ]) 1088 1089 1090 dnl 1091 dnl PHP_REGEX 1092 dnl 1093 AC_DEFUN([PHP_REGEX],[ 1094 if test "$REGEX_TYPE" = "php"; then 1095 AC_DEFINE(HAVE_REGEX_T_RE_MAGIC, 1, [ ]) 1096 AC_DEFINE(HSREGEX,1,[ ]) 1097 AC_DEFINE(REGEX,1,[ ]) 1098 PHP_ADD_SOURCES(regex, regcomp.c regexec.c regerror.c regfree.c) 1099 elif test "$REGEX_TYPE" = "system"; then 1100 AC_DEFINE(REGEX,0,[ ]) 1101 dnl Check if field re_magic exists in struct regex_t 1102 AC_CACHE_CHECK([whether field re_magic exists in struct regex_t], ac_cv_regex_t_re_magic, [ 1103 AC_TRY_COMPILE([#include <sys/types.h> 1104 #include <regex.h>], [regex_t rt; rt.re_magic;], 1105 [ac_cv_regex_t_re_magic=yes], [ac_cv_regex_t_re_magic=no]) 1106 ]) 1107 if test "$ac_cv_regex_t_re_magic" = "yes"; then 1108 AC_DEFINE([HAVE_REGEX_T_RE_MAGIC], [ ], 1) 1109 fi 1110 fi 1111 AC_MSG_CHECKING([which regex library to use]) 1112 AC_MSG_RESULT([$REGEX_TYPE]) 1113 ]) 1114 1115 1116 dnl 1117 dnl See if we have broken header files like SunOS has. 1118 dnl 1119 AC_DEFUN([PHP_MISSING_FCLOSE_DECL],[ 1120 AC_MSG_CHECKING([for fclose declaration]) 1121 AC_TRY_COMPILE([#include <stdio.h>],[int (*func)() = fclose],[ 1122 AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ]) 1123 AC_MSG_RESULT([ok]) 1124 ],[ 1125 AC_DEFINE(MISSING_FCLOSE_DECL,1,[ ]) 1126 AC_MSG_RESULT([missing]) 1127 ]) 1128 ]) 1129 1130 dnl 1131 dnl Check for broken sprintf(), C99 conformance 1132 dnl 1133 AC_DEFUN([PHP_AC_BROKEN_SPRINTF],[ 1134 AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[ 1135 AC_TRY_RUN([main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }],[ 1136 ac_cv_broken_sprintf=no 1137 ],[ 1138 ac_cv_broken_sprintf=yes 1139 ],[ 1140 ac_cv_broken_sprintf=no 1141 ]) 1142 ]) 1143 if test "$ac_cv_broken_sprintf" = "yes"; then 1144 AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [Whether sprintf is C99 conform]) 1145 else 1146 AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [Whether sprintf is C99 conform]) 1147 fi 1148 ]) 1149 1150 dnl 1151 dnl Check for broken snprintf(), C99 conformance 1152 dnl 1153 AC_DEFUN([PHP_AC_BROKEN_SNPRINTF],[ 1154 AC_CACHE_CHECK(whether snprintf is broken, ac_cv_broken_snprintf,[ 1155 AC_TRY_RUN([ 1156 #define NULL (0L) 1157 main() { 1158 char buf[20]; 1159 int res = 0; 1160 res = res || (snprintf(buf, 2, "marcus") != 6); 1161 res = res || (buf[1] != '\0'); 1162 /* Implementations may consider this as an encoding error */ 1163 snprintf(buf, 0, "boerger"); 1164 /* However, they MUST ignore the pointer */ 1165 res = res || (buf[0] != 'm'); 1166 res = res || (snprintf(NULL, 0, "boerger") != 7); 1167 res = res || (snprintf(buf, sizeof(buf), "%f", 0.12345678) != 8); 1168 exit(res); 1169 } 1170 ],[ 1171 ac_cv_broken_snprintf=no 1172 ],[ 1173 ac_cv_broken_snprintf=yes 1174 ],[ 1175 ac_cv_broken_snprintf=no 1176 ]) 1177 ]) 1178 if test "$ac_cv_broken_snprintf" = "yes"; then 1179 AC_DEFINE(PHP_BROKEN_SNPRINTF, 1, [Whether snprintf is C99 conform]) 1180 else 1181 AC_DEFINE(PHP_BROKEN_SNPRINTF, 0, [Whether snprintf is C99 conform]) 1182 fi 1183 ]) 1184 1185 dnl PHP_SHARED_MODULE(module-name, object-var, build-dir, cxx) 1186 dnl 1187 dnl Basically sets up the link-stage for building module-name 1188 dnl from object_var in build-dir. 1189 dnl 1190 AC_DEFUN([PHP_SHARED_MODULE],[ 1191 install_modules="install-modules" 1192 1193 case $host_alias in 1194 *darwin*[)] 1195 suffix=so 1196 link_cmd='ifelse($4,,[$(CC)],[$(CXX)]) -dynamic -flat_namespace -bundle -undefined suppress $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -o [$]@ $(EXTRA_LDFLAGS) $($2) $(translit($1,a-z_-,A-Z__)_SHARED_LIBADD)' 1197 ;; 1198 *netware*[)] 1199 suffix=nlm 1200 link_cmd='$(LIBTOOL) --mode=link ifelse($4,,[$(CC)],[$(CXX)]) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -o [$]@ -shared -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $($2) $(translit($1,a-z_-,A-Z__)_SHARED_LIBADD)' 1201 ;; 1202 *[)] 1203 suffix=la 1204 link_cmd='$(LIBTOOL) --mode=link ifelse($4,,[$(CC)],[$(CXX)]) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -o [$]@ -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $($2) $(translit($1,a-z_-,A-Z__)_SHARED_LIBADD)' 1205 ;; 1206 esac 1207 1208 PHP_MODULES="$PHP_MODULES \$(phplibdir)/$1.$suffix" 1209 PHP_SUBST($2) 1210 cat >>Makefile.objects<<EOF 1211 \$(phplibdir)/$1.$suffix: $3/$1.$suffix 1212 \$(LIBTOOL) --mode=install cp $3/$1.$suffix \$(phplibdir) 1213 1214 $3/$1.$suffix: \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_DEPENDENCIES) 1215 $link_cmd 1216 1217 EOF 1218 ]) 1219 1220 dnl 1221 dnl PHP_SELECT_SAPI(name, type[, sources [, extra-cflags [, build-target]]]) 1222 dnl 1223 dnl Selects the SAPI name and type (static, shared, programm) 1224 dnl and optionally also the source-files for the SAPI-specific 1225 dnl objects. 1226 dnl 1227 AC_DEFUN([PHP_SELECT_SAPI],[ 1228 PHP_SAPI=$1 1229 1230 case "$2" in 1231 static[)] PHP_BUILD_STATIC;; 1232 shared[)] PHP_BUILD_SHARED;; 1233 bundle[)] PHP_BUILD_BUNDLE;; 1234 program[)] PHP_BUILD_PROGRAM($5);; 1235 esac 1236 1237 ifelse($3,,,[PHP_ADD_SOURCES([sapi/$1],[$3],[$4],[sapi])]) 1238 ]) 1239 1240 dnl deprecated 1241 AC_DEFUN([PHP_EXTENSION],[ 1242 sources=`$AWK -f $abs_srcdir/build/scan_makefile_in.awk < []PHP_EXT_SRCDIR($1)[]/Makefile.in` 1243 1244 PHP_NEW_EXTENSION($1, $sources, $2, $3) 1245 1246 if test -r "$ext_srcdir/Makefile.frag"; then 1247 PHP_ADD_MAKEFILE_FRAGMENT 1248 fi 1249 ]) 1250 1251 AC_DEFUN([PHP_ADD_BUILD_DIR],[ 1252 BUILD_DIR="$BUILD_DIR $1" 1253 ]) 1254 1255 AC_DEFUN([PHP_GEN_BUILD_DIRS],[ 1256 $php_shtool mkdir -p $BUILD_DIR 1257 ]) 1258 1259 dnl 1260 dnl PHP_NEW_EXTENSION(extname, sources [, shared [,sapi_class[, extra-cflags[, cxx]]]]) 1261 dnl 1262 dnl Includes an extension in the build. 1263 dnl 1264 dnl "extname" is the name of the ext/ subdir where the extension resides. 1265 dnl "sources" is a list of files relative to the subdir which are used 1266 dnl to build the extension. 1267 dnl "shared" can be set to "shared" or "yes" to build the extension as 1268 dnl a dynamically loadable library. Optional parameter "sapi_class" can 1269 dnl be set to "cli" to mark extension build only with CLI or CGI sapi's. 1270 dnl extra-cflags are passed to the compiler, with @ext_srcdir@ being 1271 dnl substituted. 1272 AC_DEFUN([PHP_NEW_EXTENSION],[ 1273 ext_builddir=[]PHP_EXT_BUILDDIR($1) 1274 ext_srcdir=[]PHP_EXT_SRCDIR($1) 1275 1276 ifelse($5,,ac_extra=,[ac_extra=`echo "$5"|sed s#@ext_srcdir@#$ext_srcdir#g`]) 1277 1278 if test "$3" != "shared" && test "$3" != "yes" && test "$4" != "cli"; then 1279 dnl ---------------------------------------------- Static module 1280 1281 PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,) 1282 EXT_STATIC="$EXT_STATIC $1" 1283 if test "$3" != "nocli"; then 1284 EXT_CLI_STATIC="$EXT_CLI_STATIC $1" 1285 fi 1286 else 1287 if test "$3" = "shared" || test "$3" = "yes"; then 1288 dnl ---------------------------------------------- Shared module 1289 PHP_ADD_SOURCES_X(PHP_EXT_DIR($1),$2,$ac_extra,shared_objects_$1,yes) 1290 case $host_alias in 1291 *netware*) 1292 PHP_ADD_LIBRARY_WITH_PATH(php5lib, netware, translit($1,a-z_-,A-Z__)_SHARED_LIBADD) 1293 ;; 1294 esac 1295 PHP_SHARED_MODULE($1,shared_objects_$1, $ext_builddir, $6) 1296 AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z_-,A-Z__), 1, Whether to build $1 as dynamic module) 1297 fi 1298 fi 1299 1300 if test "$3" != "shared" && test "$3" != "yes" && test "$4" = "cli"; then 1301 dnl ---------------------------------------------- CLI static module 1302 if test "$PHP_SAPI" = "cgi"; then 1303 PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,) 1304 EXT_STATIC="$EXT_STATIC $1" 1305 else 1306 PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,cli) 1307 fi 1308 EXT_CLI_STATIC="$EXT_CLI_STATIC $1" 1309 fi 1310 PHP_ADD_BUILD_DIR($ext_builddir) 1311 ]) 1312 1313 dnl 1314 dnl Solaris requires main code to be position independent in order 1315 dnl to let shared objects find symbols. Weird. Ugly. 1316 dnl 1317 dnl Must be run after all --with-NN options that let the user 1318 dnl choose dynamic extensions, and after the gcc test. 1319 dnl 1320 AC_DEFUN([PHP_SOLARIS_PIC_WEIRDNESS],[ 1321 AC_MSG_CHECKING([whether -fPIC is required]) 1322 if test -n "$EXT_SHARED"; then 1323 os=`uname -sr 2>/dev/null` 1324 case $os in 1325 "SunOS 5.6"|"SunOS 5.7"[)] 1326 case $CC in 1327 gcc*|egcs*) CFLAGS="$CFLAGS -fPIC";; 1328 *[)] CFLAGS="$CFLAGS -fpic";; 1329 esac 1330 AC_MSG_RESULT([yes]);; 1331 *[)] 1332 AC_MSG_RESULT([no]);; 1333 esac 1334 else 1335 AC_MSG_RESULT([no]) 1336 fi 1337 ]) 1338 1339 dnl 1340 dnl Checks whether $withval is "shared" or starts with "shared,XXX" 1341 dnl and sets $shared to "yes" or "no", and removes "shared,?" stuff 1342 dnl from $withval. 1343 dnl 1344 AC_DEFUN([PHP_WITH_SHARED],[ 1345 PHP_ARG_ANALYZE_EX(withval) 1346 shared=$ext_shared 1347 unset ext_shared ext_output 1348 ]) 1349 1350 dnl The problem is that the default compilation flags in Solaris 2.6 won't 1351 dnl let programs access large files; you need to tell the compiler that 1352 dnl you actually want your programs to work on large files. For more 1353 dnl details about this brain damage please see: 1354 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html 1355 1356 dnl Written by Paul Eggert <eggert@twinsun.com>. 1357 1358 AC_DEFUN([PHP_SYS_LFS], 1359 [dnl 1360 # If available, prefer support for large files unless the user specified 1361 # one of the CPPFLAGS, LDFLAGS, or LIBS variables. 1362 AC_MSG_CHECKING([whether large file support needs explicit enabling]) 1363 ac_getconfs='' 1364 ac_result=yes 1365 ac_set='' 1366 ac_shellvars='CPPFLAGS LDFLAGS LIBS' 1367 for ac_shellvar in $ac_shellvars; do 1368 case $ac_shellvar in 1369 CPPFLAGS[)] ac_lfsvar=LFS_CFLAGS ;; 1370 *[)] ac_lfsvar=LFS_$ac_shellvar ;; 1371 esac 1372 eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar 1373 (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; } 1374 ac_getconf=`getconf $ac_lfsvar` 1375 ac_getconfs=$ac_getconfs$ac_getconf 1376 eval ac_test_$ac_shellvar=\$ac_getconf 1377 done 1378 case "$ac_result$ac_getconfs" in 1379 yes[)] ac_result=no ;; 1380 esac 1381 case "$ac_result$ac_set" in 1382 yes?*[)] ac_result="yes, but $ac_set is already set, so use its settings" 1383 esac 1384 AC_MSG_RESULT([$ac_result]) 1385 case $ac_result in 1386 yes[)] 1387 for ac_shellvar in $ac_shellvars; do 1388 eval $ac_shellvar=\$ac_test_$ac_shellvar 1389 done ;; 1390 esac 1391 ]) 1392 1393 AC_DEFUN([PHP_SOCKADDR_SA_LEN],[ 1394 AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[ 1395 AC_TRY_COMPILE([#include <sys/types.h> 1396 #include <sys/socket.h>], 1397 [struct sockaddr s; s.sa_len;], 1398 [ac_cv_sockaddr_sa_len=yes 1399 AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[ ])], 1400 [ac_cv_sockaddr_sa_len=no]) 1401 ]) 1402 ]) 1403 1404 1405 dnl ## PHP_OUTPUT(file) 1406 dnl ## adds "file" to the list of files generated by AC_OUTPUT 1407 dnl ## This macro can be used several times. 1408 AC_DEFUN([PHP_OUTPUT],[ 1409 PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1" 1410 ]) 1411 1412 AC_DEFUN([PHP_DECLARED_TIMEZONE],[ 1413 AC_CACHE_CHECK(for declared timezone, ac_cv_declared_timezone,[ 1414 AC_TRY_COMPILE([ 1415 #include <sys/types.h> 1416 #include <time.h> 1417 #ifdef HAVE_SYS_TIME_H 1418 #include <sys/time.h> 1419 #endif 1420 ],[ 1421 time_t foo = (time_t) timezone; 1422 ],[ 1423 ac_cv_declared_timezone=yes 1424 ],[ 1425 ac_cv_declared_timezone=no 1426 ])]) 1427 if test "$ac_cv_declared_timezone" = "yes"; then 1428 AC_DEFINE(HAVE_DECLARED_TIMEZONE, 1, [Whether system headers declare timezone]) 1429 fi 1430 ]) 1431 1432 AC_DEFUN([PHP_EBCDIC],[ 1433 AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[ 1434 AC_TRY_RUN( [ 1435 int main(void) { 1436 return (unsigned char)'A' != (unsigned char)0xC1; 1437 } 1438 ],[ 1439 ac_cv_ebcdic=yes 1440 ],[ 1441 ac_cv_ebcdic=no 1442 ],[ 1443 ac_cv_ebcdic=no 1444 ])]) 1445 if test "$ac_cv_ebcdic" = "yes"; then 1446 AC_DEFINE(CHARSET_EBCDIC,1, [Define if system uses EBCDIC]) 1447 fi 1448 ]) 1449 1450 dnl Some systems, notably Solaris, cause getcwd() or realpath to fail if a 1451 dnl component of the path has execute but not read permissions 1452 AC_DEFUN([PHP_BROKEN_GETCWD],[ 1453 AC_MSG_CHECKING([for broken getcwd]) 1454 os=`uname -sr 2>/dev/null` 1455 case $os in 1456 SunOS*[)] 1457 AC_DEFINE(HAVE_BROKEN_GETCWD,1, [Define if system has broken getcwd]) 1458 AC_MSG_RESULT([yes]);; 1459 *[)] 1460 AC_MSG_RESULT([no]);; 1461 esac 1462 ]) 1463 1464 AC_DEFUN([PHP_BROKEN_GLIBC_FOPEN_APPEND],[ 1465 AC_MSG_CHECKING([for broken libc stdio]) 1466 AC_CACHE_VAL(have_broken_glibc_fopen_append,[ 1467 AC_TRY_RUN([ 1468 #include <stdio.h> 1469 int main(int argc, char *argv[]) 1470 { 1471 FILE *fp; 1472 long position; 1473 char *filename = "/tmp/phpglibccheck"; 1474 1475 fp = fopen(filename, "w"); 1476 if (fp == NULL) { 1477 perror("fopen"); 1478 exit(2); 1479 } 1480 fputs("foobar", fp); 1481 fclose(fp); 1482 1483 fp = fopen(filename, "a+"); 1484 position = ftell(fp); 1485 fclose(fp); 1486 unlink(filename); 1487 if (position == 0) 1488 return 1; 1489 return 0; 1490 } 1491 ], 1492 [have_broken_glibc_fopen_append=no], 1493 [have_broken_glibc_fopen_append=yes ], 1494 AC_TRY_COMPILE([ 1495 #include <features.h> 1496 ],[ 1497 #if !__GLIBC_PREREQ(2,2) 1498 choke me 1499 #endif 1500 ], 1501 [have_broken_glibc_fopen_append=yes], 1502 [have_broken_glibc_fopen_append=no ]) 1503 )]) 1504 1505 if test "$have_broken_glibc_fopen_append" = "yes"; then 1506 AC_MSG_RESULT(yes) 1507 AC_DEFINE(HAVE_BROKEN_GLIBC_FOPEN_APPEND,1, [Define if your glibc borks on fopen with mode a+]) 1508 else 1509 AC_MSG_RESULT(no) 1510 fi 1511 ]) 1512 1513 1514 AC_DEFUN([PHP_FOPENCOOKIE],[ 1515 AC_CHECK_FUNC(fopencookie, [ have_glibc_fopencookie=yes ]) 1516 1517 if test "$have_glibc_fopencookie" = "yes" ; then 1518 dnl this comes in two flavors: 1519 dnl newer glibcs (since 2.1.2 ? ) 1520 dnl have a type called cookie_io_functions_t 1521 AC_TRY_COMPILE([ #define _GNU_SOURCE 1522 #include <stdio.h> 1523 ], 1524 [ cookie_io_functions_t cookie; ], 1525 [ have_cookie_io_functions_t=yes ], 1526 [] ) 1527 1528 if test "$have_cookie_io_functions_t" = "yes" ; then 1529 cookie_io_functions_t=cookie_io_functions_t 1530 have_fopen_cookie=yes 1531 1532 dnl even newer glibcs have a different seeker definition... 1533 1534 AC_TRY_RUN([ 1535 #define _GNU_SOURCE 1536 #include <stdio.h> 1537 1538 struct cookiedata { 1539 __off64_t pos; 1540 }; 1541 1542 __ssize_t reader(void *cookie, char *buffer, size_t size) 1543 { return size; } 1544 __ssize_t writer(void *cookie, const char *buffer, size_t size) 1545 { return size; } 1546 int closer(void *cookie) 1547 { return 0; } 1548 int seeker(void *cookie, __off64_t *position, int whence) 1549 { ((struct cookiedata*)cookie)->pos = *position; return 0; } 1550 1551 cookie_io_functions_t funcs = {reader, writer, seeker, closer}; 1552 1553 main() { 1554 struct cookiedata g = { 0 }; 1555 FILE *fp = fopencookie(&g, "r", funcs); 1556 1557 if (fp && fseek(fp, 8192, SEEK_SET) == 0 && g.pos == 8192) 1558 exit(0); 1559 exit(1); 1560 } 1561 1562 ], 1563 [ cookie_io_functions_use_off64_t=yes ], 1564 [ ] ) 1565 1566 else 1567 dnl older glibc versions (up to 2.1.2 ?) 1568 dnl call it _IO_cookie_io_functions_t 1569 AC_TRY_COMPILE([ #define _GNU_SOURCE 1570 #include <stdio.h> 1571 ], 1572 [ _IO_cookie_io_functions_t cookie; ], 1573 [ have_IO_cookie_io_functions_t=yes ], 1574 [] ) 1575 if test "$have_cookie_io_functions_t" = "yes" ; then 1576 cookie_io_functions_t=_IO_cookie_io_functions_t 1577 have_fopen_cookie=yes 1578 fi 1579 fi 1580 1581 if test "$have_fopen_cookie" = "yes" ; then 1582 AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ]) 1583 AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ]) 1584 if test "$cookie_io_functions_use_off64_t" = "yes" ; then 1585 AC_DEFINE(COOKIE_SEEKER_USES_OFF64_T, 1, [ ]) 1586 fi 1587 fi 1588 1589 fi 1590 ]) 1591 1592 1593 dnl 1594 dnl PHP_CHECK_LIBRARY(library, function [, action-found [, action-not-found [, extra-libs]]]) 1595 dnl 1596 dnl Wrapper for AC_CHECK_LIB 1597 dnl 1598 AC_DEFUN([PHP_CHECK_LIBRARY], [ 1599 save_old_LDFLAGS=$LDFLAGS 1600 ac_stuff="$5" 1601 1602 save_ext_shared=$ext_shared 1603 ext_shared=yes 1604 PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS) 1605 AC_CHECK_LIB([$1],[$2],[ 1606 LDFLAGS=$save_old_LDFLAGS 1607 ext_shared=$save_ext_shared 1608 $3 1609 ],[ 1610 LDFLAGS=$save_old_LDFLAGS 1611 ext_shared=$save_ext_shared 1612 unset ac_cv_lib_$1[]_$2 1613 $4 1614 ])dnl 1615 ]) 1616 1617 dnl 1618 dnl PHP_CHECK_FRAMEWORK(framework, function [, action-found [, action-not-found ]]) 1619 dnl 1620 dnl El cheapo wrapper for AC_CHECK_LIB 1621 dnl 1622 AC_DEFUN([PHP_CHECK_FRAMEWORK], [ 1623 save_old_LDFLAGS=$LDFLAGS 1624 LDFLAGS="-framework $1 $LDFLAGS" 1625 dnl supplying "c" to AC_CHECK_LIB is technically cheating, but 1626 dnl rewriting AC_CHECK_LIB is overkill and this only affects 1627 dnl the "checking.." output anyway. 1628 AC_CHECK_LIB(c,[$2],[ 1629 LDFLAGS=$save_old_LDFLAGS 1630 $3 1631 ],[ 1632 LDFLAGS=$save_old_LDFLAGS 1633 $4 1634 ]) 1635 ]) 1636 1637 dnl 1638 dnl PHP_SETUP_KERBEROS(shared-add [, action-found [, action-not-found]]) 1639 dnl 1640 dnl Common setup macro for kerberos 1641 dnl 1642 AC_DEFUN([PHP_SETUP_KERBEROS],[ 1643 found_kerberos=no 1644 unset KERBEROS_CFLAGS 1645 unset KERBEROS_LIBS 1646 1647 dnl First try to find krb5-config 1648 if test -z "$KRB5_CONFIG"; then 1649 AC_PATH_PROG(KRB5_CONFIG, krb5-config, no, [$PATH:/usr/kerberos/bin:/usr/local/bin]) 1650 fi 1651 1652 dnl If krb5-config is found try using it 1653 if test "$PHP_KERBEROS" = "yes" && test -x "$KRB5_CONFIG"; then 1654 KERBEROS_LIBS=`$KRB5_CONFIG --libs gssapi` 1655 KERBEROS_CFLAGS=`$KRB5_CONFIG --cflags gssapi` 1656 1657 if test -n "$KERBEROS_LIBS" && test -n "$KERBEROS_CFLAGS"; then 1658 found_kerberos=yes 1659 PHP_EVAL_LIBLINE($KERBEROS_LIBS, $1) 1660 PHP_EVAL_INCLINE($KERBEROS_CFLAGS) 1661 fi 1662 fi 1663 1664 dnl If still not found use old skool method 1665 if test "$found_kerberos" = "no"; then 1666 1667 if test "$PHP_KERBEROS" = "yes"; then 1668 PHP_KERBEROS="/usr/kerberos /usr/local /usr" 1669 fi 1670 1671 for i in $PHP_KERBEROS; do 1672 if test -f $i/lib/libkrb5.a || test -f $i/lib/libkrb5.$SHLIB_SUFFIX_NAME; then 1673 PHP_KERBEROS_DIR=$i 1674 break 1675 fi 1676 done 1677 1678 if test "$PHP_KERBEROS_DIR"; then 1679 found_kerberos=yes 1680 PHP_ADD_LIBPATH($PHP_KERBEROS_DIR/lib, $1) 1681 PHP_ADD_LIBRARY(gssapi_krb5, 1, $1) 1682 PHP_ADD_LIBRARY(krb5, 1, $1) 1683 PHP_ADD_LIBRARY(k5crypto, 1, $1) 1684 PHP_ADD_LIBRARY(com_err, 1, $1) 1685 PHP_ADD_INCLUDE($PHP_KERBEROS_DIR/include) 1686 fi 1687 fi 1688 1689 if test "$found_kerberos" = "yes"; then 1690 ifelse([$2],[],:,[$2]) 1691 ifelse([$3],[],,[else $3]) 1692 fi 1693 ]) 1694 1695 dnl 1696 dnl PHP_SETUP_OPENSSL(shared-add [, action-found [, action-not-found]]) 1697 dnl 1698 dnl Common setup macro for openssl 1699 dnl 1700 AC_DEFUN([PHP_SETUP_OPENSSL],[ 1701 found_openssl=no 1702 unset OPENSSL_INCDIR 1703 unset OPENSSL_LIBDIR 1704 1705 dnl Empty variable means 'no' 1706 test -z "$PHP_OPENSSL" && PHP_OPENSSL=no 1707 test -z "$PHP_IMAP_SSL" && PHP_IMAP_SSL=no 1708 1709 dnl Fallbacks for different configure options 1710 if test "$PHP_OPENSSL" != "no"; then 1711 PHP_OPENSSL_DIR=$PHP_OPENSSL 1712 elif test "$PHP_IMAP_SSL" != "no"; then 1713 PHP_OPENSSL_DIR=$PHP_IMAP_SSL 1714 fi 1715 1716 dnl First try to find pkg-config 1717 if test -z "$PKG_CONFIG"; then 1718 AC_PATH_PROG(PKG_CONFIG, pkg-config, no) 1719 fi 1720 1721 dnl If pkg-config is found try using it 1722 if test "$PHP_OPENSSL_DIR" = "yes" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists openssl; then 1723 if $PKG_CONFIG --atleast-version=0.9.6 openssl; then 1724 found_openssl=yes 1725 OPENSSL_LIBS=`$PKG_CONFIG --libs openssl` 1726 OPENSSL_INCS=`$PKG_CONFIG --cflags-only-I openssl` 1727 OPENSSL_INCDIR=`$PKG_CONFIG --variable=includedir openssl` 1728 else 1729 AC_MSG_ERROR([OpenSSL version 0.9.6 or greater required.]) 1730 fi 1731 1732 if test -n "$OPENSSL_LIBS" && test -n "$OPENSSL_INCS"; then 1733 PHP_EVAL_LIBLINE($OPENSSL_LIBS, $1) 1734 PHP_EVAL_INCLINE($OPENSSL_INCS) 1735 fi 1736 fi 1737 1738 dnl If pkg-config fails for some reason, revert to the old method 1739 if test "$found_openssl" = "no"; then 1740 1741 if test "$PHP_OPENSSL_DIR" = "yes"; then 1742 PHP_OPENSSL_DIR="/usr/local/ssl /usr/local /usr /usr/local/openssl" 1743 fi 1744 1745 for i in $PHP_OPENSSL_DIR; do 1746 if test -r $i/include/openssl/evp.h; then 1747 OPENSSL_INCDIR=$i/include 1748 fi 1749 if test -r $i/lib/libssl.a -o -r $i/lib/libssl.$SHLIB_SUFFIX_NAME; then 1750 OPENSSL_LIBDIR=$i/lib 1751 fi 1752 test -n "$OPENSSL_INCDIR" && test -n "$OPENSSL_LIBDIR" && break 1753 done 1754 1755 if test -z "$OPENSSL_INCDIR"; then 1756 AC_MSG_ERROR([Cannot find OpenSSL's <evp.h>]) 1757 fi 1758 1759 if test -z "$OPENSSL_LIBDIR"; then 1760 AC_MSG_ERROR([Cannot find OpenSSL's libraries]) 1761 fi 1762 1763 old_CPPFLAGS=$CPPFLAGS 1764 CPPFLAGS=-I$OPENSSL_INCDIR 1765 AC_MSG_CHECKING([for OpenSSL version]) 1766 AC_EGREP_CPP(yes,[ 1767 #include <openssl/opensslv.h> 1768 #if OPENSSL_VERSION_NUMBER >= 0x0090600fL 1769 yes 1770 #endif 1771 ],[ 1772 AC_MSG_RESULT([>= 0.9.6]) 1773 ],[ 1774 AC_MSG_ERROR([OpenSSL version 0.9.6 or greater required.]) 1775 ]) 1776 CPPFLAGS=$old_CPPFLAGS 1777 1778 PHP_ADD_INCLUDE($OPENSSL_INCDIR) 1779 1780 PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [ 1781 PHP_ADD_LIBRARY(crypto,,$1) 1782 ],[ 1783 AC_MSG_ERROR([libcrypto not found!]) 1784 ],[ 1785 -L$OPENSSL_LIBDIR 1786 ]) 1787 1788 old_LIBS=$LIBS 1789 LIBS="$LIBS -lcrypto" 1790 PHP_CHECK_LIBRARY(ssl, SSL_CTX_set_ssl_version, [ 1791 found_openssl=yes 1792 ],[ 1793 AC_MSG_ERROR([libssl not found!]) 1794 ],[ 1795 -L$OPENSSL_LIBDIR 1796 ]) 1797 LIBS=$old_LIBS 1798 PHP_ADD_LIBRARY(ssl,,$1) 1799 1800 PHP_ADD_LIBPATH($OPENSSL_LIBDIR, $1) 1801 fi 1802 1803 if test "$found_openssl" = "yes"; then 1804 dnl For apache 1.3.x static build 1805 OPENSSL_INCDIR_OPT=-I$OPENSSL_INCDIR 1806 AC_SUBST(OPENSSL_INCDIR_OPT) 1807 1808 ifelse([$2],[],:,[$2]) 1809 ifelse([$3],[],,[else $3]) 1810 fi 1811 ]) 1812 1813 dnl 1814 dnl PHP_SETUP_ICONV(shared-add [, action-found [, action-not-found]]) 1815 dnl 1816 dnl Common setup macro for iconv 1817 dnl 1818 AC_DEFUN([PHP_SETUP_ICONV], [ 1819 found_iconv=no 1820 unset ICONV_DIR 1821 1822 # Create the directories for a VPATH build: 1823 test -d ext || mkdir ext 1824 test -d ext/iconv || mkdir ext/iconv 1825 1826 echo > ext/iconv/php_have_bsd_iconv.h 1827 echo > ext/iconv/php_have_glibc_iconv.h 1828 echo > ext/iconv/php_have_libiconv.h 1829 echo > ext/iconv/php_have_iconv.h 1830 echo > ext/iconv/php_php_iconv_impl.h 1831 echo > ext/iconv/php_php_iconv_h_path.h 1832 echo > ext/iconv/php_iconv_supports_errno.h 1833 1834 dnl 1835 dnl Check libc first if no path is provided in --with-iconv 1836 dnl 1837 if test "$PHP_ICONV" = "yes"; then 1838 AC_CHECK_FUNC(iconv, [ 1839 PHP_DEFINE(HAVE_ICONV,1,[ext/iconv]) 1840 found_iconv=yes 1841 ],[ 1842 AC_CHECK_FUNC(libiconv,[ 1843 PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv]) 1844 found_iconv=yes 1845 ]) 1846 ]) 1847 fi 1848 1849 dnl 1850 dnl Check external libs for iconv funcs 1851 dnl 1852 if test "$found_iconv" = "no"; then 1853 1854 for i in $PHP_ICONV /usr/local /usr; do 1855 if test -r $i/include/giconv.h; then 1856 AC_DEFINE(HAVE_GICONV_H, 1, [ ]) 1857 ICONV_DIR=$i 1858 iconv_lib_name=giconv 1859 break 1860 elif test -r $i/include/iconv.h; then 1861 ICONV_DIR=$i 1862 iconv_lib_name=iconv 1863 break 1864 fi 1865 done 1866 1867 if test -z "$ICONV_DIR"; then 1868 AC_MSG_ERROR([Please specify the install prefix of iconv with --with-iconv=<DIR>]) 1869 fi 1870 1871 if test -f $ICONV_DIR/lib/lib$iconv_lib_name.a || 1872 test -f $ICONV_DIR/lib/lib$iconv_lib_name.$SHLIB_SUFFIX_NAME 1873 then 1874 PHP_CHECK_LIBRARY($iconv_lib_name, libiconv, [ 1875 found_iconv=yes 1876 PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv]) 1877 ], [ 1878 PHP_CHECK_LIBRARY($iconv_lib_name, iconv, [ 1879 found_iconv=yes 1880 PHP_DEFINE(HAVE_ICONV,1,[ext/iconv]) 1881 ], [], [ 1882 -L$ICONV_DIR/lib 1883 ]) 1884 ], [ 1885 -L$ICONV_DIR/lib 1886 ]) 1887 fi 1888 fi 1889 1890 if test "$found_iconv" = "yes"; then 1891 if test -n "$ICONV_DIR"; then 1892 AC_DEFINE(HAVE_ICONV, 1, [ ]) 1893 PHP_ADD_LIBRARY_WITH_PATH($iconv_lib_name, $ICONV_DIR/lib, $1) 1894 PHP_ADD_INCLUDE($ICONV_DIR/include) 1895 fi 1896 $2 1897 ifelse([$3],[],,[else $3]) 1898 fi 1899 ]) 1900 1901 dnl 1902 dnl PHP_SETUP_LIBXML(shared-add [, action-found [, action-not-found]]) 1903 dnl 1904 dnl Common setup macro for libxml 1905 dnl 1906 AC_DEFUN([PHP_SETUP_LIBXML], [ 1907 1908 for i in $PHP_LIBXML_DIR /usr/local /usr; do 1909 if test -x "$i/bin/xml2-config"; then 1910 XML2_CONFIG="$i/bin/xml2-config" 1911 break 1912 fi 1913 done 1914 1915 if test -x "$XML2_CONFIG"; then 1916 libxml_full_version=`$XML2_CONFIG --version` 1917 ac_IFS=$IFS 1918 IFS="." 1919 set $libxml_full_version 1920 IFS=$ac_IFS 1921 LIBXML_VERSION=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3` 1922 if test "$LIBXML_VERSION" -ge "2005010"; then 1923 LIBXML_LIBS=`$XML2_CONFIG --libs` 1924 LIBXML_INCS=`$XML2_CONFIG --cflags` 1925 PHP_EVAL_LIBLINE($LIBXML_LIBS, $1) 1926 PHP_EVAL_INCLINE($LIBXML_INCS) 1927 1928 dnl Check that build works with given libs 1929 AC_CACHE_CHECK(whether libxml build works, php_cv_libxml_build_works, [ 1930 PHP_TEST_BUILD(xmlInitParser, 1931 [ 1932 php_cv_libxml_build_works=yes 1933 ], [ 1934 AC_MSG_RESULT(no) 1935 AC_MSG_ERROR([build test failed. Please check the config.log for details.]) 1936 ], [ 1937 [$]$1 1938 ]) 1939 ]) 1940 if test "$php_cv_libxml_build_works" = "yes"; then 1941 AC_DEFINE(HAVE_LIBXML, 1, [ ]) 1942 fi 1943 $2 1944 else 1945 AC_MSG_ERROR([libxml2 version 2.5.10 or greater required.]) 1946 fi 1947 ifelse([$3],[],,[else $3]) 1948 fi 1949 ]) 1950 1951 AC_DEFUN([PHP_DEF_HAVE],[AC_DEFINE([HAVE_]translit($1,a-z_-,A-Z__), 1, [ ])]) 1952 1953 dnl 1954 dnl PHP_CHECK_FUNC_LIB(func, libs) 1955 dnl This macro checks whether 'func' or '__func' exists 1956 dnl in the specified library. 1957 dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS. 1958 dnl This should be called in the ACTION-IF-NOT-FOUND part of PHP_CHECK_FUNC 1959 dnl 1960 1961 dnl autoconf undefines the builtin "shift" :-( 1962 dnl If possible, we use the builtin shift anyway, otherwise we use 1963 dnl the ubercool definition I have tested so far with FreeBSD/GNU m4 1964 ifdef([builtin],[builtin(define, phpshift, [builtin(shift, $@)])],[ 1965 define([phpshift],[ifelse(index([$@],[,]),-1,,[substr([$@],incr(index([$@],[,])))])]) 1966 ]) 1967 1968 AC_DEFUN([PHP_CHECK_FUNC_LIB],[ 1969 ifelse($2,,:,[ 1970 unset ac_cv_lib_$2[]_$1 1971 unset ac_cv_lib_$2[]___$1 1972 unset found 1973 AC_CHECK_LIB($2, $1, [found=yes], [ 1974 AC_CHECK_LIB($2, __$1, [found=yes], [found=no]) 1975 ]) 1976 1977 if test "$found" = "yes"; then 1978 ac_libs=$LIBS 1979 LIBS="$LIBS -l$2" 1980 AC_TRY_RUN([main() { return (0); }],[found=yes],[found=no],[found=no]) 1981 LIBS=$ac_libs 1982 fi 1983 1984 if test "$found" = "yes"; then 1985 PHP_ADD_LIBRARY($2) 1986 PHP_DEF_HAVE($1) 1987 PHP_DEF_HAVE(lib$2) 1988 ac_cv_func_$1=yes 1989 else 1990 PHP_CHECK_FUNC_LIB($1,phpshift(phpshift($@))) 1991 fi 1992 ]) 1993 ]) 1994 1995 dnl 1996 dnl PHP_CHECK_FUNC(func, ...) 1997 dnl This macro checks whether 'func' or '__func' exists 1998 dnl in the default libraries and as a fall back in the specified library. 1999 dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS. 2000 dnl 2001 AC_DEFUN([PHP_CHECK_FUNC],[ 2002 unset ac_cv_func_$1 2003 unset ac_cv_func___$1 2004 unset found 2005 2006 AC_CHECK_FUNC($1, [found=yes],[ AC_CHECK_FUNC(__$1,[found=yes],[found=no]) ]) 2007 2008 case $found in 2009 yes[)] 2010 PHP_DEF_HAVE($1) 2011 ac_cv_func_$1=yes 2012 ;; 2013 ifelse($#,1,,[ 2014 *[)] PHP_CHECK_FUNC_LIB($@) ;; 2015 ]) 2016 esac 2017 ]) 2018 2019 dnl 2020 dnl PHP_AP_EXTRACT_VERSION(/path/httpd) 2021 dnl This macro is used to get a comparable 2022 dnl version for apache1/2. 2023 dnl 2024 AC_DEFUN([PHP_AP_EXTRACT_VERSION],[ 2025 ac_output=`$1 -v 2>&1` 2026 ac_IFS=$IFS 2027 IFS="- /. 2028 " 2029 set $ac_output 2030 IFS=$ac_IFS 2031 2032 APACHE_VERSION=`expr [$]4 \* 1000000 + [$]5 \* 1000 + [$]6` 2033 ]) 2034 2035 dnl 2036 dnl PHP_TEST_BUILD(function, action-if-ok, action-if-not-ok [, extra-libs [, extra-source]]) 2037 dnl This macro checks whether build works and given function exists. 2038 dnl 2039 AC_DEFUN([PHP_TEST_BUILD], [ 2040 old_LIBS=$LIBS 2041 LIBS="$4 $LIBS" 2042 AC_TRY_RUN([ 2043 $5 2044 char $1(); 2045 int main() { 2046 $1(); 2047 return 0; 2048 } 2049 ], [ 2050 LIBS=$old_LIBS 2051 $2 2052 ],[ 2053 LIBS=$old_LIBS 2054 $3 2055 ],[ 2056 LIBS=$old_LIBS 2057 ]) 2058 ]) 2059 2060 dnl This macro is currently a placeholder in the config.m4 file 2061 dnl it is scanned by genif.sh when it builds the internal functions 2062 dnl list, so that modules can be init'd in the correct order 2063 dnl $1 = name of extension, $2 = extension upon which it depends 2064 dnl $3 = optional: if true, it's ok for $2 to have not been configured 2065 dnl default is false and should halt the build. 2066 dnl See ADD_EXTENSION_DEP in win32 build 2067 AC_DEFUN([PHP_ADD_EXTENSION_DEP], []) 2068 2069 2070 dnl 2071 dnl PHP_C_BIGENDIAN 2072 dnl Replacement macro for AC_C_BIGENDIAN 2073 dnl 2074 AC_DEFUN([PHP_C_BIGENDIAN], 2075 [AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian_php, 2076 [ 2077 ac_cv_c_bigendian_php=unknown 2078 AC_TRY_RUN( 2079 [ 2080 int main(void) 2081 { 2082 short one = 1; 2083 char *cp = (char *)&one; 2084 2085 if (*cp == 0) { 2086 return(0); 2087 } else { 2088 return(1); 2089 } 2090 } 2091 ], [ac_cv_c_bigendian_php=yes], [ac_cv_c_bigendian_php=no], [ac_cv_c_bigendian_php=unknown]) 2092 ]) 2093 if test $ac_cv_c_bigendian_php = yes; then 2094 AC_DEFINE(WORDS_BIGENDIAN, [], [Define if processor uses big-endian word]) 2095 fi 2096 ]) 2097 2098 dnl 2099 dnl PHP_CHECK_PDO_INCLUDES([found [, not-found]]) 2100 dnl 2101 AC_DEFUN([PHP_CHECK_PDO_INCLUDES],[ 2102 AC_CACHE_CHECK([for PDO includes], pdo_inc_path, [ 2103 AC_MSG_CHECKING([for PDO includes]) 2104 if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then 2105 pdo_inc_path=$abs_srcdir/ext 2106 elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then 2107 pdo_inc_path=$abs_srcdir/ext 2108 elif test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then 2109 pdo_inc_path=$prefix/include/php/ext 2110 fi 2111 ]) 2112 if test -n "$pdo_inc_path"; then 2113 ifelse([$1],[],:,[$1]) 2114 else 2115 ifelse([$2],[],[AC_MSG_ERROR([Cannot find php_pdo_driver.h.])],[$2]) 2116 fi 2117 ])