[dev] [PATCH] (better) Infer the (n)curses(w) library to use and -l

From: Spenser Truex <truex_AT_equwal.com>
Date: Tue, 16 Aug 2022 05:09:19 -0300

Useful since curses cocks up any portability here
Better than my last patch (replace, not sequential)

---
 Makefile  | 9 +++++++++
 config.mk | 4 +++-
 2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 4c00649..85bdf0d 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -12,6 +12,15 @@ GETVER = $$(git rev-parse --is-inside-work-tree >/dev/null 2>&1 \
 	&& git describe --tags \
 	|| echo $(DEFVERSION))
+ifeq ("$(shell basename $(shell command -v pkg-config))","pkg-config")
+    pkgconfig = $(and $(findstring 0,$(and $(shell pkg-config --libs $(i)),$(.SHELLSTATUS))),$(i))
+    var := i
+    list := curses cursesw ncurses ncursesw
+    CURSESLIB = $(foreach $(var), $(list), $(pkgconfig))
+    LIBS := $(shell pkg-config --libs $(CURSESLIB))
+endif
+
+
 all: $(BIN)
 config.h:
diff --git a/config.mk b/config.mk
index 223207e..0778f71 100644
--- a/config.mk
+++ b/config.mk
_AT_@ -14,6 +14,8 @@ DEFVERSION = "1.06"
 #UI=txt
 # ti (screen-oriented)
 UI=ti
+# LIBS ignored if it can be inferred from CURSESLIB
+CURSESLIB = curses
 LIBS=-lcurses
 # IO type
_AT_@ -27,7 +29,7 @@ IOCFLAGS = -DUSE_TLS
 # OS compilation flags are used to expose the system interfaces
 # Linux, OpenBSD
 OSCFLAGS = -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -D_GNU_SOURCE
-OSLDFLAGS =
+OSLDFLAGS =
 # NetBSD, using default pkgsrc path
 #OSCFLAGS = -I/usr/pkg/include
 #OSLDFLAGS = -L/usr/pkg/lib -R/usr/pkg/lib
--
2.35.1

Received on Tue Aug 16 2022 - 10:09:19 CEST

This archive was generated by hypermail 2.3.0 : Tue Aug 16 2022 - 10:12:08 CEST