Skip to content

Commit

Permalink
Tweak Makefile logic for tesseract/leptonica.
Browse files Browse the repository at this point in the history
Firstly, we don't set HAVE_LEPTONICA or HAVE_TESSERACT if they
have already been set.

Secondly, correct the ifeq() logic to use brackets around $(HAVE_...)
to keep xcode (at least) happy.
  • Loading branch information
robinwatts committed Oct 19, 2020
1 parent 4d04efd commit ec079f3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
8 changes: 4 additions & 4 deletions Makerules
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ else ifeq ($(OS),Linux)
SYS_ZLIB_LIBS := $(shell pkg-config --libs zlib)
endif

HAVE_LEPTONICA := $(shell pkg-config --exists 'lept >= 1.7.4' && echo yes)
ifeq ($(HAVE_LEPTONICA),yes)
HAVE_SYS_LEPTONICA := $(shell pkg-config --exists 'lept >= 1.7.4' && echo yes)
ifeq ($(HAVE_SYS_LEPTONICA),yes)
SYS_LEPTONICA_CFLAGS := $(shell pkg-config --cflags lept)
SYS_LEPTONICA_LIBS := $(shell pkg-config --libs lept)
endif

HAVE_TESSERACT := $(shell pkg-config --exists 'tesseract-ocr >= 4.0.0' && echo yes)
ifeq ($(HAVE_TESSERACT),yes)
HAVE_SYS_TESSERACT := $(shell pkg-config --exists 'tesseract >= 4.0.0' && echo yes)
ifeq ($(HAVE_SYS_TESSERACT),yes)
SYS_TESSERACT_CFLAGS := $(shell pkg-config --cflags tesseract)
SYS_TESSERACT_LIBS := $(shell pkg-config --libs tesseract)
endif
Expand Down
35 changes: 20 additions & 15 deletions Makethird
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,24 @@ ifeq ($(OS),Linux)
USE_SYSTEM_CURL := yes
endif

ifneq ($(USE_SYSTEM_LEPTONICA),yes)
ifeq ($(wildcard thirdparty/leptonica/src/*),)
HAVE_LEPTONICA := no
ifeq ($(USE_SYSTEM_LEPTONICA),yes)
HAVE_LEPTONICA := $(HAVE_SYS_LEPTONICA)
else
HAVE_LEPTONICA := yes
endif
ifeq ($(wildcard thirdparty/leptonica/src/*),)
HAVE_LEPTONICA := no
else
HAVE_LEPTONICA := yes
endif
endif
ifneq ($(USE_SYSTEM_TESSERACT),yes)
ifeq ($(wildcard thirdparty/tesseract/src/*),)
HAVE_TESSERACT := no

ifeq ($(USE_SYSTEM_TESSERACT),yes)
HAVE_TESSERACT := $(HAVE_SYS_TESSERACT)
else
HAVE_TESSERACT := yes
endif
ifeq ($(wildcard thirdparty/tesseract/src/*),)
HAVE_TESSERACT := no
else
HAVE_TESSERACT := yes
endif
endif

ifeq ($(HAVE_LEPTONICA),yes)
Expand Down Expand Up @@ -809,24 +814,24 @@ THIRD_SRC += thirdparty/tesseract/src/wordrec/wordrec.cpp

THIRD_CFLAGS += -Ithirdparty/tesseract/include -Iscripts/tesseract

ifeq ($HAVE_AVX,yes)
ifeq ($(HAVE_AVX),yes)
TESSERACT_AVX_FLAGS = -mavx -DHAVE_AVX -D__AVX__
THIRD_SRC += thirdparty/tesseract/src/arch/dotproductavx.cpp
endif
ifeq ($HAVE_AVX2,yes)
ifeq ($(HAVE_AVX2),yes)
TESSERACT_AVX2_FLAGS = -mavx2 -DHAVE_AVX2 -D__AVX2__
THIRD_SRC += thirdparty/tesseract/src/arch/intsimdmatrixavx2.cpp
endif
ifeq ($HAVE_FMA,yes)
ifeq ($(HAVE_FMA),yes)
TESSERACT_FMA_FLAGS = -mfma -DHAVE_FMA -D__FMA__
THIRD_SRC += thirdparty/tesseract/src/arch/dotproductfma.cpp
endif
ifeq ($HAVE_SSE4_1,yes)
ifeq ($(HAVE_SSE4_1),yes)
TESSERACT_SSE_FLAGS = -msse4.1 -DHAVE_SSE4_1 -D__SSE4_1__
THIRD_SRC += thirdparty/tesseract/src/arch/dotproductsse.cpp
THIRD_SRC += thirdparty/tesseract/src/arch/intsimdmatrixsse.cpp
endif
ifeq ($HAVE_NEON,yes)
ifeq ($(HAVE_NEON),yes)
TESSERACT_NEON_FLAGS = -mneon -DHAVE_NEON
THIRD_SRC += thirdparty/tesseract/src/arch/intsimdmatrixneon.cpp
endif
Expand Down

0 comments on commit ec079f3

Please sign in to comment.