1dnl This file becomes configure.ac for self-contained extensions. 2 3dnl Include external macro definitions before the AC_INIT to also remove 4dnl comments starting with # and empty newlines from the included files. 5m4_include([build/ax_check_compile_flag.m4]) 6m4_include([build/ax_gcc_func_attribute.m4]) 7m4_include([build/libtool.m4]) 8m4_include([build/php_cxx_compile_stdcxx.m4]) 9m4_include([build/php.m4]) 10m4_include([build/pkg.m4]) 11 12AC_PREREQ([2.68]) 13AC_INIT 14AC_CONFIG_SRCDIR([config.m4]) 15AC_CONFIG_AUX_DIR([build]) 16AC_PRESERVE_HELP_ORDER 17 18PHP_CONFIG_NICE(config.nice) 19 20AC_DEFUN([PHP_EXT_BUILDDIR],[.])dnl 21AC_DEFUN([PHP_EXT_DIR],[""])dnl 22AC_DEFUN([PHP_EXT_SRCDIR],[$abs_srcdir])dnl 23AC_DEFUN([PHP_ALWAYS_SHARED],[ 24 ext_output="yes, shared" 25 ext_shared=yes 26 test "[$]$1" = "no" && $1=yes 27])dnl 28 29test -z "$CFLAGS" && auto_cflags=1 30 31abs_srcdir=`(cd $srcdir && pwd)` 32abs_builddir=`pwd` 33 34PKG_PROG_PKG_CONFIG 35AC_PROG_CC([cc gcc]) 36PHP_DETECT_ICC 37PHP_DETECT_SUNCC 38 39dnl Support systems with system libraries in e.g. /usr/lib64. 40PHP_ARG_WITH([libdir], 41 [for system library directory], 42 [AS_HELP_STRING([--with-libdir=NAME], 43 [Look for libraries in .../NAME rather than .../lib])], 44 [lib], 45 [no]) 46 47PHP_RUNPATH_SWITCH 48PHP_SHLIB_SUFFIX_NAMES 49 50dnl Find php-config script. 51PHP_ARG_WITH([php-config],, 52 [AS_HELP_STRING([--with-php-config=PATH], 53 [Path to php-config [php-config]])], 54 [php-config], 55 [no]) 56 57dnl For BC. 58PHP_CONFIG=$PHP_PHP_CONFIG 59prefix=`$PHP_CONFIG --prefix 2>/dev/null` 60phpincludedir=`$PHP_CONFIG --include-dir 2>/dev/null` 61INCLUDES=`$PHP_CONFIG --includes 2>/dev/null` 62EXTENSION_DIR=`$PHP_CONFIG --extension-dir 2>/dev/null` 63PHP_EXECUTABLE=`$PHP_CONFIG --php-binary 2>/dev/null` 64 65if test -z "$prefix"; then 66 AC_MSG_ERROR([Cannot find php-config. Please use --with-php-config=PATH]) 67fi 68 69php_shtool=$srcdir/build/shtool 70PHP_INIT_BUILD_SYSTEM 71 72AC_MSG_CHECKING([for PHP prefix]) 73AC_MSG_RESULT([$prefix]) 74AC_MSG_CHECKING([for PHP includes]) 75AC_MSG_RESULT([$INCLUDES]) 76AC_MSG_CHECKING([for PHP extension directory]) 77AC_MSG_RESULT([$EXTENSION_DIR]) 78AC_MSG_CHECKING([for PHP installed headers prefix]) 79AC_MSG_RESULT([$phpincludedir]) 80 81dnl Checks for PHP_DEBUG / ZEND_DEBUG / ZTS. 82AC_MSG_CHECKING([if debug is enabled]) 83old_CPPFLAGS=$CPPFLAGS 84CPPFLAGS="-I$phpincludedir" 85AC_EGREP_CPP(php_debug_is_enabled,[ 86#include <main/php_config.h> 87#if ZEND_DEBUG 88php_debug_is_enabled 89#endif 90],[ 91 PHP_DEBUG=yes 92],[ 93 PHP_DEBUG=no 94]) 95CPPFLAGS=$old_CPPFLAGS 96AC_MSG_RESULT([$PHP_DEBUG]) 97 98AC_MSG_CHECKING([if zts is enabled]) 99old_CPPFLAGS=$CPPFLAGS 100CPPFLAGS="-I$phpincludedir" 101AC_EGREP_CPP(php_zts_is_enabled,[ 102#include <main/php_config.h> 103#if ZTS 104php_zts_is_enabled 105#endif 106],[ 107 PHP_THREAD_SAFETY=yes 108],[ 109 PHP_THREAD_SAFETY=no 110]) 111CPPFLAGS=$old_CPPFLAGS 112AC_MSG_RESULT([$PHP_THREAD_SAFETY]) 113 114dnl Discard optimization flags when debugging is enabled. 115if test "$PHP_DEBUG" = "yes"; then 116 PHP_DEBUG=1 117 ZEND_DEBUG=yes 118 PHP_REMOVE_OPTIMIZATION_FLAGS 119 dnl Add -O0 only if GCC or ICC is used. 120 if test "$GCC" = "yes" || test "$ICC" = "yes"; then 121 CFLAGS="$CFLAGS -O0" 122 CXXFLAGS="$CXXFLAGS -g -O0" 123 fi 124 if test "$SUNCC" = "yes"; then 125 if test -n "$auto_cflags"; then 126 CFLAGS="-g" 127 CXXFLAGS="-g" 128 else 129 CFLAGS="$CFLAGS -g" 130 CXXFLAGS="$CFLAGS -g" 131 fi 132 fi 133else 134 PHP_DEBUG=0 135 ZEND_DEBUG=no 136fi 137 138dnl Always shared. 139PHP_BUILD_SHARED 140 141dnl Required programs. 142PHP_PROG_AWK 143 144sinclude(config.m4) 145 146enable_static=no 147enable_shared=yes 148 149dnl Only allow AC_PROG_CXX and AC_PROG_CXXCPP if they are explicitly called (by 150dnl PHP_REQUIRE_CXX). Otherwise AC_PROG_LIBTOOL fails if there is no working C++ 151dnl compiler. 152AC_PROVIDE_IFELSE([PHP_REQUIRE_CXX], [], [ 153 undefine([AC_PROG_CXX]) 154 AC_DEFUN([AC_PROG_CXX], []) 155 undefine([AC_PROG_CXXCPP]) 156 AC_DEFUN([AC_PROG_CXXCPP], [php_prog_cxxcpp=disabled]) 157]) 158AC_PROG_LIBTOOL 159 160all_targets='$(PHP_MODULES) $(PHP_ZEND_EX)' 161install_targets="install-modules install-headers" 162phplibdir="`pwd`/modules" 163CPPFLAGS="$CPPFLAGS -DHAVE_CONFIG_H" 164CFLAGS_CLEAN='$(CFLAGS) -D_GNU_SOURCE' 165CXXFLAGS_CLEAN='$(CXXFLAGS)' 166 167test "$prefix" = "NONE" && prefix="/usr/local" 168test "$exec_prefix" = "NONE" && exec_prefix='$(prefix)' 169 170if test "$cross_compiling" = yes ; then 171 AC_MSG_CHECKING(for native build C compiler) 172 AC_CHECK_PROGS(BUILD_CC, [gcc clang c99 c89 cc cl],none) 173 AC_MSG_RESULT($BUILD_CC) 174else 175 BUILD_CC=$CC 176fi 177 178PHP_SUBST(PHP_MODULES) 179PHP_SUBST(PHP_ZEND_EX) 180 181PHP_SUBST(all_targets) 182PHP_SUBST(install_targets) 183 184PHP_SUBST(prefix) 185PHP_SUBST(exec_prefix) 186PHP_SUBST(libdir) 187PHP_SUBST(prefix) 188PHP_SUBST(phplibdir) 189PHP_SUBST(phpincludedir) 190 191PHP_SUBST(CC) 192PHP_SUBST(CFLAGS) 193PHP_SUBST(CFLAGS_CLEAN) 194PHP_SUBST(CPP) 195PHP_SUBST(CPPFLAGS) 196PHP_SUBST(CXX) 197PHP_SUBST(CXXFLAGS) 198PHP_SUBST(CXXFLAGS_CLEAN) 199PHP_SUBST(EXTENSION_DIR) 200PHP_SUBST(PHP_EXECUTABLE) 201PHP_SUBST(EXTRA_LDFLAGS) 202PHP_SUBST(EXTRA_LIBS) 203PHP_SUBST(INCLUDES) 204PHP_SUBST(LFLAGS) 205PHP_SUBST(LDFLAGS) 206PHP_SUBST(SHARED_LIBTOOL) 207PHP_SUBST(LIBTOOL) 208PHP_SUBST(SHELL) 209PHP_SUBST(INSTALL_HEADERS) 210PHP_SUBST(BUILD_CC) 211 212PHP_GEN_BUILD_DIRS 213PHP_GEN_GLOBAL_MAKEFILE 214 215test -d modules || $php_shtool mkdir modules 216 217AC_CONFIG_HEADERS([config.h]) 218 219AC_CONFIG_COMMANDS_PRE([PHP_PATCH_CONFIG_HEADERS([config.h.in])]) 220 221AC_OUTPUT 222