about summary refs log tree commit diff stats
path: root/src/bindings
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-11-21 10:49:57 +0100
committerbptato <nincsnevem662@gmail.com>2023-11-21 10:49:57 +0100
commitf5d31c6ae463b9e149c8e7b9222b9be9cba089e8 (patch)
tree6d55ef8fdaa9b3f783127520b227102add830de0 /src/bindings
parentcf948921164d7d8a156de8b9d1b256da0d3e1ce7 (diff)
downloadchawan-f5d31c6ae463b9e149c8e7b9222b9be9cba089e8.tar.gz
bindings: find termcap on FreeBSD
pkg-config does not find termcap (or really, ncurses) here, so we
have to find it ourselves.
Diffstat (limited to 'src/bindings')
-rw-r--r--src/bindings/termcap.nim15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/bindings/termcap.nim b/src/bindings/termcap.nim
index 02962a67..5a98ccc0 100644
--- a/src/bindings/termcap.nim
+++ b/src/bindings/termcap.nim
@@ -1,9 +1,20 @@
-const termlib = (func(): string =
-  let libs = ["terminfo", "mytinfo", "termlib", "termcap", "tinfo", "ncurses", "curses"]
+import os
+const termlib = (proc(): string =
+  const libs = [
+    "terminfo", "mytinfo", "termlib", "termcap", "tinfo", "ncurses", "curses"
+  ]
   for lib in libs:
     let res = staticExec("pkg-config --libs --silence-errors " & lib)
     if res != "":
       return res
+  # Apparently on some systems pkg-config will fail to locate ncurses.
+  const dirs = [
+    "/lib", "/usr/lib", "/usr/local/lib"
+  ]
+  for lib in libs:
+    for dir in dirs:
+      if fileExists(dir & "/lib" & lib & ".a"):
+        return "-l" & lib
 )()
 when termlib != "":
   {.passl: termlib.}