File: config.m4

package info (click to toggle)
php-apcu 5.1.22%2B4.0.11-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,944 kB
  • sloc: ansic: 11,055; php: 1,748; xml: 963; pascal: 5; makefile: 2
file content (342 lines) | stat: -rw-r--r-- 10,084 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
dnl
dnl $Id: config.m4 327593 2012-09-10 11:50:58Z pajoye $
dnl
PHP_ARG_ENABLE(apcu, whether to enable APCu support,
[  --enable-apcu           Enable APCu support])

PHP_APC_BC=yes
AC_MSG_CHECKING(if APCu should provide APC full compatibility support)
AC_ARG_ENABLE(apc-bc,
[  --enable-apc-bc        Enable APC full compatibility support],
[ if test "x$enableval" = "xno"; then
    PHP_APC_BC=no
  else
    PHP_APC_BC=yes
  fi
])
AC_MSG_RESULT($PHP_APC_BC)

AC_MSG_CHECKING(if APCu should be allowed to use rwlocks)
AC_ARG_ENABLE(apcu-rwlocks,
[  --disable-apcu-rwlocks  Disable rwlocks in APCu],
[ PHP_APCU_RWLOCKS="$enableval" ], [ PHP_APCU_RWLOCKS=yes ])
AC_MSG_RESULT($PHP_APCU_RWLOCKS)

AC_MSG_CHECKING(if APCu should be built in debug mode)
AC_ARG_ENABLE(apcu-debug,
[  --enable-apcu-debug     Enable APCu debugging],
[
  PHP_APCU_DEBUG=$enableval
], 
[
  PHP_APCU_DEBUG=no
])
AC_MSG_RESULT($PHP_APCU_DEBUG)

AC_MSG_CHECKING(if APCu should clear on SIGUSR1)
AC_ARG_ENABLE(apcu-clear-signal,
[  --enable-apcu-clear-signal  Enable SIGUSR1 clearing handler],
[
  AC_DEFINE(APC_CLEAR_SIGNAL, 1, [ ])
  AC_MSG_RESULT(yes)
],
[
  AC_MSG_RESULT(no)
])

AC_MSG_CHECKING(if APCu will use mmap or shm)
AC_ARG_ENABLE(apcu-mmap,
[  --disable-apcu-mmap     Disable mmap, falls back on shm],
[ PHP_APCU_MMAP="$enableval" ], [ PHP_APCU_MMAP=yes ])
if test "x$enableval" = "xno"; then
  AC_MSG_RESULT(shm)
else
  AC_MSG_RESULT(mmap)
fi

PHP_APCU_SPINLOCK=no
AC_MSG_CHECKING(if APCu should utilize spinlocks before flocks)
AC_ARG_ENABLE(apcu-spinlocks,
[  --enable-apcu-spinlocks        Use spinlocks before flocks],
[ if test "x$enableval" = "xno"; then
    PHP_APCU_SPINLOCK=no
  else
    PHP_APCU_SPINLOCK=yes
  fi
])
AC_MSG_RESULT($PHP_APCU_SPINLOCK)

if test "$PHP_APCU" != "no"; then
	if test "$PHP_APC_BC" != "no"; then
		AC_DEFINE(APC_FULL_BC, 1, [APC full compatibility support])
	fi
	if test "$PHP_APCU_DEBUG" != "no"; then
		AC_DEFINE(APC_DEBUG, 1, [ ])
	fi
  
	if test "$PHP_APCU_MMAP" != "no"; then
		AC_DEFINE(APC_MMAP, 1, [ ])
	fi

  if test "$PHP_APCU_RWLOCKS" != "no"; then
	    orig_LIBS="$LIBS"
	    LIBS="$LIBS -lpthread"
	    AC_TRY_RUN(
		    [
			    #include <sys/types.h>
			    #include <pthread.h>
          main() {
			      pthread_rwlock_t rwlock;
			      pthread_rwlockattr_t attr;	

			      if(pthread_rwlockattr_init(&attr)) { 
				      puts("Unable to initialize pthread attributes (pthread_rwlockattr_init).");
				      return -1; 
			      }
			      if(pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)) { 
				      puts("Unable to set PTHREAD_PROCESS_SHARED (pthread_rwlockattr_setpshared), your system may not support shared rwlock's.");
				      return -1; 
			      }	
			      if(pthread_rwlock_init(&rwlock, &attr)) { 
				      puts("Unable to initialize the rwlock (pthread_rwlock_init).");
				      return -1; 
			      }
			      if(pthread_rwlockattr_destroy(&attr)) { 
				      puts("Unable to destroy rwlock attributes (pthread_rwlockattr_destroy).");
				      return -1; 
			      }
			      if(pthread_rwlock_destroy(&rwlock)) { 
				      puts("Unable to destroy rwlock (pthread_rwlock_destroy).");
				      return -1; 
			      }

			      return 0;
          }
		    ],
		    [ dnl -Success-
			    APCU_CFLAGS="-D_GNU_SOURCE"
			    PHP_ADD_LIBRARY(pthread)
				  PHP_LDFLAGS="$PHP_LDFLAGS -lpthread"
			    AC_DEFINE(APC_NATIVE_RWLOCK, 1, [ ])
			    AC_MSG_WARN([APCu has access to native rwlocks])
		    ],
		    [ dnl -Failure-
			    AC_MSG_WARN([It doesn't appear that pthread rwlocks are supported on your system])
    			PHP_APCU_RWLOCKS=no
		    ],
		    [
			    APCU_CFLAGS="-D_GNU_SOURCE"
			    PHP_ADD_LIBRARY(pthread)
				  PHP_LDFLAGS="$PHP_LDFLAGS -lpthread"
		    ]
    )
    LIBS="$orig_LIBS"
  fi

	if test "$PHP_APCU_RWLOCKS" != "no"; then
		AC_CACHE_CHECK([whether the target compiler supports builtin atomics], PHP_cv_APCU_GCC_ATOMICS, [

			AC_TRY_LINK([],[
					int foo = 0;
					__sync_fetch_and_add(&foo, 1);
					__sync_bool_compare_and_swap(&foo, 0, 1);
					return __sync_fetch_and_add(&foo, 1);
				],
				[PHP_cv_APCU_GCC_ATOMICS=yes],
				[PHP_cv_APCU_GCC_ATOMICS=no])
		])

		if test "x${PHP_cv_APCU_GCC_ATOMICS}" != "xno"; then
				AC_DEFINE(HAVE_ATOMIC_OPERATIONS, 1,
					[Define this if your target compiler supports builtin atomics])
			else
				if test "$PHP_APC_PTHREADRWLOCK" != "no"; then
					AC_MSG_WARN([Disabling pthread rwlocks, because of missing atomic operations])
					PHP_APCU_RWLOCKS=no
				fi
		fi
	fi
  
  if test "$PHP_APCU_RWLOCKS" == "no"; then
    orig_LIBS="$LIBS"
	  LIBS="$LIBS -lpthread"
	  AC_TRY_RUN(
			  [
				  #include <sys/types.h>
				  #include <pthread.h>
          main() {
				    pthread_mutex_t mutex;
				    pthread_mutexattr_t attr;	

				    if(pthread_mutexattr_init(&attr)) { 
					    puts("Unable to initialize pthread attributes (pthread_mutexattr_init).");
					    return -1; 
				    }
				    if(pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)) { 
					    puts("Unable to set PTHREAD_PROCESS_SHARED (pthread_mutexattr_setpshared), your system may not support shared mutex's.");
					    return -1; 
				    }	
				    if(pthread_mutex_init(&mutex, &attr)) { 
					    puts("Unable to initialize the mutex (pthread_mutex_init).");
					    return -1; 
				    }
				    if(pthread_mutexattr_destroy(&attr)) { 
					    puts("Unable to destroy mutex attributes (pthread_mutexattr_destroy).");
					    return -1; 
				    }
				    if(pthread_mutex_destroy(&mutex)) { 
					    puts("Unable to destroy mutex (pthread_mutex_destroy).");
					    return -1; 
				    }
				    return 0;
        }
			  ],
			  [ dnl -Success-
				  APCU_CFLAGS="-D_GNU_SOURCE"
				  PHP_ADD_LIBRARY(pthread)
				  PHP_LDFLAGS="$PHP_LDFLAGS -lpthread"
				  AC_MSG_WARN([APCu has access to mutexes])
			  ],
			  [ dnl -Failure-
				  AC_MSG_WARN([It doesn't appear that pthread mutexes are supported on your system])
    			PHP_APCU_MUTEX=no
			  ],
			  [
				  APCU_CFLAGS="-D_GNU_SOURCE"
				  PHP_ADD_LIBRARY(pthread)
				  PHP_LDFLAGS="$PHP_LDFLAGS -lpthread"
			  ]
	  )
	  LIBS="$orig_LIBS"
  fi
  
  if test "$PHP_APCU_RWLOCKS" == "no"; then
   if test "$PHP_APCU_MUTEX" == "no"; then
    if test "$PHP_APCU_SPINLOCK" != "no"; then
      AC_DEFINE(APC_SPIN_LOCK, 1, [ ])
      AC_MSG_WARN([APCu spin locking enabled])
    else
      AC_DEFINE(APC_FCNTL_LOCK, 1, [ ])
      AC_MSG_WARN([APCu file locking enabled])
    fi
   fi
  fi
	
  AC_CHECK_FUNCS(sigaction)
  AC_CACHE_CHECK(for union semun, php_cv_semun,
  [
    AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
    ], [union semun x; x.val=1], [
      php_cv_semun=yes
    ],[
      php_cv_semun=no
    ])
  ])
  if test "$php_cv_semun" = "yes"; then
    AC_DEFINE(HAVE_SEMUN, 1, [ ])
  else
    AC_DEFINE(HAVE_SEMUN, 0, [ ])
  fi

  AC_ARG_ENABLE(valgrind-checks,
  [  --disable-valgrind-checks
                          Disable valgrind based memory checks],
  [
    PHP_APCU_VALGRIND=no
  ], [
    PHP_APCU_VALGRIND=yes
    AC_CHECK_HEADER(valgrind/memcheck.h, 
  		[AC_DEFINE([HAVE_VALGRIND_MEMCHECK_H],1, [enable valgrind memchecks])])
  ])

  apc_sources="apc.c apc_lock.c php_apc.c \
                 apc_cache.c \
                 apc_mmap.c \
                 apc_shm.c \
                 apc_sma.c \
                 apc_stack.c \
                 apc_rfc1867.c \
                 apc_signal.c \
                 apc_pool.c \
                 apc_iterator.c \
							   apc_bin.c "
							   
  PHP_CHECK_LIBRARY(rt, shm_open, [PHP_ADD_LIBRARY(rt,,APCU_SHARED_LIBADD)])
  PHP_NEW_EXTENSION(apcu, $apc_sources, $ext_shared,, \\$(APCU_CFLAGS))
  PHP_SUBST(APCU_SHARED_LIBADD)
  PHP_SUBST(APCU_CFLAGS)
  PHP_SUBST(PHP_LDFLAGS)
  PHP_INSTALL_HEADERS(ext/apcu, [apc.h apc_api.h apc_cache_api.h apc_lock_api.h apc_pool_api.h apc_sma_api.h apc_bin_api.h apc_serializer.h])
  AC_DEFINE(HAVE_APCU, 1, [ ])
fi

PHP_ARG_ENABLE(coverage,  whether to include code coverage symbols,
[  --enable-coverage           DEVELOPERS ONLY!!], no, no)

if test "$PHP_COVERAGE" = "yes"; then

  if test "$GCC" != "yes"; then
    AC_MSG_ERROR([GCC is required for --enable-coverage])
  fi
  
  dnl Check if ccache is being used
  case `$php_shtool path $CC` in
    *ccache*[)] gcc_ccache=yes;;
    *[)] gcc_ccache=no;;
  esac

  if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
    AC_MSG_ERROR([ccache must be disabled when --enable-coverage option is used. You can disable ccache by setting environment variable 
CCACHE_DISABLE=1.])
  fi
  
  lcov_version_list="1.5 1.6 1.7 1.9"

  AC_CHECK_PROG(LCOV, lcov, lcov)
  AC_CHECK_PROG(GENHTML, genhtml, genhtml)
  PHP_SUBST(LCOV)
  PHP_SUBST(GENHTML)

  if test "$LCOV"; then
    AC_CACHE_CHECK([for lcov version], php_cv_lcov_version, [
      php_cv_lcov_version=invalid
      lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'` #'
      for lcov_check_version in $lcov_version_list; do
        if test "$lcov_version" = "$lcov_check_version"; then
          php_cv_lcov_version="$lcov_check_version (ok)"
        fi
      done
    ])
  else
    lcov_msg="To enable code coverage reporting you must have one of the following LCOV versions installed: $lcov_version_list"      
    AC_MSG_ERROR([$lcov_msg])
  fi

  case $php_cv_lcov_version in
    ""|invalid[)]
      lcov_msg="You must have one of the following versions of LCOV: $lcov_version_list (found: $lcov_version)."
      AC_MSG_ERROR([$lcov_msg])
      LCOV="exit 0;"
      ;;
  esac

  if test -z "$GENHTML"; then
    AC_MSG_ERROR([Could not find genhtml from the LCOV package])
  fi

  PHP_ADD_MAKEFILE_FRAGMENT

  dnl Remove all optimization flags from CFLAGS
  changequote({,})
  CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'`
  CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9s]*//g'`
  changequote([,])

  dnl Add the special gcc flags
  CFLAGS="$CFLAGS -O0 -ggdb -fprofile-arcs -ftest-coverage"
  CXXFLAGS="$CXXFLAGS -ggdb -O0 -fprofile-arcs -ftest-coverage"
fi
dnl vim: set ts=2