-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
67 lines (56 loc) · 1.95 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
SHELL = /bin/bash
TOOL_NAME = nef
prefix ?= /usr/local
version ?= 0.7.1
BUILD_PATH = /tmp/$(TOOL_NAME)/$(version)
PREFIX_BIN = $(prefix)/bin
PREFIX_TESTS = $(prefix)/share/tests
TAR_FILENAME = $(version).tar.gz
SWIFT_PACKAGE_PATH = .
BINARIES_PATH = $(BUILD_PATH)/release
BINARIES = nefc\
nef-clean\
nef-playground\
nef-markdown\
nef-markdown-page\
nef-jekyll\
nef-jekyll-page\
nef-carbon\
nef-carbon-page\
nef-playground-book
.PHONY: install
install: uninstall build install_folders
$(foreach binary,$(BINARIES),$(shell install $(BINARIES_PATH)/$(binary) $(PREFIX_BIN)/$(binary)))
@install $(BINARIES_PATH)/nef-menu $(PREFIX_BIN)/nef
@cp -R Documentation.app $(PREFIX_TESTS)
$(MAKE) bash
$(MAKE) zsh
.PHONY: install_folders
install_folders:
@install -d "$(PREFIX_BIN)"
@install -d "$(PREFIX_TESTS)"
.PHONY: build
build: clean
@swift build --disable-sandbox --package-path $(SWIFT_PACKAGE_PATH) --configuration release --build-path $(BUILD_PATH)
.PHONY: uninstall
uninstall:
@rm -f $(PREFIX_BIN)/$(TOOL_NAME)*
@rm -rf $(PREFIX_TESTS)
.PHONY: clean
clean:
@rm -rf $(BUILD_PATH)
.PHONY: zip
zip: build
@zip $(TOOL_NAME).$(version).zip $(foreach binary,$(BINARIES),$(BINARIES_PATH)/$(binary))
.PHONY: zsh
zsh:
@mkdir -p ~/.zsh/completion
@mkdir -p ~/.oh-my-zsh/completions
@$(PREFIX_BIN)/nef --generate-completion-script zsh > ~/.oh-my-zsh/completions/_nef
@$(PREFIX_BIN)/nef --generate-completion-script zsh > ~/.zsh/completion/nef.zsh
$(shell if [[ ! -f ~/.zshrc ]] || [[ ! `grep "~/.zsh/completion" ~/.zshrc` ]]; then echo -e '\n# Enable Zsh completions\nfpath=(~/.zsh/completion $$fpath)\nautoload -U compinit\ncompinit\n' >> ~/.zshrc; fi)
.PHONY: bash
bash:
@mkdir -p ~/.bash_completions
@$(PREFIX_BIN)/nef --generate-completion-script bash > ~/.bash_completions/nef.bash
$(shell if [[ ! -f ~/.bashrc ]] || [[ ! `grep "nef.bash" ~/.bashrc` ]]; then echo "source ~/.bash_completions/nef.bash" >> ~/.bashrc; fi)