mirror of
https://github.com/MidnightCommander/mc
synced 2025-03-12 10:53:23 +03:00
Restructure with-screen ncurses m4 logic
Search order: 1) system path (adjust by --with-ncurses-libdir=<DIR>, --with-ncurses-includedir=<DIR>) 2) pkg-config (adjust by NCURSES_LIBS, NCURSES_CFLAGS) Preference: ncursesw > ncurses more document at source code Signed-off-by: Andreas Mohr <and@gmx.li> Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
8d62147883
commit
71db61b9df
@ -1,214 +1,125 @@
|
|||||||
dnl check for ncurses in user supplied path
|
|
||||||
AC_DEFUN([mc_CHECK_NCURSES_BY_PATH], [
|
|
||||||
|
|
||||||
ac_ncurses_inc_path=[$1]
|
|
||||||
ac_ncurses_lib_path=[$2]
|
|
||||||
|
|
||||||
if test x"$ac_ncurses_inc_path" != x; then
|
|
||||||
ac_ncurses_inc_path="-I"$ac_ncurses_inc_path
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test x"$ac_ncurses_lib_path" != x; then
|
|
||||||
ac_ncurses_lib_path="-L"$ac_ncurses_lib_path
|
|
||||||
fi
|
|
||||||
|
|
||||||
saved_CPPFLAGS="$CPPFLAGS"
|
|
||||||
saved_LDFLAGS="$LDFLAGS"
|
|
||||||
CPPFLAGS="$CPPFLAGS $ac_ncurses_inc_path"
|
|
||||||
LDFLAGS="$LDFLAGS $ac_ncurses_lib_path"
|
|
||||||
|
|
||||||
dnl Check for the headers
|
|
||||||
dnl Both headers should be in the same directory
|
|
||||||
dnl AIX term.h is unusable for mc
|
|
||||||
AC_MSG_CHECKING([for ncurses/ncurses.h and ncurses/term.h])
|
|
||||||
AC_PREPROC_IFELSE(
|
|
||||||
[
|
|
||||||
AC_LANG_PROGRAM([[#include <ncurses/ncurses.h>
|
|
||||||
#include <ncurses/term.h>
|
|
||||||
]],[[return 0;]])
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AC_MSG_RESULT(yes)
|
|
||||||
if test x"$ac_ncurses_inc_path" = x; then
|
|
||||||
ac_ncurses_inc_path="-I/usr/include"
|
|
||||||
fi
|
|
||||||
if test x"$ac_ncurses_lib_path" = x; then
|
|
||||||
ac_ncurses_lib_path="-L/usr/lib"
|
|
||||||
fi
|
|
||||||
found_ncurses=yes
|
|
||||||
AC_DEFINE(HAVE_NCURSES_NCURSES_H, 1,
|
|
||||||
[Define to 1 if you have the <ncurses/ncurses.h> header file.])
|
|
||||||
AC_DEFINE(HAVE_NCURSES_TERM_H, 1,
|
|
||||||
[Define to 1 if you have the <ncurses/term.h> header file.])
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AC_MSG_RESULT(no)
|
|
||||||
found_ncurses=no
|
|
||||||
error_msg_ncurses="ncurses header not found"
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
if test x"$found_ncurses" = x"yes"; then
|
|
||||||
screen_type=ncurses
|
|
||||||
screen_msg="NCurses"
|
|
||||||
|
|
||||||
AC_DEFINE(HAVE_NCURSES, 1,
|
|
||||||
[Define to use ncurses library for screen management])
|
|
||||||
|
|
||||||
MCLIBS="$MCLIBS $ac_ncurses_lib_path"
|
|
||||||
else
|
|
||||||
CPPFLAGS="$saved_CPPFLAGS"
|
|
||||||
LDFLAGS="$saved_LDPFLAGS"
|
|
||||||
AC_MSG_ERROR([$error_msg_ncurses])
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl Use the ncurses library. It can only be requested explicitly,
|
dnl Use the NCurses library. It can only be requested explicitly,
|
||||||
dnl so just fail if anything goes wrong.
|
dnl so just fail if anything goes wrong.
|
||||||
dnl
|
dnl
|
||||||
dnl If ncurses exports the ESCDELAY variable it should be set to 0
|
dnl Search order:
|
||||||
dnl or you'll have to press Esc three times to dismiss a dialog box.
|
dnl 1) system path (adjust by --with-ncurses-libdir=<DIR>, --with-ncurses-includedir=<DIR>)
|
||||||
|
dnl 2) pkg-config (adjust by NCURSES_LIBS, NCURSES_CFLAGS)
|
||||||
dnl
|
dnl
|
||||||
|
dnl Preference:
|
||||||
|
dnl ncursesw > ncurses
|
||||||
|
dnl
|
||||||
|
dnl Rules:
|
||||||
|
dnl LIBS can be prepended
|
||||||
|
dnl CFLAGS can be appended (compiler optimizations and directives look at the last options)
|
||||||
|
dnl CPPFLAGS can be prepended (header search paths options look at the first path)
|
||||||
|
dnl
|
||||||
|
|
||||||
AC_DEFUN([mc_WITH_NCURSES], [
|
AC_DEFUN([mc_WITH_NCURSES], [
|
||||||
dnl has_colors() is specific to ncurses, it's not in the old curses
|
|
||||||
save_LIBS="$LIBS"
|
save_LIBS="$LIBS"
|
||||||
ncursesw_found=
|
save_CFLAGS="$CFLAGS"
|
||||||
|
save_CPPFLAGS="$CPPFLAGS"
|
||||||
|
save_MCLIBS="$MCLIBS"
|
||||||
|
|
||||||
dnl get the user supplied include path
|
AC_MSG_CHECKING([for specific NCurses libdir])
|
||||||
AC_ARG_WITH([ncurses-includes],
|
AC_ARG_WITH([ncurses-libdir],
|
||||||
AS_HELP_STRING([--with-ncurses-includes=@<:@DIR@:>@],
|
[AS_HELP_STRING([--with-ncurses-libdir=@<:@DIR@:>@], [Path to NCurses library files])],
|
||||||
[set path to ncurses includes @<:@default=/usr/include@:>@; make sense only if --with-screen=ncurses; for /usr/local/include/ncurses specify /usr/local/include]
|
[AS_IF([test ! -d "$withval"], [AC_MSG_ERROR([NCurses libdir path "$withval" not found])])
|
||||||
),
|
LIBS="-L$withval $LIBS"
|
||||||
[ac_ncurses_inc_path="$withval"],
|
LDFLAGS="-L$withval $LIBS"
|
||||||
[ac_ncurses_inc_path=""]
|
MCLIBS="-L$withval $MCLIBS"],
|
||||||
)
|
[with_ncurses_libdir=no])
|
||||||
|
AC_MSG_RESULT([$with_ncurses_libdir])
|
||||||
|
|
||||||
dnl get the user supplied lib path
|
AC_MSG_CHECKING([for specific NCurses includedir])
|
||||||
AC_ARG_WITH([ncurses-libs],
|
AC_ARG_WITH([ncurses-includedir],
|
||||||
AS_HELP_STRING([--with-ncurses-libs=@<:@DIR@:>@],
|
[AS_HELP_STRING([--with-ncurses-includedir=@<:@DIR@:>@], [Path to NCurses header files])],
|
||||||
[set path to ncurses library @<:@default=/usr/lib@:>@; make sense only if --with-screen=ncurses]
|
[AS_IF([test ! -d "$withval"], [AC_MSG_ERROR([NCurses includedir path "$withval" not found])])
|
||||||
),
|
CFLAGS="$save_CFLAGS -I$withval"],
|
||||||
[ac_ncurses_lib_path="$withval"],
|
[with_ncurses_includedir=no])
|
||||||
[ac_ncurses_lib_path=""]
|
AC_MSG_RESULT([$with_ncurses_includedir])
|
||||||
)
|
|
||||||
|
|
||||||
dnl we need at least the inc path, the lib may be in a std location
|
dnl
|
||||||
if test x"$ac_ncurses_inc_path" != x; then
|
dnl Check ncurses library
|
||||||
dnl check the user supplied location
|
dnl
|
||||||
mc_CHECK_NCURSES_BY_PATH([$ac_ncurses_inc_path],[$ac_ncurses_lib_path])
|
dnl has_colors is specific to ncurses, it's not in the old curses
|
||||||
|
dnl search in default linker path and LDFLAGS -L options
|
||||||
|
AC_SEARCH_LIBS([has_colors], [ncursesw ncurses],
|
||||||
|
[AS_CASE(["$ac_cv_search_has_colors"],
|
||||||
|
["-lncursesw"], [screen_msg="NCursesw"],
|
||||||
|
["-lncurses"], [screen_msg="NCurses"],
|
||||||
|
["none required"], [screen_msg="NCurses static"], dnl or system native? Who knows
|
||||||
|
[AC_MSG_ERROR([Unknown ac_cv_search_has_colors option "$ac_cv_search_has_colors"])])
|
||||||
|
],
|
||||||
|
dnl 2. Library not found by system path, try pkg-config
|
||||||
|
[PKG_CHECK_MODULES([NCURSES], [ncursesw],
|
||||||
|
[ LIBS="$NCURSES_LIBS $save_LIBS"
|
||||||
|
MCLIBS="$NCURSES_LIBS $save_MCLIBS"
|
||||||
|
CFLAGS="$save_CFLAGS $NCURSES_CFLAGS"
|
||||||
|
screen_msg="NCursesw"
|
||||||
|
AC_CHECK_FUNC([has_colors], [], dnl Always validate pkg-config result
|
||||||
|
[AC_MSG_ERROR([NCursesw pkg-config insufficient])])
|
||||||
|
],
|
||||||
|
[PKG_CHECK_MODULES([NCURSES], [ncurses],
|
||||||
|
[ LIBS="$NCURSES_LIBS $save_LIBS"
|
||||||
|
MCLIBS="$NCURSES_LIBS $save_MCLIBS"
|
||||||
|
CFLAGS="$save_CFLAGS $NCURSES_CFLAGS"
|
||||||
|
screen_msg="NCurses"
|
||||||
|
AC_CHECK_FUNC([has_colors], [], dnl Always validate pkg-config result
|
||||||
|
[AC_MSG_ERROR([NCurses pkg-config insufficient])])
|
||||||
|
],
|
||||||
|
[AC_MSG_ERROR([(N)Curses(w) library not found by system path neither pkg-config])])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
LIBS="$MCLIBS"
|
AC_SEARCH_LIBS([stdscr], [tinfow tinfo], [],
|
||||||
AC_SEARCH_LIBS([has_colors], [ncurses], [],
|
dnl 2. Library not found by system path, try pkg-config
|
||||||
[AC_MSG_ERROR([Cannot find ncurses library])])
|
[PKG_CHECK_MODULES([TINFOW], [tinfow], [],
|
||||||
AC_SEARCH_LIBS([stdscr], [tinfo], [],
|
[AC_CHECK_FUNC([stdscr], [], dnl Always validate pkg-config result
|
||||||
[AC_MSG_ERROR([Cannot find a library providing stdscr])])
|
[AC_MSG_ERROR([Tinfow pkg-config insufficient])])],
|
||||||
MCLIBS="$LIBS"
|
[PKG_CHECK_MODULES([TINFO], [tinfo],
|
||||||
|
[AC_CHECK_FUNC([stdscr], [], dnl Always validate pkg-config result
|
||||||
|
[AC_MSG_ERROR([Tinfo pkg-config insufficient])])],
|
||||||
|
[AC_MSG_ERROR([Tinfo(w) library not found by system path neither pkg-config])])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
screen_type=ncurses
|
AC_CHECK_FUNC([addwstr], [],
|
||||||
screen_msg="NCurses"
|
[AC_MSG_WARN([NCurses(w) library found without wide characters support])])
|
||||||
AC_DEFINE(USE_NCURSES, 1,
|
|
||||||
[Define to use ncurses for screen management])
|
|
||||||
else
|
|
||||||
LIBS="$MCLIBS"
|
|
||||||
AC_SEARCH_LIBS([addwstr], [ncursesw ncurses curses], [ncursesw_found=yes],
|
|
||||||
[AC_MSG_WARN([Cannot find ncurses library, that support wide characters])])
|
|
||||||
MCLIBS="$LIBS"
|
|
||||||
|
|
||||||
if test x"$ncursesw_found" = "x"; then
|
dnl
|
||||||
LIBS="$MCLIBS"
|
dnl Check ncurses header
|
||||||
AC_SEARCH_LIBS([has_colors], [ncurses curses], [],
|
dnl
|
||||||
[AC_MSG_ERROR([Cannot find ncurses library])])
|
dnl Set CPPFLAGS to avoid AC_CHECK_HEADERS warning "accepted by the compiler, rejected by the preprocessor!"
|
||||||
MCLIBS="$LIBS"
|
CPPFLAGS="$CFLAGS"
|
||||||
fi
|
dnl first match wins, using break
|
||||||
LIBS="$MCLIBS"
|
AC_CHECK_HEADERS([ncursesw/ncurses.h ncursesw/curses.h ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h],
|
||||||
AC_SEARCH_LIBS([stdscr], [tinfow tinfo], [],
|
[ncurses_h_found=yes; break],
|
||||||
[AC_MSG_ERROR([Cannot find a library providing stdscr])])
|
[ncurses_h_found=no])
|
||||||
MCLIBS="$LIBS"
|
|
||||||
|
|
||||||
dnl Check the header
|
AS_IF([test x"$ncurses_h_found" != xyes],
|
||||||
ncurses_h_found=
|
[AC_MSG_ERROR([NCurses(w) header file not found])])
|
||||||
AC_CHECK_HEADERS([ncursesw/curses.h ncurses/curses.h ncurses.h curses.h],
|
|
||||||
[ncurses_h_found=yes; break])
|
|
||||||
|
|
||||||
if test x"$ncurses_h_found" = "x"; then
|
AC_CHECK_HEADERS([ncursesw/term.h ncurses/term.h term.h],
|
||||||
AC_MSG_ERROR([Cannot find ncurses header file])
|
[ncurses_term_h_found=yes; break],
|
||||||
fi
|
[ncurses_term_h_found=no])
|
||||||
|
|
||||||
AC_CHECK_HEADERS([ncurses/term.h])
|
AS_IF([test x"$ncurses_term_h_found" != xyes],
|
||||||
|
[AC_MSG_ERROR([NCurses(w) term.h header file not found])])
|
||||||
|
|
||||||
screen_type=ncurses
|
dnl If ncurses exports the ESCDELAY variable it should be set to 0
|
||||||
screen_msg="NCurses"
|
dnl or you'll have to press Esc three times to dismiss a dialog box.
|
||||||
AC_DEFINE(USE_NCURSES, 1,
|
AC_CACHE_CHECK([for ESCDELAY variable], [mc_cv_ncurses_escdelay],
|
||||||
[Define to use ncurses for screen management])
|
[AC_LINK_IFELSE(
|
||||||
fi
|
[AC_LANG_PROGRAM([[extern int ESCDELAY;]],[[ESCDELAY = 0;]])],
|
||||||
|
[mc_cv_ncurses_escdelay=yes], [mc_cv_ncurses_escdelay=no])
|
||||||
|
])
|
||||||
|
|
||||||
dnl check for ESCDELAY
|
AS_IF([test x"$mc_cv_ncurses_escdelay" = xyes],
|
||||||
AC_CACHE_CHECK([for ESCDELAY variable],
|
[AC_DEFINE([HAVE_ESCDELAY], [1], [Define if NCurses(w) has ESCDELAY variable])])
|
||||||
[mc_cv_ncurses_escdelay],
|
|
||||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
|
|
||||||
extern int ESCDELAY;
|
|
||||||
ESCDELAY = 0;
|
|
||||||
]])],
|
|
||||||
[mc_cv_ncurses_escdelay=yes],
|
|
||||||
[mc_cv_ncurses_escdelay=no])
|
|
||||||
])
|
|
||||||
if test x"$mc_cv_ncurses_escdelay" = xyes; then
|
|
||||||
AC_DEFINE(HAVE_ESCDELAY, 1,
|
|
||||||
[Define if ncurses has ESCDELAY variable])
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl check for resizeterm
|
|
||||||
AC_CHECK_FUNCS(resizeterm)
|
|
||||||
LIBS="$save_LIBS"
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Use the ncursesw library. It can only be requested explicitly,
|
|
||||||
dnl so just fail if anything goes wrong.
|
|
||||||
dnl
|
|
||||||
dnl If ncursesw exports the ESCDELAY variable it should be set to 0
|
|
||||||
dnl or you'll have to press Esc three times to dismiss a dialog box.
|
|
||||||
dnl
|
|
||||||
|
|
||||||
AC_DEFUN([mc_WITH_NCURSESW], [
|
|
||||||
dnl has_colors() is specific to ncurses, it's not in the old curses
|
|
||||||
save_LIBS="$LIBS"
|
|
||||||
LIBS=
|
|
||||||
AC_SEARCH_LIBS([has_colors], [ncursesw], [MCLIBS="$MCLIBS $LIBS"],
|
|
||||||
[AC_MSG_ERROR([Cannot find ncursesw library])])
|
|
||||||
AC_SEARCH_LIBS([stdscr], [tinfow ncursesw], [MCLIBS="$MCLIBS $LIBS"],
|
|
||||||
[AC_MSG_ERROR([Cannot find a library providing stdscr])])
|
|
||||||
|
|
||||||
|
|
||||||
dnl Check the header
|
|
||||||
ncurses_h_found=
|
|
||||||
AC_CHECK_HEADERS([ncursesw/curses.h],
|
|
||||||
[ncursesw_h_found=yes; break])
|
|
||||||
|
|
||||||
if test x"$ncursesw_h_found" = "x"; then
|
|
||||||
AC_MSG_ERROR([Cannot find ncursesw header file])
|
|
||||||
fi
|
|
||||||
|
|
||||||
screen_type=ncursesw
|
|
||||||
screen_msg="NCursesw"
|
|
||||||
AC_DEFINE(USE_NCURSESW, 1,
|
|
||||||
[Define to use ncursesw for screen management])
|
|
||||||
|
|
||||||
AC_CACHE_CHECK([for ESCDELAY variable],
|
|
||||||
[mc_cv_ncursesw_escdelay],
|
|
||||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
|
|
||||||
extern int ESCDELAY;
|
|
||||||
ESCDELAY = 0;
|
|
||||||
]])],
|
|
||||||
[mc_cv_ncursesw_escdelay=yes],
|
|
||||||
[mc_cv_ncursesw_escdelay=no])
|
|
||||||
])
|
|
||||||
if test x"$mc_cv_ncursesw_escdelay" = xyes; then
|
|
||||||
AC_DEFINE(HAVE_ESCDELAY, 1,
|
|
||||||
[Define if ncursesw has ESCDELAY variable])
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_CHECK_FUNCS(resizeterm)
|
AC_CHECK_FUNCS(resizeterm)
|
||||||
LIBS="$save_LIBS"
|
|
||||||
|
AC_DEFINE([HAVE_NCURSES], [1], [Define to use NCurses for screen management])
|
||||||
|
AC_DEFINE_UNQUOTED([NCURSES_LIB_DISPLAYNAME], ["$screen_msg"], [Define NCurses library display name])
|
||||||
])
|
])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user