Annotation of embedaddon/php/Zend/Zend.m4, revision 1.1

1.1     ! misho       1: dnl
        !             2: dnl $Id: Zend.m4 286859 2009-08-06 01:33:54Z scottmac $
        !             3: dnl
        !             4: dnl This file contains Zend specific autoconf functions.
        !             5: dnl
        !             6: 
        !             7: AC_DEFUN([LIBZEND_CHECK_INT_TYPE],[
        !             8: AC_MSG_CHECKING(for $1)
        !             9: AC_TRY_COMPILE([
        !            10: #if HAVE_SYS_TYPES_H  
        !            11: #include <sys/types.h>
        !            12: #endif
        !            13: #if HAVE_INTTYPES_H  
        !            14: #include <inttypes.h>
        !            15: #elif HAVE_STDINT_H
        !            16: #include <stdint.h>
        !            17: #endif],
        !            18: [if (($1 *) 0)
        !            19:   return 0;
        !            20: if (sizeof ($1))
        !            21:   return 0;
        !            22: ],[
        !            23:   AC_DEFINE_UNQUOTED([HAVE_]translit($1,a-z_-,A-Z__), 1,[Define if $1 type is present. ])
        !            24:   AC_MSG_RESULT(yes)
        !            25: ], AC_MSG_RESULT(no)
        !            26: )dnl
        !            27: ])
        !            28: 
        !            29: AC_DEFUN([LIBZEND_BASIC_CHECKS],[
        !            30: 
        !            31: AC_REQUIRE([AC_PROG_YACC])
        !            32: AC_REQUIRE([AC_PROG_CC])
        !            33: AC_REQUIRE([AC_PROG_CC_C_O])
        !            34: AC_REQUIRE([AC_HEADER_STDC])
        !            35: 
        !            36: LIBZEND_BISON_CHECK
        !            37: 
        !            38: dnl Ugly hack to get around a problem with gcc on AIX.
        !            39: if test "$CC" = "gcc" -a "$ac_cv_prog_cc_g" = "yes" -a \
        !            40:    "`uname -sv`" = "AIX 4"; then
        !            41:        CFLAGS=`echo $CFLAGS | sed -e 's/-g//'`
        !            42: fi
        !            43: 
        !            44: dnl Hack to work around a Mac OS X cpp problem
        !            45: dnl Known versions needing this workaround are 5.3 and 5.4
        !            46: if test "$ac_cv_prog_gcc" = "yes" -a "`uname -s`" = "Rhapsody"; then
        !            47:         CPPFLAGS="$CPPFLAGS -traditional-cpp"
        !            48: fi
        !            49: 
        !            50: AC_CHECK_HEADERS(
        !            51: inttypes.h \
        !            52: stdint.h \
        !            53: limits.h \
        !            54: malloc.h \
        !            55: string.h \
        !            56: unistd.h \
        !            57: stdarg.h \
        !            58: sys/types.h \
        !            59: sys/time.h \
        !            60: signal.h \
        !            61: unix.h \
        !            62: stdlib.h \
        !            63: dlfcn.h)
        !            64: 
        !            65: AC_TYPE_SIZE_T
        !            66: AC_TYPE_SIGNAL
        !            67: 
        !            68: AC_DEFUN([LIBZEND_LIBDL_CHECKS],[
        !            69: AC_CHECK_LIB(dl, dlopen, [LIBS="-ldl $LIBS"])
        !            70: AC_CHECK_FUNC(dlopen,[AC_DEFINE(HAVE_LIBDL, 1,[ ])])
        !            71: ])
        !            72: 
        !            73: AC_DEFUN([LIBZEND_DLSYM_CHECK],[
        !            74: dnl
        !            75: dnl Ugly hack to check if dlsym() requires a leading underscore in symbol name.
        !            76: dnl
        !            77: AC_MSG_CHECKING([whether dlsym() requires a leading underscore in symbol names])
        !            78: _LT_AC_TRY_DLOPEN_SELF([
        !            79:   AC_MSG_RESULT(no)
        !            80: ], [
        !            81:   AC_MSG_RESULT(yes)
        !            82:   AC_DEFINE(DLSYM_NEEDS_UNDERSCORE, 1, [Define if dlsym() requires a leading underscore in symbol names. ])
        !            83: ], [
        !            84:   AC_MSG_RESULT(no)
        !            85: ], [])
        !            86: ])
        !            87: 
        !            88: dnl This is required for QNX and may be some BSD derived systems
        !            89: AC_CHECK_TYPE( uint, unsigned int )
        !            90: AC_CHECK_TYPE( ulong, unsigned long )
        !            91: 
        !            92: dnl Check if int32_t and uint32_t are defined
        !            93: LIBZEND_CHECK_INT_TYPE(int32_t)
        !            94: LIBZEND_CHECK_INT_TYPE(uint32_t)
        !            95: 
        !            96: dnl Checks for library functions.
        !            97: AC_FUNC_VPRINTF
        !            98: AC_FUNC_MEMCMP
        !            99: AC_FUNC_ALLOCA
        !           100: AC_CHECK_FUNCS(memcpy strdup getpid kill strtod strtol finite fpclass sigsetjmp)
        !           101: AC_ZEND_BROKEN_SPRINTF
        !           102: 
        !           103: AC_CHECK_FUNCS(finite isfinite isinf isnan)
        !           104: 
        !           105: ZEND_FP_EXCEPT
        !           106: 
        !           107: ZEND_CHECK_FLOAT_PRECISION
        !           108: 
        !           109: dnl test whether double cast to long preserves least significant bits
        !           110: AC_MSG_CHECKING(whether double cast to long preserves least significant bits)
        !           111: 
        !           112: AC_TRY_RUN([
        !           113: #include <limits.h>
        !           114: 
        !           115: int main()
        !           116: {
        !           117:        if (sizeof(long) == 4) {
        !           118:                double d = (double) LONG_MIN * LONG_MIN + 2e9;
        !           119: 
        !           120:                if ((long) d == 2e9 && (long) -d == -2e9) {
        !           121:                        exit(0);
        !           122:                }
        !           123:        } else if (sizeof(long) == 8) {
        !           124:                double correct = 18e18 - ((double) LONG_MIN * -2); /* Subtract ULONG_MAX + 1 */
        !           125: 
        !           126:                if ((long) 18e18 == correct) { /* On 64-bit, only check between LONG_MAX and ULONG_MAX */
        !           127:                        exit(0);
        !           128:                }
        !           129:        }
        !           130:        exit(1);
        !           131: }
        !           132: ], [
        !           133:   AC_DEFINE([ZEND_DVAL_TO_LVAL_CAST_OK], 1, [Define if double cast to long preserves least significant bits])
        !           134:   AC_MSG_RESULT(yes)
        !           135: ], [
        !           136:   AC_MSG_RESULT(no)
        !           137: ], [
        !           138:   AC_MSG_RESULT(no)
        !           139: ])
        !           140:        
        !           141: ])
        !           142: 
        !           143: AC_DEFUN([LIBZEND_ENABLE_DEBUG],[
        !           144: 
        !           145: AC_ARG_ENABLE(debug,
        !           146: [  --enable-debug          Compile with debugging symbols],[
        !           147:   ZEND_DEBUG=$enableval
        !           148: ],[
        !           149:   ZEND_DEBUG=no
        !           150: ])  
        !           151: 
        !           152: ])
        !           153: 
        !           154: AC_DEFUN([LIBZEND_OTHER_CHECKS],[
        !           155: 
        !           156: AC_ARG_WITH(zend-vm,
        !           157: [  --with-zend-vm=TYPE     Set virtual machine dispatch method. Type is
        !           158:                           one of "CALL", "SWITCH" or "GOTO" [TYPE=CALL]],[
        !           159:   PHP_ZEND_VM=$withval
        !           160: ],[
        !           161:   PHP_ZEND_VM=CALL
        !           162: ])
        !           163: 
        !           164: AC_ARG_ENABLE(maintainer-zts,
        !           165: [  --enable-maintainer-zts Enable thread safety - for code maintainers only!!],[
        !           166:   ZEND_MAINTAINER_ZTS=$enableval
        !           167: ],[
        !           168:   ZEND_MAINTAINER_ZTS=no
        !           169: ])  
        !           170: 
        !           171: AC_ARG_ENABLE(inline-optimization,
        !           172: [  --disable-inline-optimization 
        !           173:                           If building zend_execute.lo fails, try this switch],[
        !           174:   ZEND_INLINE_OPTIMIZATION=$enableval
        !           175: ],[
        !           176:   ZEND_INLINE_OPTIMIZATION=yes
        !           177: ])
        !           178: 
        !           179: AC_ARG_ENABLE(zend-multibyte,
        !           180: [  --enable-zend-multibyte Compile with zend multibyte support], [
        !           181:   ZEND_MULTIBYTE=$enableval
        !           182: ],[
        !           183:   ZEND_MULTIBYTE=no
        !           184: ])
        !           185: 
        !           186: AC_MSG_CHECKING([virtual machine dispatch method])
        !           187: AC_MSG_RESULT($PHP_ZEND_VM)
        !           188: 
        !           189: AC_MSG_CHECKING(whether to enable thread-safety)
        !           190: AC_MSG_RESULT($ZEND_MAINTAINER_ZTS)
        !           191: 
        !           192: AC_MSG_CHECKING(whether to enable inline optimization for GCC)
        !           193: AC_MSG_RESULT($ZEND_INLINE_OPTIMIZATION)
        !           194: 
        !           195: AC_MSG_CHECKING(whether to enable Zend debugging)
        !           196: AC_MSG_RESULT($ZEND_DEBUG)
        !           197: 
        !           198: AC_MSG_CHECKING(whether to enable Zend multibyte)
        !           199: AC_MSG_RESULT($ZEND_MULTIBYTE)
        !           200: 
        !           201: case $PHP_ZEND_VM in
        !           202:   SWITCH)
        !           203:     AC_DEFINE(ZEND_VM_KIND,ZEND_VM_KIND_SWITCH,[virtual machine dispatch method])
        !           204:     ;;
        !           205:   GOTO)
        !           206:     AC_DEFINE(ZEND_VM_KIND,ZEND_VM_KIND_GOTO,[virtual machine dispatch method])
        !           207:     ;;
        !           208:   *)
        !           209:     PHP_ZEND_VM=CALL
        !           210:     AC_DEFINE(ZEND_VM_KIND,ZEND_VM_KIND_CALL,[virtual machine dispatch method])
        !           211:     ;;
        !           212: esac
        !           213: 
        !           214: if test "$ZEND_DEBUG" = "yes"; then
        !           215:   AC_DEFINE(ZEND_DEBUG,1,[ ])
        !           216:   echo " $CFLAGS" | grep ' -g' >/dev/null || DEBUG_CFLAGS="-g"
        !           217:   if test "$CFLAGS" = "-g -O2"; then
        !           218:        CFLAGS=-g
        !           219:   fi
        !           220:   test -n "$GCC" && DEBUG_CFLAGS="$DEBUG_CFLAGS -Wall"
        !           221:   test -n "$GCC" && test "$USE_MAINTAINER_MODE" = "yes" && \
        !           222:     DEBUG_CFLAGS="$DEBUG_CFLAGS -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations"
        !           223: else
        !           224:   AC_DEFINE(ZEND_DEBUG,0,[ ])
        !           225: fi
        !           226: 
        !           227: test -n "$DEBUG_CFLAGS" && CFLAGS="$CFLAGS $DEBUG_CFLAGS"
        !           228: 
        !           229: if test "$ZEND_MAINTAINER_ZTS" = "yes"; then
        !           230:   AC_DEFINE(ZTS,1,[ ])
        !           231:   CFLAGS="$CFLAGS -DZTS"
        !           232:   LIBZEND_CPLUSPLUS_CHECKS
        !           233: fi  
        !           234: 
        !           235: if test "$ZEND_MULTIBYTE" = "yes"; then
        !           236:   AC_DEFINE(ZEND_MULTIBYTE, 1, [ ])
        !           237: fi
        !           238: 
        !           239: changequote({,})
        !           240: if test -n "$GCC" && test "$ZEND_INLINE_OPTIMIZATION" != "yes"; then
        !           241:   INLINE_CFLAGS=`echo $ac_n "$CFLAGS $ac_c" | sed s/-O[0-9s]*//`
        !           242: else
        !           243:   INLINE_CFLAGS="$CFLAGS"
        !           244: fi
        !           245: changequote([,])
        !           246: 
        !           247: AC_C_INLINE
        !           248: 
        !           249: AC_SUBST(INLINE_CFLAGS)
        !           250: 
        !           251: AC_MSG_CHECKING(target system is Darwin)
        !           252: if echo "$target" | grep "darwin" > /dev/null; then
        !           253:   AC_DEFINE([DARWIN], 1, [Define if the target system is darwin])
        !           254:   AC_MSG_RESULT(yes)
        !           255: else
        !           256:   AC_MSG_RESULT(no)
        !           257: fi
        !           258: 
        !           259: dnl test and set the alignment define for ZEND_MM
        !           260: dnl this also does the logarithmic test for ZEND_MM.
        !           261: AC_MSG_CHECKING(for MM alignment and log values)
        !           262: 
        !           263: AC_TRY_RUN([
        !           264: #include <stdio.h>
        !           265: 
        !           266: typedef union _mm_align_test {
        !           267:   void *ptr;
        !           268:   double dbl;
        !           269:   long lng;
        !           270: } mm_align_test;
        !           271: 
        !           272: #if (defined (__GNUC__) && __GNUC__ >= 2)
        !           273: #define ZEND_MM_ALIGNMENT (__alignof__ (mm_align_test))
        !           274: #else
        !           275: #define ZEND_MM_ALIGNMENT (sizeof(mm_align_test))
        !           276: #endif
        !           277: 
        !           278: int main()
        !           279: {
        !           280:   int i = ZEND_MM_ALIGNMENT;
        !           281:   int zeros = 0;
        !           282:   FILE *fp;
        !           283: 
        !           284:   while (i & ~0x1) {
        !           285:     zeros++;
        !           286:     i = i >> 1;
        !           287:   }
        !           288: 
        !           289:   fp = fopen("conftest.zend", "w");
        !           290:   fprintf(fp, "%d %d\n", ZEND_MM_ALIGNMENT, zeros);  
        !           291:   fclose(fp);
        !           292: 
        !           293:   exit(0);
        !           294: }
        !           295: ], [
        !           296:   LIBZEND_MM_ALIGN=`cat conftest.zend | cut -d ' ' -f 1`
        !           297:   LIBZEND_MM_ALIGN_LOG2=`cat conftest.zend | cut -d ' ' -f 2`
        !           298:   AC_DEFINE_UNQUOTED(ZEND_MM_ALIGNMENT, $LIBZEND_MM_ALIGN, [ ])
        !           299:   AC_DEFINE_UNQUOTED(ZEND_MM_ALIGNMENT_LOG2, $LIBZEND_MM_ALIGN_LOG2, [ ]) 
        !           300: ], [], [
        !           301:   dnl cross-compile needs something here
        !           302:   LIBZEND_MM_ALIGN=8
        !           303: ])
        !           304: 
        !           305: AC_MSG_RESULT(done)
        !           306: 
        !           307: dnl test for memory allocation using mmap(MAP_ANON)
        !           308: AC_MSG_CHECKING(for memory allocation using mmap(MAP_ANON))
        !           309: 
        !           310: AC_TRY_RUN([
        !           311: #include <sys/types.h>
        !           312: #include <sys/stat.h>
        !           313: #include <fcntl.h>
        !           314: #include <sys/mman.h>
        !           315: #include <stdlib.h>
        !           316: #include <stdio.h>
        !           317: #ifndef MAP_ANON
        !           318: # ifdef MAP_ANONYMOUS
        !           319: #  define MAP_ANON MAP_ANONYMOUS
        !           320: # endif
        !           321: #endif
        !           322: #ifndef MREMAP_MAYMOVE
        !           323: # define MREMAP_MAYMOVE 0
        !           324: #endif
        !           325: #ifndef MAP_FAILED
        !           326: # define MAP_FAILED ((void*)-1)
        !           327: #endif
        !           328: 
        !           329: #define SEG_SIZE (256*1024)
        !           330: 
        !           331: int main()
        !           332: {
        !           333:        void *seg = mmap(NULL, SEG_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
        !           334:        if (seg == MAP_FAILED) {
        !           335:                return 1;
        !           336:        }
        !           337:        if (munmap(seg, SEG_SIZE) != 0) {
        !           338:                return 2;
        !           339:        }
        !           340:        return 0;
        !           341: }
        !           342: ], [
        !           343:   AC_DEFINE([HAVE_MEM_MMAP_ANON], 1, [Define if the target system has support for memory allocation using mmap(MAP_ANON)])
        !           344:   AC_MSG_RESULT(yes)
        !           345: ], [
        !           346:   AC_MSG_RESULT(no)
        !           347: ], [
        !           348:   dnl cross-compile needs something here
        !           349:   AC_MSG_RESULT(no)
        !           350: ])
        !           351: 
        !           352: dnl test for memory allocation using mmap("/dev/zero")
        !           353: AC_MSG_CHECKING(for memory allocation using mmap("/dev/zero"))
        !           354: 
        !           355: AC_TRY_RUN([
        !           356: #include <sys/types.h>
        !           357: #include <sys/stat.h>
        !           358: #include <fcntl.h>
        !           359: #include <sys/mman.h>
        !           360: #include <stdlib.h>
        !           361: #include <stdio.h>
        !           362: #ifndef MAP_ANON
        !           363: # ifdef MAP_ANONYMOUS
        !           364: #  define MAP_ANON MAP_ANONYMOUS
        !           365: # endif
        !           366: #endif
        !           367: #ifndef MREMAP_MAYMOVE
        !           368: # define MREMAP_MAYMOVE 0
        !           369: #endif
        !           370: #ifndef MAP_FAILED
        !           371: # define MAP_FAILED ((void*)-1)
        !           372: #endif
        !           373: 
        !           374: #define SEG_SIZE (256*1024)
        !           375: 
        !           376: int main()
        !           377: {
        !           378:        int fd;
        !           379:        void *seg;
        !           380: 
        !           381:        fd = open("/dev/zero", O_RDWR, S_IRUSR | S_IWUSR);
        !           382:        if (fd < 0) {
        !           383:                return 1;
        !           384:        }
        !           385:        seg = mmap(NULL, SEG_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
        !           386:        if (seg == MAP_FAILED) {
        !           387:                return 2;
        !           388:        }
        !           389:        if (munmap(seg, SEG_SIZE) != 0) {
        !           390:                return 3;
        !           391:        }
        !           392:        if (close(fd) != 0) {
        !           393:                return 4;
        !           394:        }
        !           395:        return 0;
        !           396: }
        !           397: ], [
        !           398:   AC_DEFINE([HAVE_MEM_MMAP_ZERO], 1, [Define if the target system has support for memory allocation using mmap("/dev/zero")])
        !           399:   AC_MSG_RESULT(yes)
        !           400: ], [
        !           401:   AC_MSG_RESULT(no)
        !           402: ], [
        !           403:   dnl cross-compile needs something here
        !           404:   AC_MSG_RESULT(no)
        !           405: ])
        !           406: 
        !           407: AC_CHECK_FUNCS(mremap)
        !           408: 
        !           409: ])
        !           410: 
        !           411: 
        !           412: AC_DEFUN([LIBZEND_CPLUSPLUS_CHECKS],[
        !           413: 
        !           414: ])
        !           415: 
        !           416: AC_MSG_CHECKING(whether /dev/urandom exists) 
        !           417: if test -r "/dev/urandom" && test -c "/dev/urandom"; then 
        !           418:   AC_DEFINE([HAVE_DEV_URANDOM], 1, [Define if the target system has /dev/urandom device])
        !           419:   AC_MSG_RESULT(yes) 
        !           420: else 
        !           421:   AC_MSG_RESULT(no) 
        !           422: fi 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>