# Example configuration for Darwin / macOS.

ifeq ($(origin HOMEBREW_PREFIX), undefined)
HOMEBREW_PREFIX := $(shell brew --prefix 2>/dev/null)
endif

# Work-around for Homebrew-based xmlto.
export XML_CATALOG_FILES=$(HOMEBREW_PREFIX)/etc/xml/catalog

TIG_CFLAGS += -DHAVE_EXECINFO_H
TIG_LDLIBS = -liconv

NCURSES_DIR ?= $(wildcard $(HOMEBREW_PREFIX)/opt/ncurses)

ifneq ($(NCURSES_DIR),)
	TIG_NCURSES = -lncursesw
	TIG_CPPFLAGS += -I$(NCURSES_DIR)/include -DHAVE_NCURSESW_CURSES_H
	TIG_LDFLAGS += -L$(NCURSES_DIR)/lib
else
	TIG_CPPFLAGS += -DHAVE_CURSES_H
endif

READLINE_DIR ?= $(wildcard $(HOMEBREW_PREFIX)/opt/readline)

ifneq ($(READLINE_DIR),)
	TIG_LDLIBS += -lreadline
	TIG_LDFLAGS += -L$(READLINE_DIR)/lib
	TIG_CPPFLAGS += -I$(READLINE_DIR)/include -DHAVE_READLINE
endif

PCRE2_DIR ?= $(wildcard $(HOMEBREW_PREFIX)/opt/pcre2)

ifneq ($(PCRE2_DIR),)
	TIG_LDLIBS += -lpcre2-posix -lpcre2-8
	TIG_LDFLAGS += -L$(PCRE2_DIR)/lib
	TIG_CPPFLAGS += -I$(PCRE2_DIR)/include -DHAVE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8
endif

# vim: ft=make:
