1dnl config.m4 for the solr extension 2 3dnl Configuring the CURL external library 4dnl This folder is the grand-parent folder of easy.h 5PHP_ARG_WITH(curl, for cURL support, [ --with-curl[=DIR] SOLR : libcurl install prefix]) 6 7if test -r $PHP_CURL/include/curl/easy.h; then 8 CURL_DIR=$PHP_CURL 9 AC_MSG_RESULT(curl headers found in $PHP_CURL) 10else 11 AC_MSG_CHECKING(for cURL in default path) 12 for i in /usr/local /usr; do 13 if test -r $i/include/curl/easy.h; then 14 CURL_DIR=$i 15 AC_MSG_RESULT(found in $i) 16 break 17 fi 18 done 19fi 20 21if test -z "$CURL_DIR"; then 22 AC_MSG_RESULT(not found) 23 AC_MSG_ERROR([Please reinstall the libcurl distribution - 24 easy.h should be in <curl-dir>/include/curl/]) 25fi 26 27CURL_CONFIG="curl-config" 28AC_MSG_CHECKING(for cURL 7.15.0 or greater) 29 30if ${CURL_DIR}/bin/curl-config --libs > /dev/null 2>&1; then 31 CURL_CONFIG=${CURL_DIR}/bin/curl-config 32else 33 if ${CURL_DIR}/curl-config --libs > /dev/null 2>&1; then 34 CURL_CONFIG=${CURL_DIR}/curl-config 35 fi 36fi 37 38curl_version_full=`$CURL_CONFIG --version` 39curl_version=`echo ${curl_version_full} | sed -e 's/libcurl //' | $AWK 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'` 40 41if test "$curl_version" -ge 7015000; then 42 AC_MSG_RESULT($curl_version_full) 43 CURL_LIBS=`$CURL_CONFIG --libs` 44else 45 AC_MSG_ERROR([The Solr extension does not support libcurl libraries < 7.15.0. Please update your libraries]) 46fi 47 48PHP_ARG_ENABLE(solr, whether to enable the Solr extension, 49[ --enable-solr Enable solr support]) 50 51PHP_ARG_ENABLE(solr-debug, whether to compile with solr in verbose mode, 52[ --enable-solr-debug Compile with solr in verbose mode], no, no) 53 54dnl Configuring the LibXML external Library 55if test -z "$PHP_LIBXML_DIR"; then 56 PHP_ARG_WITH(libxml-dir, libxml2 install dir, 57 [ --with-libxml-dir=[DIR] SOLR : libxml2 install prefix], no, no) 58fi 59 60PHP_ARG_ENABLE(coverage, whether to enable code coverage, 61 [ --enable-coverage Enable developer code coverage information],, no) 62 63dnl Setting up the apache Solr extension 64if test "$PHP_SOLR" != "no"; then 65 66 if test "$PHP_CURL" = "no"; then 67 AC_MSG_ERROR([Solr extension requires curl extension, add --with-curl]) 68 fi 69 70 PHP_CHECK_LIBRARY(curl,curl_easy_perform, 71 [ 72 AC_DEFINE(HAVE_CURL,1,[ ]) 73 ],[ 74 AC_MSG_ERROR(There is something wrong. Please check config.log for more information.) 75 ],[ 76 $CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR 77 ]) 78 79 PHP_ADD_INCLUDE($CURL_DIR/include) 80 PHP_EVAL_LIBLINE($CURL_LIBS, SOLR_SHARED_LIBADD) 81 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/lib, SOLR_SHARED_LIBADD) 82 83 if test "$PHP_LIBXML" = "no"; then 84 AC_MSG_ERROR([Solr extension requires LIBXML extension, add --enable-libxml]) 85 fi 86 87 AC_MSG_CHECKING(for JSON) 88 if test -f "$phpincludedir/ext/json/php_json.h" || test "$HAVE_JSON" != "no"; then 89 AC_DEFINE(HAVE_JSON, 1, [JSON support]) 90 AC_MSG_RESULT(Yes) 91 else 92 AC_MSG_ERROR([Solr extension requires json or jsonc support]) 93 fi 94 95 PHP_SETUP_LIBXML(SOLR_SHARED_LIBADD, [ 96 AC_DEFINE(HAVE_SOLR, 1,[Setting the value of HAVE_SOLR to 1 ]) 97 98 if test "$PHP_SOLR_DEBUG" != "no"; then 99 AC_DEFINE(SOLR_DEBUG, 1, [Setting the value of SOLR_DEBUG to 1 ]) 100 else 101 AC_DEFINE(SOLR_DEBUG_OFF, 1, [Setting the value of SOLR_DEBUG_OFF to 1 ]) 102 fi 103 104 if test "$PHP_COVERAGE" = "yes"; then 105 PHP_CHECK_GCC_ARG(-fprofile-arcs, COVERAGE_CFLAGS="$COVERAGE_CFLAGS -fprofile-arcs") 106 PHP_CHECK_GCC_ARG(-ftest-coverage, COVERAGE_CFLAGS="$COVERAGE_CFLAGS -ftest-coverage") 107 EXTRA_LDFLAGS="$COVERAGE_CFLAGS" 108 fi 109 110 111 export OLD_CPPFLAGS="$CPPFLAGS" 112 export CPPFLAGS="$CPPFLAGS $INCLUDES" 113 114 AC_MSG_CHECKING(PHP version) 115 116 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 117 #include <php_version.h> 118 ]], [[ 119#if PHP_MAJOR_VERSION > 5 120#error PHP > 5 121#endif 122 ]])],[ 123 subdir=src/php5 124 AC_MSG_RESULT([PHP 5]) 125 ],[ 126 subdir=src/php7 127 AC_MSG_RESULT([PHP 7]) 128 ]) 129 130 131 PHP_SOLR_SRC_FILES="$subdir/php_solr.c \ 132 $subdir/php_solr_object.c \ 133 $subdir/php_solr_document.c \ 134 $subdir/php_solr_input_document.c \ 135 $subdir/php_solr_client.c \ 136 $subdir/php_solr_params.c \ 137 $subdir/php_solr_query.c \ 138 $subdir/php_solr_response.c \ 139 $subdir/php_solr_exception.c \ 140 $subdir/php_solr_utils.c \ 141 $subdir/php_solr_dismax_query.c \ 142 $subdir/php_solr_collapse_function.c \ 143 $subdir/php_solr_extract.c \ 144 $subdir/solr_string.c \ 145 $subdir/solr_functions_document.c \ 146 $subdir/solr_functions_client.c \ 147 $subdir/solr_functions_helpers.c \ 148 $subdir/solr_functions_params.c \ 149 $subdir/solr_functions_response.c \ 150 $subdir/solr_functions_debug.c" 151 152 PHP_NEW_EXTENSION(solr, $PHP_SOLR_SRC_FILES, 153 $ext_shared,, [$COVERAGE_CFLAGS]) 154 PHP_ADD_BUILD_DIR($abs_builddir/$subdir, 1) 155 PHP_SUBST(SOLR_SHARED_LIBADD) 156 ], [ 157 AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.]) 158 ]) 159fi 160