New PHP5 APC - version 3.0.19, using PHP5 5.2.0-8+etch11,
[php5-apc.git] / config.m4
1 dnl
2 dnl $Id: config.m4,v 3.30.2.2 2008/03/25 21:00:22 rasmus Exp $
3 dnl
4
5 AC_MSG_CHECKING(whether apc needs to get compiler flags from apxs)
6 AC_ARG_WITH(apxs,
7 [  --with-apxs[=FILE]      Get compiler flags from apxs -q.  Provide the
8                           pathname to the Apache apxs tool; defaults to "apxs".],[
9   if test "$withval" != "no"; then
10     if test "$withval" = "yes"; then
11       APXS=apxs
12       $APXS -q CFLAGS >/dev/null 2>&1
13       if test "$?" != "0" && test -x /usr/sbin/apxs; then #SUSE 6.x
14         APXS=/usr/sbin/apxs
15       elif test -x /usr/bin/apxs2;  then
16         APXS=/usr/bin/apxs2
17       elif test -x /usr/sbin/apxs2; then
18         APXS=/usr/sbin/apxs2
19       fi
20     else
21       PHP_EXPAND_PATH($withval, APXS)
22     fi
23
24     $APXS -q CFLAGS >/dev/null 2>&1
25     if test "$?" != "0"; then
26       AC_MSG_RESULT()
27       AC_MSG_RESULT()
28       AC_MSG_RESULT([Sorry, I was not able to successfully run APXS.  Possible reasons:])
29       AC_MSG_RESULT()
30       AC_MSG_RESULT([1.  Perl is not installed;])
31       AC_MSG_RESULT([2.  Apache was not compiled with DSO support (--enable-module=so);])
32       AC_MSG_RESULT([3.  'apxs' is not in your path.  Try to use --with-apxs=/path/to/apxs])
33       AC_MSG_RESULT([The output of $APXS follows])
34       $APXS -q CFLAGS
35       AC_MSG_ERROR([Aborting])
36     fi
37
38     APC_CFLAGS=`$APXS -q CFLAGS`
39     AC_MSG_RESULT(yes)
40   else
41     AC_MSG_RESULT(no)
42   fi
43 ],[
44   AC_MSG_RESULT(no)
45 ])
46
47 PHP_ARG_ENABLE(apc, whether to enable APC support,
48 [  --enable-apc           Enable APC support])
49
50 AC_MSG_CHECKING(Checking whether we should enable cache request file info)
51 AC_ARG_ENABLE(apc-filehits,
52 [  --enable-apc-filehits   Enable per request file info about files used from the APC cache (ie: apc_cache_info('filehits')) ],
53 [
54   PHP_APC_FILEHITS=$enableval
55         AC_MSG_RESULT($enableval)
56 ], 
57 [
58   PHP_APC_FILEHITS=no
59         AC_MSG_RESULT(no)
60 ])
61
62
63
64 AC_MSG_CHECKING(Checking whether we should use mmap)
65 AC_ARG_ENABLE(apc-mmap,
66 [  --disable-apc-mmap
67                           Disable mmap support and use IPC shm instead],
68 [
69   PHP_APC_MMAP=$enableval
70   AC_MSG_RESULT($enableval)
71 ], [
72   PHP_APC_MMAP=yes
73   AC_MSG_RESULT(yes)
74 ])
75
76 AC_MSG_CHECKING(Checking whether we should use semaphore locking instead of fcntl)
77 AC_ARG_ENABLE(apc-sem,
78 [  --enable-apc-sem
79                           Enable semaphore locks instead of fcntl],
80 [
81   PHP_APC_SEM=$enableval
82   AC_MSG_RESULT($enableval)
83 ], [
84   PHP_APC_SEM=no
85   AC_MSG_RESULT(no)
86 ])
87
88 AC_MSG_CHECKING(Checking whether we should use futex locking)
89 AC_ARG_ENABLE(apc-futex,
90 [  --enable-apc-futex
91                           Enable linux futex based locks  EXPERIMENTAL ],
92 [
93   PHP_APC_FUTEX=$enableval
94   AC_MSG_RESULT($enableval)
95 ],
96 [
97   PHP_APC_FUTEX=no
98   AC_MSG_RESULT(no)
99 ])
100
101 if test "$PHP_APC_FUTEX" != "no"; then
102         AC_CHECK_HEADER(linux/futex.h, , [ AC_MSG_ERROR([futex.h not found.  Please verify you that are running a 2.5 or older linux kernel and that futex support is enabled.]); ] )
103 fi
104
105 AC_MSG_CHECKING(Checking whether we should use pthread mutex locking)
106 AC_ARG_ENABLE(apc-pthreadmutex,
107 [  --disable-apc-pthreadmutex
108                           Disable pthread mutex locking ],
109 [
110   PHP_APC_PTHREADMUTEX=$enableval
111   AC_MSG_RESULT($enableval)
112 ],
113 [
114   PHP_APC_PTHREADMUTEX=yes
115   AC_MSG_RESULT(yes)
116 ])
117 if test "$PHP_APC_PTHREADMUTEX" != "no"; then
118         orig_LIBS="$LIBS"
119         LIBS="$LIBS -lpthread"
120         AC_TRY_RUN(
121                         [
122                                 #include <sys/types.h>
123                                 #include <pthread.h>
124                                 main() {
125                                 pthread_mutex_t mutex;
126                                 pthread_mutexattr_t attr;       
127
128                                 if(pthread_mutexattr_init(&attr)) { 
129                                         puts("Unable to initialize pthread attributes (pthread_mutexattr_init).");
130                                         return -1; 
131                                 }
132                                 if(pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)) { 
133                                         puts("Unable to set PTHREAD_PROCESS_SHARED (pthread_mutexattr_setpshared), your system may not support shared mutex's.");
134                                         return -1; 
135                                 }       
136                                 if(pthread_mutex_init(&mutex, &attr)) { 
137                                         puts("Unable to initialize the mutex (pthread_mutex_init).");
138                                         return -1; 
139                                 }
140                                 if(pthread_mutexattr_destroy(&attr)) { 
141                                         puts("Unable to destroy mutex attributes (pthread_mutexattr_destroy).");
142                                         return -1; 
143                                 }
144                                 if(pthread_mutex_destroy(&mutex)) { 
145                                         puts("Unable to destroy mutex (pthread_mutex_destroy).");
146                                         return -1; 
147                                 }
148
149                                 puts("pthread mutex's are supported!");
150                                 return 0;
151                                 }
152                         ],
153                         [ dnl -Success-
154                                 PHP_ADD_LIBRARY(pthread)
155                         ],
156                         [ dnl -Failure-
157                                 AC_MSG_WARN([It doesn't appear that pthread mutex's are supported on your system])
158                         PHP_APC_PTHREADMUTEX=no
159                         ],
160                         [
161                                 PHP_ADD_LIBRARY(pthread)
162                         ]
163         )
164         LIBS="$orig_LIBS"
165 fi
166
167 AC_MSG_CHECKING(Checking whether we should use spin locks)
168 AC_ARG_ENABLE(apc-spinlocks,
169 [  --enable-apc-spinlocks
170                           Enable spin locks  EXPERIMENTAL ],
171 [
172   PHP_APC_SPINLOCKS=$enableval
173   AC_MSG_RESULT($enableval)
174 ],
175 [
176   PHP_APC_SPINLOCKS=no
177   AC_MSG_RESULT(no)
178 ])
179
180 if test "$PHP_APC" != "no"; then
181   test "$PHP_APC_MMAP" != "no" && AC_DEFINE(APC_MMAP, 1, [ ])
182   test "$PHP_APC_FILEHITS" != "no" && AC_DEFINE(APC_FILEHITS, 1, [ ])
183
184         if test "$PHP_APC_SEM" != "no"; then
185                 AC_DEFINE(APC_SEM_LOCKS, 1, [ ])
186         elif test "$PHP_APC_FUTEX" != "no"; then
187                 AC_DEFINE(APC_FUTEX_LOCKS, 1, [ ])
188         elif test "$PHP_APC_SPINLOCKS" != "no"; then
189                 AC_DEFINE(APC_SPIN_LOCKS, 1, [ ]) 
190         elif test "$PHP_APC_PTHREADMUTEX" != "no"; then 
191                 AC_DEFINE(APC_PTHREADMUTEX_LOCKS, 1, [ ])
192         fi
193
194   AC_CHECK_FUNCS(sigaction)
195   AC_CACHE_CHECK(for union semun, php_cv_semun,
196   [
197     AC_TRY_COMPILE([
198 #include <sys/types.h>
199 #include <sys/ipc.h>
200 #include <sys/sem.h>
201     ], [union semun x;], [
202       php_cv_semun=yes
203     ],[
204       php_cv_semun=no
205     ])
206   ])
207   if test "$php_cv_semun" = "yes"; then
208     AC_DEFINE(HAVE_SEMUN, 1, [ ])
209   else
210     AC_DEFINE(HAVE_SEMUN, 0, [ ])
211   fi
212
213   AC_MSG_CHECKING(whether we should enable valgrind support)
214   AC_ARG_ENABLE(valgrind-checks,
215   [  --enable-valgrind-checks
216                           Enable valgrind based memory checks],
217   [
218     PHP_APC_VALGRIND=$enableval
219     AC_MSG_RESULT($enableval)
220     AC_CHECK_HEADER(valgrind/memcheck.h, 
221                 [AC_DEFINE([HAVE_VALGRIND_MEMCHECK_H],1, [enable valgrind memchecks])])
222   ], [
223     PHP_APC_VALGRIND=no
224     AC_MSG_RESULT(no)
225   ])
226
227
228   apc_sources="apc.c php_apc.c \
229                apc_cache.c \
230                apc_compile.c \
231                apc_debug.c \
232                apc_fcntl.c \
233                apc_main.c \
234                apc_mmap.c \
235                apc_sem.c \
236                apc_shm.c \
237                apc_futex.c \
238                apc_pthreadmutex.c \
239                apc_spin.c \
240                pgsql_s_lock.c \
241                apc_sma.c \
242                apc_stack.c \
243                apc_zend.c \
244                apc_rfc1867.c \
245                apc_signal.c \
246                apc_pool.c "
247
248   PHP_CHECK_LIBRARY(rt, shm_open, [PHP_ADD_LIBRARY(rt,,APC_SHARED_LIBADD)])
249   PHP_NEW_EXTENSION(apc, $apc_sources, $ext_shared,, \\$(APC_CFLAGS))
250   PHP_SUBST(APC_SHARED_LIBADD)
251   PHP_SUBST(APC_CFLAGS)
252   AC_DEFINE(HAVE_APC, 1, [ ])
253 fi
254