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

From: Spenser Truex <truex_AT_equwal.com>
Date: Tue, 16 Aug 2022 02:11:21 -0300

Useful since curses cocks up any portability here. We prioritise the
user's entries in CURSESLIB where possible, and use LIBS when pkg-config
cannot be used.

An opinioned change (maybe the user should just figure this stuff out
himself or curses should be fixed).

---
 Makefile  | 31 +++++++++++++++++++++++++++++++
 config.mk |  4 +++-
 2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 4c00649..5cf1e3a 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -12,6 +12,37 @@ GETVER = $$(git rev-parse --is-inside-work-tree >/dev/null 2>&1 \
 	&& git describe --tags \
 	|| echo $(DEFVERSION))
+NEWCURSES = "$(shell pkg-config --libs curses)"
+ifeq ($(.SHELLSTATUS),0)
+	CURSESLIB = $(NEWCURSES)
+endif
+
+NEWCURSES = "$(shell pkg-config --libs cursesw)"
+ifeq ($(.SHELLSTATUS),0)
+	CURSESLIB = $(NEWCURSES)
+endif
+
+NEWCURSES = "$(shell pkg-config --libs ncurses)"
+ifeq ($(.SHELLSTATUS),0)
+	CURSESLIB = $(NEWCURSES)
+endif
+
+NEWCURSES = "$(shell pkg-config --libs ncursesw)"
+ifeq ($(.SHELLSTATUS),0)
+	CURSESLIB = $(NEWCURSES)
+endif
+
+NEWCURSES = "$(shell pkg-config --libs $(CURSESLIB))"
+ifeq ($(.SHELLSTATUS),0)
+	CURSESLIB = $(NEWCURSES)
+endif
+
+ifeq ("$(shell basename $(shell command -v pkg-config))", "pkg-config")
+    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 - 07:11:21 CEST

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