|
1 | 1 | # Tesseract configuration |
2 | | - |
3 | 2 | RWINLIB = ../windows/tesseract |
4 | 3 | PKG_CPPFLAGS = -I${RWINLIB}/include -I${RWINLIB}/include/leptonica -fvisibility=hidden |
5 | 4 |
|
6 | | -# Exclude unwanted symbols from DLL |
| 5 | +# Exclude unwanted symbols from DLL using more aggressive approach |
7 | 6 | PKG_LIBS = -L${RWINLIB}/lib${subst gcc,,${COMPILED_BY}}${R_ARCH} \ |
8 | 7 | -L${RWINLIB}/lib \ |
| 8 | + -Wl,--whole-archive \ |
9 | 9 | -ltesseract -lleptonica \ |
| 10 | + -Wl,--no-whole-archive \ |
10 | 11 | -ltiff -lopenjp2 -lwebp -lsharpyuv -ljpeg -lgif -lpng16 -lz \ |
11 | 12 | -lws2_32 \ |
12 | | - -Wl,--exclude-all-symbols |
| 13 | + -Wl,--exclude-all-symbols \ |
| 14 | + -static-libgcc -static-libstdc++ |
13 | 15 |
|
14 | | -# CRAN note: consistent C++11 standard usage |
15 | | -CXX_STD = CXX11 |
| 16 | +# For R 4.5.0 compatibility |
| 17 | +ifeq ($(shell ${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe -e 'cat(as.numeric(R.version$$major) + as.numeric(R.version$$minor)/10)'),4.5) |
| 18 | + PKG_LIBS += -Wl,--version-script=../tools/exports.map |
| 19 | +endif |
16 | 20 |
|
17 | 21 | # Compile |
18 | | -all: clean winlibs |
| 22 | +all: clean winlibs exports.map |
19 | 23 |
|
20 | 24 | clean: |
21 | | - rm -Rf $(OBJECTS) $(SHLIB) |
| 25 | + rm -Rf $(OBJECTS) $(SHLIB) exports.map cpp11tesseract.def |
| 26 | + |
| 27 | +exports.map: clean |
| 28 | + @echo "{ global: R_init_cpp11tesseract; local: *; };" > ../tools/exports.map |
22 | 29 |
|
23 | 30 | winlibs: |
24 | 31 | mkdir -p ../inst |
25 | 32 | "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R" ${VERSION} |
26 | 33 | cp -Rf ../windows/tessdata ../inst/ |
27 | 34 | cp -Rf ${RWINLIB}/share/tessdata ../inst/ |
28 | 35 |
|
29 | | -# Create DEF file to control exports |
30 | | -$(SHLIB): $(OBJECTS) cpp11tesseract.def |
31 | | - |
32 | | -cpp11tesseract.def: |
33 | | - echo EXPORTS > cpp11tesseract.def |
34 | | - ${DLLTOOL} --input-def cpp11tesseract.def --kill-at --output-lib cpp11tesseract.a $(OBJECTS) |
| 36 | +$(SHLIB): $(OBJECTS) |
35 | 37 |
|
36 | 38 | .PHONY: all winlibs clean |
37 | | - |
|
0 commit comments