From 2441e4d8ace924376aa0feb05b13266511f9b749 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 24 May 2019 16:51:47 +0200 Subject: [PATCH] Implement check for Tensorflow header file This looks for one of the header files which are included by Tesseract. It currently uses a hard coded path which works for Debian / Ubuntu. Simplify also the rules for linking Tensorflow. Signed-off-by: Stefan Weil --- configure.ac | 16 +++++++++++++--- src/api/Makefile.am | 6 +----- src/training/Makefile.am | 4 +--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index 06f0ffcaff..25b176ca52 100644 --- a/configure.ac +++ b/configure.ac @@ -196,13 +196,23 @@ if test "$enable_opencl" = "yes"; then fi # Check whether to build with support for Tensorflow. -AC_MSG_CHECKING([--with-tensorflow]) AC_ARG_WITH([tensorflow], AS_HELP_STRING([--with-tensorflow], [support Tensorflow @<:@default=check@:>@]), [], [with_tensorflow=check]) -AC_MSG_RESULT([$with_tensorflow]) -AM_CONDITIONAL([TENSORFLOW], [test "$with_tensorflow" != "no"]) +AM_CONDITIONAL([TENSORFLOW], false) +TENSORFLOW_LIBS= +AS_IF([test "x$with_tensorflow" != xno], + [AC_CHECK_FILE([/usr/include/tensorflow/core/framework/graph.pb.h], + [AC_SUBST([TENSORFLOW_LIBS], ["-lprotobuf -ltensorflow_cc"]) + AM_CONDITIONAL([TENSORFLOW], true) + ], + [if test "x$with_tensorflow" != xcheck; then + AC_MSG_FAILURE( + [--with-tensorflow was given, but test for libtensorflow-dev failed]) + fi + ]) + ]) # https://lists.apple.com/archives/unix-porting/2009/Jan/msg00026.html m4_define([MY_CHECK_FRAMEWORK], diff --git a/src/api/Makefile.am b/src/api/Makefile.am index 69ee467c3b..d9b76eb6e2 100644 --- a/src/api/Makefile.am +++ b/src/api/Makefile.am @@ -88,6 +88,7 @@ tesseract_LDFLAGS = $(OPENCL_LDFLAGS) tesseract_LDADD += $(LEPTONICA_LIBS) tesseract_LDADD += $(OPENMP_CXXFLAGS) +tesseract_LDADD += $(TENSORFLOW_LIBS) tesseract_LDADD += $(libarchive_LIBS) if T_WIN @@ -98,8 +99,3 @@ endif if ADD_RT tesseract_LDADD += -lrt endif - -if TENSORFLOW -tesseract_LDADD += -lprotobuf -tesseract_LDADD += -ltensorflow_cc -endif diff --git a/src/training/Makefile.am b/src/training/Makefile.am index 9017c337a8..d0ca8149a0 100644 --- a/src/training/Makefile.am +++ b/src/training/Makefile.am @@ -282,9 +282,7 @@ unicharset_extractor_LDADD += $(LEPTONICA_LIBS) wordlist2dawg_LDADD += $(LEPTONICA_LIBS) extralib = $(libarchive_LIBS) -if TENSORFLOW -extralib += -lprotobuf -ltensorflow_cc -endif +extralib += $(TENSORFLOW_LIBS) if !DISABLED_LEGACY_ENGINE ambiguous_words_LDADD += $(extralib)