Skip to content

Commit 3a5446b

Browse files
committed
Use pkg-config for Leptonica compiler flags
The old settings don't work for cross compilations (wrong include path) or require setting LIBLEPT_HEADERSDIR. They are used as fallback if there is no pkg-config configuration. Signed-off-by: Stefan Weil <[email protected]>
1 parent 9ec0c4f commit 3a5446b

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

configure.ac

+23-17
Original file line numberDiff line numberDiff line change
@@ -415,30 +415,36 @@ AC_CHECK_TYPES([mbstate_t],,, [#include "wchar.h"])
415415
# ----------------------------------------
416416

417417
# Check location of leptonica/liblept headers.
418-
AC_MSG_CHECKING([for leptonica])
419418
AC_ARG_VAR([LIBLEPT_HEADERSDIR], [Leptonica headers directory])
420419

421-
have_lept=no
422-
if test "$LIBLEPT_HEADERSDIR" = "" ; then
423-
LIBLEPT_HEADERSDIR="/usr/local/include /usr/include /opt/local/include/leptonica"
424-
fi
425-
for incd in $LIBLEPT_HEADERSDIR
426-
do
427-
for lept in . leptonica liblept
420+
PKG_CHECK_MODULES([LEPTONICA], [lept], [have_lept=true], [have_lept=false])
421+
if !($have_lept); then
422+
AC_MSG_CHECKING([for leptonica])
423+
if test "$LIBLEPT_HEADERSDIR" = "" ; then
424+
LIBLEPT_HEADERSDIR="/usr/local/include /usr/include /opt/local/include/leptonica"
425+
fi
426+
for incd in $LIBLEPT_HEADERSDIR
428427
do
429-
if test -r "$incd/$lept/allheaders.h" ; then
430-
CPPFLAGS="$CPPFLAGS -I$incd/$lept"
431-
have_lept=yes
432-
fi
428+
for lept in . leptonica liblept
429+
do
430+
if test -r "$incd/$lept/allheaders.h" ; then
431+
CPPFLAGS="$CPPFLAGS -I$incd/$lept"
432+
have_lept=true
433+
fi
434+
done
433435
done
434-
done
436+
if $have_lept; then
437+
AC_MSG_RESULT(yes)
438+
else
439+
AC_MSG_ERROR([leptonica not found])
440+
fi
441+
else
442+
CPPFLAGS="$CPPFLAGS $LEPTONICA_CFLAGS"
443+
fi
435444

436-
if test "$have_lept" = yes ; then
437-
AC_MSG_RESULT(yes)
445+
if $have_lept; then
438446
AC_CHECK_LIB([lept], [l_generateCIDataForPdf], [],
439447
[AC_MSG_ERROR([leptonica library with pdf support (>= 1.71) is missing])])
440-
else
441-
AC_MSG_ERROR([leptonica not found])
442448
fi
443449

444450
AC_MSG_CHECKING([leptonica headers version >= 1.71])

0 commit comments

Comments
 (0)