-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
158 lines (126 loc) · 2.68 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/env make
.PHONY: pull-request
pull-request: clear clean dump lint build test ok
# https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_7.html
# https://stackoverflow.com/a/26936855/1954789
# https://stackoverflow.com/a/39420097/1954789
# SHELL := /bin/bash
SHELL=/bin/bash -o pipefail -o errexit
# Locale per default
LANG=C.UTF-8
# .ONESHELL:
.SECONDEXPANSION:
ROOT = $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
TMP = tmp
ROOT_TMP = $(ROOT)/$(TMP)
GITHUB_STEP_SUMMARY ?= "$(ROOT_TMP)/GITHUB_STEP_SUMMARY.log"
PUBLISH = $(TMP)/publish
VERSION_FILE = $(PUBLISH)/version.txt
export PATH := $(ROOT)/bin:$(ROOT)/packages/jehon/usr/bin:$(PATH)
define mkdir
@mkdir -p "$(dir $(1))"
endef
define touch
$(call mkdir,$(1))
@touch "$(1)"
endef
define copy
$(call mkdir,$(1))
@cp -fv "$(2)" "$(1)"
endef
# Identation is important:
define version
$(shell cat "$(VERSION_FILE)" || echo "1")
endef
DUMP_ALIGN=40
define dump_info
@if [ -n "$(2)" ]; then \
printf "* %-$(DUMP_ALIGN)s %s\n" '$(1): ' '$(2)'; \
else \
printf "* %-$(DUMP_ALIGN)s %s\n" '$(1): ' '$($(1))'; \
fi
endef
define dump_version
@printf "* %-$(DUMP_ALIGN)s %s\n" '$(shell type $(1)): ' '$(shell $(1) --version | head -n $(if $2,$2,1) | tail -n 1)'
endef
define dump_title
@printf "**************************** $(1) **************************\n"
endef
define dump_space
@printf "*\n"
endef
#
#
# Generic targets
#
#
.PHONY: dump
dump:
$(call dump_space)
$(call dump_title,GLOBAL)
$(call dump_info,PWD,$(shell pwd))
$(call dump_info,ROOT)
$(call dump_info,ROOT_TMP)
$(call dump_info,REPO)
$(call dump_info,VERSION)
$(call dump_space)
$(call dump_info,VERSION_LAST_GIT)
$(call dump_info,VERSION_LAST_EMAIL)
$(call dump_info,VERSION_CURRENT_TIME_TAG)
$(call dump_info,VERSION_RUN)
$(call dump_space)
$(call dump_info,GITHUB_REPOSITORY_OWNER)
$(call dump_info,GITHUB_ACTOR)
$(call dump_info,GITHUB_STEP_SUMMARY)
$(call dump_space)
lsb_release -a || true
.PHONY: dump-runtimes
dump-runtimes:
@true
.PHONY: clean
clean:
rm -fr "$(TMP)"
.PHONY: build
build:
@true
.PHONY: test
test:
@true
.PHONY: lint
lint:
@true
#
#
# Helpers
#
#
.PHONY: clear
clear:
clear
.PHONY: ok
ok:
@echo "Ok: done"
# target 'start' could not exists, since it is the name of a file
#
#
# Global
#
#
lint: global-lint
.PHONY: global-lint
global-lint: global-lint-prettier
.PHONY: global-lint-prettier
global-lint-prettier: $(NODE_DEPENDENCY_MARK)
prettier --list-different .
.PHONY: global-lint-prettier
global-lint-prettier-fix: $(NODE_DEPENDENCY_MARK)
prettier --write .
#
#
# Externals makefiles
#
#
clean-force: clean
# Thanks to https://stackoverflow.com/a/46273201/1954789
git clean -dfX
include Makefile.node