1dnl $Id: acinclude.m4,v 1.1 2004/03/20 01:31:21 nealr Exp $ 2dnl 3dnl This file contains local autoconf functions. 4 5sinclude(dynlib.m4) 6 7dnl 8dnl PHP_TARGET_RDYNAMIC 9dnl 10dnl Checks whether -rdynamic is supported by the compiler. This 11dnl is necessary for some targets to populate the global symbol 12dnl table. Otherwise, dynamic modules would not be able to resolve 13dnl PHP-related symbols. 14dnl 15dnl If successful, adds -rdynamic to PHP_LDFLAGS. 16dnl 17AC_DEFUN(PHP_TARGET_RDYNAMIC,[ 18 if test -n "$GCC"; then 19 dnl we should use a PHP-specific macro here 20 TSRM_CHECK_GCC_ARG(-rdynamic, gcc_rdynamic=yes) 21 if test "$gcc_rdynamic" = "yes"; then 22 PHP_LDFLAGS="$PHP_LDFLAGS -rdynamic" 23 fi 24 fi 25]) 26 27AC_DEFUN(PHP_REMOVE_USR_LIB,[ 28 unset ac_new_flags 29 for i in [$]$1; do 30 case [$]i in 31 -L/usr/lib|-L/usr/lib/) ;; 32 *) ac_new_flags="[$]ac_new_flags [$]i" ;; 33 esac 34 done 35 $1=[$]ac_new_flags 36]) 37 38AC_DEFUN(PHP_SETUP_OPENSSL,[ 39 if test "$PHP_OPENSSL" = "no"; then 40 PHP_OPENSSL="/usr/local/ssl /usr/local /usr /usr/local/openssl" 41 fi 42 43 for i in $PHP_OPENSSL; do 44 if test -r $i/include/openssl/evp.h; then 45 OPENSSL_DIR=$i 46 OPENSSL_INC=$i/include 47 fi 48 done 49 50 if test -z "$OPENSSL_DIR"; then 51 AC_MSG_ERROR(Cannot find OpenSSL's <evp.h>) 52 fi 53 54 old_CPPFLAGS=$CPPFLAGS 55 CPPFLAGS=-I$OPENSSL_INC 56 AC_MSG_CHECKING(for OpenSSL version) 57 AC_EGREP_CPP(yes,[ 58 #include <openssl/opensslv.h> 59 #if OPENSSL_VERSION_NUMBER >= 0x0090500fL 60 yes 61 #endif 62 ],[ 63 AC_MSG_RESULT(>= 0.9.5) 64 ],[ 65 AC_MSG_ERROR(OpenSSL version 0.9.5 or greater required.) 66 ]) 67 CPPFLAGS=$old_CPPFLAGS 68 69 PHP_ADD_LIBPATH($OPENSSL_DIR/lib) 70 71 AC_CHECK_LIB(crypto, CRYPTO_free, [ 72 PHP_ADD_LIBRARY(crypto) 73 ],[ 74 AC_MSG_ERROR(libcrypto not found!) 75 ]) 76 77 AC_CHECK_LIB(ssl, SSL_CTX_set_ssl_version, [ 78 PHP_ADD_LIBRARY(ssl) 79 ],[ 80 AC_MSG_ERROR(libssl not found!) 81 ]) 82 PHP_ADD_INCLUDE($OPENSSL_INC) 83]) 84 85dnl PHP_EVAL_LIBLINE(LINE, SHARED-LIBADD) 86dnl 87dnl Use this macro, if you need to add libraries and or library search 88dnl paths to the PHP build system which are only given in compiler 89dnl notation. 90dnl 91AC_DEFUN(PHP_EVAL_LIBLINE,[ 92 for ac_i in $1; do 93 case $ac_i in 94 -l*) 95 ac_ii=`echo $ac_i|cut -c 3-` 96 PHP_ADD_LIBRARY($ac_ii,,$2) 97 ;; 98 -L*) 99 ac_ii=`echo $ac_i|cut -c 3-` 100 PHP_ADD_LIBPATH($ac_ii,$2) 101 ;; 102 esac 103 done 104]) 105 106dnl PHP_EVAL_INCLINE(LINE) 107dnl 108dnl Use this macro, if you need to add header search paths to the PHP 109dnl build system which are only given in compiler notation. 110dnl 111AC_DEFUN(PHP_EVAL_INCLINE,[ 112 for ac_i in $1; do 113 case $ac_i in 114 -I*) 115 ac_ii=`echo $ac_i|cut -c 3-` 116 PHP_ADD_INCLUDE($ac_ii) 117 ;; 118 esac 119 done 120]) 121 122AC_DEFUN(PHP_READDIR_R_TYPE,[ 123 dnl HAVE_READDIR_R is also defined by libmysql 124 AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no) 125 if test "$ac_cv_func_readdir_r" = "yes"; then 126 AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[ 127 AC_TRY_RUN([ 128#define _REENTRANT 129#include <sys/types.h> 130#include <dirent.h> 131 132#ifndef PATH_MAX 133#define PATH_MAX 1024 134#endif 135 136main() { 137 DIR *dir; 138 char entry[sizeof(struct dirent)+PATH_MAX]; 139 struct dirent *pentry = (struct dirent *) &entry; 140 141 dir = opendir("/"); 142 if (!dir) 143 exit(1); 144 if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0) 145 exit(0); 146 exit(1); 147} 148 ],[ 149 ac_cv_what_readdir_r=POSIX 150 ],[ 151 AC_TRY_CPP([ 152#define _REENTRANT 153#include <sys/types.h> 154#include <dirent.h> 155int readdir_r(DIR *, struct dirent *); 156 ],[ 157 ac_cv_what_readdir_r=old-style 158 ],[ 159 ac_cv_what_readdir_r=none 160 ]) 161 ],[ 162 ac_cv_what_readdir_r=none 163 ]) 164 ]) 165 case $ac_cv_what_readdir_r in 166 POSIX) 167 AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);; 168 old-style) 169 AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);; 170 esac 171 fi 172]) 173 174AC_DEFUN(PHP_SHLIB_SUFFIX_NAME,[ 175 PHP_SUBST(SHLIB_SUFFIX_NAME) 176 SHLIB_SUFFIX_NAME=so 177 case $host_alias in 178 *hpux*) 179 SHLIB_SUFFIX_NAME=sl 180 ;; 181 esac 182]) 183 184AC_DEFUN(PHP_DEBUG_MACRO,[ 185 DEBUG_LOG=$1 186 cat >$1 <<X 187CONFIGURE: $CONFIGURE_COMMAND 188CC: $CC 189CFLAGS: $CFLAGS 190CPPFLAGS: $CPPFLAGS 191CXX: $CXX 192CXXFLAGS: $CXXFLAGS 193INCLUDES: $INCLUDES 194LDFLAGS: $LDFLAGS 195LIBS: $LIBS 196DLIBS: $DLIBS 197SAPI: $PHP_SAPI 198PHP_RPATHS: $PHP_RPATHS 199uname -a: `uname -a` 200 201X 202 cat >conftest.$ac_ext <<X 203main() 204{ 205 exit(0); 206} 207X 208 (eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1 209 rm -fr conftest* 210]) 211 212AC_DEFUN(PHP_MISSING_PREAD_DECL,[ 213 AC_CACHE_CHECK(whether pread works without custom declaration,ac_cv_pread,[ 214 AC_TRY_COMPILE([#include <unistd.h>],[size_t (*func)() = pread],[ 215 ac_cv_pread=yes 216 ],[ 217 echo test > conftest_in 218 AC_TRY_RUN([ 219#include <sys/types.h> 220#include <sys/stat.h> 221#include <fcntl.h> 222 main() { char buf[3]; return !(pread(open("conftest_in", O_RDONLY), buf, 2, 0) == 2); } 223 ],[ 224 ac_cv_pread=yes 225 ],[ 226 echo test > conftest_in 227 AC_TRY_RUN([ 228#include <sys/types.h> 229#include <sys/stat.h> 230#include <fcntl.h> 231#include <unistd.h> 232 ssize_t pread(int, void *, size_t, off64_t); 233 main() { char buf[3]; return !(pread(open("conftest_in", O_RDONLY), buf, 2, 0) == 2); } 234 ],[ 235 ac_cv_pread=64 236 ],[ 237 ac_cv_pread=no 238 ]) 239 ]) 240 ]) 241 ]) 242 case $ac_cv_pread in 243 no) ac_cv_func_pread=no;; 244 64) AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default]);; 245 esac 246]) 247 248AC_DEFUN(PHP_MISSING_PWRITE_DECL,[ 249 AC_CACHE_CHECK(whether pwrite works without custom declaration,ac_cv_pwrite,[ 250 AC_TRY_COMPILE([#include <unistd.h>],[size_t (*func)() = pwrite],[ 251 ac_cv_pwrite=yes 252 ],[ 253 AC_TRY_RUN([ 254#include <sys/types.h> 255#include <sys/stat.h> 256#include <fcntl.h> 257 main() { return !(pwrite(open("conftest_out", O_WRONLY|O_CREAT, 0600), "Ok", 2, 0) == 2); } 258 ],[ 259 ac_cv_pwrite=yes 260 ],[ 261 AC_TRY_RUN([ 262#include <sys/types.h> 263#include <sys/stat.h> 264#include <fcntl.h> 265#include <unistd.h> 266 ssize_t pwrite(int, void *, size_t, off64_t); 267 main() { return !(pwrite(open("conftest_out", O_WRONLY|O_CREAT, 0600), "Ok", 2, 0) == 2); } 268 ],[ 269 ac_cv_pwrite=64 270 ],[ 271 ac_cv_pwrite=no 272 ]) 273 ]) 274 ]) 275 ]) 276 case $ac_cv_pwrite in 277 no) ac_cv_func_pwrite=no;; 278 64) AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default]);; 279 esac 280]) 281 282AC_DEFUN(PHP_MISSING_TIME_R_DECL,[ 283 AC_MSG_CHECKING(for missing declarations of reentrant functions) 284 AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = localtime_r],[ 285 : 286 ],[ 287 AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared]) 288 ]) 289 AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = gmtime_r],[ 290 : 291 ],[ 292 AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared]) 293 ]) 294 AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = asctime_r],[ 295 : 296 ],[ 297 AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared]) 298 ]) 299 AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = ctime_r],[ 300 : 301 ],[ 302 AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared]) 303 ]) 304 AC_TRY_COMPILE([#include <string.h>],[char *(*func)() = strtok_r],[ 305 : 306 ],[ 307 AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared]) 308 ]) 309 AC_MSG_RESULT(done) 310]) 311 312dnl 313dnl PHP_LIBGCC_LIBPATH(gcc) 314dnl Stores the location of libgcc in libgcc_libpath 315dnl 316AC_DEFUN(PHP_LIBGCC_LIBPATH,[ 317 changequote({,}) 318 libgcc_libpath=`$1 --print-libgcc-file-name|sed 's%/*[^/][^/]*$%%'` 319 changequote([,]) 320]) 321 322AC_DEFUN(PHP_ARG_ANALYZE,[ 323case [$]$1 in 324shared,*) 325 ext_output="yes, shared" 326 ext_shared=yes 327 $1=`echo "[$]$1"|sed 's/^shared,//'` 328 ;; 329shared) 330 ext_output="yes, shared" 331 ext_shared=yes 332 $1=yes 333 ;; 334no) 335 ext_output=no 336 ext_shared=no 337 ;; 338*) 339 ext_output=yes 340 ext_shared=no 341 ;; 342esac 343 344if test "$php_always_shared" = "yes"; then 345 ext_output="yes, shared" 346 ext_shared=yes 347 test "[$]$1" = "no" && $1=yes 348fi 349 350AC_MSG_RESULT($ext_output) 351]) 352 353dnl 354dnl PHP_ARG_WITH(arg-name, check message, help text[, default-val]) 355dnl Sets PHP_ARG_NAME either to the user value or to the default value. 356dnl default-val defaults to no. This will also set the variable ext_shared, 357dnl and will overwrite any previous variable of that name. 358dnl 359AC_DEFUN(PHP_ARG_WITH,[ 360PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_)) 361]) 362 363AC_DEFUN(PHP_REAL_ARG_WITH,[ 364AC_MSG_CHECKING($2) 365AC_ARG_WITH($1,[$3],$5=[$]withval,$5=ifelse($4,,no,$4)) 366PHP_ARG_ANALYZE($5) 367]) 368 369dnl 370dnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val]) 371dnl Sets PHP_ARG_NAME either to the user value or to the default value. 372dnl default-val defaults to no. This will also set the variable ext_shared, 373dnl and will overwrite any previous variable of that name. 374dnl 375AC_DEFUN(PHP_ARG_ENABLE,[ 376PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z-,A-Z_)) 377]) 378 379AC_DEFUN(PHP_REAL_ARG_ENABLE,[ 380AC_MSG_CHECKING($2) 381AC_ARG_ENABLE($1,[$3],$5=[$]enableval,$5=ifelse($4,,no,$4)) 382PHP_ARG_ANALYZE($5) 383]) 384 385AC_DEFUN(PHP_MODULE_PTR,[ 386 EXTRA_MODULE_PTRS="$EXTRA_MODULE_PTRS $1," 387]) 388 389AC_DEFUN(PHP_CONFIG_NICE,[ 390 rm -f $1 391 cat >$1<<EOF 392#! /bin/sh 393# 394# Created by configure 395 396EOF 397 398 for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS LIBS CC CXX; do 399 eval val=\$$var 400 if test -n "$val"; then 401 echo "$var='$val' \\" >> $1 402 fi 403 done 404 405 for arg in [$]0 "[$]@"; do 406 echo "'[$]arg' \\" >> $1 407 done 408 echo '"[$]@"' >> $1 409 chmod +x $1 410]) 411 412AC_DEFUN(PHP_TIME_R_TYPE,[ 413AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[ 414AC_TRY_RUN([ 415#include <time.h> 416 417main() { 418char buf[27]; 419struct tm t; 420time_t old = 0; 421int r, s; 422 423s = gmtime_r(&old, &t); 424r = (int) asctime_r(&t, buf, 26); 425if (r == s && s == 0) return (0); 426return (1); 427} 428],[ 429 ac_cv_time_r_type=hpux 430],[ 431 AC_TRY_RUN([ 432#include <time.h> 433main() { 434 struct tm t, *s; 435 time_t old = 0; 436 char buf[27], *p; 437 438 s = gmtime_r(&old, &t); 439 p = asctime_r(&t, buf, 26); 440 if (p == buf && s == &t) return (0); 441 return (1); 442} 443 ],[ 444 ac_cv_time_r_type=irix 445 ],[ 446 ac_cv_time_r_type=POSIX 447 ]) 448],[ 449 ac_cv_time_r_type=POSIX 450]) 451]) 452 case $ac_cv_time_r_type in 453 hpux) AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;; 454 irix) AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;; 455 esac 456]) 457 458AC_DEFUN(PHP_SUBST,[ 459 PHP_VAR_SUBST="$PHP_VAR_SUBST $1" 460]) 461 462AC_DEFUN(PHP_SUBST_OLD,[ 463 PHP_SUBST($1) 464 AC_SUBST($1) 465]) 466 467AC_DEFUN(PHP_FAST_OUTPUT,[ 468 PHP_FAST_OUTPUT_FILES="$PHP_FAST_OUTPUT_FILES $1" 469]) 470 471AC_DEFUN(PHP_MKDIR_P_CHECK,[ 472 AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[ 473 test -d conftestdir && rm -rf conftestdir 474 mkdir -p conftestdir/somedir >/dev/null 2>&1 475dnl `mkdir -p' must be quiet about creating existing directories 476 mkdir -p conftestdir/somedir >/dev/null 2>&1 477 if test "$?" = "0" && test -d conftestdir/somedir; then 478 ac_cv_mkdir_p=yes 479 else 480 ac_cv_mkdir_p=no 481 fi 482 rm -rf conftestdir 483 ]) 484]) 485 486AC_DEFUN(PHP_GEN_CONFIG_VARS,[ 487 PHP_MKDIR_P_CHECK 488 echo creating config_vars.mk 489 > config_vars.mk 490 for i in $PHP_VAR_SUBST; do 491 eval echo "$i = \$$i" >> config_vars.mk 492 done 493]) 494 495AC_DEFUN(PHP_GEN_MAKEFILES,[ 496 $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $BSD_MAKEFILE $1 497]) 498 499AC_DEFUN(PHP_TM_GMTOFF,[ 500AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff, 501[AC_TRY_COMPILE([#include <sys/types.h> 502#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;], 503 ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)]) 504 505if test "$ac_cv_struct_tm_gmtoff" = yes; then 506 AC_DEFINE(HAVE_TM_GMTOFF,1,[whether you have tm_gmtoff in struct tm]) 507fi 508]) 509 510dnl PHP_CONFIGURE_PART(MESSAGE) 511dnl Idea borrowed from mm 512AC_DEFUN(PHP_CONFIGURE_PART,[ 513 AC_MSG_RESULT() 514 AC_MSG_RESULT(${T_MD}$1${T_ME}) 515]) 516 517AC_DEFUN(PHP_PROG_SENDMAIL,[ 518AC_PATH_PROG(PROG_SENDMAIL, sendmail,[], $PATH:/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib) 519if test -n "$PROG_SENDMAIL"; then 520 AC_DEFINE(HAVE_SENDMAIL,1,[whether you have sendmail]) 521fi 522]) 523 524AC_DEFUN(PHP_RUNPATH_SWITCH,[ 525dnl check for -R, etc. switch 526AC_MSG_CHECKING(if compiler supports -R) 527AC_CACHE_VAL(php_cv_cc_dashr,[ 528 SAVE_LIBS=$LIBS 529 LIBS="-R /usr/lib $LIBS" 530 AC_TRY_LINK([], [], php_cv_cc_dashr=yes, php_cv_cc_dashr=no) 531 LIBS=$SAVE_LIBS]) 532AC_MSG_RESULT($php_cv_cc_dashr) 533if test $php_cv_cc_dashr = "yes"; then 534 ld_runpath_switch=-R 535else 536 AC_MSG_CHECKING([if compiler supports -Wl,-rpath,]) 537 AC_CACHE_VAL(php_cv_cc_rpath,[ 538 SAVE_LIBS=$LIBS 539 LIBS="-Wl,-rpath,/usr/lib $LIBS" 540 AC_TRY_LINK([], [], php_cv_cc_rpath=yes, php_cv_cc_rpath=no) 541 LIBS=$SAVE_LIBS]) 542 AC_MSG_RESULT($php_cv_cc_rpath) 543 if test $php_cv_cc_rpath = "yes"; then 544 ld_runpath_switch=-Wl,-rpath, 545 else 546 dnl something innocuous 547 ld_runpath_switch=-L 548 fi 549fi 550]) 551 552AC_DEFUN(PHP_STRUCT_FLOCK,[ 553AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock, 554 AC_TRY_COMPILE([ 555#include <unistd.h> 556#include <fcntl.h> 557 ], 558 [struct flock x;], 559 [ 560 ac_cv_struct_flock=yes 561 ],[ 562 ac_cv_struct_flock=no 563 ]) 564) 565if test "$ac_cv_struct_flock" = "yes" ; then 566 AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock]) 567fi 568]) 569 570AC_DEFUN(PHP_SOCKLEN_T,[ 571AC_CACHE_CHECK(for socklen_t,ac_cv_socklen_t, 572 AC_TRY_COMPILE([ 573#include <sys/types.h> 574#include <sys/socket.h> 575],[ 576socklen_t x; 577],[ 578 ac_cv_socklen_t=yes 579],[ 580 ac_cv_socklen_t=no 581])) 582if test "$ac_cv_socklen_t" = "yes"; then 583 AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t]) 584fi 585]) 586 587dnl 588dnl PHP_SET_SYM_FILE(path) 589dnl 590dnl set the path of the file which contains the symbol export list 591dnl 592AC_DEFUN(PHP_SET_SYM_FILE, 593[ 594 PHP_SYM_FILE=$1 595]) 596 597dnl 598dnl PHP_BUILD_THREAD_SAFE 599dnl 600AC_DEFUN(PHP_BUILD_THREAD_SAFE,[ 601 enable_experimental_zts=yes 602 if test "$pthreads_working" != "yes"; then 603 AC_MSG_ERROR(ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads.) 604 fi 605]) 606 607AC_DEFUN(PHP_REQUIRE_CXX,[ 608 if test -z "$php_cxx_done"; then 609 AC_PROG_CXX 610 AC_PROG_CXXCPP 611 php_cxx_done=yes 612 fi 613]) 614 615dnl 616dnl PHP_BUILD_SHARED 617dnl 618AC_DEFUN(PHP_BUILD_SHARED,[ 619 php_build_target=shared 620]) 621 622dnl 623dnl PHP_BUILD_STATIC 624dnl 625AC_DEFUN(PHP_BUILD_STATIC,[ 626 php_build_target=static 627]) 628 629dnl 630dnl PHP_BUILD_PROGRAM 631dnl 632AC_DEFUN(PHP_BUILD_PROGRAM,[ 633 php_build_target=program 634]) 635 636dnl 637dnl AC_PHP_ONCE(namespace, variable, code) 638dnl 639dnl execute code, if variable is not set in namespace 640dnl 641AC_DEFUN(AC_PHP_ONCE,[ 642 changequote({,}) 643 unique=`echo $2|sed 's/[^a-zA-Z0-9]/_/g'` 644 changequote([,]) 645 cmd="echo $ac_n \"\$$1$unique$ac_c\"" 646 if test -n "$unique" && test "`eval $cmd`" = "" ; then 647 eval "$1$unique=set" 648 $3 649 fi 650]) 651 652dnl 653dnl PHP_EXPAND_PATH(path, variable) 654dnl 655dnl expands path to an absolute path and assigns it to variable 656dnl 657AC_DEFUN(PHP_EXPAND_PATH,[ 658 if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then 659 $2=$1 660 else 661 changequote({,}) 662 ep_dir="`echo $1|sed 's%/*[^/][^/]*/*$%%'`" 663 changequote([,]) 664 ep_realdir="`(cd \"$ep_dir\" && pwd)`" 665 $2="$ep_realdir/`basename \"$1\"`" 666 fi 667]) 668 669dnl 670dnl PHP_ADD_LIBPATH(path[, shared-libadd]) 671dnl 672dnl add a library to linkpath/runpath 673dnl 674AC_DEFUN(PHP_ADD_LIBPATH,[ 675 if test "$1" != "/usr/lib"; then 676 PHP_EXPAND_PATH($1, ai_p) 677 if test "$ext_shared" = "yes" && test -n "$2"; then 678 $2="-R$1 -L$1 [$]$2" 679 else 680 AC_PHP_ONCE(LIBPATH, $ai_p, [ 681 test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$ai_p" 682 LDFLAGS="$LDFLAGS -L$ai_p" 683 PHP_RPATHS="$PHP_RPATHS $ai_p" 684 ]) 685 fi 686 fi 687]) 688 689dnl 690dnl PHP_BUILD_RPATH() 691dnl 692dnl builds RPATH from PHP_RPATHS 693dnl 694AC_DEFUN(PHP_BUILD_RPATH,[ 695 if test "$PHP_RPATH" = "yes" && test -n "$PHP_RPATHS"; then 696 OLD_RPATHS="$PHP_RPATHS" 697 unset PHP_RPATHS 698 for i in $OLD_RPATHS; do 699 PHP_LDFLAGS="$PHP_LDFLAGS -L$i" 700 PHP_RPATHS="$PHP_RPATHS -R $i" 701 NATIVE_RPATHS="$NATIVE_RPATHS $ld_runpath_switch$i" 702 done 703 fi 704]) 705 706dnl 707dnl PHP_ADD_INCLUDE(path [,before]) 708dnl 709dnl add an include path. 710dnl if before is 1, add in the beginning of INCLUDES. 711dnl 712AC_DEFUN(PHP_ADD_INCLUDE,[ 713 if test "$1" != "/usr/include"; then 714 PHP_EXPAND_PATH($1, ai_p) 715 AC_PHP_ONCE(INCLUDEPATH, $ai_p, [ 716 if test "$2"; then 717 INCLUDES="-I$ai_p $INCLUDES" 718 else 719 INCLUDES="$INCLUDES -I$ai_p" 720 fi 721 ]) 722 fi 723]) 724 725AC_DEFUN(PHP_X_ADD_LIBRARY,[ 726 ifelse($2,,$3="-l$1 [$]$3", $3="[$]$3 -l$1") 727]) 728 729dnl 730dnl PHP_ADD_LIBRARY(library[, append[, shared-libadd]]) 731dnl 732dnl add a library to the link line 733dnl 734AC_DEFUN(PHP_ADD_LIBRARY,[ 735 case $1 in 736 c|c_r|pthread*) ;; 737 *) 738ifelse($3,,[ 739 PHP_X_ADD_LIBRARY($1,$2,LIBS) 740],[ 741 if test "$ext_shared" = "yes"; then 742 PHP_X_ADD_LIBRARY($1,$2,$3) 743 else 744 PHP_ADD_LIBRARY($1,$2) 745 fi 746]) 747 ;; 748 esac 749]) 750 751dnl 752dnl PHP_ADD_LIBRARY_DEFER(library[, append[, shared-libadd]]) 753dnl 754dnl add a library to the link line (deferred) 755dnl 756AC_DEFUN(PHP_ADD_LIBRARY_DEFER,[ 757 case $1 in 758 c|c_r|pthread*) ;; 759 *) 760ifelse($3,,[ 761 PHP_X_ADD_LIBRARY($1,$2,DLIBS) 762],[ 763 if test "$ext_shared" = "yes"; then 764 PHP_X_ADD_LIBRARY($1,$2,$3) 765 else 766 PHP_ADD_LIBRARY_DEFER($1,$2) 767 fi 768]) 769 ;; 770 esac 771]) 772 773dnl 774dnl PHP_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd]) 775dnl 776dnl add a library to the link line and path to linkpath/runpath. 777dnl if shared-libadd is not empty and $ext_shared is yes, 778dnl shared-libadd will be assigned the library information 779dnl 780AC_DEFUN(PHP_ADD_LIBRARY_WITH_PATH,[ 781ifelse($3,,[ 782 if test -n "$2"; then 783 PHP_ADD_LIBPATH($2) 784 fi 785 PHP_ADD_LIBRARY($1) 786],[ 787 if test "$ext_shared" = "yes"; then 788 $3="-l$1 [$]$3" 789 if test -n "$2"; then 790 PHP_ADD_LIBPATH($2,$3) 791 fi 792 else 793 PHP_ADD_LIBRARY_WITH_PATH($1,$2) 794 fi 795]) 796]) 797 798dnl 799dnl PHP_ADD_LIBRARY_DEFER_WITH_PATH(library, path) 800dnl 801dnl add a library to the link line (deferred) 802dnl and path to linkpath/runpath (not deferred) 803dnl 804AC_DEFUN(PHP_ADD_LIBRARY_DEFER_WITH_PATH,[ 805 PHP_ADD_LIBPATH($2) 806 PHP_ADD_LIBRARY_DEFER($1) 807]) 808 809dnl 810dnl Set libtool variable 811dnl 812AC_DEFUN(AM_SET_LIBTOOL_VARIABLE,[ 813 LIBTOOL='$(SHELL) $(top_builddir)/libtool $1' 814]) 815 816dnl 817dnl Check for cc option 818dnl 819AC_DEFUN(PHP_CHECK_CC_OPTION,[ 820 echo "main(){return 0;}" > conftest.$ac_ext 821 opt=$1 822 changequote({,}) 823 var=`echo $opt|sed 's/[^a-zA-Z0-9]/_/g'` 824 changequote([,]) 825 AC_MSG_CHECKING([if compiler supports -$1 really]) 826 ac_php_compile="${CC-cc} -$opt -o conftest $CFLAGS $CPPFLAGS conftest.$ac_ext 2>&1" 827 if eval $ac_php_compile 2>&1 | egrep "$opt" > /dev/null 2>&1 ; then 828 eval php_cc_$var=no 829 AC_MSG_RESULT(no) 830 else 831 if eval ./conftest 2>/dev/null ; then 832 eval php_cc_$var=yes 833 AC_MSG_RESULT(yes) 834 else 835 eval php_cc_$var=no 836 AC_MSG_RESULT(no) 837 fi 838 fi 839]) 840 841AC_DEFUN(PHP_REGEX,[ 842 843if test "$REGEX_TYPE" = "php"; then 844 REGEX_LIB=regex/libregex.la 845 REGEX_DIR=regex 846 AC_DEFINE(HSREGEX,1,[ ]) 847 AC_DEFINE(REGEX,1,[ ]) 848 PHP_FAST_OUTPUT(regex/Makefile) 849elif test "$REGEX_TYPE" = "system"; then 850 AC_DEFINE(REGEX,0,[ ]) 851fi 852 853AC_MSG_CHECKING(which regex library to use) 854AC_MSG_RESULT($REGEX_TYPE) 855 856PHP_SUBST(REGEX_DIR) 857PHP_SUBST(REGEX_LIB) 858PHP_SUBST(HSREGEX) 859]) 860 861dnl 862dnl See if we have broken header files like SunOS has. 863dnl 864AC_DEFUN(PHP_MISSING_FCLOSE_DECL,[ 865 AC_MSG_CHECKING([for fclose declaration]) 866 AC_TRY_COMPILE([#include <stdio.h>],[int (*func)() = fclose],[ 867 AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ]) 868 AC_MSG_RESULT(ok) 869 ],[ 870 AC_DEFINE(MISSING_FCLOSE_DECL,1,[ ]) 871 AC_MSG_RESULT(missing) 872 ]) 873]) 874 875dnl 876dnl Check for broken sprintf() 877dnl 878AC_DEFUN(PHP_AC_BROKEN_SPRINTF,[ 879 AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[ 880 AC_TRY_RUN([main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }],[ 881 ac_cv_broken_sprintf=no 882 ],[ 883 ac_cv_broken_sprintf=yes 884 ],[ 885 ac_cv_broken_sprintf=no 886 ]) 887 ]) 888 if test "$ac_cv_broken_sprintf" = "yes"; then 889 AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [ ]) 890 else 891 AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [ ]) 892 fi 893]) 894 895dnl 896dnl PHP_EXTENSION(extname [, shared]) 897dnl 898dnl Includes an extension in the build. 899dnl 900dnl "extname" is the name of the ext/ subdir where the extension resides 901dnl "shared" can be set to "shared" or "yes" to build the extension as 902dnl a dynamically loadable library. 903dnl 904AC_DEFUN(PHP_EXTENSION,[ 905 EXT_SUBDIRS="$EXT_SUBDIRS $1" 906 907 if test -d "$abs_srcdir/ext/$1"; then 908dnl ---------------------------------------------- Internal Module 909 ext_builddir=ext/$1 910 ext_srcdir=$abs_srcdir/ext/$1 911 else 912dnl ---------------------------------------------- External Module 913 ext_builddir=. 914 ext_srcdir=$abs_srcdir 915 fi 916 917 if test "$2" != "shared" && test "$2" != "yes"; then 918dnl ---------------------------------------------- Static module 919 LIB_BUILD($ext_builddir) 920 EXT_LTLIBS="$EXT_LTLIBS $ext_builddir/lib$1.la" 921 EXT_STATIC="$EXT_STATIC $1" 922 else 923dnl ---------------------------------------------- Shared module 924 LIB_BUILD($ext_builddir,yes) 925 AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z-,A-Z_), 1, Whether to build $1 as dynamic module) 926 fi 927 928 PHP_FAST_OUTPUT($ext_builddir/Makefile) 929]) 930 931dnl 932dnl Solaris requires main code to be position independent in order 933dnl to let shared objects find symbols. Weird. Ugly. 934dnl 935dnl Must be run after all --with-NN options that let the user 936dnl choose dynamic extensions, and after the gcc test. 937dnl 938AC_DEFUN(PHP_SOLARIS_PIC_WEIRDNESS,[ 939 AC_MSG_CHECKING(whether -fPIC is required) 940 if test -n "$EXT_SHARED"; then 941 os=`uname -sr 2>/dev/null` 942 case $os in 943 "SunOS 5.6"|"SunOS 5.7") 944 case $CC in 945 gcc*|egcs*) CFLAGS="$CFLAGS -fPIC";; 946 *) CFLAGS="$CFLAGS -fpic";; 947 esac 948 AC_MSG_RESULT(yes);; 949 *) 950 AC_MSG_RESULT(no);; 951 esac 952 else 953 AC_MSG_RESULT(no) 954 fi 955]) 956 957dnl 958dnl Checks whether $withval is "shared" or starts with "shared,XXX" 959dnl and sets $shared to "yes" or "no", and removes "shared,?" stuff 960dnl from $withval. 961dnl 962AC_DEFUN(PHP_WITH_SHARED,[ 963 case $withval in 964 shared) 965 shared=yes 966 withval=yes 967 ;; 968 shared,*) 969 shared=yes 970 withval=`echo $withval | sed -e 's/^shared,//'` 971 ;; 972 *) 973 shared=no 974 ;; 975 esac 976 if test -n "$php_always_shared"; then 977 shared=yes 978 fi 979]) 980 981dnl The problem is that the default compilation flags in Solaris 2.6 won't 982dnl let programs access large files; you need to tell the compiler that 983dnl you actually want your programs to work on large files. For more 984dnl details about this brain damage please see: 985dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html 986 987dnl Written by Paul Eggert <eggert@twinsun.com>. 988 989AC_DEFUN(PHP_SYS_LFS, 990[dnl 991 # If available, prefer support for large files unless the user specified 992 # one of the CPPFLAGS, LDFLAGS, or LIBS variables. 993 AC_MSG_CHECKING(whether large file support needs explicit enabling) 994 ac_getconfs='' 995 ac_result=yes 996 ac_set='' 997 ac_shellvars='CPPFLAGS LDFLAGS LIBS' 998 for ac_shellvar in $ac_shellvars; do 999 case $ac_shellvar in 1000 CPPFLAGS) ac_lfsvar=LFS_CFLAGS ;; 1001 *) ac_lfsvar=LFS_$ac_shellvar ;; 1002 esac 1003 eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar 1004 (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; } 1005 ac_getconf=`getconf $ac_lfsvar` 1006 ac_getconfs=$ac_getconfs$ac_getconf 1007 eval ac_test_$ac_shellvar=\$ac_getconf 1008 done 1009 case "$ac_result$ac_getconfs" in 1010 yes) ac_result=no ;; 1011 esac 1012 case "$ac_result$ac_set" in 1013 yes?*) ac_result="yes, but $ac_set is already set, so use its settings" 1014 esac 1015 AC_MSG_RESULT($ac_result) 1016 case $ac_result in 1017 yes) 1018 for ac_shellvar in $ac_shellvars; do 1019 eval $ac_shellvar=\$ac_test_$ac_shellvar 1020 done ;; 1021 esac 1022]) 1023 1024AC_DEFUN(PHP_SOCKADDR_SA_LEN,[ 1025 AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[ 1026 AC_TRY_COMPILE([#include <sys/types.h> 1027#include <sys/socket.h>], 1028 [struct sockaddr s; s.sa_len;], 1029 [ac_cv_sockaddr_sa_len=yes 1030 AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[ ])], 1031 [ac_cv_sockaddr_sa_len=no]) 1032 ]) 1033]) 1034 1035 1036dnl ## PHP_OUTPUT(file) 1037dnl ## adds "file" to the list of files generated by AC_OUTPUT 1038dnl ## This macro can be used several times. 1039AC_DEFUN(PHP_OUTPUT,[ 1040 PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1" 1041]) 1042 1043AC_DEFUN(PHP_DECLARED_TIMEZONE,[ 1044 AC_CACHE_CHECK(for declared timezone, ac_cv_declared_timezone,[ 1045 AC_TRY_COMPILE([ 1046#include <sys/types.h> 1047#include <time.h> 1048#ifdef HAVE_SYS_TIME_H 1049#include <sys/time.h> 1050#endif 1051],[ 1052 time_t foo = (time_t) timezone; 1053],[ 1054 ac_cv_declared_timezone=yes 1055],[ 1056 ac_cv_declared_timezone=no 1057])]) 1058 if test "$ac_cv_declared_timezone" = "yes"; then 1059 AC_DEFINE(HAVE_DECLARED_TIMEZONE, 1, [Whether system headers declare timezone]) 1060 fi 1061]) 1062 1063AC_DEFUN(PHP_EBCDIC,[ 1064 AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[ 1065 AC_TRY_RUN( [ 1066int main(void) { 1067 return (unsigned char)'A' != (unsigned char)0xC1; 1068} 1069],[ 1070 ac_cv_ebcdic=yes 1071],[ 1072 ac_cv_ebcdic=no 1073],[ 1074 ac_cv_ebcdic=no 1075])]) 1076 if test "$ac_cv_ebcdic" = "yes"; then 1077 AC_DEFINE(CHARSET_EBCDIC,1, [Define if system uses EBCDIC]) 1078 fi 1079]) 1080 1081AC_DEFUN(AC_ADD_LIBPATH, [indir([PHP_ADD_LIBPATH], $@)]) 1082AC_DEFUN(AC_ADD_LIBRARY, [indir([PHP_ADD_LIBRARY], $@)]) 1083AC_DEFUN(AC_ADD_LIBRARY_WITH_PATH, [indir([PHP_ADD_LIBRARY_WITH_PATH], $@)]) 1084AC_DEFUN(AC_ADD_INCLUDE, [indir([PHP_ADD_INCLUDE], $@)]) 1085 1086AC_DEFUN(PHP_FOPENCOOKIE,[ 1087 AC_CHECK_FUNC(fopencookie, [ have_glibc_fopencookie=yes ]) 1088 1089 if test "$have_glibc_fopencookie" = "yes" ; then 1090 dnl this comes in two flavors: 1091 dnl newer glibcs (since 2.1.2 ? ) 1092 dnl have a type called cookie_io_functions_t 1093 AC_TRY_COMPILE([ #define _GNU_SOURCE 1094 #include <stdio.h> 1095 ], 1096 [ cookie_io_functions_t cookie; ], 1097 [ have_cookie_io_functions_t=yes ], 1098 [ ] ) 1099 1100 if test "$have_cookie_io_functions_t" = "yes" ; then 1101 cookie_io_functions_t=cookie_io_functions_t 1102 have_fopen_cookie=yes 1103 else 1104 dnl older glibc versions (up to 2.1.2 ?) 1105 dnl call it _IO_cookie_io_functions_t 1106 AC_TRY_COMPILE([ #define _GNU_SOURCE 1107 #include <stdio.h> 1108 ], 1109 [ _IO_cookie_io_functions_t cookie; ], 1110 [ have_IO_cookie_io_functions_t=yes ], 1111 [] ) 1112 if test "$have_cookie_io_functions_t" = "yes" ; then 1113 cookie_io_functions_t=_IO_cookie_io_functions_t 1114 have_fopen_cookie=yes 1115 fi 1116 fi 1117 1118 if test "$have_fopen_cookie" = "yes" ; then 1119 AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ]) 1120 AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ]) 1121 fi 1122 1123 fi 1124]) 1125