-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
47 lines (42 loc) · 1.9 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
COMMAND_NAME := novaxis
LOCAL_COMMAND_BIN_PATH := $(PWD)/bin/$(COMMAND_NAME)
COMMAND_BIN_PATH := /bin/$(COMMAND_NAME)
.PHONY: help install reinstall uninstall
help:
@echo "Available commands:"
@echo " install - Creates a symbolic link for the '$(COMMAND_NAME)' command in /bin."
@echo " This operation requires superuser permissions."
@echo " reinstall - Removes and then creates the symbolic link for the '$(COMMAND_NAME)' command in /bin."
@echo " This can be used to refresh the installation. Requires superuser permissions."
@echo " uninstall - Removes the symbolic link for the '$(COMMAND_NAME)' command from /bin."
@echo " Use this to clean up after an install. Requires superuser permissions."
@echo " help - Displays this help message."
install:
@if [ ! -f "$(COMMAND_BIN_PATH)" ]; then \
if [ -f "$(LOCAL_COMMAND_BIN_PATH)" ]; then \
echo "Creating symlink for $(COMMAND_NAME) in /bin"; \
chmod +x $(LOCAL_COMMAND_BIN_PATH); \
ln -s $(LOCAL_COMMAND_BIN_PATH) $(COMMAND_BIN_PATH); \
echo "Novaxis installed successfully."; \
else \
echo "Local command binary does not exist: $(LOCAL_COMMAND_BIN_PATH)"; \
fi; \
else \
echo "The file already exists: $(COMMAND_BIN_PATH), no action taken."; \
fi
reinstall:
@echo "Recreating symlink for $(COMMAND_NAME) in /bin"; \
chmod +x $(LOCAL_COMMAND_BIN_PATH); \
rm $(COMMAND_BIN_PATH); \
ln -s $(LOCAL_COMMAND_BIN_PATH) $(COMMAND_BIN_PATH); \
echo "Novaxis reinstalled successfully."; \
uninstall:
@if [ -L "$(COMMAND_BIN_PATH)" ]; then \
echo "Removing symlink for $(COMMAND_NAME) from /bin"; \
echo "Novaxis uninstalled successfully."; \
rm $(COMMAND_BIN_PATH); \
elif [ -f "$(COMMAND_BIN_PATH)" ]; then \
echo "The path exists but is not a symlink: $(COMMAND_BIN_PATH). Manual removal required."; \
else \
echo "Symlink does not exist: $(COMMAND_BIN_PATH), no action taken."; \
fi