-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMakefile
More file actions
215 lines (190 loc) · 4 KB
/
Makefile
File metadata and controls
215 lines (190 loc) · 4 KB
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# SPDX-License-Identifier: AGPL-3.0
# -----------------------------------------------------
# Copyright © 2024, 2025, 2026 Pellegrino Prevete
#
# All rights reserved
# -----------------------------------------------------
#
# This program is free software: you can redistribute
# it and/or modify it under the terms of the
# GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it
# will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the
# GNU Affero General Public License
# along with this program.
# If not, see <https://www.gnu.org/licenses/>.
SHELL=bash
PREFIX ?= /usr/local
_PROJECT_NPM=erc20-tools
_PROJECT=$(_PROJECT_NPM).js
_NAMESPACE=themartiancompany
DOC_DIR=$(DESTDIR)$(PREFIX)/share/doc/$(_PROJECT_NPM)
USR_DIR=$(DESTDIR)$(PREFIX)
BIN_DIR=$(DESTDIR)$(PREFIX)/bin
LIB_DIR=$(DESTDIR)$(PREFIX)/lib/$(_PROJECT_NPM)
MAN_DIR?=$(DESTDIR)$(PREFIX)/share/man
NODE_DIR=$(PREFIX)/lib/node_modules/$(_PROJECT_NPM)
BUILD_NPM_DIR=build
_INSTALL_FILE=\
install \
-vDm644
_INSTALL_EXE=\
install \
-vDm755
_INSTALL_DIR=\
install \
-vdm755
DOC_FILES=\
$(wildcard \
*.rst) \
$(wildcard \
*.md)
NPM_FILES=\
"README.md" \
"COPYING" \
"AUTHORS.rst" \
"dist" \
"lib" \
"erc20-tools" \
"eslint.config.mjs" \
"fs-worker.webpack.config.cjs" \
"package.json" \
"webpack.config.cjs"
MAN_FILES=\
erc20-token-send
all: build-man build-npm build-scripts
check: eslint
eslint:
npm \
install \
--save-dev; \
npx \
eslint \
"."
install: install-scripts install-doc install-examples install-man
install-scripts:
$(_INSTALL_DIR) \
"$(LIB_DIR)/nodejs/lib"
for _file in $(NPM_FILES); do
$(_INSTALL_FILE) \
"$${_file}" \
"$(LIB_DIR)/nodejs/$${_file}"; \
ln \
-s \
"$(PREFIX)/lib/$(_PROJECT_NPM)/nodejs/$${_file}" \
"$(LIB_DIR)/$${_file}" || \
true; \
done
# ln \
# -s \
# "$(PREFIX)/lib/$(_PROJECT_NPM)/node/lib$(_PROJECT_NPM)" \
# "$(LIB_DIR)/$(_PROJECT_NPM)-js" || \
# true
build-man:
git \
submodule \
update \
--init \
"man" || \
true
mkdir \
-p \
"build/man"
cp \
"man/variables.rst" \
"build/man"
_version="$$( \
npm \
view \
"$${PWD}" \
"version")"; \
sed \
"s/insert.version.here/$${_version}/" \
-i \
"build/man/variables.rst"; \
for _file in $(MAN_FILES); do \
cp \
"man/$${_file}.1.rst" \
"build/man/$${_file}.1.rst"; \
rst2man \
"build/man/$${_file}.1.rst" \
"build/man/$${_file}.1"; \
rm \
"build/man/$${_file}.1.rst"; \
done
rm \
"build/man/variables.rst"
build-npm:
make \
build-man
cp \
-r \
$(NPM_FILES) \
"build"; \
cd \
"build"; \
_version="$$( \
npm \
view \
"$${PWD}" \
"version")"; \
npm \
install; \
npm \
run \
"build"; \
npm \
pack; \
mv \
"$(_PROJECT_NPM)-$${_version}.tgz" \
".."
install-npm:
_npm_opts=( \
-g \
--prefix \
'$(USR_DIR)' \
); \
_version="$$( \
npm \
view \
"$${PWD}" \
"version")"; \
npm \
install \
"$${_npm_opts[@]}" \
"$(_PROJECT_NPM)-$${_version}.tgz"; \
$(_INSTALL_DIR) \
"$(DESTDIR)$(PREFIX)/lib"; \
ln \
-s \
"$(NODE_DIR)" \
"$(LIB_DIR)" || \
true
publish-npm:
cd \
"build"; \
npm \
publish \
--access \
"public"
install-doc:
$(_INSTALL_FILE) \
$(DOC_FILES) \
-t \
$(DOC_DIR)
install-man:
$(_INSTALL_DIR) \
"$(MAN_DIR)/man1"
$(_INSTALL_FILE) \
"build/man/$(_PROJECT_NPM).1" \
"$(MAN_DIR)/man1/$(_PROJECT_NPM).1"
.PHONY: check build-man build-npm build-scripts install install-doc install-man install-npm install-scripts shellcheck