📄 acinclude.m4
字号:
dnl $Id: acinclude.m4,v 1.218.2.24 2003/08/14 00:24:25 bfrance Exp $dnldnl This file contains local autoconf functions.dnl PHP_ADD_MAKEFILE_FRAGMENT([srcfile[, ext_srcdir[, ext_builddir]]])dnldnl Processes a file called Makefile.frag in the source directorydnl of the most recently added extension. $(srcdir) and $(builddir)dnl are substituted with the proper paths. Can be used to supplydnl custom rules and/or additional targets.dnlAC_DEFUN([PHP_ADD_MAKEFILE_FRAGMENT],[ ifelse($1,,src=$ext_srcdir/Makefile.frag,src=$1) ifelse($2,,ac_srcdir=$ext_srcdir,ac_srcdir=$2) ifelse($3,,ac_builddir=$ext_builddir,ac_builddir=$3) sed -e "s#\$(srcdir)#$ac_srcdir#g" -e "s#\$(builddir)#$ac_builddir#g" $src >> Makefile.fragments])dnl PHP_DEFINE(WHAT[, value])dnldnl Creates builddir/include/what.h and in there #define WHAT valuednlAC_DEFUN([PHP_DEFINE],[ [echo "#define ]$1[]ifelse([$2],,[ 1],[ $2])[" > include/php_]translit($1,A-Z,a-z)[.h]])dnl PHP_INIT_BUILD_SYSTEMdnlAC_DEFUN([PHP_INIT_BUILD_SYSTEM],[test -d include || mkdir include> Makefile.objects> Makefile.fragmentsdnl We need to play tricks here to avoid matching the egrep line itselfpattern=defineegrep $pattern'.*include/php' $srcdir/configure|sed 's/.*>//'|xargs touch 2>/dev/null])dnl PHP_GEN_GLOBAL_MAKEFILEdnl dnl Generates the global makefile.dnlAC_DEFUN([PHP_GEN_GLOBAL_MAKEFILE],[ cat >Makefile <<EOFsrcdir = $abs_srcdirbuilddir = $abs_builddirtop_srcdir = $abs_srcdirtop_builddir = $abs_builddirEOF for i in $PHP_VAR_SUBST; do eval echo "$i = \$$i" >> Makefile done cat $abs_srcdir/Makefile.global Makefile.fragments Makefile.objects >> Makefile])dnl PHP_ADD_SOURCES(source-path, sources[, special-flags[, type]])dnldnl Adds sources which are located relative to source-path to the dnl array of type type. Sources are processed with optional dnl special-flags which are passed to the compiler. Sourcesdnl can be either written in C or C++ (filenames shall end in .c dnl or .cpp, respectively).dnldnl Note: If source-path begins with a "/", the "/" is removed anddnl the path is interpreted relative to the top build-directory.dnldnl which array to append to?AC_DEFUN([PHP_ADD_SOURCES],[ PHP_ADD_SOURCES_X($1, $2, $3, ifelse($4,cli,PHP_CLI_OBJS,ifelse($4,sapi,PHP_SAPI_OBJS,PHP_GLOBAL_OBJS)))])dnldnl _PHP_ASSIGN_BUILD_VARS(type)dnl internal, don't useAC_DEFUN([_PHP_ASSIGN_BUILD_VARS],[ifelse($1,shared,[ b_c_pre=$shared_c_pre b_cxx_pre=$shared_cxx_pre b_c_meta=$shared_c_meta b_cxx_meta=$shared_cxx_meta b_c_post=$shared_c_post b_cxx_post=$shared_cxx_post],[ b_c_pre=$php_c_pre b_cxx_pre=$php_cxx_pre b_c_meta=$php_c_meta b_cxx_meta=$php_cxx_meta b_c_post=$php_c_post b_cxx_post=$php_cxx_post])dnl b_lo=[$]$1_lo])dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared[, special-post-flags]]]])dnldnl Additional to PHP_ADD_SOURCES (see above), this lets you set thednl name of the array target-var directly, as well as whetherdnl shared objects will be built from the sources. Should not be dnl used directly.dnl AC_DEFUN([PHP_ADD_SOURCES_X],[dnl relative to source- or build-directory?dnl ac_srcdir/ac_bdir include trailing slash case $1 in ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir; ac_inc="-I. -I$abs_srcdir" ;; /*[)] ac_srcdir=`echo "$1"|cut -c 2-`"/"; ac_bdir=$ac_srcdir; ac_inc="-I$ac_bdir -I$abs_srcdir/$ac_bdir" ;; *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$1/"; ac_inc="-I$ac_bdir -I$ac_srcdir" ;; esac dnl how to build .. shared or static? ifelse($5,yes,_PHP_ASSIGN_BUILD_VARS(shared),_PHP_ASSIGN_BUILD_VARS(php))dnl iterate over the sources old_IFS=[$]IFS for ac_src in $2; do dnl remove the suffix IFS=. set $ac_src ac_obj=[$]1 IFS=$old_IFS dnl append to the array which has been dynamically chosen at m4 time $4="[$]$4 [$]ac_bdir[$]ac_obj.lo"dnl choose the right compiler/flags/etc. for the source-file case $ac_src in *.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" ;; *.cpp[)] 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" ;; esacdnl create a rule for the object/source combo cat >>Makefile.objects<<EOF$ac_bdir[$]ac_obj.lo: $ac_srcdir[$]ac_src $ac_compEOF done])dnldnl Disable building CLIdnlAC_DEFUN([PHP_DISABLE_CLI],[ disable_cli=1]) dnldnl Separator into the configure --help display.dnl AC_DEFUN([PHP_HELP_SEPARATOR],[AC_ARG_ENABLE([],[$1],[])])dnldnl PHP_TARGET_RDYNAMICdnldnl Checks whether -rdynamic is supported by the compiler. Thisdnl is necessary for some targets to populate the global symboldnl table. Otherwise, dynamic modules would not be able to resolvednl PHP-related symbols.dnldnl If successful, adds -rdynamic to PHP_LDFLAGS.dnlAC_DEFUN([PHP_TARGET_RDYNAMIC],[ if test -n "$GCC"; then dnl we should use a PHP-specific macro here TSRM_CHECK_GCC_ARG(-rdynamic, gcc_rdynamic=yes) if test "$gcc_rdynamic" = "yes"; then PHP_LDFLAGS="$PHP_LDFLAGS -rdynamic" fi fi])AC_DEFUN([PHP_REMOVE_USR_LIB],[ unset ac_new_flags for i in [$]$1; do case [$]i in -L/usr/lib|-L/usr/lib/[)] ;; *[)] ac_new_flags="[$]ac_new_flags [$]i" ;; esac done $1=[$]ac_new_flags])AC_DEFUN([PHP_SETUP_OPENSSL],[ if test "$PHP_OPENSSL" = "yes"; then PHP_OPENSSL="/usr/local/ssl /usr/local /usr /usr/local/openssl" fi for i in $PHP_OPENSSL; do if test -r $i/include/openssl/evp.h; then OPENSSL_INCDIR=$i/include fi if test -r $i/lib/libssl.a -o -r $i/lib/libssl.$SHLIB_SUFFIX_NAME; then OPENSSL_LIBDIR=$i/lib fi done if test -z "$OPENSSL_INCDIR"; then AC_MSG_ERROR([Cannot find OpenSSL's <evp.h>]) fi if test -z "$OPENSSL_LIBDIR"; then AC_MSG_ERROR([Cannot find OpenSSL's libraries]) fi old_CPPFLAGS=$CPPFLAGS CPPFLAGS=-I$OPENSSL_INCDIR AC_MSG_CHECKING([for OpenSSL version]) AC_EGREP_CPP(yes,[#include <openssl/opensslv.h>#if OPENSSL_VERSION_NUMBER >= 0x0090600fL yes#endif ],[ AC_MSG_RESULT([>= 0.9.6]) ],[ AC_MSG_ERROR([OpenSSL version 0.9.6 or greater required.]) ]) CPPFLAGS=$old_CPPFLAGS PHP_ADD_INCLUDE($OPENSSL_INCDIR) PHP_ADD_LIBPATH($OPENSSL_LIBDIR) PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [ PHP_ADD_LIBRARY(crypto) ],[ AC_MSG_ERROR([libcrypto not found!]) ],[ -L$OPENSSL_LIBDIR ]) PHP_CHECK_LIBRARY(ssl, SSL_CTX_set_ssl_version, [ PHP_ADD_LIBRARY(ssl) ],[ AC_MSG_ERROR([libssl not found!]) ],[ -L$OPENSSL_LIBDIR ]) OPENSSL_INCDIR_OPT=-I$OPENSSL_INCDIR AC_SUBST(OPENSSL_INCDIR_OPT)])dnl PHP_EVAL_LIBLINE(LINE, SHARED-LIBADD)dnldnl Use this macro, if you need to add libraries and or library searchdnl paths to the PHP build system which are only given in compilerdnl notation.dnlAC_DEFUN([PHP_EVAL_LIBLINE],[ for ac_i in $1; do case $ac_i in -l*[)] ac_ii=`echo $ac_i|cut -c 3-` PHP_ADD_LIBRARY($ac_ii,1,$2) ;; -L*[)] ac_ii=`echo $ac_i|cut -c 3-` PHP_ADD_LIBPATH($ac_ii,$2) ;; esac done])dnl PHP_EVAL_INCLINE(LINE)dnldnl Use this macro, if you need to add header search paths to the PHPdnl build system which are only given in compiler notation.dnlAC_DEFUN([PHP_EVAL_INCLINE],[ for ac_i in $1; do case $ac_i in -I*[)] ac_ii=`echo $ac_i|cut -c 3-` PHP_ADD_INCLUDE($ac_ii) ;; esac done])AC_DEFUN([PHP_READDIR_R_TYPE],[ dnl HAVE_READDIR_R is also defined by libmysql AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no) if test "$ac_cv_func_readdir_r" = "yes"; then AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[ AC_TRY_RUN([#define _REENTRANT#include <sys/types.h>#include <dirent.h>#ifndef PATH_MAX#define PATH_MAX 1024#endifmain() { DIR *dir; char entry[sizeof(struct dirent)+PATH_MAX]; struct dirent *pentry = (struct dirent *) &entry; dir = opendir("/"); if (!dir) exit(1); if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0) exit(0); exit(1);} ],[ ac_cv_what_readdir_r=POSIX ],[ AC_TRY_CPP([#define _REENTRANT#include <sys/types.h>#include <dirent.h>int readdir_r(DIR *, struct dirent *); ],[ ac_cv_what_readdir_r=old-style ],[ ac_cv_what_readdir_r=none ]) ],[ ac_cv_what_readdir_r=none ]) ]) case $ac_cv_what_readdir_r in POSIX) AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);; old-style) AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);; esac fi])AC_DEFUN([PHP_SHLIB_SUFFIX_NAME],[ PHP_SUBST(SHLIB_SUFFIX_NAME) SHLIB_SUFFIX_NAME=so case $host_alias in *hpux*[)] SHLIB_SUFFIX_NAME=sl ;; *darwin*[)] SHLIB_SUFFIX_NAME=dylib ;; esac])AC_DEFUN([PHP_DEBUG_MACRO],[ DEBUG_LOG=$1 cat >$1 <<XCONFIGURE: $CONFIGURE_COMMANDCC: $CCCFLAGS: $CFLAGSCPPFLAGS: $CPPFLAGSCXX: $CXXCXXFLAGS: $CXXFLAGSINCLUDES: $INCLUDESLDFLAGS: $LDFLAGSLIBS: $LIBSDLIBS: $DLIBSSAPI: $PHP_SAPIPHP_RPATHS: $PHP_RPATHSuname -a: `uname -a`X cat >conftest.$ac_ext <<Xmain(){ exit(0);}X (eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1 rm -fr conftest*])AC_DEFUN([PHP_DOES_PWRITE_WORK],[ AC_TRY_RUN([#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <errno.h>$1 main() { int fd = open("conftest_in", O_WRONLY|O_CREAT, 0600); if (fd < 0) exit(1); if (pwrite(fd, "text", 4, 0) != 4) exit(1); /* Linux glibc breakage until 2.2.5 */ if (pwrite(fd, "text", 4, -1) != -1 || errno != EINVAL) exit(1); exit(0); } ],[ ac_cv_pwrite=yes ],[ ac_cv_pwrite=no ],[ ac_cv_pwrite=no ])])AC_DEFUN([PHP_DOES_PREAD_WORK],[ echo test > conftest_in AC_TRY_RUN([#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <errno.h>$1 main() { char buf[3]; int fd = open("conftest_in", O_RDONLY); if (fd < 0) exit(1); if (pread(fd, buf, 2, 0) != 2) exit(1); /* Linux glibc breakage until 2.2.5 */ if (pread(fd, buf, 2, -1) != -1 || errno != EINVAL) exit(1); exit(0); } ],[ ac_cv_pread=yes ],[ ac_cv_pread=no ],[ ac_cv_pread=no ]) rm -f conftest_in])AC_DEFUN([PHP_PWRITE_TEST],[ AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[ PHP_DOES_PWRITE_WORK if test "$ac_cv_pwrite" = "no"; then PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);]) if test "$ac_cv_pwrite" = "yes"; then ac_cv_pwrite=64 fi fi ]) if test "$ac_cv_pwrite" != "no"; then AC_DEFINE(HAVE_PWRITE, 1, [ ]) if test "$ac_cv_pwrite" = "64"; then AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default]) fi fi ])AC_DEFUN([PHP_PREAD_TEST],[ AC_CACHE_CHECK(whether pread works,ac_cv_pread,[ PHP_DOES_PREAD_WORK if test "$ac_cv_pread" = "no"; then PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);]) if test "$ac_cv_pread" = "yes"; then ac_cv_pread=64 fi fi ]) if test "$ac_cv_pread" != "no"; then AC_DEFINE(HAVE_PREAD, 1, [ ]) if test "$ac_cv_pread" = "64"; then AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default]) fi fi ])AC_DEFUN([PHP_MISSING_TIME_R_DECL],[ AC_MSG_CHECKING([for missing declarations of reentrant functions]) AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = localtime_r],[ : ],[ AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared]) ]) AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = gmtime_r],[ : ],[ AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared]) ]) AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = asctime_r],[ : ],[ AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared]) ]) AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = ctime_r],[ : ],[ AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared]) ]) AC_TRY_COMPILE([#include <string.h>],[char *(*func)() = strtok_r],[ : ],[ AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared]) ]) AC_MSG_RESULT([done])])dnldnl PHP_LIBGCC_LIBPATH(gcc)dnl Stores the location of libgcc in libgcc_libpathdnlAC_DEFUN([PHP_LIBGCC_LIBPATH],[ changequote({,}) libgcc_libpath=`$1 --print-libgcc-file-name|sed 's%/*[^/][^/]*$%%'` changequote([,])])AC_DEFUN([PHP_ARG_ANALYZE_EX],[ext_output="yes, shared"ext_shared=yescase [$]$1 inshared,*[)] $1=`echo "[$]$1"|sed 's/^shared,//'` ;;shared[)] $1=yes ;;no[)] ext_output=no ext_shared=no ;;*[)] ext_output=yes ext_shared=no ;;esacPHP_ALWAYS_SHARED([$1])])AC_DEFUN([PHP_ARG_ANALYZE],[ifelse([$3],yes,[PHP_ARG_ANALYZE_EX([$1])],[ext_output=ifelse([$]$1,,no,[$]$1)])ifelse([$2],,,[AC_MSG_RESULT([$ext_output])])])dnldnl PHP_ARG_WITH(arg-name, check message, help text[, default-val[, extension-or-not]])dnl Sets PHP_ARG_NAME either to the user value or to the default value.dnl default-val defaults to no. This will also set the variable ext_shared,dnl and will overwrite any previous variable of that name.dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and rundnl the PHP_ARG_ANALYZE_EX.dnlAC_DEFUN([PHP_ARG_WITH],[PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)])])AC_DEFUN([PHP_REAL_ARG_WITH],[ifelse([$2],,,[AC_MSG_CHECKING([$2])])AC_ARG_WITH($1,[$3],$5=[$]withval,[ $5=ifelse($4,,no,$4) if test "$PHP_ENABLE_ALL" && test "$6" = "yes"; then $5=$PHP_ENABLE_ALL fi])PHP_ARG_ANALYZE($5,[$2],$6)])dnldnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val[, extension-or-not]])dnl Sets PHP_ARG_NAME either to the user value or to the default value.dnl default-val defaults to no. This will also set the variable ext_shared,dnl and will overwrite any previous variable of that name.dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and rundnl the PHP_ARG_ANALYZE_EX.dnlAC_DEFUN([PHP_ARG_ENABLE],[PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z-,A-Z_),[ifelse($5,,yes,$5)])])AC_DEFUN([PHP_REAL_ARG_ENABLE],[ifelse([$2],,,[AC_MSG_CHECKING([$2])])AC_ARG_ENABLE($1,[$3],$5=[$]enableval,[ $5=ifelse($4,,no,$4) if test "$PHP_ENABLE_ALL" && test "$6" = "yes"; then $5=$PHP_ENABLE_ALL fi])PHP_ARG_ANALYZE($5,[$2],$6)])AC_DEFUN([PHP_MODULE_PTR],[ EXTRA_MODULE_PTRS="$EXTRA_MODULE_PTRS $1,"]) AC_DEFUN([PHP_CONFIG_NICE],[ test -f $1 && mv $1 $1.old rm -f $1.old cat >$1<<EOF#! /bin/sh## Created by configureEOF
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -