forked from duncantl/Rtesseract
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
294 lines (237 loc) · 5.92 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
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
288
289
290
291
292
293
294
AC_INIT(src/ext.cpp)
# find leptonica, tesseract
# determine what image formats leptonica supports
AC_PATH_PROG(PKG_CONFIG, pkg-config, [echo "Cannot find pkg-config"])
if test -n "$PKG_CONFIG" ; then
LEPT_CFLAGS=`${PKG_CONFIG} --cflags lept`
if ! test "$?" = "0" ; then
echo "Failed to get compilation flags for leptonica via pkg-config"
echo "LEPT_CFLAGS = $LEPT_CFLAGS"
fi
LEPT_LIBS=`$PKG_CONFIG --libs lept`
TESS_CFLAGS=`${PKG_CONFIG} --cflags tesseract`
TESS_LIBS=`${PKG_CONFIG} --libs tesseract`
fi
dnl For 4.00dev beta, we need -std=c++11. Should check for this in a more structured manner, but for now just bang it in
dnl but allow the user set CXXFLAGS and override this.
if test -z "$CXXFLAGS" ; then
CXXFLAGS="-std=c++11"
fi
dnl probably should use the one from R's configuration
dnl CXX=`R CMD config CXX`
AC_PROG_CXX
echo "CXXFLAGS = $CXXFLAGS"
CXXFLAGS="$TESS_CFLAGS $CXXFLAGS"
echo "Tesseract CFLAGS = $TESS_CFLAGS"
AC_LANG(C++)
AC_TRY_COMPILE(
[
#include <string>
using std::string;
#include <baseapi.h>
],
[
tesseract::TessBaseAPI api;
api.GetInputName();
],
[CPPDEFS="$CPPDEFS -DHAS_GETINPUT_NAME=1"],
[echo "No GetInputName() method for the TessBaseAPI"]
)
AC_TRY_COMPILE(
[
#include <string>
using std::string;
#include <baseapi.h>
],
[
tesseract::TessBaseAPI * api;
api->GetDatapath();
],
[CPPDEFS="$CPPDEFS -DHAS_GETDATAPATH=1"],
[echo "No GetDatapath() method for the TessBaseAPI"]
)
AC_TRY_COMPILE(
[
#include <string>
using std::string;
#include <baseapi.h>
],
[
tesseract::TessBaseAPI * api;
api->GetSourceYResolution();
],
[CPPDEFS="$CPPDEFS -DHAS_GETSOURCEYRESOLUTION=1"],
[echo "No GetSourceYResolution() method for the TessBaseAPI"]
)
AC_TRY_COMPILE(
[
#include <string>
using std::string;
#include <tesseract/baseapi.h>
#include <tesseract/renderer.h>
],
[
tesseract::TessPDFRenderer render("", "", true);
],
[CPPDEFS="$CPPDEFS -DPDF_RENDER_HAS_TEXT_ONLY=1"; echo "Has textonly parameter"],
[echo "TessPDFRender constructor has no textonly parameter"]
)
AC_TRY_COMPILE(
[
#include <string>
using std::string;
#include <tesseract/baseapi.h>
],
[
tesseract::DetectOrientationScript;
],
[CPPDEFS="$CPPDEFS -DHAS_DETECT_ORIENTATION_SCRIPT=1"; echo "Has DetectOrientatinScript() method"],
[echo "NO DetectOrientationScript() method"]
)
AC_TRY_COMPILE(
[
#include <publictypes.h>
],
[
tesseract::OEM_LSTM_ONLY;
],
[CPPDEFS="$CPPDEFS -DHAS_OEM_LSTM=1"],
[echo "No OEM_LSTM_ONLY enumeration value for the TessBaseAPI"]
)
AC_TRY_COMPILE(
[
#include <publictypes.h>
],
[
tesseract::OEM_CUBE_ONLY;
],
[CPPDEFS="$CPPDEFS -DHAS_CUBE_ONLY=1"],
[echo "No OEM_CUBE_ONLY enumeration value for the TessBaseAPI"]
)
PNG_FILES="NA"
JPG_FILES="NA"
TIFF_FILES="NA"
WEBP_FILES="NA"
JP2_FILES="NA"
PNM_FILES="NA"
GIF_FILES="NA"
BMP_FILES="NA"
PS_FILES="NA"
PDF_FILES="NA"
SPIX_FILES="NA"
echo "Compiling readImage"
$CXX $CPPFLAGS $CXXFLAGS -o readImage readImg.cpp $TESS_CFLAGS $LEPT_CFLAGS $TESS_LIBS $LEPT_LIBS
if test "$?" = "0" ; then
echo "testing leptonica can read different image formats"
JPG_FILES="FALSE"
./readImage inst/images/IMG_1236.jpg
if test $? -eq 0 ; then
echo "jpg support"
JPG_FILES="TRUE"
fi
TIFF_FILES="FALSE"
./readImage inst/images/OCRSample.tiff
if test $? -eq 0 ; then
echo "tiff support"
TIFF_FILES="TRUE"
fi
PNG_FILES="FALSE"
./readImage inst/images/DifferentFonts.png
if test $? -eq 0 ; then
echo "png support"
PNG_FILES="TRUE"
fi
WEBP_FILES="FALSE"
./readImage sampleImage.webp
if test $? -eq 0 ; then
echo "webp support"
WEBP_FILES="TRUE"
fi
JP2_FILES="FALSE"
./readImage sampleImage.jp2
if test $? -eq 0 ; then
echo "jp2 support"
JP2_FILES="TRUE"
else
echo "** no jp2 suppport"
fi
GIF_FILES="FALSE"
./readImage sampleImage.gif
if test $? -eq 0 ; then
echo "gif support"
GIF_FILES="TRUE"
fi
BMP_FILES="FALSE"
./readImage sampleImage.bmp
if test $? -eq 0 ; then
echo "bmp support"
BMP_FILES="TRUE"
fi
PNM_FILES="FALSE"
./readImage sampleImage.pnm
if test $? -eq 0 ; then
echo "pnm support"
PNM_FILES="TRUE"
fi
PS_FILES="FALSE"
./readImage sampleImage.ps
if test $? -eq 0 ; then
echo "ps support"
PS_FILES="TRUE"
fi
SPIX_FILES="FALSE"
./readImage sampleImage.spix
if test $? -eq 0 ; then
echo "spix support"
SPIX_FILES="TRUE"
fi
else
echo "Failed to create readImage. Problems with compilation and/or linking."
fi
AC_SUBST(CPPDEFS)
AC_SUBST(LEPT_LIBS)
AC_SUBST(LEPT_CFLAGS)
AC_SUBST(TESS_CFLAGS)
AC_SUBST(TESS_LIBS)
AC_SUBST(PNG_FILES)
AC_SUBST(JPG_FILES)
AC_SUBST(TIFF_FILES)
AC_SUBST(WEBP_FILES)
AC_SUBST(JP2_FILES)
AC_SUBST(PNM_FILES)
AC_SUBST(BMP_FILES)
AC_SUBST(GIF_FILES)
AC_SUBST(PS_FILES)
AC_SUBST(SPIX_FILES)
TESSERACT_VERSION=`$PKG_CONFIG --modversion tesseract`
LEPTONICA_VERSION=`$PKG_CONFIG --modversion lept`
echo "Tesseract version: $TESSERACT_VERSION"
echo "Leptonica version: $LEPTONICA_VERSION"
AC_SUBST(TESSERACT_VERSION)
AC_SUBST(LEPTONICA_VERSION)
USE_REXIT="FALSE"
echo "R_INCLUDE_DIR: $R_INCLUDE_DIR"
if test -n "" ; then
echo "Building libRexit.a"
(cd src/Rexit; make)
if test $? = 0 ; then
AC_OUTPUT(testRexit/Makevars)
echo "Compiling testRexit/tmp.so"
(cd testRexit; R CMD SHLIB -o tmp.so main.cc)
echo "Checking testRexit/tmp.so"
STR=`Rscript -e 'dyn.load("testRexit/tmp.so"); .C("R_check")' 2>&1 | grep '<tesseract>'`
echo "output: $STR"
if test -n "$STR" ; then
USE_REXIT="TRUE"
REXIT_LIB="-LRexit -lRexit"
echo "Using libRexit mechanism"
else
echo "libRexit didn't seem to work. Using atexit() mechanism"
fi
else
echo "Could not build src/Rexit/libRexit.a. Using atexit() mechanism"
fi # end of test for building libRexit.a
fi
AC_SUBST(USE_REXIT)
AC_SUBST(REXIT_LIB)
AC_OUTPUT(src/Makevars R/imageCapabilities.R R/config.R)