$NetBSD: patch-src_Makefile,v 1.4 2023/04/19 13:38:54 sjmulder Exp $ - Make libdl and curses flags overridable - Make color support opt in so we can control it - Remove hardcoded paths for NetBSD --- src/Makefile.orig 2023-01-12 17:57:03.000000000 +0000 +++ src/Makefile @@ -37,7 +37,7 @@ CFLAGS += -DDFLT_PAGER=\"less\" # Sets default editor. Its use in case EDITOR env variable is not set CFLAGS += -DDFLT_EDITOR=\"vim\" # Comment out to disable color support -CFLAGS += -DUSECOLORS +#CFLAGS += -DUSECOLORS # Command history file, relative to HISTORY_DIR directory. Comment out to disable commandline history CFLAGS += -DHISTORY_FILE=\"$(HISTORY_FILE)\" -DHISTORY_DIR=\"$(HISTORY_DIR)\" # Configuration file, relative to CONFIG_DIR directory @@ -94,25 +94,27 @@ endif # dynamic linking (not available in BSD) ifneq ($(shell uname -s | grep -o BSD),BSD) - LDLIBS += -ldl + LDLIBS_DL += -ldl endif +LDLIBS += $(LDLIBS_DL) + ifneq (, $(shell which pkg-config)) # Any system with pkg-config # NOTE: ncursesw (required) ifeq ($(shell uname -s),Darwin) # macOS' ncurses is built with wide-char support - LDFLAGS += -lncurses + LDLIBS_CURSES ?= -lncurses else ifneq ($(shell pkg-config --exists ncursesw || echo 'no'),no) - CFLAGS += $(shell pkg-config --cflags ncursesw) - LDLIBS += $(shell pkg-config --libs ncursesw) + CFLAGS_CURSES ?= $(shell pkg-config --cflags ncursesw) + LDLIBS_CURSES ?= $(shell pkg-config --libs ncursesw) else ifneq ($(shell pkg-config --exists ncurses || echo 'no'),no) # hopefully this includes wide character support then - CFLAGS += $(shell pkg-config --cflags ncurses) - LDLIBS += $(shell pkg-config --libs ncurses) + CFLAGS_CURSES ?= $(shell pkg-config --cflags ncurses) + LDLIBS_CURSES ?= $(shell pkg-config --libs ncurses) else - LDLIBS += -lncursesw + LDLIBS_CURSES ?= -lncursesw endif # NOTE: libxlsreader (libxls) is required for xls file reading support @@ -153,21 +155,14 @@ else ifeq ($(shell uname -s),Darwin) # macOS without pkg-config # macOS' ncurses is built with wide-char support - LDFLAGS += -lncurses -else ifeq ($(shell uname -s),NetBSD) - # NetBSD without pkg-config - - CFLAGS += -I/usr/pkg/include - CFLAGS += -I/usr/pkg/include/ncursesw - - LDFLAGS += -L/usr/pkg/lib - LDFLAGS += -Wl,-R/usr/pkg/lib - - LDLIBS += -lncursesw + LDLIBS_CURSES += -lncurses else - LDFLAGS += -lncursesw + LDLIBS_CURSES += -lncursesw endif +CFLAGS += $(CFLAGS_CURSES) +LDLIBS += $(LDLIBS_CURSES) + OBJS = $(patsubst %.c, %.o, $(wildcard *.c) $(wildcard actions/*.c) $(wildcard formats/*.c) $(wildcard cmds/*.c) $(wildcard utils/*.c)) gram.o .PHONY : all clean install docs man_install man_uninstall