aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorGravatar Mischievous Meerkat <engineerarun@gmail.com>2019-10-09 20:44:46 +0530
committerGravatar GitHub <noreply@github.com>2019-10-09 20:44:46 +0530
commit0125684d3ff47167e1e5bd59df1802519e6fe5d3 (patch)
treea9ed2e813f831cea2ee858cff25a7928d1dab570 /Makefile
parent84bb0b5bfecce3e065fc1c8f87733e330c0fda62 (diff)
parent9e25886694aec45afd80edc3191ea16c2482165c (diff)
downloadnnn-0125684d3ff47167e1e5bd59df1802519e6fe5d3.tar.gz
Merge pull request #344 from rindeal/make
do build configuration with variables instead of targets
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile46
1 files changed, 37 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 89355df..9b96345 100644
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,38 @@ CP ?= cp
CFLAGS_OPTIMIZATION ?= -O3
+O_DEBUG := 0
+O_NORL := 0 # no readline support
+O_NOLOC := 0 # no locale support
+
+# convert targets to flags for backwards compatibility
+ifeq ($(MAKECMDGOALS),debug)
+ O_DEBUG := 1
+endif
+ifeq ($(MAKECMDGOALS),norl)
+ O_NORL := 1
+endif
+ifeq ($(MAKECMDGOALS),noloc)
+ O_NORL := 1
+ O_NOLOC := 1
+endif
+
+ifeq ($(O_DEBUG),1)
+ CPPFLAGS += -DDBGMODE
+ CFLAGS += -g
+ LDLIBS += -lrt
+endif
+
+ifeq ($(O_NORL),1)
+ CPPFLAGS += -DNORL
+else
+ LDLIBS += -lreadline
+endif
+
+ifeq ($(O_NOLOC),1)
+ CPPFLAGS += -DNOLOCALE
+endif
+
ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1)
CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw)
LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw)
@@ -34,16 +66,12 @@ all: $(BIN)
$(SRC): src/nnn.h
$(BIN): $(SRC)
- $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) -lreadline
-
-debug: $(SRC)
- $(CC) -DDBGMODE -g $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $(BIN) $^ $(LDLIBS) -lreadline -lrt
-
-norl: $(SRC)
- $(CC) -DNORL $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $(BIN) $^ $(LDLIBS)
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
-noloc: $(SRC)
- $(CC) -DNORL -DNOLOCALE $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $(BIN) $^ $(LDLIBS)
+# targets for backwards compatibility
+debug: $(BIN)
+norl: $(BIN)
+noloc: $(BIN)
install: all
$(INSTALL) -m 0755 -d $(DESTDIR)$(PREFIX)/bin