acinclude.m4 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. dnl ---------------------------------------------------------------------------
  2. dnl Macro: AC_CHECK_MYSQL
  3. dnl Check for custom MySQL paths in --with-mysql-* options.
  4. dnl If some paths are missing, check if mysql_config exists.
  5. dnl ---------------------------------------------------------------------------
  6. AC_DEFUN([AC_CHECK_MYSQL],[
  7. mysqlconfig_locations="mysql_config /usr/bin/mysql_config /usr/local/bin/mysql_config /usr/local/mysql/bin/mysql_config /opt/mysql/bin/mysql_config /usr/pkg/bin/mysql_config"
  8. user_mysql_includes=
  9. user_mysql_libs=
  10. # check explicit MySQL root for mysql_config, include, lib
  11. if test [ x$1 != xyes -a x$1 != xno ]
  12. then
  13. mysqlroot=`echo $1 | sed -e 's+/$++'`
  14. if test [ -x "$mysqlroot/bin/mysql_config" ]
  15. then
  16. # if there's mysql_config, that's the best route
  17. mysqlconfig_locations="$mysqlroot/bin/mysql_config"
  18. elif test [ -d "$mysqlroot/include" -a -d "$mysqlroot/lib" ]
  19. then
  20. # explicit root; do not check well-known paths
  21. mysqlconfig_locations=
  22. # includes
  23. if test [ -d "$mysqlroot/include/mysql" ]
  24. then
  25. user_mysql_includes="$mysqlroot/include/mysql"
  26. else
  27. user_mysql_includes="$mysqlroot/include"
  28. fi
  29. # libs
  30. if test [ -d "$mysqlroot/lib/mysql" ]
  31. then
  32. user_mysql_libs="$mysqlroot/lib/mysql"
  33. else
  34. user_mysql_libs="$mysqlroot/lib"
  35. fi
  36. else
  37. AC_MSG_ERROR([invalid MySQL root directory '$mysqlroot'; neither bin/mysql_config, nor include/ and lib/ were found there])
  38. fi
  39. fi
  40. # try running mysql_config
  41. AC_MSG_CHECKING([for mysql_config])
  42. for mysqlconfig in $mysqlconfig_locations
  43. do
  44. if test [ -n "$mysqlconfig" ]
  45. then
  46. MYSQL_CFLAGS=`${mysqlconfig} --cflags 2>/dev/null`
  47. MYSQL_LIBS=`${mysqlconfig} --libs 2>/dev/null`
  48. if test [ $? -eq 0 ]
  49. then
  50. MYSQL_PKGLIBDIR=`echo $MYSQL_LIBS | sed -e 's/-[[^L]][[^ ]]*//g;s/\s*-L//g;'`
  51. AC_MSG_RESULT([$mysqlconfig])
  52. mysqlconfig=
  53. break
  54. else
  55. MYSQL_CFLAGS=
  56. MYSQL_LIBS=
  57. MYSQL_PKGLIBDIR=
  58. fi
  59. fi
  60. done
  61. if test [ -n "$mysqlconfig" ]
  62. then
  63. mysqlconfig_used=
  64. AC_MSG_RESULT([not found])
  65. else
  66. mysqlconfig_used=yes
  67. fi
  68. # if there's nothing from mysql_config, check well-known include paths
  69. # explicit overrides will be applied later
  70. if test [ -z "$MYSQL_CFLAGS" ]
  71. then
  72. for CANDIDATE in "$user_mysql_includes" "/usr/local/mysql/include" "/usr/local/mysql/include/mysql" \
  73. "/usr/include/mysql"
  74. do
  75. if test [ -n "$CANDIDATE" -a -r "$CANDIDATE/mysql.h" ]
  76. then
  77. MYSQL_CFLAGS="-I$CANDIDATE"
  78. break
  79. fi
  80. done
  81. fi
  82. # if there's nothing from mysql_config, check well-known library paths
  83. # explicit overrides will be applied later
  84. if test [ -z "$MYSQL_LIBS" ]
  85. then
  86. for CANDIDATE in "$user_mysql_libs" "/usr/lib64/mysql" \
  87. "/usr/local/mysql/lib/mysql" "/usr/local/mysql/lib" \
  88. "/usr/local/lib/mysql" "/usr/lib/mysql" \
  89. "/opt/mysql/lib/mysql" "/usr/pkg/lib/mysql"
  90. do
  91. if test [ -n "$CANDIDATE" -a -d "$CANDIDATE" ]
  92. then
  93. MYSQL_LIBS="-L$CANDIDATE -lmysqlclient -lz"
  94. MYSQL_PKGLIBDIR="$CANDIDATE"
  95. break
  96. fi
  97. done
  98. fi
  99. # apply explicit include path overrides
  100. AC_ARG_WITH([mysql-includes],
  101. AC_HELP_STRING([--with-mysql-includes], [path to MySQL header files]),
  102. [ac_cv_mysql_includes=$withval])
  103. if test [ -n "$ac_cv_mysql_includes" ]
  104. then
  105. MYSQL_CFLAGS="-I$ac_cv_mysql_includes"
  106. fi
  107. # apply explicit lib path overrides
  108. AC_ARG_WITH([mysql-libs],
  109. AC_HELP_STRING([--with-mysql-libs], [path to MySQL libraries]),
  110. [ac_cv_mysql_libs=$withval])
  111. if test [ -n "$ac_cv_mysql_libs" ]
  112. then
  113. # Trim trailing '.libs' if user passed it in --with-mysql-libs option
  114. ac_cv_mysql_libs=`echo ${ac_cv_mysql_libs} | sed -e 's/.libs$//' \
  115. -e 's+.libs/$++'`
  116. MYSQL_LIBS="-L$ac_cv_mysql_libs -lmysqlclient -lz"
  117. MYSQL_PKGLIBDIR="$ac_cv_mysql_libs"
  118. fi
  119. # if we got options from mysqlconfig try to actually use them
  120. if test [ -n "$mysqlconfig_used" -a -n "$MYSQL_CFLAGS" -a -n "$MYSQL_LIBS" ]
  121. then
  122. _CFLAGS=$CFLAGS
  123. _LIBS=$LIBS
  124. CFLAGS="$CFLAGS $MYSQL_CFLAGS"
  125. LIBS="$LIBS $MYSQL_LIBS"
  126. AC_CHECK_FUNC(mysql_real_connect,[],
  127. [
  128. # if mysql binary was built using a different compiler and we
  129. # got options from mysql_config some of them might not work
  130. # with compiler we will be using
  131. # throw away everything that isn't one of -D -L -I -l and retry
  132. MYSQL_CFLAGS=`echo $MYSQL_CFLAGS | sed -e 's/-[[^DLIl]][[^ ]]*//g'`
  133. MYSQL_LIBS=`echo $MYSQL_LIBS | sed -e 's/-[[^DLIl]][[^ ]]*//g'`
  134. CFLAGS="$_CFLAGS $MYSQL_CFLAGS"
  135. LIBS="$_LIBS $MYSQL_LIBS"
  136. unset ac_cv_func_mysql_real_connect
  137. AC_CHECK_FUNC(mysql_real_connect,[],
  138. [
  139. # ... that didn't help
  140. # clear flags, the code below will complain
  141. MYSQL_CFLAGS=
  142. MYSQL_LIBS=
  143. MYSQL_PKGLIBDIR=
  144. ])
  145. ])
  146. CFLAGS=$_CFLAGS
  147. LIBS=$_LIBS
  148. fi
  149. # now that we did all we could, perform final checks
  150. AC_MSG_CHECKING([MySQL include files])
  151. if test [ -z "$MYSQL_CFLAGS" ]
  152. then
  153. AC_MSG_ERROR([missing include files.
  154. ******************************************************************************
  155. ERROR: cannot find MySQL include files.
  156. Check that you do have MySQL include files installed.
  157. The package name is typically 'mysql-devel'.
  158. If include files are installed on your system, but you are still getting
  159. this message, you should do one of the following:
  160. 1) either specify includes location explicitly, using --with-mysql-includes;
  161. 2) or specify MySQL installation root location explicitly, using --with-mysql;
  162. 3) or make sure that the path to 'mysql_config' program is listed in
  163. your PATH environment variable.
  164. To disable MySQL support, use --without-mysql option.
  165. ******************************************************************************
  166. ])
  167. else
  168. AC_MSG_RESULT([$MYSQL_CFLAGS])
  169. fi
  170. AC_MSG_CHECKING([MySQL libraries])
  171. if test [ -z "$MYSQL_LIBS" ]
  172. then
  173. AC_MSG_ERROR([missing libraries.
  174. ******************************************************************************
  175. ERROR: cannot find MySQL libraries.
  176. Check that you do have MySQL libraries installed.
  177. The package name is typically 'mysql-devel'.
  178. If libraries are installed on your system, but you are still getting
  179. this message, you should do one of the following:
  180. 1) either specify libraries location explicitly, using --with-mysql-libs;
  181. 2) or specify MySQL installation root location explicitly, using --with-mysql;
  182. 3) or make sure that the path to 'mysql_config' program is listed in
  183. your PATH environment variable.
  184. To disable MySQL support, use --without-mysql option.
  185. ******************************************************************************
  186. ])
  187. else
  188. AC_MSG_RESULT([$MYSQL_LIBS])
  189. fi
  190. ])
  191. dnl ---------------------------------------------------------------------------
  192. dnl Macro: AC_CHECK_PGSQL
  193. dnl First check for custom PostgreSQL paths in --with-pgsql-* options.
  194. dnl If some paths are missing, check if pg_config exists.
  195. dnl ---------------------------------------------------------------------------
  196. AC_DEFUN([AC_CHECK_PGSQL],[
  197. # Check for custom includes path
  198. if test [ -z "$ac_cv_pgsql_includes" ]
  199. then
  200. AC_ARG_WITH([pgsql-includes],
  201. AC_HELP_STRING([--with-pgsql-includes], [path to PostgreSQL header files]),
  202. [ac_cv_pgsql_includes=$withval])
  203. fi
  204. if test [ -n "$ac_cv_pgsql_includes" ]
  205. then
  206. AC_CACHE_CHECK([PostgreSQL includes], [ac_cv_pgsql_includes], [ac_cv_pgsql_includes=""])
  207. PGSQL_CFLAGS="-I$ac_cv_pgsql_includes"
  208. fi
  209. # Check for custom library path
  210. if test [ -z "$ac_cv_pgsql_libs" ]
  211. then
  212. AC_ARG_WITH([pgsql-libs],
  213. AC_HELP_STRING([--with-pgsql-libs], [path to PostgreSQL libraries]),
  214. [ac_cv_pgsql_libs=$withval])
  215. fi
  216. if test [ -n "$ac_cv_pgsql_libs" ]
  217. then
  218. AC_CACHE_CHECK([PostgreSQL libraries], [ac_cv_pgsql_libs], [ac_cv_pgsql_libs=""])
  219. PGSQL_PKGLIBDIR="$ac_cv_pgsql_libs"
  220. PGSQL_LIBS="-L$PGSQL_PKGLIBDIR -lpq"
  221. fi
  222. # If some path is missing, try to autodetermine with pgsql_config
  223. if test [ -z "$ac_cv_pgsql_includes" -o -z "$ac_cv_pgsql_libs" ]
  224. then
  225. if test [ -z "$pgconfig" ]
  226. then
  227. AC_PATH_PROG(pgconfig,pg_config)
  228. fi
  229. if test [ -z "$pgconfig" ]
  230. then
  231. AC_MSG_ERROR([pg_config executable not found
  232. ********************************************************************************
  233. ERROR: cannot find PostgreSQL libraries. If you want to compile with PosgregSQL support,
  234. you must either specify file locations explicitly using
  235. --with-pgsql-includes and --with-pgsql-libs options, or make sure path to
  236. pg_config is listed in your PATH environment variable. If you want to
  237. disable PostgreSQL support, use --without-pgsql option.
  238. ********************************************************************************
  239. ])
  240. else
  241. if test [ -z "$ac_cv_pgsql_includes" ]
  242. then
  243. AC_MSG_CHECKING(PostgreSQL C flags)
  244. PGSQL_CFLAGS="-I`${pgconfig} --includedir`"
  245. AC_MSG_RESULT($PGSQL_CFLAGS)
  246. fi
  247. if test [ -z "$ac_cv_pgsql_libs" ]
  248. then
  249. AC_MSG_CHECKING(PostgreSQL linker flags)
  250. PGSQL_PKGLIBDIR=`${pgconfig} --libdir`
  251. PGSQL_LIBS="-L$PGSQL_PKGLIBDIR -lpq"
  252. AC_MSG_RESULT($PGSQL_LIBS)
  253. fi
  254. fi
  255. fi
  256. ])
  257. dnl ---------------------------------------------------------------------------
  258. dnl Macro: AC_CHECK_LIBSTEMMER
  259. dnl Check the libstemmer first in custom include path in --with-libstemmer=*
  260. dnl If not given, try to guess common shared libs, and finally fall back into
  261. dnl old sphinx way which invokes statically linked lib built from the sources
  262. dnl ---------------------------------------------------------------------------
  263. AC_DEFUN([AC_CHECK_LIBSTEMMER],[
  264. # cflags and libs
  265. LIBSTEMMER_CFLAGS=
  266. LIBSTEMMER_LIBS=
  267. # First check, if we have the sources of internal libstemmer.
  268. # If so, it has the max. priority over any other possibilities
  269. if test -d ./libstemmer_c && test -f libstemmer_c/include/libstemmer.h; then
  270. ac_cv_use_internal_libstemmer=yes
  271. LIBSTEMMER_LIBS="\$(top_srcdir)/libstemmer_c/libstemmer.a"
  272. LIBSTEMMER_CFLAGS="-I\$(top_srcdir)/libstemmer_c/include"
  273. else
  274. # possible includedir paths
  275. includedirs="/usr/include /usr/include/libstemmer /usr/include/libstemmer_c"
  276. # possible libdirs -- 64bit first in case of multiarch environments
  277. libdirs="/usr/lib/x86_64-linux-gnu /usr/lib64 /usr/local/lib64 /usr/lib/i386-linux-gnu /usr/lib /usr/local/lib"
  278. # possible libnames -- shared one first, then static one
  279. libnames="stemmer stemmer_c"
  280. # was (include) path explicitely given?
  281. if test [ -n "$ac_cv_use_libstemmer" -a x$ac_cv_use_libstemmer != xyes]; then
  282. includedirs=$ac_cv_use_libstemmer
  283. fi
  284. # try to find header files
  285. for includedir in $includedirs
  286. do
  287. if test [ -f $includedir/libstemmer.h ]; then
  288. LIBSTEMMER_CFLAGS="-I$includedir"
  289. break
  290. fi
  291. done
  292. # try to find shared library
  293. for libname in $libnames
  294. do
  295. for libdir in $libdirs
  296. do
  297. if test [ -f $libdir/lib${libname}.so ]; then
  298. LIBSTEMMER_LIBS="-L$libdir -l$libname"
  299. break 2
  300. fi
  301. done
  302. done
  303. # if not found, check static libs
  304. if test [ -z "$LIBSTEMMER_LIBS" ]; then
  305. for libname in $libnames
  306. do
  307. for libdir in $libdirs
  308. do
  309. if test [ -f $libdir/lib${libname}.a ]; then
  310. LIBSTEMMER_LIBS="$libdir/lib${libname}.a"
  311. break 2
  312. fi
  313. done
  314. done
  315. fi
  316. fi
  317. # Now we either have libstemmer, or not
  318. if test [ -z "$LIBSTEMMER_LIBS" ]; then
  319. AC_MSG_ERROR([missing libstemmer sources from libstemmer_c.
  320. Please download the C version of libstemmer library from
  321. http://snowball.tartarus.org/ and extract its sources over libstemmer_c/
  322. subdirectory in order to build Sphinx with libstemmer support. Or
  323. install the package named like 'libstemmer-dev' using your favorite
  324. package manager.
  325. ])
  326. fi
  327. ])
  328. dnl ---------------------------------------------------------------------------
  329. dnl Macro: AC_CHECK_RE2
  330. dnl Check user-specified path in --with-re2=*, then check ./libre2 path.
  331. dnl Finally check for installed libraries and headers if present.
  332. dnl Also libraries and headers paths can be given using --with-re2-libs and
  333. dnl --with-re2-includes
  334. dnl ---------------------------------------------------------------------------
  335. AC_DEFUN([AC_CHECK_RE2],[
  336. # Includes and libraries
  337. LIBRE2_CFLAGS=
  338. LIBRE2_LIBS=
  339. # First check if include path was explicitly given.
  340. # If so, it has the maximum priority over any other possibilities
  341. if test [ -n "$ac_cv_use_re2" -a x$ac_cv_use_re2 != xyes]; then
  342. re2include=$ac_cv_use_re2
  343. if test [ -f $re2include/re2/re2.h ]; then
  344. LIBRE2_CFLAGS="-I$re2include"
  345. LIBRE2_LIBS="$re2include/obj/libre2.a"
  346. # Use re2 Makefile if present
  347. if test [ -f $re2include/Makefile ]; then
  348. LIBRE2_PATH="$re2include"
  349. fi
  350. fi
  351. else
  352. # Check if there any sources in ./libre2 path
  353. if test -d ./libre2 && test -f ./libre2/re2/re2.h; then
  354. ac_cv_use_re2=yes
  355. LIBRE2_LIBS="\$(top_srcdir)/libre2/obj/libre2.a"
  356. LIBRE2_CFLAGS="-I\$(top_srcdir)/libre2"
  357. LIBRE2_PATH="libre2"
  358. else
  359. # Possible include paths
  360. re2includedirs="/usr/include /usr/include/re2"
  361. # Possible libraries paths
  362. re2libdirs="/usr/lib/x86_64-linux-gnu /usr/lib64 /usr/local/lib64 /usr/lib/i386-linux-gnu /usr/lib /usr/local/lib"
  363. # Trying to find installed header files
  364. for re2includedir in $re2includedirs
  365. do
  366. if test [ -f $re2includedir/re2/re2.h ]; then
  367. LIBRE2_CFLAGS="-I$re2includedir"
  368. break
  369. fi
  370. done
  371. # Trying to find installed libraries
  372. for re2libdir in $re2libdirs
  373. do
  374. if test [ -f $re2libdir/libre2.a ]; then
  375. LIBRE2_LIBS="$re2libdir/libre2.a"
  376. break 2
  377. fi
  378. done
  379. fi
  380. fi
  381. # Apply explicit include path overrides
  382. if test x$ac_cv_re2_includes != xno; then
  383. if test [ -f $ac_cv_re2_includes/re2/re2.h ]; then
  384. LIBRE2_CFLAGS="-I$ac_cv_re2_includes"
  385. else
  386. AC_MSG_ERROR([missing re2 headers])
  387. fi
  388. fi
  389. # Apply explicit lib path overrides
  390. if test x$ac_cv_re2_libs != xno; then
  391. if test [ -f "$ac_cv_re2_libs" ]; then
  392. LIBRE2_LIBS="$ac_cv_re2_libs"
  393. else
  394. AC_MSG_ERROR([missing re2 library libre2.a])
  395. fi
  396. fi
  397. # Now we either have re2, or not
  398. if test [ -z "$LIBRE2_LIBS" ]; then
  399. AC_MSG_ERROR([missing re2 sources])
  400. fi
  401. ])
  402. dnl ---------------------------------------------------------------------------
  403. dnl Macro: SPHINX_CONFIGURE_PART
  404. dnl
  405. dnl Tells what stage is ./configure running now, nicely formatted
  406. dnl ---------------------------------------------------------------------------
  407. dnl SPHINX_CONFIGURE_PART(MESSAGE)
  408. AC_DEFUN([SPHINX_CONFIGURE_PART],[
  409. AC_MSG_RESULT()
  410. AC_MSG_RESULT([$1])
  411. TMP=`echo $1 | sed -e sX.X-Xg`
  412. AC_MSG_RESULT([$TMP])
  413. AC_MSG_RESULT()
  414. ])
  415. dnl ---------------------------------------------------------------------------
  416. dnl Macro: SPHINX_CHECK_DEFINE
  417. dnl
  418. dnl Checks if this symbol is defined in that header file
  419. dnl ---------------------------------------------------------------------------
  420. AC_DEFUN([SPHINX_CHECK_DEFINE],[
  421. AC_CACHE_CHECK([for $1 in $2],ac_cv_define_$1,[
  422. AC_EGREP_CPP(YES_IS_DEFINED, [
  423. #include <$2>
  424. #ifdef $1
  425. YES_IS_DEFINED
  426. #endif
  427. ], ac_cv_define_$1=yes, ac_cv_define_$1=no)
  428. ])
  429. if test "$ac_cv_define_$1" = "yes"; then
  430. AC_DEFINE(HAVE_$1, 1, [Define if $1 is defined in $2])
  431. fi
  432. ])