Skip to content

Commit

Permalink
ncurses6-config, ncurses5.4-config, ncurses5-config, ...
Browse files Browse the repository at this point in the history
  • Loading branch information
berquist committed Mar 8, 2024
1 parent 5ff2e32 commit 1c67b79
Showing 1 changed file with 37 additions and 26 deletions.
63 changes: 37 additions & 26 deletions config/sst_check_curses.m4
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,59 @@ AC_DEFUN([SST_CHECK_CURSES],
AC_ARG_WITH([curses],
[AS_HELP_STRING([--with-ncurses@<:@=DIR or EXEC@:>@],
[Use ncurses library found in DIR or associated with the ncurses6-config utility specified by EXEC])])
[Use ncurses library found in DIR or associated with the ncursesN-config utility specified by EXEC])])
AS_IF([test "$with_curses" = "no"], [sst_check_curses_happy="no"])
NCURSES_CONFIG_EXE="no"
dnl check if user provided a specific ncurses6-config
dnl check if user provided a specific ncursesN-config
AS_IF([test ! -d "$with_curses"],
[AS_IF([test -x "$with_curses"],
[NCURSES_CONFIG_EXE=$with_curses])])
dnl test ncurses6-config
dnl test ncursesN-config
AS_IF([test $NCURSES_CONFIG_EXE = "no"],
[AS_IF([test -n "$with_curses"],
[AC_PATH_PROGS([NCURSES_CONFIG_EXE], ["ncurses6-config" "ncurses5.4-config" "ncurses5-config"], ["no"], ["$with_curses/bin"])],
[AC_PATH_PROGS([NCURSES_CONFIG_EXE], ["ncurses6-config" "ncurses5.4-config" "ncurses5-config"], ["no"])])])
AS_IF([test $NCURSES_CONFIG_EXE = "no"],
[AS_IF([test -n "$with_curses"],
[AC_PATH_PROGS([NCURSES_CONFIG_EXE], ["ncurses6-config"], ["no"], ["$with_curses/bin"])],
[AC_PATH_PROGS([NCURSES_CONFIG_EXE], ["ncurses6-config"], ["no"])])])
dnl error if ncurses6-config can't be found rather than look for the
dnl don't continue if ncursesN-config can't be found rather than look for the
dnl specific libraries
AC_MSG_CHECKING([ncurses6-config exists])
AC_MSG_RESULT([$NCURSES_CONFIG_EXE])
AS_IF([test $NCURSES_CONFIG_EXE = "no"],
[AC_MSG_ERROR([Unable to locate ncurses6-config utility])])
dnl Older versions only have --libs, not --libs-only-l and --libs-only-L,
dnl which combines the two. Ideally, CURSES_LDFLAGS (sstinfo_x_LDFLAGS)
dnl contains --libs-only-L and CURSES_LIBS (sstinfo_x_LDADD) contains
dnl --libs-only-l, but rather than complicated logic testing the above,
dnl combining everything into LDADD seems acceptable..
CURSES_CPPFLAGS=`$NCURSES_CONFIG_EXE --cflags`
CURSES_LIBS=`$NCURSES_CONFIG_EXE --libs`
CPPFLAGS_saved="$CPPFLAGS"
LDFLAGS_saved="$LDFLAGS"
dnl Check for header
AC_LANG_PUSH([C++])
AC_CHECK_HEADER([ncurses.h], [], [sst_check_curses_happy="no"])
AC_LANG_POP([C++])
CPPFLAGS="$CPPFLAGS_saved"
LDFLAGS="$LDFLAGS_saved"
[
CURSES_CPPFLAGS=
CURSES_LIBS=
sst_check_curses_happy="no"
],
[
dnl Older versions only have --libs, not --libs-only-l and --libs-only-L,
dnl which combines the two. Ideally, CURSES_LDFLAGS (sstinfo_x_LDFLAGS)
dnl contains --libs-only-L and CURSES_LIBS (sstinfo_x_LDADD) contains
dnl --libs-only-l, but rather than complicated logic testing the above,
dnl combining everything into LDADD seems acceptable..
CURSES_CPPFLAGS=`$NCURSES_CONFIG_EXE --cflags`
CURSES_LIBS=`$NCURSES_CONFIG_EXE --libs`
CPPFLAGS_saved="$CPPFLAGS"
LDFLAGS_saved="$LDFLAGS"
CPPFLAGS="$CPPFLAGS $CURSES_CPPFLAGS"
LDFLAGS="$LDFLAGS $CURSES_LIBS"
dnl Check for specific header
AC_LANG_PUSH([C++])
AC_CHECK_HEADER([ncurses.h], [], [sst_check_curses_happy="no"])
AC_LANG_POP([C++])
CPPFLAGS="$CPPFLAGS_saved"
LDFLAGS="$LDFLAGS_saved"
]
)
AC_SUBST([CURSES_CPPFLAGS])
AC_SUBST([CURSES_LIBS])
Expand Down

0 comments on commit 1c67b79

Please sign in to comment.