configure.ac 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. # -*-Shell-script-*-
  2. #
  3. # Copyright (c) Luc Vincent
  4. # ----------------------------------------
  5. # Initialization
  6. # ----------------------------------------
  7. AC_PREREQ([2.69])
  8. AC_INIT([tesseract],
  9. [m4_esyscmd_s([test -d .git && git describe --abbrev=4 2>/dev/null || cat VERSION])],
  10. [https://github.com/tesseract-ocr/tesseract/issues],,
  11. [https://github.com/tesseract-ocr/tesseract/])
  12. # Store command like options for CXXFLAGS
  13. OLD_CXXFLAGS=$CXXFLAGS
  14. AC_PROG_CXX([g++ clang++])
  15. # reset compiler flags to initial flags
  16. AC_LANG([C++])
  17. AC_LANG_COMPILER_REQUIRE
  18. CXXFLAGS=${CXXFLAGS:-""}
  19. AC_CONFIG_MACRO_DIR([m4])
  20. AC_CONFIG_AUX_DIR([config])
  21. AC_CONFIG_SRCDIR([src/tesseract.cpp])
  22. AC_PREFIX_DEFAULT([/usr/local])
  23. # Automake configuration. Do not require README file (we use README.md).
  24. AM_INIT_AUTOMAKE([foreign subdir-objects nostdinc])
  25. # Define date of package, etc. Could be useful in auto-generated
  26. # documentation.
  27. PACKAGE_YEAR=2024
  28. PACKAGE_DATE="11/10"
  29. abs_top_srcdir=`AS_DIRNAME([$0])`
  30. AC_DEFINE_UNQUOTED([PACKAGE_NAME], ["${PACKAGE_NAME}"], [Name of package])
  31. AC_DEFINE_UNQUOTED([PACKAGE_VERSION], ["${PACKAGE_VERSION}"], [Version number])
  32. AC_DEFINE_UNQUOTED([PACKAGE_YEAR], ["$PACKAGE_YEAR"], [Official year for this release])
  33. AC_DEFINE_UNQUOTED([PACKAGE_DATE], ["$PACKAGE_DATE"], [Official date of release])
  34. AC_SUBST([PACKAGE_NAME])
  35. AC_SUBST([PACKAGE_VERSION])
  36. AC_SUBST([PACKAGE_YEAR])
  37. AC_SUBST([PACKAGE_DATE])
  38. GENERIC_LIBRARY_NAME=tesseract
  39. # Release versioning. Get versions from PACKAGE_VERSION.
  40. AX_SPLIT_VERSION
  41. GENERIC_MAJOR_VERSION=$(echo "$AX_MAJOR_VERSION" | $SED 's/^[[^0-9]]*//')
  42. GENERIC_MINOR_VERSION=$AX_MINOR_VERSION
  43. GENERIC_MICRO_VERSION=`echo "$AX_POINT_VERSION" | $SED 's/^\([[0-9]][[0-9]]*\).*/\1/'`
  44. # API version (often = GENERIC_MAJOR_VERSION.GENERIC_MINOR_VERSION)
  45. GENERIC_API_VERSION=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION
  46. GENERIC_LIBRARY_VERSION=$GENERIC_MAJOR_VERSION:$GENERIC_MINOR_VERSION
  47. AC_SUBST([GENERIC_API_VERSION])
  48. AC_SUBST([GENERIC_MAJOR_VERSION])
  49. AC_SUBST([GENERIC_MINOR_VERSION])
  50. AC_SUBST([GENERIC_MICRO_VERSION])
  51. AC_SUBST([GENERIC_LIBRARY_VERSION])
  52. PACKAGE=$GENERIC_LIBRARY_NAME
  53. AC_SUBST([GENERIC_LIBRARY_NAME])
  54. GENERIC_VERSION=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION.$GENERIC_MICRO_VERSION
  55. GENERIC_RELEASE=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION
  56. AC_SUBST([GENERIC_RELEASE])
  57. AC_SUBST([GENERIC_VERSION])
  58. AC_CONFIG_HEADERS([include/config_auto.h:config/config.h.in])
  59. # default conditional
  60. AM_CONDITIONAL([T_WIN], false)
  61. AM_CONDITIONAL([MINGW], false)
  62. AM_CONDITIONAL([GRAPHICS_DISABLED], false)
  63. AC_SUBST([AM_CPPFLAGS])
  64. # Be less noisy by default.
  65. # Can be overridden with `configure --disable-silent-rules` or with `make V=1`.
  66. AM_SILENT_RULES([yes])
  67. #############################
  68. #
  69. # Platform specific setup
  70. #
  71. #############################
  72. AC_CANONICAL_HOST
  73. case "${host_os}" in
  74. mingw*)
  75. AC_DEFINE_UNQUOTED([MINGW], 1, [This is a MinGW system])
  76. AM_CONDITIONAL([T_WIN], true)
  77. AM_CONDITIONAL([MINGW], true)
  78. AM_CONDITIONAL([ADD_RT], false)
  79. AC_SUBST([AM_LDFLAGS], ['-no-undefined'])
  80. ;;
  81. cygwin*)
  82. AM_CONDITIONAL([ADD_RT], false)
  83. AC_SUBST([NOUNDEFINED], ['-no-undefined'])
  84. ;;
  85. solaris*)
  86. LIBS="$LIBS -lsocket -lnsl -lrt -lxnet"
  87. AM_CONDITIONAL([ADD_RT], true)
  88. ;;
  89. *darwin*)
  90. AM_CONDITIONAL([ADD_RT], false)
  91. ;;
  92. *android*|openbsd*)
  93. AM_CONDITIONAL([ADD_RT], false)
  94. ;;
  95. powerpc-*-darwin*)
  96. ;;
  97. *)
  98. # default
  99. AM_CONDITIONAL([ADD_RT], true)
  100. ;;
  101. esac
  102. WERROR=-Werror
  103. # The test code used by AX_CHECK_COMPILE_FLAG uses an empty statement
  104. # and unused macros which must not raise a compiler error, but it must
  105. # be an error if flags like -avx are ignored on ARM and other
  106. # architectures because they are unsupported.
  107. AX_CHECK_COMPILE_FLAG([-Werror=unused-command-line-argument], [WERROR=-Werror=unused-command-line-argument])
  108. ## Checks for supported compiler options.
  109. AM_CONDITIONAL([HAVE_AVX], false)
  110. AM_CONDITIONAL([HAVE_AVX2], false)
  111. AM_CONDITIONAL([HAVE_AVX512F], false)
  112. AM_CONDITIONAL([HAVE_FMA], false)
  113. AM_CONDITIONAL([HAVE_SSE4_1], false)
  114. AM_CONDITIONAL([HAVE_NEON], false)
  115. AM_CONDITIONAL([HAVE_RVV], false)
  116. case "${host_cpu}" in
  117. amd64|*86*)
  118. AX_CHECK_COMPILE_FLAG([-mavx], [avx=true], [avx=false], [$WERROR])
  119. AM_CONDITIONAL([HAVE_AVX], ${avx})
  120. if $avx; then
  121. AC_DEFINE([HAVE_AVX], [1], [Enable AVX instructions])
  122. fi
  123. AX_CHECK_COMPILE_FLAG([-mavx2], [avx2=true], [avx2=false], [$WERROR])
  124. AM_CONDITIONAL([HAVE_AVX2], $avx2)
  125. if $avx2; then
  126. AC_DEFINE([HAVE_AVX2], [1], [Enable AVX2 instructions])
  127. fi
  128. AX_CHECK_COMPILE_FLAG([-mavx512f], [avx512f=true], [avx512f=false], [$WERROR])
  129. AM_CONDITIONAL([HAVE_AVX512F], $avx512f)
  130. if $avx512f; then
  131. AC_DEFINE([HAVE_AVX512F], [1], [Enable AVX512F instructions])
  132. fi
  133. AX_CHECK_COMPILE_FLAG([-mfma], [fma=true], [fma=false], [$WERROR])
  134. AM_CONDITIONAL([HAVE_FMA], $fma)
  135. if $fma; then
  136. AC_DEFINE([HAVE_FMA], [1], [Enable FMA instructions])
  137. fi
  138. AX_CHECK_COMPILE_FLAG([-msse4.1], [sse41=true], [sse41=false], [$WERROR])
  139. AM_CONDITIONAL([HAVE_SSE4_1], $sse41)
  140. if $sse41; then
  141. AC_DEFINE([HAVE_SSE4_1], [1], [Enable SSE 4.1 instructions])
  142. fi
  143. ;;
  144. aarch64*|arm64)
  145. # ARMv8 always has NEON and does not need special compiler flags.
  146. AM_CONDITIONAL([HAVE_NEON], true)
  147. AC_DEFINE([HAVE_NEON], [1], [Enable NEON instructions])
  148. ;;
  149. arm*)
  150. AX_CHECK_COMPILE_FLAG([-mfpu=neon], [neon=true], [neon=false], [$WERROR])
  151. AM_CONDITIONAL([HAVE_NEON], $neon)
  152. if $neon; then
  153. AC_DEFINE([HAVE_NEON], [1], [Enable NEON instructions])
  154. NEON_CXXFLAGS="-mfpu=neon"
  155. AC_SUBST([NEON_CXXFLAGS])
  156. check_for_neon=1
  157. fi
  158. ;;
  159. riscv*)
  160. AX_CHECK_COMPILE_FLAG([-march=rv64gcv], [rvv=true], [rvv=false], [$WERROR])
  161. AM_CONDITIONAL([HAVE_RVV], [$rvv])
  162. if $rvv; then
  163. AC_DEFINE([HAVE_RVV], [1], [Enable RVV instructions])
  164. check_for_rvv=1
  165. fi
  166. ;;
  167. *)
  168. AC_MSG_WARN([No compiler options for $host_cpu])
  169. esac
  170. # check whether feenableexcept is supported. some C libraries (e.g. uclibc) don't.
  171. AC_CHECK_FUNCS([feenableexcept])
  172. # additional checks for NEON targets
  173. if test x$check_for_neon = x1; then
  174. AC_MSG_NOTICE([checking how to detect NEON availability])
  175. AC_CHECK_FUNCS([getauxval elf_aux_info android_getCpuFamily])
  176. if test $ac_cv_func_getauxval = no && test $ac_cv_func_elf_aux_info = no && test $ac_cv_func_android_getCpuFamily = no; then
  177. AC_MSG_WARN([NEON is available, but we don't know how to check for it. Will not be able to use NEON.])
  178. fi
  179. fi
  180. # additional checks for RVV targets
  181. if test x$check_for_rvv = x1; then
  182. AC_MSG_NOTICE([checking how to detect RVV availability])
  183. AC_CHECK_FUNCS([getauxval])
  184. if test $ac_cv_func_getauxval = no; then
  185. AC_MSG_WARN([RVV is available, but we don't know how to check for it. Will not be able to use RVV.])
  186. fi
  187. fi
  188. AX_CHECK_COMPILE_FLAG([-fopenmp-simd], [openmp_simd=true], [openmp_simd=false], [$WERROR])
  189. AM_CONDITIONAL([OPENMP_SIMD], $openmp_simd)
  190. AC_ARG_WITH([extra-includes],
  191. [AS_HELP_STRING([--with-extra-includes=DIR],
  192. [Define an additional directory for include files])],
  193. [if test -d "$withval" ; then
  194. CFLAGS="$CFLAGS -I$withval"
  195. else
  196. AC_MSG_ERROR([Cannot stat directory $withval])
  197. fi])
  198. AC_ARG_WITH([extra-libraries],
  199. [AS_HELP_STRING([--with-extra-libraries=DIR],
  200. [Define an additional directory for library files])],
  201. [if test -d "$withval" ; then
  202. LDFLAGS="$LDFLAGS -L$withval"
  203. else
  204. AC_MSG_ERROR([Cannot stat directory $withval])
  205. fi])
  206. AC_MSG_CHECKING([--enable-float32 argument])
  207. AC_ARG_ENABLE([float32],
  208. AS_HELP_STRING([--disable-float32], [disable float and enable double for LSTM]))
  209. AC_MSG_RESULT([$enable_float32])
  210. if test "$enable_float32" != "no"; then
  211. AC_DEFINE([FAST_FLOAT], [1], [Enable float for LSTM])
  212. fi
  213. AC_MSG_CHECKING([--enable-graphics argument])
  214. AC_ARG_ENABLE([graphics],
  215. AS_HELP_STRING([--disable-graphics], [disable graphics (ScrollView)]))
  216. AC_MSG_RESULT([$enable_graphics])
  217. if test "$enable_graphics" = "no"; then
  218. AC_DEFINE([GRAPHICS_DISABLED], [], [Disable graphics])
  219. AM_CONDITIONAL([GRAPHICS_DISABLED], true)
  220. fi
  221. AC_MSG_CHECKING([--enable-legacy argument])
  222. AC_ARG_ENABLE([legacy],
  223. AS_HELP_STRING([--disable-legacy], [disable the legacy OCR engine]))
  224. AC_MSG_RESULT([$enable_legacy])
  225. AM_CONDITIONAL([DISABLED_LEGACY_ENGINE], test "$enable_legacy" = "no")
  226. if test "$enable_legacy" = "no"; then
  227. AC_DEFINE([DISABLED_LEGACY_ENGINE], [1], [Disable legacy OCR engine])
  228. fi
  229. # check whether to build OpenMP support
  230. AC_OPENMP
  231. have_tiff=false
  232. # Note that the first usage of AC_CHECK_HEADERS must be unconditional.
  233. AC_CHECK_HEADERS([tiffio.h], [have_tiff=true], [have_tiff=false])
  234. # Configure arguments which allow disabling some optional libraries.
  235. AC_ARG_WITH([archive],
  236. AS_HELP_STRING([--with-archive],
  237. [Build with libarchive which supports compressed model files @<:@default=check@:>@]),
  238. [], [with_archive=check])
  239. AC_ARG_WITH([curl],
  240. AS_HELP_STRING([--with-curl],
  241. [Build with libcurl which supports processing an image URL @<:@default=check@:>@]),
  242. [], [with_curl=check])
  243. # https://lists.apple.com/archives/unix-porting/2009/Jan/msg00026.html
  244. m4_define([MY_CHECK_FRAMEWORK],
  245. [AC_CACHE_CHECK([if -framework $1 works],[my_cv_framework_$1],
  246. [save_LIBS="$LIBS"
  247. LIBS="$LIBS -framework $1"
  248. AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
  249. [my_cv_framework_$1=yes],
  250. [my_cv_framework_$1=no])
  251. LIBS="$save_LIBS"
  252. ])
  253. if test "$my_cv_framework_$1"="yes"; then
  254. AC_DEFINE(AS_TR_CPP([HAVE_FRAMEWORK_$1]), 1,
  255. [Define if you have the $1 framework])
  256. AS_TR_CPP([FRAMEWORK_$1])="-framework $1"
  257. AC_SUBST(AS_TR_CPP([FRAMEWORK_$1]))
  258. fi]
  259. )
  260. case "${host_os}" in
  261. *darwin* | *-macos10*)
  262. MY_CHECK_FRAMEWORK([Accelerate])
  263. if test $my_cv_framework_Accelerate = yes; then
  264. AM_CPPFLAGS="-DHAVE_FRAMEWORK_ACCELERATE $AM_CPPFLAGS"
  265. AM_LDFLAGS="$AM_LDFLAGS -framework Accelerate"
  266. fi
  267. ;;
  268. *)
  269. # default
  270. ;;
  271. esac
  272. # check whether to build tesseract with -fvisibility=hidden -fvisibility-inlines-hidden
  273. # http://gcc.gnu.org/wiki/Visibility
  274. # https://groups.google.com/g/tesseract-dev/c/l2ZFrpgYkSc/m/_cdYSRDSXuUJ
  275. AC_MSG_CHECKING([--enable-visibility argument])
  276. AC_ARG_ENABLE([visibility],
  277. AS_HELP_STRING([--enable-visibility],
  278. [enable experimental build with -fvisibility [default=no]]))
  279. AC_MSG_RESULT([$enable_visibility])
  280. AM_CONDITIONAL([VISIBILITY], [test "$enable_visibility" = "yes"])
  281. # Check if tessdata-prefix is disabled
  282. AC_MSG_CHECKING([whether to use tessdata-prefix])
  283. AC_ARG_ENABLE([tessdata-prefix],
  284. [AS_HELP_STRING([--disable-tessdata-prefix],
  285. [don't set TESSDATA-PREFIX during compile])],
  286. [tessdata_prefix="no"], [tessdata_prefix="yes"])
  287. AC_MSG_RESULT([$tessdata_prefix])
  288. AM_CONDITIONAL([NO_TESSDATA_PREFIX], [test "$tessdata_prefix" = "no"])
  289. # Detect Clang compiler
  290. AC_MSG_CHECKING([if compiling with clang])
  291. AC_COMPILE_IFELSE(
  292. [AC_LANG_PROGRAM([], [[
  293. #ifndef __clang__
  294. not clang
  295. #endif
  296. ]])],
  297. [CLANG=yes], [CLANG=no])
  298. AC_MSG_RESULT([$CLANG])
  299. # Check whether to enable debugging
  300. AC_MSG_CHECKING([whether to enable debugging])
  301. AC_ARG_ENABLE([debug],
  302. AS_HELP_STRING([--enable-debug], [turn on debugging [default=no]]))
  303. AC_MSG_RESULT([$enable_debug])
  304. if test x"$enable_debug" = x"yes"; then
  305. CXXFLAGS=${CXXFLAGS:-"-O2"}
  306. AM_CPPFLAGS="$AM_CPPFLAGS -g -Wall -DDEBUG -pedantic"
  307. AM_CXXFLAGS="$AM_CXXFLAGS -g -Wall -DDEBUG -pedantic"
  308. if test "x$CLANG" = "xyes"; then
  309. # https://clang.llvm.org/docs/CommandGuide/clang.html
  310. # clang treats -Og as -O1
  311. AM_CPPFLAGS="$AM_CPPFLAGS -O0"
  312. AM_CXXFLAGS="$AM_CXXFLAGS -O0"
  313. else
  314. AM_CPPFLAGS="$AM_CPPFLAGS -Og"
  315. AM_CXXFLAGS="$AM_CXXFLAGS -Og"
  316. fi
  317. else
  318. AM_CXXFLAGS="$AM_CXXFLAGS -O2 -DNDEBUG"
  319. AM_CPPFLAGS="$AM_CPPFLAGS -O2 -DNDEBUG"
  320. fi
  321. # ----------------------------------------
  322. # Init libtool
  323. # ----------------------------------------
  324. LT_INIT
  325. # ----------------------------------------
  326. # C++ related options
  327. # ----------------------------------------
  328. dnl **********************
  329. dnl Turn on C++17 or newer
  330. dnl **********************
  331. CPLUSPLUS=
  332. AX_CHECK_COMPILE_FLAG([-std=c++17], [CPLUSPLUS=17], [], [$WERROR])
  333. AX_CHECK_COMPILE_FLAG([-std=c++20], [CPLUSPLUS=20], [], [$WERROR])
  334. if test -z "$CPLUSPLUS"; then
  335. AC_MSG_ERROR([Your compiler does not have the necessary C++17 support! Cannot proceed.])
  336. fi
  337. # Set C++17 or newer support based on platform/compiler
  338. case "${host_os}" in
  339. cygwin*)
  340. CXXFLAGS="$CXXFLAGS -std=gnu++$CPLUSPLUS"
  341. ;;
  342. *-darwin* | *-macos10*)
  343. CXXFLAGS="$CXXFLAGS -std=c++$CPLUSPLUS"
  344. if test "x$CLANG" = "xyes"; then
  345. LDFLAGS="$LDFLAGS -stdlib=libc++"
  346. fi
  347. ;;
  348. *)
  349. # default
  350. CXXFLAGS="$CXXFLAGS -std=c++$CPLUSPLUS"
  351. ;;
  352. esac
  353. # ----------------------------------------
  354. # Check for libraries
  355. # ----------------------------------------
  356. AC_SEARCH_LIBS([pthread_create], [pthread])
  357. # Set PKG_CONFIG_PATH for macOS with Homebrew unless it is already set.
  358. AC_CHECK_PROG([have_brew], brew, true, false)
  359. if $have_brew; then
  360. brew_prefix=$(brew --prefix)
  361. if test -z "$PKG_CONFIG_PATH"; then
  362. PKG_CONFIG_PATH=$brew_prefix/opt/icu4c/lib/pkgconfig:$brew_prefix/opt/libarchive/lib/pkgconfig
  363. export PKG_CONFIG_PATH
  364. fi
  365. fi
  366. # ----------------------------------------
  367. # Check for programs needed to build documentation.
  368. # ----------------------------------------
  369. AM_CONDITIONAL([ASCIIDOC], false)
  370. AM_CONDITIONAL([HAVE_XML_CATALOG_FILES], false)
  371. AC_ARG_ENABLE([doc],
  372. AS_HELP_STRING([--disable-doc], [disable build of documentation])
  373. [],
  374. [: m4_divert_text([DEFAULTS], [enable_doc=check])])
  375. AS_IF([test "$enable_doc" != "no"], [
  376. AC_CHECK_PROG([have_asciidoc], asciidoc, true, false)
  377. AC_CHECK_PROG([have_xsltproc], xsltproc, true, false)
  378. # macOS with Homebrew requires the environment variable
  379. # XML_CATALOG_FILES for xsltproc.
  380. if $have_asciidoc && $have_xsltproc; then
  381. AM_CONDITIONAL([ASCIIDOC], true)
  382. XML_CATALOG_FILES=
  383. if $have_brew; then
  384. catalog_file=$brew_prefix/etc/xml/catalog
  385. if test -f $catalog_file; then
  386. AM_CONDITIONAL([HAVE_XML_CATALOG_FILES], true)
  387. XML_CATALOG_FILES=file:$catalog_file
  388. else
  389. AC_MSG_WARN([Missing file $catalog_file.])
  390. fi
  391. fi
  392. AC_SUBST([XML_CATALOG_FILES])
  393. else
  394. AS_IF([test "x$enable_doc" != xcheck], [
  395. AC_MSG_FAILURE(
  396. [--enable-doc was given, but test for asciidoc and xsltproc failed])
  397. ])
  398. fi
  399. ])
  400. # ----------------------------------------
  401. # Checks for typedefs, structures, and compiler characteristics.
  402. # ----------------------------------------
  403. AC_CHECK_TYPES([wchar_t],,, [#include "wchar.h"])
  404. AC_CHECK_TYPES([long long int])
  405. # ----------------------------------------
  406. # Test auxiliary packages
  407. # ----------------------------------------
  408. AM_CONDITIONAL([HAVE_LIBCURL], false)
  409. AS_IF([test "x$with_curl" != xno], [
  410. PKG_CHECK_MODULES([libcurl], [libcurl], [have_libcurl=true], [have_libcurl=false])
  411. AM_CONDITIONAL([HAVE_LIBCURL], $have_libcurl)
  412. if $have_libcurl; then
  413. AC_DEFINE([HAVE_LIBCURL], [1], [Enable libcurl])
  414. else
  415. AS_IF([test "x$with_curl" != xcheck], [
  416. AC_MSG_FAILURE(
  417. [--with-curl was given, but test for libcurl failed])
  418. ])
  419. fi
  420. ])
  421. PKG_CHECK_MODULES([LEPTONICA], [lept >= 1.74], [have_lept=true], [have_lept=false])
  422. if $have_lept; then
  423. CPPFLAGS="$CPPFLAGS $LEPTONICA_CFLAGS"
  424. else
  425. AC_MSG_ERROR([Leptonica 1.74 or higher is required. Try to install libleptonica-dev package.])
  426. fi
  427. AM_CONDITIONAL([HAVE_LIBARCHIVE], false)
  428. AS_IF([test "x$with_archive" != xno], [
  429. PKG_CHECK_MODULES([libarchive], [libarchive], [have_libarchive=true], [have_libarchive=false])
  430. AM_CONDITIONAL([HAVE_LIBARCHIVE], [$have_libarchive])
  431. if $have_libarchive; then
  432. AC_DEFINE([HAVE_LIBARCHIVE], [1], [Enable libarchive])
  433. CPPFLAGS="$CPPFLAGS $libarchive_CFLAGS"
  434. else
  435. AS_IF([test "x$with_archive" != xcheck], [
  436. AC_MSG_FAILURE(
  437. [--with-archive was given, but test for libarchive failed])
  438. ])
  439. fi
  440. ])
  441. AM_CONDITIONAL([ENABLE_TRAINING], true)
  442. # Check availability of ICU packages.
  443. PKG_CHECK_MODULES([ICU_UC], [icu-uc >= 52.1], [have_icu_uc=true], [have_icu_uc=false])
  444. PKG_CHECK_MODULES([ICU_I18N], [icu-i18n >= 52.1], [have_icu_i18n=true], [have_icu_i18n=false])
  445. if !($have_icu_uc && $have_icu_i18n); then
  446. AC_MSG_WARN([icu 52.1 or higher is required, but was not found.])
  447. AC_MSG_WARN([Training tools WILL NOT be built.])
  448. AC_MSG_WARN([Try to install libicu-dev package.])
  449. AM_CONDITIONAL([ENABLE_TRAINING], false)
  450. fi
  451. # Check location of pango headers
  452. PKG_CHECK_MODULES([pango], [pango >= 1.38.0], [have_pango=true], [have_pango=false])
  453. if !($have_pango); then
  454. AC_MSG_WARN([pango 1.38.0 or higher is required, but was not found.])
  455. AC_MSG_WARN([Training tools WILL NOT be built.])
  456. AC_MSG_WARN([Try to install libpango1.0-dev package.])
  457. AM_CONDITIONAL([ENABLE_TRAINING], false)
  458. fi
  459. # Check location of cairo headers
  460. PKG_CHECK_MODULES([cairo], [cairo], [have_cairo=true], [have_cairo=false])
  461. if !($have_cairo); then
  462. AC_MSG_WARN([Training tools WILL NOT be built because of missing cairo library.])
  463. AC_MSG_WARN([Try to install libcairo-dev?? package.])
  464. AM_CONDITIONAL([ENABLE_TRAINING], false)
  465. fi
  466. PKG_CHECK_MODULES([pangocairo], [pangocairo], [], [false])
  467. PKG_CHECK_MODULES([pangoft2], [pangoft2], [], [false])
  468. # ----------------------------------------
  469. # Final Tasks and Output
  470. # ----------------------------------------
  471. # Output files
  472. AC_CONFIG_FILES([include/tesseract/version.h])
  473. AC_CONFIG_FILES([Makefile tesseract.pc])
  474. AC_CONFIG_FILES([tessdata/Makefile])
  475. AC_CONFIG_FILES([tessdata/configs/Makefile])
  476. AC_CONFIG_FILES([tessdata/tessconfigs/Makefile])
  477. AC_CONFIG_FILES([java/Makefile])
  478. AC_CONFIG_FILES([java/com/Makefile])
  479. AC_CONFIG_FILES([java/com/google/Makefile])
  480. AC_CONFIG_FILES([java/com/google/scrollview/Makefile])
  481. AC_CONFIG_FILES([java/com/google/scrollview/events/Makefile])
  482. AC_CONFIG_FILES([java/com/google/scrollview/ui/Makefile])
  483. AC_CONFIG_FILES([nsis/Makefile])
  484. AC_OUTPUT
  485. # Final message
  486. echo ""
  487. echo "Configuration is done."
  488. echo "You can now build and install $PACKAGE_NAME by running:"
  489. echo ""
  490. echo "$ make"
  491. echo "$ sudo make install"
  492. echo "$ sudo ldconfig"
  493. echo ""
  494. AM_COND_IF([ASCIIDOC], [
  495. echo "This will also build the documentation."
  496. ], [
  497. AS_IF([test "$enable_doc" = "no"], [
  498. echo "Documentation will not be built because it was disabled."
  499. ], [
  500. echo "Documentation will not be built because asciidoc or xsltproc is missing."
  501. ])
  502. ])
  503. # echo "$ sudo make install LANGS=\"eng ara deu\""
  504. # echo " Or:"
  505. # echo "$ sudo make install-langs"
  506. echo ""
  507. AM_COND_IF([ENABLE_TRAINING],
  508. [
  509. echo "Training tools can be built and installed with:"
  510. echo ""
  511. echo "$ make training"
  512. echo "$ sudo make training-install"
  513. echo ""],
  514. [
  515. echo "You cannot build training tools because of missing dependency."
  516. echo "Check configure output for details."
  517. echo ""]
  518. )
  519. # ----------------------------------------
  520. # CONFIG Template
  521. # ----------------------------------------
  522. # Fence added in configuration file
  523. AH_TOP([
  524. #ifndef CONFIG_AUTO_H
  525. #define CONFIG_AUTO_H
  526. /* config_auto.h: begin */
  527. ])
  528. # Stuff added at bottom of file
  529. AH_BOTTOM([
  530. /* Miscellaneous defines */
  531. #define AUTOCONF 1
  532. /* Not used yet
  533. #ifndef NO_GETTEXT
  534. #define USING_GETTEXT
  535. #endif
  536. */
  537. /* config_auto.h: end */
  538. #endif
  539. ])