Skip to content

Commit

Permalink
fix OSX build
Browse files Browse the repository at this point in the history
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@1059 d0cd1f9f-072b-0410-8dd7-cf729c803f20
  • Loading branch information
zdenop committed Apr 16, 2014
1 parent 0ebcf0d commit c3b9b7c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 14 deletions.
48 changes: 36 additions & 12 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ case "${host_os}" in
AC_SUBST([AM_LDFLAGS], ['-Wl,-no-undefined -Wl,--as-needed'])
;;
cygwin*)
AM_CONDITIONAL(ADD_RT, false)
is_cygwin=yes
AM_CONDITIONAL(ADD_RT, false)
;;
solaris*)
LIBS="-lsocket -lnsl -lrt -lxnet"
Expand Down Expand Up @@ -266,6 +265,17 @@ LT_INIT

AC_LANG_CPLUSPLUS

AC_MSG_CHECKING([if compiling with clang])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
#ifndef __clang__
not clang
#endif
]])],
[CLANG=yes], [CLANG=no])

AC_MSG_RESULT([$CLANG])

dnl ********************
dnl turn on c++11
dnl ********************
Expand Down Expand Up @@ -315,6 +325,7 @@ AC_HEADER_STDBOOL
AC_SYS_INTERPRETER
AC_SYS_LARGEFILE

AC_CHECK_FUNCS([getline])

# ----------------------------------------
# Checks for typedefs, structures, and compiler characteristics.
Expand Down Expand Up @@ -355,7 +366,7 @@ fi

AC_MSG_CHECKING([leptonica version >= 1.70])
AC_PREPROC_IFELSE(
[AC_LANG_PROGRAM([#include <leptonica/allheaders.h>],
[AC_LANG_PROGRAM([#include "allheaders.h"],
[#if (LIBLEPT_MAJOR_VERSION >= 1) && (LIBLEPT_MINOR_VERSION >= 70)
int i = 0;
#else
Expand Down Expand Up @@ -395,18 +406,31 @@ else
fi
AM_CONDITIONAL(ENABLE_TRAINING, $have_cairo)

# set c++11 support based on platform/compiler
if test "x$has_cpp11" = "xyes"; then
if test "x$is_cygwin" = "xyes" -a "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"
else
CXXFLAGS="$CXXFLAGS -std=c++11"
fi
case "$host" 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
;;
*-darwin* | *-macos10*)
if test "x$CLANG" = "xyes"; then
CXXFLAGS="$CXXFLAGS -std=c++11 "
LDFLAGS="$LDFLAGS -stdlib=libc++"
else
CXXFLAGS="$CXXFLAGS -std=c++11"
fi
;;
*)
# default
CXXFLAGS="$CXXFLAGS -std=c++11"
;;
esac
fi



# ----------------------------------------
# Final Tasks and Output
# ----------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions training/fileio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ bool InputBuffer::ReadLine(string* out) {
ASSERT_HOST(stream_ != NULL);
char* line = NULL;
int len = -1;
#ifdef _WIN32
#ifndef HAVE_GETLINE
char line_buf[BUFSIZ];
if ((line = fgets(line_buf, BUFSIZ, stream_)) != NULL) {
len = strlen(line);
Expand All @@ -180,7 +180,7 @@ bool InputBuffer::ReadLine(string* out) {
line[len - 1] = '\0';
*out = string(line);
free(line);
#endif // _WIN32
#endif // HAVE_GETLINE
return true;
}

Expand Down

0 comments on commit c3b9b7c

Please sign in to comment.