Skip to content

Commit

Permalink
Build: restructure ncurses/tinfo checks (#1119)
Browse files Browse the repository at this point in the history
* Build: restructure ncurses/tinfo checks

Issue #1118

* Fallback to ncurses library for tgetent

This fixes the configure phase in NetBSD, which doesn't have a separate
tinfo library in base.

Issue #1118
  • Loading branch information
gahr committed Apr 5, 2018
1 parent 92914f2 commit 6c995c7
Showing 1 changed file with 30 additions and 22 deletions.
52 changes: 30 additions & 22 deletions auto.def
Original file line number Diff line number Diff line change
Expand Up @@ -470,45 +470,53 @@ if {[get-define want-fmemopen]} {
switch [opt-val with-ui ncurses] {
ncurses {
define-append CFLAGS -DNCURSES_WIDECHAR
# Locate the library defining waddnwstr()
set ncurses_prefix [opt-val with-ncurses $prefix]

cc-with [list -libs -L$ncurses_prefix/lib] {
foreach ncurses_lib {ncursesw ncurses curses} {
if {[cc-check-function-in-lib waddnwstr $ncurses_lib]} {

set tinfo_libs {tinfow tinfo}
set ncurses_libs {ncursesw ncurses curses}

# Locate the library defining tgetent()
# This must be done *before* checking for ncurses functions, see
# https://github.com/neomutt/neomutt/issues/1118
foreach tinfo_lib [concat $tinfo_libs $ncurses_libs] {
if {[cc-check-function-in-lib tgetent $tinfo_lib]} {
break
}
}
}
if {![have-feature waddnwstr]} {
user-error "Unable to find ncursesw library"
}

# Locate the directory containing ncurses.h
# See https://github.com/neomutt/neomutt/pull/679
set found 0
cc-with [list -cflags -I$ncurses_prefix/include] {
foreach ncurses_inc {ncursesw/ ncurses/ curses/ {}} {
if {[cc-check-includes ${ncurses_inc}ncurses.h] ||
[cc-check-includes ${ncurses_inc}curses.h]} {
set found 1
# Locate the library defining waddnwstr()
foreach ncurses_lib $ncurses_libs {
if {[cc-check-function-in-lib waddnwstr $ncurses_lib]} {
break
}
}
}
if {!$found} {
user-error "Unable to find ncurses headers"
}

cc-with [list -libs -L$ncurses_prefix/lib] {
if {![cc-check-function-in-lib tgetent $ncurses_lib]} {
cc-check-function-in-lib tgetent tinfo
if {![have-feature waddnwstr] || ![have-feature tgetent]} {
user-error "Unable to find ncursesw library"
}

foreach f {start_color typeahead bkgdset curs_set meta use_default_colors} {
cc-check-function-in-lib $f $ncurses_lib
}
cc-check-functions use_extended_names
}

# Locate the directory containing ncurses.h
# See https://github.com/neomutt/neomutt/pull/679
apply {{ncurses_prefix} {
cc-with [list -cflags -I$ncurses_prefix/include] {
foreach ncurses_inc {ncursesw/ ncurses/ curses/ {}} {
if {[cc-check-includes ${ncurses_inc}ncurses.h] ||
[cc-check-includes ${ncurses_inc}curses.h]} {
return
}
}
user-error "Unable to find ncurses headers"
}
}} $ncurses_prefix

if {[have-feature start_color]} {
define-feature COLOR
}
Expand Down

0 comments on commit 6c995c7

Please sign in to comment.