xref: /PHP-7.4/scripts/phpize.m4 (revision a6daded1)
12fe9208eSBrian Evansdnl This file becomes configure.ac for self-contained extensions.
2f2f8d38eSSascha Schumann
34e7064d1SPeter Kokotdnl Include external macro definitions before the AC_INIT to also remove
44e7064d1SPeter Kokotdnl comments starting with # and empty newlines from the included files.
54e7064d1SPeter Kokotm4_include([build/ax_check_compile_flag.m4])
64e7064d1SPeter Kokotm4_include([build/ax_gcc_func_attribute.m4])
74e7064d1SPeter Kokotm4_include([build/libtool.m4])
84e7064d1SPeter Kokotm4_include([build/php_cxx_compile_stdcxx.m4])
94e7064d1SPeter Kokotm4_include([build/php.m4])
104e7064d1SPeter Kokotm4_include([build/pkg.m4])
114e7064d1SPeter Kokot
120b0d4b5fSPeter KokotAC_PREREQ([2.68])
13afd52f9dSPeter KokotAC_INIT
14afd52f9dSPeter KokotAC_CONFIG_SRCDIR([config.m4])
157e445ef3SPeter KokotAC_CONFIG_AUX_DIR([build])
169bbf9967SPeter KokotAC_PRESERVE_HELP_ORDER
179d9d39a0SSascha Schumann
18b74a5eacSfoobarPHP_CONFIG_NICE(config.nice)
19b74a5eacSfoobar
2069eec3f3SfoobarAC_DEFUN([PHP_EXT_BUILDDIR],[.])dnl
2169eec3f3SfoobarAC_DEFUN([PHP_EXT_DIR],[""])dnl
2269eec3f3SfoobarAC_DEFUN([PHP_EXT_SRCDIR],[$abs_srcdir])dnl
2369eec3f3SfoobarAC_DEFUN([PHP_ALWAYS_SHARED],[
242ea99fe1SSascha Schumann  ext_output="yes, shared"
252ea99fe1SSascha Schumann  ext_shared=yes
262ea99fe1SSascha Schumann  test "[$]$1" = "no" && $1=yes
272ea99fe1SSascha Schumann])dnl
282b830291SDavid Soria Parra
292b830291SDavid Soria Parratest -z "$CFLAGS" && auto_cflags=1
302b830291SDavid Soria Parra
313b9bcd74SSascha Schumannabs_srcdir=`(cd $srcdir && pwd)`
329d9d39a0SSascha Schumannabs_builddir=`pwd`
333b9bcd74SSascha Schumann
34c9ee822bSHugh McMasterPKG_PROG_PKG_CONFIG
352b830291SDavid Soria ParraAC_PROG_CC([cc gcc])
3687acbd26SJani TaskinenPHP_DETECT_ICC
372b830291SDavid Soria ParraPHP_DETECT_SUNCC
38f2f8d38eSSascha Schumann
3975fb7486SPeter Kokotdnl Support systems with system libraries in e.g. /usr/lib64.
409df6a1e4SPeter KokotPHP_ARG_WITH([libdir],
419df6a1e4SPeter Kokot  [for system library directory],
429df6a1e4SPeter Kokot  [AS_HELP_STRING([--with-libdir=NAME],
439df6a1e4SPeter Kokot    [Look for libraries in .../NAME rather than .../lib])],
449df6a1e4SPeter Kokot  [lib],
459df6a1e4SPeter Kokot  [no])
4676906e04Sfoobar
47775a0641SfoobarPHP_RUNPATH_SWITCH
48276171f8SfoobarPHP_SHLIB_SUFFIX_NAMES
49f2f8d38eSSascha Schumann
5075fb7486SPeter Kokotdnl Find php-config script.
519df6a1e4SPeter KokotPHP_ARG_WITH([php-config],,
529df6a1e4SPeter Kokot  [AS_HELP_STRING([--with-php-config=PATH],
539df6a1e4SPeter Kokot    [Path to php-config [php-config]])],
549df6a1e4SPeter Kokot  [php-config],
559df6a1e4SPeter Kokot  [no])
569d9d39a0SSascha Schumann
5775fb7486SPeter Kokotdnl For BC.
58e602885eSJani TaskinenPHP_CONFIG=$PHP_PHP_CONFIG
59e602885eSJani Taskinenprefix=`$PHP_CONFIG --prefix 2>/dev/null`
60e602885eSJani Taskinenphpincludedir=`$PHP_CONFIG --include-dir 2>/dev/null`
61e602885eSJani TaskinenINCLUDES=`$PHP_CONFIG --includes 2>/dev/null`
62e602885eSJani TaskinenEXTENSION_DIR=`$PHP_CONFIG --extension-dir 2>/dev/null`
63e602885eSJani TaskinenPHP_EXECUTABLE=`$PHP_CONFIG --php-binary 2>/dev/null`
64cf3b8521SPeter Kokot
656b4b1e74SJani Taskinenif test -z "$prefix"; then
666b4b1e74SJani Taskinen  AC_MSG_ERROR([Cannot find php-config. Please use --with-php-config=PATH])
676b4b1e74SJani Taskinenfi
686b4b1e74SJani Taskinen
696b4b1e74SJani Taskinenphp_shtool=$srcdir/build/shtool
706b4b1e74SJani TaskinenPHP_INIT_BUILD_SYSTEM
716b4b1e74SJani Taskinen
726b4b1e74SJani TaskinenAC_MSG_CHECKING([for PHP prefix])
736b4b1e74SJani TaskinenAC_MSG_RESULT([$prefix])
746b4b1e74SJani TaskinenAC_MSG_CHECKING([for PHP includes])
756b4b1e74SJani TaskinenAC_MSG_RESULT([$INCLUDES])
766b4b1e74SJani TaskinenAC_MSG_CHECKING([for PHP extension directory])
776b4b1e74SJani TaskinenAC_MSG_RESULT([$EXTENSION_DIR])
786b4b1e74SJani TaskinenAC_MSG_CHECKING([for PHP installed headers prefix])
796b4b1e74SJani TaskinenAC_MSG_RESULT([$phpincludedir])
806b4b1e74SJani Taskinen
8175fb7486SPeter Kokotdnl Checks for PHP_DEBUG / ZEND_DEBUG / ZTS.
8287acbd26SJani TaskinenAC_MSG_CHECKING([if debug is enabled])
8387acbd26SJani Taskinenold_CPPFLAGS=$CPPFLAGS
8487acbd26SJani TaskinenCPPFLAGS="-I$phpincludedir"
8587acbd26SJani TaskinenAC_EGREP_CPP(php_debug_is_enabled,[
8687acbd26SJani Taskinen#include <main/php_config.h>
8787acbd26SJani Taskinen#if ZEND_DEBUG
8887acbd26SJani Taskinenphp_debug_is_enabled
8987acbd26SJani Taskinen#endif
9087acbd26SJani Taskinen],[
9187acbd26SJani Taskinen  PHP_DEBUG=yes
9287acbd26SJani Taskinen],[
9387acbd26SJani Taskinen  PHP_DEBUG=no
9487acbd26SJani Taskinen])
95d0ef9301SJani TaskinenCPPFLAGS=$old_CPPFLAGS
96708cb0ecSJani TaskinenAC_MSG_RESULT([$PHP_DEBUG])
97708cb0ecSJani Taskinen
98708cb0ecSJani TaskinenAC_MSG_CHECKING([if zts is enabled])
99708cb0ecSJani Taskinenold_CPPFLAGS=$CPPFLAGS
100708cb0ecSJani TaskinenCPPFLAGS="-I$phpincludedir"
101708cb0ecSJani TaskinenAC_EGREP_CPP(php_zts_is_enabled,[
102708cb0ecSJani Taskinen#include <main/php_config.h>
103708cb0ecSJani Taskinen#if ZTS
104708cb0ecSJani Taskinenphp_zts_is_enabled
105708cb0ecSJani Taskinen#endif
106708cb0ecSJani Taskinen],[
107708cb0ecSJani Taskinen  PHP_THREAD_SAFETY=yes
108708cb0ecSJani Taskinen],[
109708cb0ecSJani Taskinen  PHP_THREAD_SAFETY=no
110708cb0ecSJani Taskinen])
11187acbd26SJani TaskinenCPPFLAGS=$old_CPPFLAGS
1122bd097c9SYuchen WangAC_MSG_RESULT([$PHP_THREAD_SAFETY])
11387acbd26SJani Taskinen
11475fb7486SPeter Kokotdnl Discard optimization flags when debugging is enabled.
11587acbd26SJani Taskinenif test "$PHP_DEBUG" = "yes"; then
11687acbd26SJani Taskinen  PHP_DEBUG=1
11787acbd26SJani Taskinen  ZEND_DEBUG=yes
11887acbd26SJani Taskinen  changequote({,})
11987acbd26SJani Taskinen  CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'`
12087acbd26SJani Taskinen  CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9s]*//g'`
12187acbd26SJani Taskinen  changequote([,])
12275fb7486SPeter Kokot  dnl Add -O0 only if GCC or ICC is used.
12387acbd26SJani Taskinen  if test "$GCC" = "yes" || test "$ICC" = "yes"; then
12487acbd26SJani Taskinen    CFLAGS="$CFLAGS -O0"
125309a56f3SJani Taskinen    CXXFLAGS="$CXXFLAGS -g -O0"
12687acbd26SJani Taskinen  fi
1272b830291SDavid Soria Parra  if test "$SUNCC" = "yes"; then
1282b830291SDavid Soria Parra    if test -n "$auto_cflags"; then
1292b830291SDavid Soria Parra      CFLAGS="-g"
1302b830291SDavid Soria Parra      CXXFLAGS="-g"
1312b830291SDavid Soria Parra    else
1322b830291SDavid Soria Parra      CFLAGS="$CFLAGS -g"
1332b830291SDavid Soria Parra      CXXFLAGS="$CFLAGS -g"
1342b830291SDavid Soria Parra    fi
1352b830291SDavid Soria Parra  fi
13687acbd26SJani Taskinenelse
13787acbd26SJani Taskinen  PHP_DEBUG=0
13887acbd26SJani Taskinen  ZEND_DEBUG=no
13987acbd26SJani Taskinenfi
14087acbd26SJani Taskinen
14175fb7486SPeter Kokotdnl Always shared.
1426b4b1e74SJani TaskinenPHP_BUILD_SHARED
143f2f8d38eSSascha Schumann
14475fb7486SPeter Kokotdnl Required programs.
1452a6da0f2SfoobarPHP_PROG_AWK
1462af5002dSJani Taskinen
147f2f8d38eSSascha Schumannsinclude(config.m4)
148f2f8d38eSSascha Schumann
149f2f8d38eSSascha Schumannenable_static=no
150f2f8d38eSSascha Schumannenable_shared=yes
151f2f8d38eSSascha Schumann
15275fb7486SPeter Kokotdnl Only allow AC_PROG_CXX and AC_PROG_CXXCPP if they are explicitly called (by
15375fb7486SPeter Kokotdnl PHP_REQUIRE_CXX). Otherwise AC_PROG_LIBTOOL fails if there is no working C++
15475fb7486SPeter Kokotdnl compiler.
155395e75bcSJani TaskinenAC_PROVIDE_IFELSE([PHP_REQUIRE_CXX], [], [
156395e75bcSJani Taskinen  undefine([AC_PROG_CXX])
157395e75bcSJani Taskinen  AC_DEFUN([AC_PROG_CXX], [])
158395e75bcSJani Taskinen  undefine([AC_PROG_CXXCPP])
159e4ad2672SDavid Soria Parra  AC_DEFUN([AC_PROG_CXXCPP], [php_prog_cxxcpp=disabled])
160395e75bcSJani Taskinen])
161f2f8d38eSSascha SchumannAC_PROG_LIBTOOL
162f2f8d38eSSascha Schumann
163708cb0ecSJani Taskinenall_targets='$(PHP_MODULES) $(PHP_ZEND_EX)'
1647243d31aSfoobarinstall_targets="install-modules install-headers"
165f2f8d38eSSascha Schumannphplibdir="`pwd`/modules"
16683b18832SStig BakkenCPPFLAGS="$CPPFLAGS -DHAVE_CONFIG_H"
167a283caf3SSascha SchumannCFLAGS_CLEAN='$(CFLAGS)'
168c1c44ddcSfoobarCXXFLAGS_CLEAN='$(CXXFLAGS)'
169f2f8d38eSSascha Schumann
170f2f8d38eSSascha Schumanntest "$prefix" = "NONE" && prefix="/usr/local"
171f2f8d38eSSascha Schumanntest "$exec_prefix" = "NONE" && exec_prefix='$(prefix)'
172f2f8d38eSSascha Schumann
1739d9d39a0SSascha SchumannPHP_SUBST(PHP_MODULES)
174708cb0ecSJani TaskinenPHP_SUBST(PHP_ZEND_EX)
175708cb0ecSJani Taskinen
1769d9d39a0SSascha SchumannPHP_SUBST(all_targets)
1779d9d39a0SSascha SchumannPHP_SUBST(install_targets)
1789d9d39a0SSascha Schumann
179f2f8d38eSSascha SchumannPHP_SUBST(prefix)
180f2f8d38eSSascha SchumannPHP_SUBST(exec_prefix)
181f2f8d38eSSascha SchumannPHP_SUBST(libdir)
182f2f8d38eSSascha SchumannPHP_SUBST(prefix)
183f2f8d38eSSascha SchumannPHP_SUBST(phplibdir)
1847243d31aSfoobarPHP_SUBST(phpincludedir)
185f2f8d38eSSascha Schumann
186f2f8d38eSSascha SchumannPHP_SUBST(CC)
187f2f8d38eSSascha SchumannPHP_SUBST(CFLAGS)
188e5b86174SSascha SchumannPHP_SUBST(CFLAGS_CLEAN)
189f2f8d38eSSascha SchumannPHP_SUBST(CPP)
190f2f8d38eSSascha SchumannPHP_SUBST(CPPFLAGS)
191f2f8d38eSSascha SchumannPHP_SUBST(CXX)
192e891278fSfoobarPHP_SUBST(CXXFLAGS)
193c1c44ddcSfoobarPHP_SUBST(CXXFLAGS_CLEAN)
1945989ae5dSSascha SchumannPHP_SUBST(EXTENSION_DIR)
195ee5fd96eSfoobarPHP_SUBST(PHP_EXECUTABLE)
196f2f8d38eSSascha SchumannPHP_SUBST(EXTRA_LDFLAGS)
197f2f8d38eSSascha SchumannPHP_SUBST(EXTRA_LIBS)
198f2f8d38eSSascha SchumannPHP_SUBST(INCLUDES)
199f2f8d38eSSascha SchumannPHP_SUBST(LFLAGS)
2004a0291d2SfoobarPHP_SUBST(LDFLAGS)
2015989ae5dSSascha SchumannPHP_SUBST(SHARED_LIBTOOL)
202f2f8d38eSSascha SchumannPHP_SUBST(LIBTOOL)
203f2f8d38eSSascha SchumannPHP_SUBST(SHELL)
2047243d31aSfoobarPHP_SUBST(INSTALL_HEADERS)
205f2f8d38eSSascha Schumann
2069d9d39a0SSascha SchumannPHP_GEN_BUILD_DIRS
2079d9d39a0SSascha SchumannPHP_GEN_GLOBAL_MAKEFILE
208f2f8d38eSSascha Schumann
20962625394Sfoobartest -d modules || $php_shtool mkdir modules
2105989ae5dSSascha Schumann
211491f1477SPeter KokotAC_CONFIG_HEADERS([config.h])
212f2f8d38eSSascha Schumann
213*a6daded1SPeter KokotAC_CONFIG_COMMANDS_PRE([PHP_PATCH_CONFIG_HEADERS([config.h.in])])
214*a6daded1SPeter Kokot
215daaf706dSPeter KokotAC_OUTPUT
216