aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-06-15 13:52:32 -0700
committerBruce Hill <bruce@bruce-hill.com>2019-06-15 13:52:32 -0700
commit3614df7450860858f05a1eefe34c7c9c1f9261f1 (patch)
tree0c58998ba7af7e7662d1f48e1e2cc88f71539ef9 /Makefile
parent8000a4a1bbe5685bf096971563743424ed60c78a (diff)
More robust/automatic handling of PICKER
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile31
1 files changed, 21 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 5c06cc5..3902c84 100644
--- a/Makefile
+++ b/Makefile
@@ -8,23 +8,34 @@ CWARN=-Wall -Wpedantic -Wno-unknown-pragmas
G=
ifeq ($(shell uname),Darwin)
-CFLAGS += -D_DARWIN_C_SOURCE
-CWARN += -Weverything -Wno-missing-field-initializers -Wno-padded\
- -Wno-missing-noreturn -Wno-cast-qual
+ CFLAGS += -D_DARWIN_C_SOURCE
+ CWARN += -Weverything -Wno-missing-field-initializers -Wno-padded\
+ -Wno-missing-noreturn -Wno-cast-qual
endif
-ifeq ($(PICKER),fzy)
-CFLAGS += -D'PICK(prompt, initial)=" { printf \"\\033[3A\" >/dev/tty; fzy --lines=3 --prompt=\"" prompt "\" --query=\"" initial "\"; } "'
+PICKER_FLAG=
+ifeq (, $(PICKER))
+ PICKER=$(shell sh -c "(which fzy >/dev/null 2>/dev/null && echo 'fzy') || (which fzf >/dev/null 2>/dev/null && echo 'fzf') || (which pick >/dev/null 2>/dev/null && echo 'pick') || (which ask >/dev/null 2>/dev/null && echo 'ask')")
endif
-ifeq ($(PICKER),fzf)
-CFLAGS += -D'PICK(prompt, initial)=" { printf \"\\033[3A\" >/dev/tty; fzf --height=4 --prompt=\"" prompt "\" --query=\"" initial "\"; } "'
+ifneq (, $(PICKER))
+ PICKER_FLAG=-D"PICK(prompt, initial)=\"$(PICKER)\""
endif
-ifeq ($(PICKER),ask)
-CFLAGS += -D'PICK(prompt, initial)=" ask --prompt=\"" prompt "\" --query=\"" initial "\" "'
+ifeq ($(shell which $(PICKER)),$(shell which fzy || echo '<none>'))
+ PICKER_FLAG=-D'PICK(prompt, initial)="{ printf \"\\033[3A\" >/dev/tty; fzy --lines=3 --prompt=\"" prompt "\" --query=\"" initial "\"; }"'
endif
+ifeq ($(shell which $(PICKER)),$(shell which fzf || echo '<none>'))
+ PICKER_FLAG=-D'PICK(prompt, initial)="{ printf \"\\033[3A\" >/dev/tty; fzf --height=4 --prompt=\"" prompt "\" --query=\"" initial "\"; }"'
+endif
+ifeq ($(shell which $(PICKER)),$(shell which ask || echo '<none>'))
+ PICKER_FLAG=-D'PICK(prompt, initial)="ask --prompt=\"" prompt "\" --query=\"" initial "\""'
+endif
+ifeq ($(shell which $(PICKER)),$(shell which pick || echo '<none>'))
+ PICKER_FLAG=-D'PICK(prompt, initial)="pick -q \"" initial "\""'
+endif
+CFLAGS += $(PICKER_FLAG)
ifneq (, $(USE_ASK))
-CFLAGS += -D'USE_ASK=1'
+ CFLAGS += -D'USE_ASK=1'
endif
all: $(NAME)