1PHP_ARG_ENABLE(grpc, whether to enable grpc support, 2[ --enable-grpc Enable grpc support]) 3 4PHP_ARG_ENABLE(coverage, whether to include code coverage symbols, 5[ --enable-coverage Enable coverage support], no, no) 6 7PHP_ARG_ENABLE(tests, whether to compile helper methods for tests, 8[ --enable-tests Enable tests methods], no, no) 9 10dnl Check whether to enable tests 11if test "$PHP_TESTS" != "no"; then 12 CPPFLAGS="$CPPFLAGS -DGRPC_PHP_DEBUG" 13fi 14 15if test "$PHP_GRPC" != "no"; then 16 dnl Write more examples of tests here... 17 18 dnl # --with-grpc -> check with-path 19 SEARCH_PATH="/usr/local /usr" # you might want to change this 20 SEARCH_FOR="include/grpc/grpc.h" # you most likely want to change this 21 if test -r $PHP_GRPC/$SEARCH_FOR; then # path given as parameter 22 GRPC_DIR=$PHP_GRPC 23 else # search default path list 24 AC_MSG_CHECKING([for grpc files in default path]) 25 for i in $SEARCH_PATH ; do 26 if test -r $i/$SEARCH_FOR; then 27 GRPC_DIR=$i 28 AC_MSG_RESULT(found in $i) 29 fi 30 done 31 fi 32 if test -z "$GRPC_DIR"; then 33 AC_MSG_RESULT([not found]) 34 AC_MSG_ERROR([Please reinstall the grpc distribution]) 35 fi 36 37 dnl # --with-grpc -> add include path 38 PHP_ADD_INCLUDE($GRPC_DIR/include) 39 40 LIBS="-lpthread $LIBS" 41 42 dnl PHP_ADD_LIBRARY(pthread,,GRPC_SHARED_LIBADD) 43 GRPC_SHARED_LIBADD="-lpthread $GRPC_SHARED_LIBADD" 44 PHP_ADD_LIBRARY(pthread) 45 46 PHP_ADD_LIBRARY(dl,,GRPC_SHARED_LIBADD) 47 PHP_ADD_LIBRARY(dl) 48 49 case $host in 50 *darwin*) ;; 51 *) 52 PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD) 53 PHP_ADD_LIBRARY(rt) 54 ;; 55 esac 56 57 GRPC_LIBDIR=$GRPC_DIR/${GRPC_LIB_SUBDIR-lib} 58 59 PHP_ADD_LIBPATH($GRPC_LIBDIR) 60 61 PHP_CHECK_LIBRARY(gpr,gpr_now, 62 [ 63 PHP_ADD_LIBRARY(gpr,,GRPC_SHARED_LIBADD) 64 PHP_ADD_LIBRARY(gpr) 65 AC_DEFINE(HAVE_GPRLIB,1,[ ]) 66 ],[ 67 AC_MSG_ERROR([wrong gpr lib version or lib not found]) 68 ],[ 69 -L$GRPC_LIBDIR 70 ]) 71 72 PHP_CHECK_LIBRARY(grpc,grpc_channel_destroy, 73 [ 74 PHP_ADD_LIBRARY(grpc,,GRPC_SHARED_LIBADD) 75 dnl PHP_ADD_LIBRARY_WITH_PATH(grpc, $GRPC_DIR/lib, GRPC_SHARED_LIBADD) 76 AC_DEFINE(HAVE_GRPCLIB,1,[ ]) 77 ],[ 78 AC_MSG_ERROR([wrong grpc lib version or lib not found]) 79 ],[ 80 -L$GRPC_LIBDIR 81 ]) 82 83 PHP_SUBST(GRPC_SHARED_LIBADD) 84 85 PHP_NEW_EXTENSION(grpc, byte_buffer.c call.c call_credentials.c channel.c \ 86 channel_credentials.c completion_queue.c timeval.c server.c \ 87 server_credentials.c php_grpc.c, $ext_shared, , -Wall -Werror -std=c11) 88fi 89 90if test "$PHP_COVERAGE" = "yes"; then 91 92 if test "$GCC" != "yes"; then 93 AC_MSG_ERROR([GCC is required for --enable-coverage]) 94 fi 95 96 dnl Check if ccache is being used 97 case `$php_shtool path $CC` in 98 *ccache*[)] gcc_ccache=yes;; 99 *[)] gcc_ccache=no;; 100 esac 101 102 if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then 103 AC_MSG_ERROR([ccache must be disabled when --enable-coverage option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.]) 104 fi 105 106 lcov_version_list="1.5 1.6 1.7 1.9 1.10 1.11" 107 108 AC_CHECK_PROG(LCOV, lcov, lcov) 109 AC_CHECK_PROG(GENHTML, genhtml, genhtml) 110 PHP_SUBST(LCOV) 111 PHP_SUBST(GENHTML) 112 113 if test "$LCOV"; then 114 AC_CACHE_CHECK([for lcov version], php_cv_lcov_version, [ 115 php_cv_lcov_version=invalid 116 lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'` #' 117 for lcov_check_version in $lcov_version_list; do 118 if test "$lcov_version" = "$lcov_check_version"; then 119 php_cv_lcov_version="$lcov_check_version (ok)" 120 fi 121 done 122 ]) 123 else 124 lcov_msg="To enable code coverage reporting you must have one of the following LCOV versions installed: $lcov_version_list" 125 AC_MSG_ERROR([$lcov_msg]) 126 fi 127 128 case $php_cv_lcov_version in 129 ""|invalid[)] 130 lcov_msg="You must have one of the following versions of LCOV: $lcov_version_list (found: $lcov_version)." 131 AC_MSG_ERROR([$lcov_msg]) 132 LCOV="exit 0;" 133 ;; 134 esac 135 136 if test -z "$GENHTML"; then 137 AC_MSG_ERROR([Could not find genhtml from the LCOV package]) 138 fi 139 140 PHP_ADD_MAKEFILE_FRAGMENT 141 142 dnl Remove all optimization flags from CFLAGS 143 changequote({,}) 144 CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'` 145 CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9s]*//g'` 146 changequote([,]) 147 148 dnl Add the special gcc flags 149 CFLAGS="$CFLAGS -O0 -ggdb -fprofile-arcs -ftest-coverage" 150 CXXFLAGS="$CXXFLAGS -ggdb -O0 -fprofile-arcs -ftest-coverage" 151fi 152