From f257cda04ad0f5b6efbb435de61e45d2ae5acbb1 Mon Sep 17 00:00:00 2001 From: "Sijmen J. Mulder" Date: Sun, 16 Dec 2018 17:56:41 +0100 Subject: [PATCH 1/5] Make optimization flags configurable --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b1f1af16..30d66f4c 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,10 @@ STRIP ?= strip PKG_CONFIG ?= pkg-config INSTALL ?= install -CFLAGS ?= -O3 +CFLAGS_OPTIMIZATION ?= -O3 + CFLAGS += -Wall -Wextra -Wno-unused-parameter +CFLAGS += $(CFLAGS_OPTIMIZATION) ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1) CFLAGS += $(shell $(PKG_CONFIG) --cflags ncursesw) From 599f4e82b7cc030eb3d10876677f44fabe5194b5 Mon Sep 17 00:00:00 2001 From: "Sijmen J. Mulder" Date: Sun, 16 Dec 2018 17:59:20 +0100 Subject: [PATCH 2/5] Also use pkg-config for regular ncurses --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 30d66f4c..7d983e8f 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,9 @@ CFLAGS += $(CFLAGS_OPTIMIZATION) ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1) CFLAGS += $(shell $(PKG_CONFIG) --cflags ncursesw) LDLIBS += $(shell $(PKG_CONFIG) --libs ncursesw) +else ifeq ($(shell $(PKG_CONFIG) ncurses && echo 1),1) + CFLAGS += $(shell $(PKG_CONFIG) --cflags ncurses) + LDLIBS += $(shell $(PKG_CONFIG) --libs ncurses) else LDLIBS += -lncurses endif From 78337812218f12c1d6fc7ac35b4deff21b6a0d6b Mon Sep 17 00:00:00 2001 From: "Sijmen J. Mulder" Date: Sun, 16 Dec 2018 18:01:24 +0100 Subject: [PATCH 3/5] Make curses flags configurable --- Makefile | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 7d983e8f..e5b645e0 100644 --- a/Makefile +++ b/Makefile @@ -8,18 +8,21 @@ INSTALL ?= install CFLAGS_OPTIMIZATION ?= -O3 +ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1) + CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw) + LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw) +else ifeq ($(shell $(PKG_CONFIG) ncurses && echo 1),1) + CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncurses) + LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncurses) +else + LDLIBS_CURSES ?= -lncurses +endif + CFLAGS += -Wall -Wextra -Wno-unused-parameter CFLAGS += $(CFLAGS_OPTIMIZATION) +CFLAGS += $(CFLAGS_CURSES) -ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1) - CFLAGS += $(shell $(PKG_CONFIG) --cflags ncursesw) - LDLIBS += $(shell $(PKG_CONFIG) --libs ncursesw) -else ifeq ($(shell $(PKG_CONFIG) ncurses && echo 1),1) - CFLAGS += $(shell $(PKG_CONFIG) --cflags ncurses) - LDLIBS += $(shell $(PKG_CONFIG) --libs ncurses) -else - LDLIBS += -lncurses -endif +LDLIBS += $(LDLIBS_CURSES) DISTFILES = src nnn.1 Makefile README.md LICENSE SRC = src/nnn.c From 4005a1fa4679adcfcb4d51fa89aca0ab1db3cd26 Mon Sep 17 00:00:00 2001 From: "Sijmen J. Mulder" Date: Sun, 16 Dec 2018 18:02:19 +0100 Subject: [PATCH 4/5] Remove CPPFLAGS since C++ is not used --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e5b645e0..0235c029 100644 --- a/Makefile +++ b/Makefile @@ -33,10 +33,10 @@ all: $(BIN) $(SRC): src/nnn.h $(BIN): $(SRC) - $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) debug: $(SRC) - $(CC) -DDEBUGMODE -g $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $(BIN) $^ $(LDLIBS) + $(CC) -DDEBUGMODE -g $(CFLAGS) $(LDFLAGS) -o $(BIN) $^ $(LDLIBS) install: all $(INSTALL) -m 0755 -d $(DESTDIR)$(PREFIX)/bin From 6658af3f66232211fe4720cf611bf4cf10ce415e Mon Sep 17 00:00:00 2001 From: "Sijmen J. Mulder" Date: Mon, 17 Dec 2018 09:50:29 +0100 Subject: [PATCH 5/5] Revert "Remove CPPFLAGS since C++ is not used" Mistook CPPFLAGS ("C preprocessor flags") for CXXFLAGS ("C++ flags"). This reverts commit 0956b82d33fb2956da837e6a06a2a6f7216d47c0. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0235c029..e5b645e0 100644 --- a/Makefile +++ b/Makefile @@ -33,10 +33,10 @@ all: $(BIN) $(SRC): src/nnn.h $(BIN): $(SRC) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) + $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) debug: $(SRC) - $(CC) -DDEBUGMODE -g $(CFLAGS) $(LDFLAGS) -o $(BIN) $^ $(LDLIBS) + $(CC) -DDEBUGMODE -g $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $(BIN) $^ $(LDLIBS) install: all $(INSTALL) -m 0755 -d $(DESTDIR)$(PREFIX)/bin