configure.ac 12.2 KB
Newer Older
T
tmbdev 已提交
1 2 3 4 5 6 7 8 9
# -*-Shell-script-*-
#
# Copyright (c) Luc Vincent

# ----------------------------------------
# Initialization
# ----------------------------------------

AC_PREREQ(2.50)
10
AC_INIT([tesseract], [3.03], [http://code.google.com/p/tesseract-ocr/issues/list])
Z
zdenop@gmail.com 已提交
11
${CXXFLAGS=""}
J
joregan@gmail.com 已提交
12
AC_CONFIG_MACRO_DIR([m4])
Z
zdenop@gmail.com 已提交
13
AC_REVISION([$Revision$])
T
tmbdev 已提交
14
AC_CONFIG_AUX_DIR(config)
T
theraysmith 已提交
15
AC_CONFIG_SRCDIR(api/tesseractmain.cpp)
T
tmbdev 已提交
16 17 18 19 20
AC_PREFIX_DEFAULT(/usr/local)

# Define date of package, etc. Could be useful in auto-generated
# documentation.
# TODO(luc) Generate good documentation using doxygen or equivalent
Z
zdenop@gmail.com 已提交
21
PACKAGE_YEAR=2013
22
PACKAGE_DATE="08/13"
T
tmbdev 已提交
23 24 25 26 27 28 29 30 31 32 33

AC_DEFINE_UNQUOTED(PACKAGE_NAME,["${PACKAGE_NAME}"],[Name of package])
AC_DEFINE_UNQUOTED(PACKAGE_VERSION,["${PACKAGE_VERSION}"],[Version number])
AC_DEFINE_UNQUOTED(PACKAGE_YEAR,"$PACKAGE_YEAR",[Official year for this release])
AC_DEFINE_UNQUOTED(PACKAGE_DATE,"$PACKAGE_DATE",[Official date of release])

AC_SUBST(PACKAGE_NAME)
AC_SUBST(PACKAGE_VERSION)
AC_SUBST(PACKAGE_YEAR)
AC_SUBST(PACKAGE_DATE)

J
joregan 已提交
34 35 36 37
GENERIC_LIBRARY_NAME=tesseract

# Release versioning
GENERIC_MAJOR_VERSION=3
38 39
GENERIC_MINOR_VERSION=3
GENERIC_MICRO_VERSION=0
J
joregan 已提交
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55

# API version (often = GENERIC_MAJOR_VERSION.GENERIC_MINOR_VERSION)
GENERIC_API_VERSION=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION
GENERIC_LIBRARY_VERSION=$GENERIC_MAJOR_VERSION:$GENERIC_MINOR_VERSION
AC_SUBST(GENERIC_API_VERSION)
AC_SUBST(GENERIC_MAJOR_VERSION)

AC_SUBST(GENERIC_LIBRARY_VERSION)
PACKAGE=$GENERIC_LIBRARY_NAME
AC_SUBST(GENERIC_LIBRARY_NAME)

GENERIC_VERSION=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION.$GENERIC_MICRO_VERSION
GENERIC_RELEASE=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION
AC_SUBST(GENERIC_RELEASE)
AC_SUBST(GENERIC_VERSION)

56 57 58 59
# default conditional
AM_CONDITIONAL(MINGW, false)
AM_CONDITIONAL(GRAPHICS_DISABLED, false)

60 61
OPENCL_INC="/opt/AMDAPP/include"
OPENCL_LIBS="-lOpenCL"
62
#############################
63 64 65 66 67
#
# Platform specific setup
#
#############################
AC_CANONICAL_HOST
Z
zdenop@gmail.com 已提交
68
case "${host_os}" in
69 70 71 72 73
    mingw32*)
        AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
        AM_CONDITIONAL(MINGW, true)
        AC_SUBST([AM_LDFLAGS], ['-Wl,-no-undefined -Wl,--as-needed'])
        ;;
Z
zdenop@gmail.com 已提交
74 75 76
    solaris*)
        LIBS="-lsocket -lnsl -lrt -lxnet"
        ;;
77 78 79 80 81 82 83 84
    powerpc-*-darwin*)
        OPENCL_LIBS=""
        OPENCL_INC=""
        ;;
    *-*-darwin*)
        OPENCL_LIBS="-framework OpenCL"
        OPENCL_INC=""
        ;;
85
     *)
86
        # default
87 88 89
        ;;
esac

90
includedir="${includedir}/tesseract"
91

92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
AC_ARG_WITH(extra-includes,
            AC_HELP_STRING([--with-extra-includes=DIR],
                       [Define an additional directory for include files]),
        [ if test -d "$withval" ; then
            CFLAGS="$CFLAGS -I$withval"
          else
            AC_MSG_ERROR([Cannot stat directory $withval])
          fi ] )

AC_ARG_WITH(extra-libraries,
            AC_HELP_STRING([--with-extra-libraries=DIR],
                       [Define an additional directory for library files]),
        [ if test -d "$withval" ; then
           LDFLAGS="$LDFLAGS -L$withval"
          else
            AC_MSG_ERROR([Cannot stat directory $withval])
          fi ] )

110
AC_MSG_CHECKING(--enable-graphics argument)
J
joregan 已提交
111
AC_ARG_ENABLE([graphics],
112 113
 [AC_HELP_STRING([--enable-graphics],[enable graphics (ScrollView) (default)])
AC_HELP_STRING([--disable-graphics],[disable graphics (ScrollView)])],
114 115 116 117
    [enable_graphics=$enableval],
    [enable_graphics="yes"])
AC_MSG_RESULT($enable_graphics)
if test "$enable_graphics" = "no"; then
118 119
  AC_DEFINE([GRAPHICS_DISABLED], [], [Disable graphics])
  AM_CONDITIONAL(GRAPHICS_DISABLED, true)
120 121
fi

122 123 124 125 126 127 128 129 130 131 132 133
# check whether to build embedded version
AC_MSG_CHECKING(--enable-embedded argument)
AC_ARG_ENABLE([embedded],
    [  --enable-embedded       enable embedded build (default=no)],
    [enable_embedded=$enableval],
    [enable_embedded="no"])
AC_MSG_RESULT($enable_embedded)
AM_CONDITIONAL([EMBEDDED], [test "$enable_embedded" = "yes"])
if test "$enable_embedded" = "yes"; then
  AC_SUBST([AM_CPPFLAGS], [-DEMBEDDED])
fi

134 135 136
# check whether to build opencl version
AC_MSG_CHECKING(--enable-opencl argument)
AC_ARG_ENABLE([opencl],
137
    [  --enable-opencl         enable opencl build (default=no)],
138 139 140 141 142 143
    [enable_opencl=$enableval],
    [enable_opencl="no"])
AC_MSG_RESULT($enable_opencl)
AM_CONDITIONAL([USE_OPENCL], [test "$enable_opencl" = "yes"])
if test "$enable_opencl" = "yes"; then
  AC_SUBST([AM_CPPFLAGS], [-DUSE_OPENCL])
144 145
  AC_SUBST([OPENCL_HDR_PATH],[$OPENCL_INC])
  AC_SUBST([OPENCL_LIB],[$OPENCL_LIBS])
146 147
fi

148 149 150 151 152 153 154 155 156 157 158
# check whether to build tesseract with -fvisibility=hidden -fvisibility-inlines-hidden
# http://gcc.gnu.org/wiki/Visibility
# http://groups.google.com/group/tesseract-dev/browse_thread/thread/976645ae98189127
AC_MSG_CHECKING(--enable-visibility argument)
AC_ARG_ENABLE([visibility],
    [AC_HELP_STRING([--enable-visibility],[enable experimental build with fvisibility (default=no)])],
    [enable_visibility=$enableval],
    [enable_visibility="no"])
AC_MSG_RESULT($enable_visibility)
AM_CONDITIONAL([VISIBILITY], [test "$enable_visibility" = "yes"])

159 160 161
# check whether to build multiple libraries
AC_MSG_CHECKING(--enable-multiple-libraries argument)
AC_ARG_ENABLE([multiple-libraries],
162
    [AC_HELP_STRING([--enable-multiple-libraries],[enable multiple libraries (default=no)])],
163 164 165 166 167
    [enable_mlibs=$enableval],
    [enable_mlibs="no"])
AC_MSG_RESULT($enable_mlibs)
AM_CONDITIONAL([USING_MULTIPLELIBS], [test "$enable_mlibs" = "yes"])

168 169 170
# Check if tessdata-prefix is disabled
AC_MSG_CHECKING(whether to use tessdata-prefix)
AC_ARG_ENABLE(tessdata-prefix,
171 172 173
    [AC_HELP_STRING([--disable-tessdata-prefix],
            [dont set TESSDATA-PREFIX during compile])],
    [tessdata_prefix="no"], [tessdata_prefix="yes"])
174 175
AC_MSG_RESULT($tessdata_prefix)
AM_CONDITIONAL([NO_TESSDATA_PREFIX], [test "$tessdata_prefix" = "no"])
176

177 178 179 180 181 182 183 184 185
# Check whether enable debuging
AC_MSG_CHECKING(whether to enable debugging)
AC_ARG_ENABLE([debug],
    [AC_HELP_STRING([--enable-debug],
        [turn on debugging (default=no)])],
    [debug=$enableval],
    [debug="no"])
AC_MSG_RESULT($debug)
if test x"$debug" = x"yes"; then
186 187
    AM_CXXFLAGS="$AM_CXXFLAGS -g -Wall -Wno-uninitialized -O0 -DDEBUG"
    AM_CPPFLAGS="$AM_CPPFLAGS -g -Wall -Wno-uninitialized -O0 -DDEBUG"
188
else
Z
zdenop@gmail.com 已提交
189 190
    AM_CXXFLAGS="$AM_CXXFLAGS -O2 -DNDEBUG"
    AM_CPPFLAGS="$AM_CPPFLAGS -O2 -DNDEBUG"
191 192
fi

193
#localedir='${prefix}/share/locale'
J
joregan 已提交
194

T
tmbdev 已提交
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
# Always look into a "gnu" directory.
curwd=`pwd`
if test -d $curwd/gnu/include ; then
   CPPFLAGS="$CPPFLAGS -I$curwd/gnu/include"
fi
if test -d $curwd/gnu/lib ; then
   LDFLAGS="$LDFLAGS -L$curwd/gnu/lib"
fi

# Special cases
case "$host" in
  *-darwin* | *-macos10*)
     if test -d /opt/local ; then
       CPPFLAGS="$CPPFLAGS -I/opt/local/include"
       LDFLAGS="$LDFLAGS -L/opt/local/lib"
     elif test -d /sw ; then
       CPPFLAGS="$CPPFLAGS -I/sw/include"
       LDFLAGS="$LDFLAGS -L/sw/lib"
     fi
  ;;
esac

# ----------------------------------------
# Check Compiler Characteristics and
# configure automake. The two appear to
# be intimately linked...
# ----------------------------------------

# Define order of compilers
224
AC_PROG_CXX(g++)
T
tmbdev 已提交
225

J
joregan 已提交
226 227
AC_PROG_LIBTOOL

228
# ----------------------------------------
T
tmbdev 已提交
229 230 231 232
# Automake configuration
# ----------------------------------------

AM_INIT_AUTOMAKE
233
AC_CONFIG_HEADERS(config_auto.h:config/config.h.in)
T
tmbdev 已提交
234 235
AM_MAINTAINER_MODE

236
# ----------------------------------------
T
tmbdev 已提交
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
# Additional checking of compiler characteristics
# ----------------------------------------

# Check Endianness. If Big Endian, this will define WORDS_BIGENDIAN
# See also at end of this file, where we define INTEL_BYTE_ORDER
# or MOTOROLA_BYTE_ORDER.
AC_C_BIGENDIAN


# ----------------------------------------
# Check for programs we need
# ----------------------------------------

# Check where all the following programs are and set
# variables accordingly:
J
joregan 已提交
252
LT_INIT
T
tmbdev 已提交
253 254 255 256 257 258 259 260


# ----------------------------------------
# C++ related options
# ----------------------------------------

AC_LANG_CPLUSPLUS

Z
zdenop@gmail.com 已提交
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
dnl ********************
dnl turn on c++11
dnl ********************

OLD_CXXFLAGS=$CXXFLAGS
AC_MSG_CHECKING(whether compiler supports C++11)
CXXFLAGS="$CXXFLAGS -std=c++11"
AC_COMPILE_IFELSE(
[
  AC_LANG_SOURCE([[
    #if (__cplusplus < 201103L)
    #error C++ 11 is unsupported
    #endif
  ]])
], [
     AC_MSG_RESULT(yes)
     has_cpp11=yes
   ],
   [
     AC_MSG_RESULT(no)
     has_cpp11=no
   ])
CXXFLAGS="$OLD_CXXFLAGS"
if test "x$has_cpp11" = "xyes"
then
  CXXFLAGS="$CXXFLAGS -std=c++11"
fi
T
tmbdev 已提交
288 289 290 291 292

# ----------------------------------------
# Check for libraries
# ----------------------------------------

293
AC_SEARCH_LIBS(sem_init,pthread rt)
294

T
tmbdev 已提交
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317

# ----------------------------------------
# Checks for header files.
# ----------------------------------------

AC_HEADER_STDC
AC_HEADER_TIME
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(sys/ipc.h sys/shm.h)
AC_CHECK_HEADERS(limits.h malloc.h)
# Enable use of system-defined bool type if available:
AC_HEADER_STDBOOL

# Misc
AC_SYS_INTERPRETER
AC_SYS_LARGEFILE


# ----------------------------------------
# Checks for typedefs, structures, and compiler characteristics.
# ----------------------------------------

AC_CHECK_TYPES(wchar_t)
318
AC_CHECK_TYPES(long long int)
T
tmbdev 已提交
319 320 321
AC_CHECK_TYPES(mbstate_t,,,[#include "wchar.h"])

# ----------------------------------------
322
# Test auxiliary packages
T
tmbdev 已提交
323 324
# ----------------------------------------

T
theraysmith 已提交
325
# Check location of leptonica/liblept headers.
326 327 328
AC_MSG_CHECKING(for leptonica)
AC_ARG_VAR(LIBLEPT_HEADERSDIR,[Leptonica headers directory])

T
theraysmith 已提交
329
have_lept=no
330 331 332 333
if test "$LIBLEPT_HEADERSDIR" = "" ; then
  LIBLEPT_HEADERSDIR="/usr/local/include /usr/include"
fi
for incd in $LIBLEPT_HEADERSDIR
T
theraysmith 已提交
334 335 336 337 338 339 340 341 342 343
do
  for lept in . leptonica liblept
  do
    if test -r "$incd/$lept/allheaders.h" ; then
      CPPFLAGS="$CPPFLAGS -I$incd/$lept"
      have_lept=yes
    fi
  done
done
if test "$have_lept" = yes ; then
344
  AC_MSG_RESULT(yes)
345
  AC_CHECK_LIB(lept,pixCreate,[], AC_MSG_ERROR([leptonica library missing]))
346 347
else
  AC_MSG_ERROR([leptonica not found])
T
theraysmith 已提交
348 349
fi

350 351 352 353 354 355 356 357 358
# Check location of icu headers
have_icu=false
AC_CHECK_HEADERS(unicode/uchar.h, have_icu=true, have_icu=false)
if !($have_icu); then
        AC_MSG_WARN(Training tools WILL NOT be built because of missing icu library.)
        AC_MSG_WARN(Try to install libicu-devel package.)
fi
AM_CONDITIONAL(ENABLE_TRAINING, $have_icu)

T
tmbdev 已提交
359 360 361 362 363
# ----------------------------------------
# Final Tasks and Output
# ----------------------------------------

# Output files
364
AC_CONFIG_FILES([Makefile tesseract.pc])
T
theraysmith 已提交
365
AC_CONFIG_FILES(api/Makefile)
T
tmbdev 已提交
366
AC_CONFIG_FILES(ccmain/Makefile)
367
AC_CONFIG_FILES(opencl/Makefile)
T
tmbdev 已提交
368 369 370
AC_CONFIG_FILES(ccstruct/Makefile)
AC_CONFIG_FILES(ccutil/Makefile)
AC_CONFIG_FILES(classify/Makefile)
371
AC_CONFIG_FILES(cube/Makefile)
T
tmbdev 已提交
372 373 374
AC_CONFIG_FILES(cutil/Makefile)
AC_CONFIG_FILES(dict/Makefile)
AC_CONFIG_FILES(image/Makefile)
375
AC_CONFIG_FILES(neural_networks/runtime/Makefile)
T
tmbdev 已提交
376 377 378 379
AC_CONFIG_FILES(textord/Makefile)
AC_CONFIG_FILES(viewer/Makefile)
AC_CONFIG_FILES(wordrec/Makefile)
AC_CONFIG_FILES(training/Makefile)
380
AC_CONFIG_FILES(tessdata/Makefile)
T
theraysmith 已提交
381 382 383
AC_CONFIG_FILES(tessdata/configs/Makefile)
AC_CONFIG_FILES(tessdata/tessconfigs/Makefile)
AC_CONFIG_FILES(testing/Makefile)
384
AC_CONFIG_FILES(java/Makefile)
385 386 387 388 389
AC_CONFIG_FILES(java/com/Makefile)
AC_CONFIG_FILES(java/com/google/Makefile)
AC_CONFIG_FILES(java/com/google/scrollview/Makefile)
AC_CONFIG_FILES(java/com/google/scrollview/events/Makefile)
AC_CONFIG_FILES(java/com/google/scrollview/ui/Makefile)
390
AC_CONFIG_FILES(doc/Makefile)
T
tmbdev 已提交
391 392 393 394 395
AC_OUTPUT

# Final message
echo ""
echo "Configuration is done."
396
echo "You can now build and install $PACKAGE_NAME by running:"
T
tmbdev 已提交
397
echo ""
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
echo "$ make"
echo "$ sudo make install"
echo "$ sudo make install LANGS=\"eng ara deu\""
echo "  Or:"
echo "$ sudo make install-langs"

if !($have_icu); then
  echo ""
  echo "You can not build training tools because of missing dependency."
  echo "Check configure output for details."
  echo ""
else
  echo ""
  echo "Training tools can be build and installed (after building of $PACKAGE_NAME) with:"
  echo ""
  echo "$ make training"
  echo "$ sudo make training-install"
  echo ""
fi
T
tmbdev 已提交
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
# ----------------------------------------
# CONFIG Template
# ----------------------------------------

# Fence added in configuration file
AH_TOP([
#ifndef CONFIG_AUTO_H
#define CONFIG_AUTO_H
/* config_auto.h: begin */
])

# Stuff added at bottom of file
AH_BOTTOM([

/* Miscellaneous defines */
#define AUTOCONF 1

434
/* Not used yet
435 436
#ifndef NO_GETTEXT
#define USING_GETTEXT
J
joregan 已提交
437
#endif
438
*/
J
joregan 已提交
439

T
tmbdev 已提交
440 441 442
/* config_auto.h: end */
#endif
])