You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.3 KiB
86 lines
2.3 KiB
MAKEFLAGS += --warn-undefined-variables |
|
|
|
install_path = /usr/local/bin |
|
links_path = ~/.shellrc/bin/scripts |
|
|
|
SRC := scripts |
|
|
|
find := $(shell { command -v gfind || command -v find; } 2>&-) |
|
|
|
SCRIPTS := $(wildcard $(SRC)/*) |
|
|
|
# -------------------------------------------------------------------------------------------------- |
|
|
|
# install_files [FILES] TO/ |
|
define install_files |
|
@for file in $(1); do \ |
|
echo install -m $(3) $$(realpath -- $$file) $(2)/$$(basename $$file); \ |
|
install -m $(3) $$(realpath -- $$file) $(2)/$$(basename $$file); \ |
|
done |
|
endef |
|
|
|
# link_files [FILES] TO/ |
|
define link_files |
|
@for file in $(1); do \ |
|
ln -f -s -v $$(realpath -- $$file) $(2)/$$(basename $$file); \ |
|
done |
|
endef |
|
|
|
# delete_files [FILES] FROM/ |
|
define delete_files |
|
@for file in $(1); do \ |
|
rm -v $(2)/$$(basename $$file) || :; \ |
|
done |
|
endef |
|
|
|
# -------------------------------------------------------------------------------------------------- |
|
|
|
help: ## Display this help. |
|
@awk 'BEGIN { \ |
|
FS = ":.*##"; \ |
|
printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n" \ |
|
} \ |
|
/^[a-zA-Z_-]+:.*?##/ { \ |
|
printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 \ |
|
} \ |
|
END { \ |
|
print \ |
|
}' \ |
|
$(MAKEFILE_LIST) |
|
|
|
# -------------------------------------------------------------------------------------------------- |
|
|
|
links: make_local_dirs make_links ## Install kubectl scripts by creating links. |
|
install: copy_bin ## Install kubectl scripts to /usr/local/bin. |
|
uninstall: rm_bin rm_links rm_local_dirs ## Uninstall kubectl scripts. |
|
|
|
# -------------------------------------------------------------------------------------------------- |
|
|
|
%: $(BIN)/% |
|
|
|
# -------------------------------------------------------------------------------------------------- |
|
|
|
copy_bin: |
|
$(call install_files, $(SCRIPTS), $(install_path), 755) |
|
|
|
rm_bin: |
|
$(call delete_files, $(SCRIPTS), $(install_path)) |
|
|
|
# -------------------------------------------------------------------------------------------------- |
|
|
|
make_local_dirs: |
|
mkdir -p -v $(links_path) |
|
|
|
rm_local_dirs: |
|
rmdir $(links_path) 2>&-; : |
|
|
|
make_links: |
|
$(call link_files, $(SCRIPTS), $(links_path)) |
|
|
|
rm_links: |
|
$(call delete_files, $(SCRIPTS), $(links_path)) |
|
|
|
# -------------------------------------------------------------------------------------------------- |
|
|
|
.PHONY: all make_local_dirs rm_local_dirs links install uninstall |
|
|
|
|