-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
44 lines (37 loc) · 1.06 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
MAN2PDF := man2pdf
BASH_DIR := src/bash
MAN2PDF_EXEC := man2pdf.sh
ifeq ($(shell whoami),root)
INSTALL_DIR := /usr/local/bin
SHARE_DIR := /usr/local/share/$(MAN2PDF)
else
USER := $(shell whoami)
OS := $(shell uname -s)
ifeq ($(OS),Darwin)
HOME := /Users/$(USER)
else
HOME := /home/$(USER)
endif
INSTALL_DIR := $(HOME)/bin
SHARE_DIR := $(HOME)/.local/share/$(MAN2PDF)
endif
.PHONY: all
all: help
.PHONY: help
help:
@echo "[MAN2PDF]"
@echo "- \`make install\` / \`make uninstall\`: Install / uninstall for current user only."
@echo "- \`sudo make install\` / \`sudo make uninstall\`: Install / uninstall for all users."
.PHONY: install
install: $(INSTALL_DIR) $(SHARE_DIR)
ifneq ($(USER),root)
$(info [NOTE] To install "$(MAN2PDF)" for current user, please ensure that the directory "$(INSTALL_DIR)" exists and is in $$PATH.)
endif
@cp -rv "$(BASH_DIR)"/* "$(SHARE_DIR)"
@ln -rsfv "$(SHARE_DIR)/$(MAN2PDF_EXEC)" "$(INSTALL_DIR)/$(MAN2PDF)"
.PHONY: uninstall
uninstall:
@-rm -fv "$(INSTALL_DIR)/$(MAN2PDF)"
@-rm -rfv "$(SHARE_DIR)"
$(INSTALL_DIR) $(SHARE_DIR):
@mkdir -p $@