]> granicus.if.org Git - neomutt/commitdiff
Build: restructure ncurses/tinfo checks (#1119)
authorPietro Cerutti <gahr@gahr.ch>
Thu, 5 Apr 2018 11:20:31 +0000 (12:20 +0100)
committerGitHub <noreply@github.com>
Thu, 5 Apr 2018 11:20:31 +0000 (12:20 +0100)
* 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

auto.def

index 1d492ff20567dbd25ff48274fe7f957d4b84fc52..b6155c8cafcb31612170184ad3c0924e5b371d23 100644 (file)
--- a/auto.def
+++ b/auto.def
@@ -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
     }