From 292b477fb8971f90348d1f32a24f1caccefec355 Mon Sep 17 00:00:00 2001 From: Iku Date: Sun, 2 Jul 2017 13:53:04 +0200 Subject: Group Makefile rules with and without pkg-config This will make it easier to maintain a build on vanilla macOS. Whenever pkg-config is used without a check it breaks the build. Grouping these rules makes it harder to do by accident. Note that the vanilla (non-Homebrew) macOS build is broken because of an incompatibility with system ncurses: https://github.com/andmarti1424/sc-im/issues/159 --- src/Makefile | 77 ++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/src/Makefile b/src/Makefile index d013cc8..bc65db0 100755 --- a/src/Makefile +++ b/src/Makefile @@ -16,21 +16,9 @@ MANDIR = $(prefix)/share/man/man1 #YACC = bison -y #SED = sed -ifeq ($(shell uname -s),Darwin) - NCURSES_CFLAGS ?= - NCURSES_LIBS ?= -lncursesw -else ifeq ($(shell pkg-config --exists ncursesw || echo 'no'),no) - NCURSES_CFLAGS ?= - NCURSES_LIBS ?= -lncursesw -else - NCURSES_CFLAGS ?= $(shell pkg-config --cflags ncursesw) - NCURSES_LIBS ?= $(shell pkg-config --libs ncursesw) -endif - -LDLIBS += -lm $(NCURSES_LIBS) +LDLIBS += -lm CFLAGS += -Wall -g -CFLAGS += $(NCURSES_CFLAGS) CFLAGS += -DNCURSES CFLAGS += -D_XOPEN_SOURCE_EXTENDED -D_GNU_SOURCE CFLAGS += -DSNAME=\"$(name)\" @@ -79,40 +67,63 @@ CFLAGS += -DDEFAULT_PASTE_FROM_CLIPBOARD_CMD=\""tmux show-buffer"\" CFLAGS += -DAUTOBACKUP # Have threads? Set these two, if you want the autobackup feature to work with threads. CFLAGS += -DHAVE_PTHREAD -ifneq ($(shell uname -s),Darwin) -LDLIBS += -pthread -endif -# NOTE: libxml and libzip are required for xlsx file import support -ifneq ($(shell pkg-config --exists libzip libxml-2.0 || echo 'no'),no) -CFLAGS += -DXLSX $(shell pkg-config --cflags libxml-2.0 libzip) -LDLIBS += $(shell pkg-config --libs libxml-2.0 libzip) +ifneq ($(shell uname -s),Darwin) + LDLIBS += -pthread endif # NOTE: libxlsxwriter is required for xlsx file export support ifneq (,$(wildcard /usr/include/xlsxwriter.h)) -CFLAGS += -DXLSX_EXPORT -LDLIBS += -lxlsxwriter + CFLAGS += -DXLSX_EXPORT + LDLIBS += -lxlsxwriter endif -# NOTE: lua support -ifneq ($(shell pkg-config --exists lua51 || echo 'no'),no) -CFLAGS += -DXLUA $(shell pkg-config --cflags lua51) -LDLIBS += $(shell pkg-config --libs lua51) -Wl,--export-dynamic -else ifneq ($(shell pkg-config --exists lua-5.1 || echo 'no'),no) # FreeBSD -CFLAGS += -DXLUA $(shell pkg-config --cflags lua-5.1) -LDLIBS += $(shell pkg-config --libs lua-5.1) -Wl,--export-dynamic +# Check for gnuplot existance +ifneq (, $(shell which gnuplot)) + CFLAGS += -DGNUPLOT endif # dynamic linking (should not be used in FreeBSD ifneq ($(shell uname -s),FreeBSD) -LDLIBS += -ldl + LDLIBS += -ldl endif -# Check for gnuplot existance -ifneq (, $(shell which gnuplot)) -CFLAGS += -DGNUPLOT +ifneq (, $(shell which pkg-config)) + # Any system with pkg-config + + # NOTE: ncursesw (required) + ifneq ($(shell pkg-config --exists ncursesw || echo 'no'),no) + CFLAGS += $(shell pkg-config --cflags ncursesw) + LDLIBS += $(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) + else + LDLIBS += -lncursesw + endif + + # NOTE: libxml and libzip are required for xlsx file import support + ifneq ($(shell pkg-config --exists libzip libxml-2.0 || echo 'no'),no) + CFLAGS += -DXLSX $(shell pkg-config --cflags libxml-2.0 libzip) + LDLIBS += $(shell pkg-config --libs libxml-2.0 libzip) + endif + + # NOTE: lua support + ifneq ($(shell pkg-config --exists lua51 || echo 'no'),no) + CFLAGS += -DXLUA $(shell pkg-config --cflags lua51) + LDLIBS += $(shell pkg-config --libs lua51) -Wl,--export-dynamic + else ifneq ($(shell pkg-config --exists lua-5.1 || echo 'no'),no) # FreeBSD + CFLAGS += -DXLUA $(shell pkg-config --cflags lua-5.1) + LDLIBS += $(shell pkg-config --libs lua-5.1) -Wl,--export-dynamic + endif +else ifeq ($(shell uname -s),Darwin) + # macOS without pkg-config + + # macOS' ncurses is built with wide-char support + LDFLAGS += -lncurses endif + OBJS = $(patsubst %.c, %.o, $(wildcard *.c) $(wildcard utils/*.c)) gram.o .PHONY : all clean install -- cgit v1.2.3 From 0cc9efd181c2adcff8a0a003cef8d4b5e5c5c1dd Mon Sep 17 00:00:00 2001 From: Iku Date: Sun, 2 Jul 2017 14:52:10 +0200 Subject: Fix segfault on launch with Mac ncurses It appears that in some versions of ncurses the call to newscr() does not accept a NULL ifp argument. I don't know if this is the correct solution but it does prevent the segfault. See: https://github.com/andmarti1424/sc-im/issues/159 --- src/tui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tui.c b/src/tui.c index 198f371..cbc2fa1 100644 --- a/src/tui.c +++ b/src/tui.c @@ -81,7 +81,7 @@ SCREEN * sstdout; srange * ranges; void ui_start_screen() { - sstderr = newterm(NULL, stderr, NULL); + sstderr = newterm(NULL, stderr, stdin); noecho(); sstdout = newterm(NULL, stdout, stdin); set_term(sstdout); -- cgit v1.2.3