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