Files
keycodex/snippets/make.snippets
T
2024-05-05 15:24:18 +05:45

55 lines
1.6 KiB
Plaintext

snippet boil "boilerplate"
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.ONESHELL:
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
.RECIPEPREFIX = >
.DEFAULT_GOAL = help
HOME := \${HOME}
UNAME = \$(shell uname -s | tr A-Z a-z)
HOSTNAME = \$(shell hostname)
SOURCE = \$(realpath \$(dir \$(realpath \$(lastword \$(MAKEFILE_LIST)))))
BLACK = \$(shell tput -Txterm setaf 0)
RED = \$(shell tput -Txterm setaf 1)
GREEN = \$(shell tput -Txterm setaf 2)
YELLOW = \$(shell tput -Txterm setaf 3)
BLUE = \$(shell tput -Txterm setaf 4)
MAGENTA = \$(shell tput -Txterm setaf 5)
CYAN = \$(shell tput -Txterm setaf 6)
WHITE = \$(shell tput -Txterm setaf 7)
RESET = \$(shell tput -Txterm sgr0)
define print_mod_start
@echo "╭── \$(1)"
endef
define print_mod
@echo "│ • \$(1)"
endef
define print_mod_end
@echo "╰──────"
endef
define link
\$(eval REL_SRC=\$(strip \$(1)))
\$(eval SRC=\$(SOURCE)/\$(strip \$(1)))
\$(eval LOG="\${RED}link\${RESET} \${MAGENTA}\$(REL_SRC)\${RESET} -> \${YELLOW}\$(strip \$(2)\${RESET})")
\$(call print_mod,"\$(LOG)")
@ln -fns \$(SRC) \$(2)
endef
help: ## help
> @grep --no-filename -E '^[a-zA-Z_0-9%-]+:.*?## .*\$\$' \$(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\${BLUE}%-20s\${RESET} %s\n", \$\$1, \$\$2}'
.PHONY: help
build: ## build
> @echo " 🔥 Building on \${YELLOW}☯ \$(HOSTNAME)\${RESET} \${MAGENTA}(\$(UNAME))\${RESET}"
> $(call print_mod_start,Link)
> \$(call link,src_path,dest_path)
> \$(call print_mod_end)
.PHONY: build