diff --git a/api/Makefile.am b/api/Makefile.am index 05cc8b3e..129c31ad 100644 --- a/api/Makefile.am +++ b/api/Makefile.am @@ -66,7 +66,7 @@ libtesseract_la_LIBADD = \ libtesseract_la_LDFLAGS += -version-info $(GENERIC_LIBRARY_VERSION) bin_PROGRAMS = tesseract -tesseract_SOURCES = $(top_srcdir)/api/tesseractmain.cpp +tesseract_SOURCES = tesseractmain.cpp tesseract_CPPFLAGS = $(AM_CPPFLAGS) if VISIBILITY tesseract_CPPFLAGS += -DTESS_IMPORTS @@ -78,7 +78,7 @@ if USE_OPENCL tesseract_LDADD += $(OPENCL_LIB) endif -if MINGW +if T_WIN tesseract_LDADD += -lws2_32 libtesseract_la_LDFLAGS += -no-undefined -Wl,--as-needed -lws2_32 endif diff --git a/ccutil/Makefile.am b/ccutil/Makefile.am index 84399b13..ea88c74e 100644 --- a/ccutil/Makefile.am +++ b/ccutil/Makefile.am @@ -1,3 +1,4 @@ +AUTOMAKE_OPTIONS = subdir-objects SUBDIRS = AM_CXXFLAGS = @@ -40,8 +41,7 @@ libtesseract_ccutil_la_SOURCES = \ unichar.cpp unicharmap.cpp unicharset.cpp unicodes.cpp \ params.cpp universalambigs.cpp - -if MINGW +if T_WIN AM_CPPFLAGS += -I$(top_srcdir)/vs2008/port -DWINDLLNAME=\"lib@GENERIC_LIBRARY_NAME@\" noinst_HEADERS += ../vs2010/port/strtok_r.h libtesseract_ccutil_la_SOURCES += ../vs2010/port/strtok_r.cpp diff --git a/ccutil/ambigs.cpp b/ccutil/ambigs.cpp index 166352e2..7620e958 100644 --- a/ccutil/ambigs.cpp +++ b/ccutil/ambigs.cpp @@ -24,13 +24,13 @@ #include "helpers.h" #include "universalambigs.h" -#ifdef _WIN32 +#if defined _WIN32 || defined(__CYGWIN__) #ifndef __GNUC__ #define strtok_r strtok_s #else #include "strtok_r.h" #endif /* __GNUC__ */ -#endif /* _WIN32 */ +#endif /* _WIN32 __CYGWIN__*/ namespace tesseract { diff --git a/ccutil/scanutils.cpp b/ccutil/scanutils.cpp index d97632bb..f49c6f63 100644 --- a/ccutil/scanutils.cpp +++ b/ccutil/scanutils.cpp @@ -34,7 +34,7 @@ #include "tprintf.h" // workaround for "'off_t' was not declared in this scope" with -std=c++11 -#if !defined(off_t) && !defined(__APPLE__) +#if !defined(off_t) && !defined(__APPLE__) && !defined(__CYGWIN__) typedef long off_t; #endif // off_t diff --git a/configure.ac b/configure.ac index 33427043..8d8f7fa8 100644 --- a/configure.ac +++ b/configure.ac @@ -62,7 +62,7 @@ AC_CONFIG_HEADERS(config_auto.h:config/config.h.in) AM_MAINTAINER_MODE # default conditional -AM_CONDITIONAL(MINGW, false) +AM_CONDITIONAL(T_WIN, false) AM_CONDITIONAL(OSX, false) AM_CONDITIONAL(GRAPHICS_DISABLED, false) @@ -77,12 +77,14 @@ AC_CANONICAL_HOST case "${host_os}" in mingw32*) AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system]) - AM_CONDITIONAL(MINGW, true) + AM_CONDITIONAL(T_WIN, true) AM_CONDITIONAL(ADD_RT, false) AC_SUBST([AM_LDFLAGS], ['-Wl,-no-undefined -Wl,--as-needed']) ;; cygwin*) - AM_CONDITIONAL(ADD_RT, false) + AM_CONDITIONAL(ADD_RT, false) + AM_CONDITIONAL(T_WIN, true) + AC_SUBST([AM_LDFLAGS], ['-Wl,-no-undefined -Wl,--as-needed']) ;; solaris*) LIBS="-lsocket -lnsl -lrt -lxnet" @@ -408,13 +410,9 @@ AM_CONDITIONAL(ENABLE_TRAINING, $have_cairo) # set c++11 support based on platform/compiler if test "x$has_cpp11" = "xyes"; then - case "$host" in + case "${host_os}" in cygwin*) - if test "x$snprintfworks" = "xno"; then - # cygwin workaround - # http://stackoverflow.com/questions/20149633/how-to-use-snprintf-in-g-std-c11-version-4-8-2/20149792#20149792 - CXXFLAGS="$CXXFLAGS -std=gnu++11" - fi + CXXFLAGS="$CXXFLAGS -std=gnu++11" ;; *-darwin* | *-macos10*) if test "x$CLANG" = "xyes"; then diff --git a/training/Makefile.am b/training/Makefile.am index cc24b4cf..00a81b33 100644 --- a/training/Makefile.am +++ b/training/Makefile.am @@ -1,3 +1,4 @@ +AUTOMAKE_OPTIONS = subdir-objects AM_CPPFLAGS += \ -DUSE_STD_NAMESPACE -DPANGO_ENABLE_ENGINE\ -I$(top_srcdir)/ccmain -I$(top_srcdir)/api \ @@ -9,7 +10,7 @@ AM_CPPFLAGS += \ EXTRA_DIST = tesstrain.sh -if MINGW +if T_WIN # try static build #AM_LDFLAGS += -all-static #libic=-lsicuin -licudt -lsicuuc @@ -279,7 +280,7 @@ wordlist2dawg_LDADD += \ ../api/libtesseract.la endif -if MINGW +if T_WIN ambiguous_words_LDADD += -lws2_32 classifier_tester_LDADD += -lws2_32 cntraining_LDADD += -lws2_32 diff --git a/viewer/svutil.cpp b/viewer/svutil.cpp index a660b0f0..a820eafb 100644 --- a/viewer/svutil.cpp +++ b/viewer/svutil.cpp @@ -222,7 +222,7 @@ void SVNetwork::Flush() { // This will always return one line of char* (denoted by \n). char* SVNetwork::Receive() { char* result = NULL; -#ifdef _WIN32 +#if defined(_WIN32) || defined(__CYGWIN__) if (has_content) { result = strtok (NULL, "\n"); } #else if (buffer_ptr_ != NULL) { result = strtok_r(NULL, "\n", &buffer_ptr_); }