-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.head
66 lines (59 loc) · 2.14 KB
/
Makefile.head
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
#
# Because I never remember all the possible ways to twist things
#
# # Bookmarks of what helped crafting this Makefile:
# - https://github.com/Respect/Foundation/blob/6d136c03/Makefile
# - https://tech.davis-hansson.com/p/make/
#
# # Bookmarks of cool notes
#
# - https://github.com/xelalexv/dregsy/blob/b0615fda/Makefile
# - https://gist.github.com/evertrol/4b6fd05f3b6be2b331c60638b1af7101
# - https://github.com/xelalexv/dregsy/blob/b0615fda/Makefile
# - https://github.com/box/Makefile.test
# - https://makefiletutorial.com/
# - http://yszheda.github.io/wiki/makefile.html
#
# # Makefile so complex (and powerful) I wanna cry
#
# - https://github.com/Respect/Foundation/blob/6d136c03/Makefile
# - https://github.com/xelalexv/dregsy/blob/b0615fda/Makefile
#
VERSION := 0.1.0
SHELL := $(shell which bash)
.SHELLFLAGS = -c
THIS = $(word 1,$(MAKEFILE_LIST))
UNAME = $(shell uname)
ENV = $(shell command -v env)
GIT = $(shell command -v git)
HAS_OPEN = $(shell command -v open)
HAS_XDG = $(shell command -v xdg)
HAS_SENSIBLE = $(shell command -v sensible-browser)
BROWSER_ALTERNS = $(HAS_XDG) $(HAS_SENSIBLE) $(HAS_OPEN)
BROWSE = $(word 1,$(BROWSER_ALTERNS))
DOTS = $(shell printf '%0.1s' '.'{1..25})
# Macros
.CLEAR=\x1b[0m
.BOLD=\x1b[01m
.RED=\x1b[31;01m
.GREEN=\x1b[32;01m
.YELLOW=\x1b[33;01m
.ERROR="\ ""\ ""\ ""\ ">"\ "$(.RED)[ERROR]$(.CLEAR)
.OK="$(.GREEN)[OK]$(.CLEAR)"
.OKN="\ ""\ ""\ ""\ ">"\ "$(.GREEN)[OK]$(.CLEAR)
.WARN="\ ""\ ""\ ""\ ">"\ "$(.YELLOW)[WARNING]$(.CLEAR)
.ONESHELL: ; # recipes execute in same shell
.NOTPARALLEL: ; # wait for this target to finish
.EXPORT_ALL_VARIABLES: ; # send all vars to shell
default: help-default; # default target
Makefile: ; # skip prerequisite discovery
.title:
@if [[ ! -n "$(notitle)" ]]; then \
echo -e " $(.BOLD)# Makefile helper: $(VERSION)$(.CLEAR)"; \
echo ""; \
fi; \
.menu-heading:
@echo -e " $(.BOLD)${title}$(.CLEAR)"
@echo -e " $$(printf '%0.1s' $$(seq -f'=%g' 1 $${#title}))\n"
.menu-item:
printf "%-s%0.*s%s\n" "${tgt}:" $$((25 - $${#tgt})) $(DOTS) "${desc}"