-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
505 lines (424 loc) · 21.6 KB
/
Makefile
File metadata and controls
505 lines (424 loc) · 21.6 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
# ---------------------------------------
# Author: David Marsh <rdmarsh@gmail.com>
# ---------------------------------------
#
# This Makefile is used to generate files for elm
# for usage: make help
# more info: make about
#
# elm Extract LogicMonitor
# Copyright (C) 2021--2025 David Marsh rdmarsh@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# MAKE FLAGS
#MAKEFLAGS += -j4
EDITABLE ?= --editable
# API VERSION
# ---------------------------------------
# set to '3' to use api v3, anything else will use v2
apiversion ?= 3
# FILE EXTENSIONS
# ---------------------------------------
# change only if needed
JSN ?= json
J2 ?= j2
PY ?= py
# SOURCE DIR and FILENAMES
# ---------------------------------------
# change only if needed
name := elm
prog := $(name).$(PY)
HOME := $(shell echo $$HOME)
bakdir := ../$(name)_back
cfgdir := $(HOME)/.$(name)
bindir := $(HOME)/bin
cmddir := _cmds
defdir := _defs
jnjdir := _jnja
# EXECUTABLE AND PROGRAM FLAGS
# ---------------------------------------
# change only if needed
CURL ?= curl
JQ ?= jq
AWK ?= awk
JINJA ?= venv/bin/jinja2
# for testing non-required commands
GREP ?= grep
GREPFLAGS += -l
# for backup
TAR ?= tar
TARFLAGS += -cvf
#python
PYTHON ?= python3
# venv location
VENV := venv
# pip for install
PIP ?= $(VENV)/bin/$(PYTHON) -m pip
PIPFLAGS += install
REQUIREMENTS = requirements.txt
# for pyinstaller
pyiworkdir := _build
pyidistdir := _dist
PYINST ?= $(VENV)/bin/pyinstaller
PYINSTFLAGS += --name $(name) --hidden-import=engine --collect-all=pandas --collect-all=numpy --workpath $(pyiworkdir) --distpath $(pyidistdir) --noconfirm
# SWAGGER PATHS AND API VERSION
# ---------------------------------------
# do not change
SWAGGER_V2_URL := https://www.logicmonitor.com/swagger-ui-master/dist/swagger.json
SWAGGER_V3_URL := https://www.logicmonitor.com/swagger-ui-master/api-v3/dist/swagger.json
ifneq ($(apiversion),3)
apiversion = 2
endif
ifeq ($(apiversion),3)
lm_swagger_url := $(SWAGGER_V3_URL)
else
lm_swagger_url := $(SWAGGER_V2_URL)
endif
# BUILD SOURCE AND TARGTS
# ---------------------------------------
# do not change
CMDSOURCES := $(wildcard $(defdir)/[A-Z]*.$(JSN))
CMDTARGETS := $(patsubst $(defdir)/%.$(JSN),$(cmddir)/%.$(PY),$(CMDSOURCES))
TSTTARGETS := $(patsubst $(defdir)/%.$(JSN),%,$(CMDSOURCES))
REQSOURCES := $(patsubst $(defdir)/%.$(JSN),%,$$(shell $(GREP) $(GREPFLAGS) "\"required\":true" $(CMDSOURCES)))
NONREQTARGETS := $(filter-out $(REQSOURCES),$(TSTTARGETS))
NONREQTARGETS := $(filter-out ExternalApiStats,$(NONREQTARGETS))
# COLOUR OUTPUT
# ---------------------------------------
# do not change
NO_COLOR=\033[0m
OK_COLOR=\033[0;32m
IN_COLOR=\033[0;34m
WR_COLOR=\033[0;33m
ER_COLOR=\033[0;31m
OK_STRING=$(OK_COLOR)[OK]$(NO_COLOR)
IN_STRING=$(IN_COLOR)[INFO]$(NO_COLOR)
WR_STRING=$(WR_COLOR)[WARN]$(NO_COLOR)
ER_STRING=$(ER_COLOR)[ERROR]$(NO_COLOR)
# TARGETS
# ---------------------------------------
# do not change
.PHONY: all
all: render build ## Build everything except install (init, render, cfg, build)
@echo "$(OK_STRING) $@"
# INIT FOR COMPILE
# =======================================
# do not change
.PHONY: init
init: $(defdir)/commands.$(JSN) upgrade ## Check prerequisites, initialise dirs, get swagger file, create definition files, install jinja2-cli
$(GREP) -m1 jinja2-cli $(REQUIREMENTS) | xargs -r $(PIP) $(PIPFLAGS) $(grep -m1 jinja2-cli $(REQUIREMENTS)
@echo "$(OK_STRING) $@"
# REQ FOR COMPILE
# =======================================
# do not change
.PHONY: PYTHON-exists CURL-exists JINJA-exists JQ-exists PYINST-exists
PYTHON-exists: ; @which $(PYTHON) || { echo "$(ER_STRING) $(PYTHON) not found"; exit 1; }
PYINST-exists: ; @which $(PYINST) || { echo "$(ER_STRING) $(PYINST) not found"; exit 1; }
CURL-exists: ; @which $(CURL) || { echo "$(ER_STRING) $(CURL) not found"; exit 1; }
JINJA-exists: ; @which $(JINJA) || { echo "$(ER_STRING) $(JINJA) not found"; exit 1; }
JQ-exists: ; @which $(JQ) || { echo "$(ER_STRING) $(JQ) not found"; exit 1; }
# REQ DIRS
# =======================================
# do not change
$(bakdir) $(cmddir) $(defdir) $(cfgdir) $(bindir):
mkdir -p $@
chown $$(id -u):$$(id -g) $@
chmod 700 $@
@echo "$(OK_STRING) $@"
# Combine the commands.*.json files into one for use by jinja later.
# MAKE is called again so we don't have to call make manually after all
# defs have been created after making the commands.*.json files.
$(defdir)/commands.$(JSN): $(defdir)/commands.documented.$(JSN) $(defdir)/commands.undocumented.$(JSN) | $(defdir) JQ-exists
$(JQ) -s '{commands: (.[0].commands + .[1].commands)}' $^ > $@
@echo "$(OK_STRING) $@"
$(MAKE)
#todo avoid calling make twice
# The commands.*.json files are used to trigger when the individual defs
# need to be (re)built as we don't know the names of the individual def
# files at this stage and CMDSOURCES isn't populated. There's probably
# a better way to do this, but this will do for now. First jq creates
# commands.*.json from the swagger files. Second jq creates individual
# def json files from commands.*.json files
# cant split these long lines, high level magic
# https://stackoverflow.com/questions/56167046/jq-split-a-huge-json-of-array-and-save-into-file-named-with-a-value
$(defdir)/commands.documented.$(JSN): $(defdir)/swagger.$(JSN) $(MAKEFILE_LIST) | $(defdir) JQ-exists
$(JQ) '{ "commands": [ .paths | to_entries[] | .key as $$path | .value | to_entries[] | select(.key == "get") | .value.operationId as $$opid | .value.operationId |= gsub("^(get|collect|fetch)";"") | { opid:$$opid, command:.value.operationId, path:$$path, summary:.value.summary, tag:.value.tags[0], options:(.value.parameters // []) } ]}' $< > $@
$(JQ) -c '.commands[] | (.command | if type == "number" then . else tostring | gsub("[^A-Za-z0-9-_]";"+") end), .' $@ | $(AWK) 'function fn(s) { sub(/^"/,"",s); sub(/"$$/,"",s); return "$(defdir)/" s ".$(JSN)"; } NR%2{f=fn($$0); next} {print > f; close(f);} '
@echo "$(OK_STRING) $@"
$(defdir)/commands.undocumented.$(JSN): ./swagger.undocumented.$(JSN) $(MAKEFILE_LIST) | $(defdir) JQ-exists
$(JQ) '{ "commands": [ .paths | to_entries[] | .key as $$path | .value | to_entries[] | select(.key == "get") | .value.operationId as $$opid | .value.operationId |= gsub("^(get|collect|fetch)";"") | { opid:$$opid, command:.value.operationId, path:$$path, summary:.value.summary, tag:.value.tags[0], options:(.value.parameters // []) } ]}' $< > $@
$(JQ) -c '.commands[] | (.command | if type == "number" then . else tostring | gsub("[^A-Za-z0-9-_]";"+") end), .' $@ | $(AWK) 'function fn(s) { sub(/^"/,"",s); sub(/"$$/,"",s); return "$(defdir)/" s ".$(JSN)"; } NR%2{f=fn($$0); next} {print > f; close(f);} '
@echo "$(OK_STRING) $@"
$(defdir)/swagger.$(JSN): $(MAKEFILE_LIST) | $(defdir) CURL-exists
$(CURL) $(lm_swagger_url) $(OUTPUT_OPTION)
@echo "$(OK_STRING) $@"
.PHONY: cfg
cfg: $(cfgdir)/config.example.ini ## Create config dir, copy example file and set permissions of all config files
@echo "$(OK_STRING) $@"
.PHONY: $(cfgdir)/config.example.ini
$(cfgdir)/config.example.ini: config.example.ini | $(cfgdir)
cmp -s $< $@ || cp $< $@
chmod 600 $(@D)/*
@if [ ! -s $(@D)/config.ini ] ; then \
echo ;\
echo "$(OK_COLOR)>>> API credentials can be placed in an ini file <<<$(NO_COLOR)" ;\
echo ;\
echo "cp $(@D)/config.example.ini $(@D)/config.ini" ;\
echo "vi $(@D)/config.ini" ;\
echo ;\
echo ;\
fi
@echo "$(OK_STRING) $@"
# BUILD AND INSTALL COMMANDS
# =======================================
# do not change
.PHONY: render
render: init engine.$(PY) $(prog) ## Make python commands from templates and install requirements
@echo "$(OK_STRING) $@"
$(prog): $(jnjdir)/$(prog).$(J2) $(defdir)/commands.$(JSN) $(CMDTARGETS) | JINJA-exists
$(JINJA) $(jnjdir)/$(prog).$(J2) $(defdir)/commands.$(JSN) $(OUTPUT_OPTION)
@echo "$(OK_STRING) $@"
engine.$(PY): $(jnjdir)/engine.$(PY).$(J2) $(defdir)/commands.$(JSN) | JINJA-exists
$(JINJA) -D apiversion=$(apiversion) $^ $(OUTPUT_OPTION)
@echo "$(OK_STRING) $@"
$(cmddir)/%.$(PY): $(jnjdir)/command.$(PY).$(J2) $(defdir)/%.$(JSN) | $(cmddir) JINJA-exists
$(JINJA) -D apiversion=$(apiversion) $^ $(OUTPUT_OPTION)
@echo "$(OK_STRING) $@"
.PHONY: build
build: render $(pyidistdir)/$(name)/$(name) ## (Re)build the script
@echo "$(OK_STRING) $@"
$(pyidistdir)/$(name)/$(name): reqs | PYTHON-exists PYINST-exists
$(PIP) $(PIPFLAGS) $(EDITABLE) .
$(PYINST) $(PYINSTFLAGS) $(prog)
@echo "$(OK_STRING) $@"
.PHONY: install
install: $(bindir)/$(name) cfg ## (Re)installs the script and modifies the path
@echo
@echo "$(OK_COLOR)>>> If needed, you can add \$${HOME}/bin to your \$$PATH like this <<<$(NO_COLOR)"
@echo
@echo "echo 'export PATH=\"\$${HOME}/bin:\$${PATH}\"' >> \$${HOME}/.bash_profile"
@echo "source ~/.bash_profile"
@echo
@echo "$(OK_COLOR)>>> Finished <<<$(NO_COLOR)"
@echo
@echo "You can now run '$(OK_COLOR)elm$(NO_COLOR)' from anywhere on the cli"
@echo "$(WR_COLOR)Note:$(NO_COLOR) The first run may take longer than usual"
@echo
@echo "$(OK_STRING) $@"
$(bindir)/$(name): $(pyidistdir)/$(name)/$(name) | $(bindir)
$(RM) -r $(dir $@)_internal
cp -r $(pyidistdir)/$(name)/_internal $(dir $@)
install -m 755 $< $@
@echo "$(OK_STRING) $@"
.PHONY: reqs
reqs: $(REQUIREMENTS) upgrade | PYTHON-exists ## Install python requirements
$(PIP) $(PIPFLAGS) -r $<
@echo "$(OK_STRING) $@"
.PHONY: upgrade
upgrade: $(VENV) | PYTHON-exists ## Upgrade pip
$(PIP) $(PIPFLAGS) --upgrade pip
$(VENV): | PYTHON-exists
$(PYTHON) -m venv $@
@echo "$(OK_STRING) $@"
# TESTS
# =======================================
# do not change
.PHONY: test
test: testbasic testfmts testverb testid ## Run quick and simple tests
@echo "$(OK_STRING) $@"
.PHONY: testlong
testlong: testhelp testcount testtotal ## Tests that take a long time to complete
@echo "$(OK_STRING) $@"
.PHONY: testbasic
testbasic: ## Test basic flags
@echo testing: ./$(name) ; ./$(name) >/dev/null
@echo testing: ./$(name) --help ; ./$(name) --help >/dev/null
@echo testing: ./$(name) --version ; ./$(name) --version >/dev/null
@echo "$(OK_STRING) $@"
.PHONY: texttext
testtext: testH testI testHI testhead testfoot testheadfoot ## Test commands that alter columns, indices, header and footer
@echo "$(OK_STRING) $@"
.PHONY: testhelp
testhelp: ## Test all commands with help flag
@$(foreach cmd,$(TSTTARGETS), \
echo testing: ./$(name) $(cmd) --help ;\
./$(name) $(cmd) --help >/dev/null || exit ;\
)
@echo "$(OK_STRING) $@"
.PHONY: testid
testid: ## Test a command with an id flag (connects to LM)
@echo testing: ./$(name) AdminById --id 2 ; ./$(name) AdminById --id 2 ;
@echo "$(OK_STRING) $@"
.PHONY: testcount
testcount: ## Test 'non-required' commands with count flag (connects to LM)
@$(foreach cmd,$(NONREQTARGETS), \
echo testing: ./$(name) $(cmd) -c ;\
./$(name) $(cmd) -c || exit ;\
)
@echo "$(OK_STRING) $@"
.PHONY: testtotal
testtotal: ## Test 'non-required' commands with total flag (connects to LM)
@$(foreach cmd,$(NONREQTARGETS), \
echo testing: ./$(name) $(cmd) -C ;\
./$(name) $(cmd) -C || exit ;\
)
@echo "$(OK_STRING) $@"
.PHONY: testfmts
testfmts: ## Test a command with all formats (connects to LM)
@echo testing: ./$(name) --format csv MetricsUsage ; ./$(name) --format csv MetricsUsage
@echo testing: ./$(name) --format html MetricsUsage ; ./$(name) --format html MetricsUsage
@echo testing: ./$(name) --format prettyhtml MetricsUsage ; ./$(name) --format prettyhtml MetricsUsage
@echo testing: ./$(name) --format jira MetricsUsage ; ./$(name) --format jira MetricsUsage
@echo testing: ./$(name) --format json MetricsUsage ; ./$(name) --format json MetricsUsage
@echo testing: ./$(name) --format prettyjson MetricsUsage ; ./$(name) --format prettyjson MetricsUsage
@echo testing: ./$(name) --format latex MetricsUsage ; ./$(name) --format latex MetricsUsage
@echo testing: ./$(name) --format md MetricsUsage ; ./$(name) --format md MetricsUsage
@echo testing: ./$(name) --format rst MetricsUsage ; ./$(name) --format rst MetricsUsage
@echo testing: ./$(name) --format tab MetricsUsage ; ./$(name) --format tab MetricsUsage
@echo testing: ./$(name) --format raw MetricsUsage ; ./$(name) --format raw MetricsUsage
@echo testing: ./$(name) --format txt MetricsUsage ; ./$(name) --format txt MetricsUsage
@echo testing: ./$(name) --format api MetricsUsage ; ./$(name) --format api MetricsUsage
@echo "$(OK_STRING) $@"
.PHONY: testH
testH: ## Test a command and hide headers (connects to LM)
@echo testing: ./$(name) -H --format csv MetricsUsage ; ./$(name) -H --format csv MetricsUsage
@echo testing: ./$(name) -H --format html MetricsUsage ; ./$(name) -H --format html MetricsUsage
@echo testing: ./$(name) -H --format prettyhtml MetricsUsage ; ./$(name) -H --format prettyhtml MetricsUsage
@echo testing: ./$(name) -H --format jira MetricsUsage ; ./$(name) -H --format jira MetricsUsage
@echo testing: ./$(name) -H --format latex MetricsUsage ; ./$(name) -H --format latex MetricsUsage
@echo testing: ./$(name) -H --format md MetricsUsage ; ./$(name) -H --format md MetricsUsage
@echo testing: ./$(name) -H --format rst MetricsUsage ; ./$(name) -H --format rst MetricsUsage
@echo testing: ./$(name) -H --format tab MetricsUsage ; ./$(name) -H --format tab MetricsUsage
@echo testing: ./$(name) -H --format txt MetricsUsage ; ./$(name) -H --format txt MetricsUsage
@echo "$(OK_STRING) $@"
.PHONY: testI
testI: ## Test a command and show index (connects to LM)
@echo testing: ./$(name) -I --format csv MetricsUsage ; ./$(name) -I --format csv MetricsUsage
@echo testing: ./$(name) -I --format html MetricsUsage ; ./$(name) -I --format html MetricsUsage
@echo testing: ./$(name) -I --format prettyhtml MetricsUsage ; ./$(name) -I --format prettyhtml MetricsUsage
@echo testing: ./$(name) -I --format jira MetricsUsage ; ./$(name) -I --format jira MetricsUsage
@echo testing: ./$(name) -I --format latex MetricsUsage ; ./$(name) -I --format latex MetricsUsage
@echo testing: ./$(name) -I --format md MetricsUsage ; ./$(name) -I --format md MetricsUsage
@echo testing: ./$(name) -I --format rst MetricsUsage ; ./$(name) -I --format rst MetricsUsage
@echo testing: ./$(name) -I --format tab MetricsUsage ; ./$(name) -I --format tab MetricsUsage
@echo testing: ./$(name) -I --format txt MetricsUsage ; ./$(name) -I --format txt MetricsUsage
@echo "$(OK_STRING) $@"
.PHONY: testHI
testHI: ## Test a command, hide headers and show index (connects to LM)
@echo testing: ./$(name) -H -I --format csv MetricsUsage ; ./$(name) -H -I --format csv MetricsUsage
@echo testing: ./$(name) -H -I --format html MetricsUsage ; ./$(name) -H -I --format html MetricsUsage
@echo testing: ./$(name) -H -I --format prettyhtml MetricsUsage ; ./$(name) -H -I --format prettyhtml MetricsUsage
@echo testing: ./$(name) -H -I --format jira MetricsUsage ; ./$(name) -H -I --format jira MetricsUsage
@echo testing: ./$(name) -H -I --format latex MetricsUsage ; ./$(name) -H -I --format latex MetricsUsage
@echo testing: ./$(name) -H -I --format md MetricsUsage ; ./$(name) -H -I --format md MetricsUsage
@echo testing: ./$(name) -H -I --format rst MetricsUsage ; ./$(name) -H -I --format rst MetricsUsage
@echo testing: ./$(name) -H -I --format tab MetricsUsage ; ./$(name) -H -I --format tab MetricsUsage
@echo testing: ./$(name) -H -I --format txt MetricsUsage ; ./$(name) -H -I --format txt MetricsUsage
@echo "$(OK_STRING) $@"
.PHONY: testhead
testhead: ## Test a command, custom header text (connects to LM)
@echo testing: ./$(name) --head \"this is header text\" --format jira MetricsUsage ; ./$(name) --head "this is header text" --format jira MetricsUsage
@echo testing: ./$(name) --head \"this is header text\" --format md MetricsUsage ; ./$(name) --head "this is header text" --format md MetricsUsage
@echo testing: ./$(name) --head \"this is header text\" --format rst MetricsUsage ; ./$(name) --head "this is header text" --format rst MetricsUsage
@echo testing: ./$(name) --head \"this is header text\" --format tab MetricsUsage ; ./$(name) --head "this is header text" --format tab MetricsUsage
@echo testing: ./$(name) --head \"this is header text\" --format txt MetricsUsage ; ./$(name) --head "this is header text" --format txt MetricsUsage
@echo "$(OK_STRING) $@"
.PHONY: testfoot
testfoot: ## Test a command, custom footer text (connects to LM)
@echo testing: ./$(name) --foot \"this is footer text\" --format jira MetricsUsage ; ./$(name) --foot "this is footer text" --format jira MetricsUsage
@echo testing: ./$(name) --foot \"this is footer text\" --format md MetricsUsage ; ./$(name) --foot "this is footer text" --format md MetricsUsage
@echo testing: ./$(name) --foot \"this is footer text\" --format rst MetricsUsage ; ./$(name) --foot "this is footer text" --format rst MetricsUsage
@echo testing: ./$(name) --foot \"this is footer text\" --format tab MetricsUsage ; ./$(name) --foot "this is footer text" --format tab MetricsUsage
@echo testing: ./$(name) --foot \"this is footer text\" --format txt MetricsUsage ; ./$(name) --foot "this is footer text" --format txt MetricsUsage
@echo "$(OK_STRING) $@"
.PHONY: testheadfoot
testheadfoot: ## Test a command, custom header and footer text (connects to LM)
@echo testing: ./$(name) --head \"this is header text\" --foot \"this is footer text\" --format jira MetricsUsage ; ./$(name) --head "this is header text" --foot "this is footer text" --format jira MetricsUsage
@echo testing: ./$(name) --head \"this is header text\" --foot \"this is footer text\" --format md MetricsUsage ; ./$(name) --head "this is header text" --foot "this is footer text" --format md MetricsUsage
@echo testing: ./$(name) --head \"this is header text\" --foot \"this is footer text\" --format rst MetricsUsage ; ./$(name) --head "this is header text" --foot "this is footer text" --format rst MetricsUsage
@echo testing: ./$(name) --head \"this is header text\" --foot \"this is footer text\" --format tab MetricsUsage ; ./$(name) --head "this is header text" --foot "this is footer text" --format tab MetricsUsage
@echo testing: ./$(name) --head \"this is header text\" --foot \"this is footer text\" --format txt MetricsUsage ; ./$(name) --head "this is header text" --foot "this is footer text" --format txt MetricsUsage
@echo "$(OK_STRING) $@"
.PHONY: testverb
testverb: ## Test the verbose flags (connects to LM)
@echo testing: ./$(name) -v MetricsUsage ; ./$(name) -v MetricsUsage
@echo testing: ./$(name) -vv MetricsUsage ; ./$(name) -vv MetricsUsage
@echo "$(OK_STRING) $@"
.PHONY: fail
fail: ## A failing test
@echo test false ; false >/dev/null
# BACKUP
# =======================================
# do not change
.PHONY: back
back: nomac $(bakdir) ## TAR and backup (eg ../name_backup/name.YYYY-MM-DD.tar.gz)
$(TAR) $(TARFLAGS) $(bakdir)/$(name).$(shell date +%Y-%m-%d).tar.gz .
@echo "$(OK_STRING) $@"
.PHONY: clean
clean: nomac ## Remove generated files
$(RM) -r $(VENV)
$(RM) -r __pycache__
$(RM) -r $(name).egg-info
$(RM) -r $(cmddir) $(defdir)
$(RM) -r $(pyiworkdir) $(pyidistdir)
ifdef CMDTARGETS
$(RM) $(CMDTARGETS)
endif
$(RM) $(prog)
$(RM) engine.$(PY)
$(RM) $(name).spec
@echo "$(OK_STRING) $@"
.PHONY: nomac
nomac: ## Remove unneeded mac files
$(RM) .DS_Store
@echo "$(OK_STRING) $@"
# ABOUT COPY HELP
# =======================================
# do not change
.PHONY: about
about: ## About this Makefile
@echo
@echo 'This Makefile is used to generate files for $(name)'
@echo
@echo 'Run "make help" to for how to run'
@echo
@echo 'See https://github.com/rdmarsh/$(name)'
@echo
.PHONY: copying
copying: ## Copyright notice
@echo
@echo 'Copyright (C) 2021--2025 David Marsh'
@echo 'rdmarsh@gmail.com'
@echo
@echo 'This program is free software: you can redistribute it and/or modify'
@echo 'it under the terms of the GNU General Public License as published by'
@echo 'the Free Software Foundation, either version 3 of the License, or'
@echo '(at your option) any later version.'
@echo
@echo 'This program comes with ABSOLUTELY NO WARRANTY.'
@echo 'This is free software, and you are welcome to redistribute it'
@echo 'under certain conditions. View the file "LICENSE" for details.'
@echo
.PHONY: help
help: ## Show this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage: make [flags] [option]\n"} /^[$$()% \.0-9a-zA-Z_-]+:.*?##/ { printf " \033[36mmake %-12s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
@echo
@echo 'Useful make flags:'
@echo ' make -n : dry run'
@echo ' make -j : run simultaneous jobs'
@echo ' make -B : force make target'
@echo
@echo 'You can override Makefile vars like so:'
@echo ' make apiversion=2'
@echo