1
0
Fork 0

Fixed --enabled-debug on Windows MSYS2

This fixes the prior logic that relies on the (*)curses library
and header existing in compiler-derived default locations
such as /usr/include, and /usr/lib. However, if the package manager
happens to not install them there, then they will not be found
and the check will fail.

Four scenarios:
1. `./configure` or `./configure --enable-debug=no` produce:
    (no mention of debugger; configure continues)

2. `./configure --enable-debug=wrong` produces:
    configure: error: --enable-debug=wrong was requested but the value "wrong" is invalid
    (terminates with exit code 1)

3. `./configure --enable-debug` produces:

    config.h:
    defines C_DEBUG 1

    With only ncurses library installed:

    configure: debugger was requested, finding curses library ...
    checking for NCURSES... yes
    configure: debugger enabled using the ncurses library

    Makefile:
    CPPFLAGS = ... -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -I/usr/local/ncurses ...
    LIBS = ...  -L/usr/local/ncurses -lncurses -ltinfo ...

    With only ncursesw installed:

    configure: debugger was requested, finding curses library ...
    checking for NCURSES... no
    checking for NCURSESW... yes
    configure: debugger enabled using the ncursesw library

    Makefile:
    CPPFLAGS = ... -I/opt/ncursesw ...
    LIBS = ... -L/opt/ncursesw -lncursesw ...

    With only pdcurses isntalled:

    configure: debugger was requested, finding curses library ...
    checking for NCURSES... no
    checking for NCURSESW... no
    checking for PDCURSES... yes
    configure: debugger enabled using the pdcurses library

    Makefile:
    CPPFLAGS = ... -I/usr/local/pdcurses ...
    LIBS = ...  -L/usr/local/pdcurses -lpdcurses -ltinfo ...

    Without any curses library installed:

    configure: debugger was requested, finding curses library ...
    checking for NCURSES... no
    checking for NCURSESW... no
    checking for PDCURSES... no
    configure: error: Package requirements were not met:
    <pkg-info prints info about missing package>
    (terminates with exit code 1)

4. `./configure --enable-debug=heavy` produces same as above, but:

    config.h:
    defines C_DEBUG 1
    defines C_HEAVY_DEBUG 1

    The configure message mentions heavy, for example:

    configure: debugger was requested, finding curses library ...
    checking for NCURSES... yes
    configure: debugger with heavy debugging enabled using the ncurses library
This commit is contained in:
krcroft 2019-12-13 02:43:53 -08:00 committed by Patryk Obara
parent 5cc7e300e5
commit 12ee84cfd4
4 changed files with 53 additions and 44 deletions

View file

@ -4,6 +4,9 @@ AC_DEFINE([CONF_BRAND],["staging-git"],[Suffix of the .conf file.])
AC_PREREQ(2.50)
AC_CONFIG_SRCDIR(README)
dnl Check for pkg-config
PKG_PROG_PKG_CONFIG
dnl Detect the canonical host and target build environment
AC_CANONICAL_HOST
AC_CANONICAL_BUILD
@ -230,38 +233,35 @@ fi
AC_C_BIGENDIAN
#Features to enable/disable
AH_TEMPLATE(C_DEBUG,[Define to 1 to enable internal debugger, requires libcurses])
AH_TEMPLATE(C_HEAVY_DEBUG,[Define to 1 to enable heavy debugging, also have to enable C_DEBUG])
AC_ARG_ENABLE(debug,AC_HELP_STRING([--enable-debug],[Enable debug mode]),[
AC_CHECK_HEADER(curses.h,have_curses_h=yes,)
AC_CHECK_LIB(curses, initscr, have_curses_lib=yes, , )
AC_CHECK_LIB(ncurses, initscr, have_ncurses_lib=yes, , )
AC_CHECK_LIB(pdcurses, initscr, have_pdcurses_lib=yes, , )
if test x$enable_debug = xno; then
AC_MSG_RESULT([Debugger not enabled])
elif test x$have_ncurses_lib = xyes -a x$have_curses_h = xyes ; then
LIBS="$LIBS -lncurses"
AC_DEFINE(C_DEBUG,1)
if test x$enable_debug = xheavy ; then
AC_DEFINE(C_HEAVY_DEBUG,1)
fi
elif test x$have_curses_lib = xyes -a x$have_curses_h = xyes ; then
LIBS="$LIBS -lcurses"
AC_DEFINE(C_DEBUG,1)
if test x$enable_debug = xheavy ; then
AC_DEFINE(C_HEAVY_DEBUG,1)
fi
elif test x$have_pdcurses_lib = xyes -a x$have_curses_h = xyes ; then
LIBS="$LIBS -lpdcurses"
AC_DEFINE(C_DEBUG,1)
if test x$enable_debug = xheavy ; then
AC_DEFINE(C_HEAVY_DEBUG,1)
fi
else
AC_MSG_ERROR([Can't find curses, which is required for debug mode])
fi
],)
AH_TEMPLATE(C_DEBUG,[Define to 1 to enable internal debugger, requires ncurses or pdcurses])
AH_TEMPLATE(C_HEAVY_DEBUG,[Define to 1 to enable heavy debugging, requires C_DEBUG])
AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable internal debugger]),,)
AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug=heavy], [Enable internal debugger with heavy debugging]),,)
if test x$enable_debug = xyes -o x$enable_debug = xheavy; then
AC_MSG_NOTICE([debugger was requested, finding curses library ...])
PKG_CHECK_MODULES(NCURSES, ncurses, [
curses=ncurses
LIBS="$LIBS ${NCURSES_LIBS}"
CPPFLAGS="$CPPFLAGS ${NCURSES_CFLAGS}"], [
PKG_CHECK_MODULES(NCURSESW, ncursesw, [
curses=ncursesw
LIBS="$LIBS ${NCURSESW_LIBS}"
CPPFLAGS="$CPPFLAGS ${NCURSESW_CFLAGS}"], [
PKG_CHECK_MODULES(PDCURSES, pdcurses, [
curses=pdcurses
LIBS="$LIBS ${PDCURSES_LIBS}"
CPPFLAGS="$CPPFLAGS ${PDCURSES_CFLAGS}"],[]) ]) ])
if test x$enable_debug = xyes; then
AC_DEFINE(C_DEBUG,1)
AC_MSG_NOTICE([debugger enabled using the $curses library])
else
AC_DEFINE(C_DEBUG,1)
AC_DEFINE(C_HEAVY_DEBUG,1)
AC_MSG_NOTICE([debugger with heavy debugging enabled using the $curses library])
fi
elif test empty$enable_debug != empty -a x$enable_debug != xno; then
AC_MSG_ERROR(--enable-debug=$enable_debug was requested but the value "$enable_debug" is invalid)
fi
AH_TEMPLATE(C_CORE_INLINE,[Define to 1 to use inlined memory functions in cpu core])
AC_ARG_ENABLE(core-inline,AC_HELP_STRING([--disable-core-inline],[Disable inlined memory handling in CPU Core]),,enable_core_inline=yes)