1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
AC_INIT([Haskell readline package], [1.0], [libraries@haskell.org], [readline])
FP_ARG_READLINE
if test "$enable_readline" = no; then
READLINE_BUILD_PACKAGE=no
BUILD_PACKAGE_BOOL=False
else
# Safety check: Ensure that we are in the correct source directory.
AC_CONFIG_SRCDIR([include/HsReadline.h])
AC_CONFIG_HEADERS([include/HsReadlineConfig.h])
READLINE_INCLUDE_DIRS=
READLINE_LIB_DIRS=
if test "x$readline_libraries" != "xNONE"; then
LDFLAGS="-L$readline_libraries $LDFLAGS"
READLINE_LDFLAGS="-L$readline_libraries $READLINE_LDFLAGS"
READLINE_LIB_DIRS=$readline_libraries
fi
if test "x$readline_includes" != "xNONE"; then
CPPFLAGS="-I$readline_includes $CPPFLAGS"
READLINE_CFLAGS="-I$readline_includes $READLINE_CFLAGS"
READLINE_INCLUDE_DIRS=$readline_includes
fi
AC_SUBST(READLINE_INCLUDE_DIRS)
AC_SUBST(READLINE_LIB_DIRS)
AC_ARG_WITH([cc],
[C compiler],
[CC=$withval])
AC_PROG_CC()
# Mac OS X only: check for GNUreadline.framework (should be harmless on other systems)
# If it's found, we'll prefer it over linking via "-lreadline".
if test "x$readline_libraries" = "xNONE" && test "x$readline_includes" = "xNONE" ; then
AC_MSG_CHECKING([for GNUreadline.framework])
save_libs="$LIBS"
LIBS="-framework GNUreadline"
AC_CHECK_FUNC(readline, HaveFrameworkReadline=YES, HaveFrameworkReadline=NO)
LIBS="$save_libs"
fi
if test "x$HaveFrameworkReadline" = xYES ; then
LIBS="-framework GNUreadline $LIBS"
READLINE_FRAMEWORKS="GNUreadline"
AC_DEFINE([HAVE_FRAMEWORK_READLINE], [1], [Define to 1 if we're using GNUreadline.framework.])
else
dnl ** check for readline, for Hugs and hslibs' Readline
dnl ncurses supersedes termcap and curses, but for compatibility,
dnl we have to check for all...
AC_CHECK_LIB(ncurses, tputs, HaveLibTermcap=YES; LibTermcap=ncurses,
AC_CHECK_LIB(termcap, tputs, HaveLibTermcap=YES; LibTermcap=termcap,
AC_CHECK_LIB(curses, tputs, HaveLibTermcap=YES; LibTermcap=curses,
HaveLibTermcap=NO; LibTermcap=not-installed)))
if test $HaveLibTermcap = YES ; then
LIBS="-l$LibTermcap $LIBS"
AC_CHECK_LIB(readline, readline, HaveLibReadline=YES)
READLINE_LIBS="readline $LibTermcap"
LIBS="$LIBS -lreadline"
fi
fi
dnl ** At this point, $LIB should be completely set, so we can use AC_CHECK_FUNC from now on.
dnl ** Is our readline really readline, or is it BSD's libedit?
dnl ** Second test is necessary on Mac OS X 10.5.
AC_CHECK_FUNC(rl_readline_version, ReadlineIsLibedit=NO, ReadlineIsLibedit=YES)
if test "x$ReadlineIsLibedit" = xNO ; then
AC_CHECK_FUNC(rl_begin_undo_group, , ReadlineIsLibedit=YES)
fi
if (test "x$HaveLibReadline" = xYES || test "x$HaveFrameworkReadline" = xYES) && test "x$ReadlineIsLibedit" = xNO ; then
HAVE_READLINE=YES
else
AC_MSG_FAILURE([readline not found, so this package cannot be built])
HAVE_READLINE=NO
fi
if test "x$HAVE_READLINE" = xYES ; then
AC_CHECK_FUNC(rl_erase_empty_line,
[AC_DEFINE([HAVE_READLINE_4], [1], [Define to 1 if readline has version >= 4.0.])],
[AC_DEFINE([HAVE_READLINE_4], [0], [Define to 1 if readline has version >= 4.0.])])
AC_CHECK_FUNC(rl_free_undo_list,
[AC_DEFINE([HAVE_READLINE_4_2], [1], [Define to 1 if readline has version >= 4.2.])],
[AC_DEFINE([HAVE_READLINE_4_2], [0], [Define to 1 if readline has version >= 4.2.])])
AC_CHECK_LIB(readline, rl_completion_word_break_hook,
[AC_DEFINE([HAVE_READLINE_5], [1], [Define to 1 if readline has version >= 5.0.])],
[AC_DEFINE([HAVE_READLINE_5], [0], [Define to 1 if readline has version >= 5.0.])])
else
AC_DEFINE([HAVE_READLINE_4], [0], [Define to 1 if readline has version >= 4.0.])
AC_DEFINE([HAVE_READLINE_4_2], [0], [Define to 1 if readline has version >= 4.2.])
AC_DEFINE([HAVE_READLINE_5], [0], [Define to 1 if readline has version >= 5.0.])
fi
if test "x$HAVE_READLINE" = xYES; then
READLINE_BUILD_PACKAGE=yes
BUILD_PACKAGE_BOOL=True
else
READLINE_BUILD_PACKAGE=no
BUILD_PACKAGE_BOOL=False
fi
fi
AC_SUBST([READLINE_BUILD_PACKAGE])
AC_SUBST([BUILD_PACKAGE_BOOL])
AC_SUBST([READLINE_CFLAGS])
AC_SUBST([READLINE_LDFLAGS])
AC_SUBST([READLINE_LIBS])
AC_SUBST([READLINE_FRAMEWORKS])
AC_CONFIG_FILES([config.mk readline.buildinfo])
AC_OUTPUT
|