Debian Codegraph @

Makefile

raw
1 #! /usr/bin/make -rRf
2 #?
3 #? NAME
4 #? Makefile - makefile for O-Saft project
5 #?
6 #? SYNOPSYS
7 #? make [options] [target] [...]
8 #?
9 #? DESCRIPTION
10 #? For help about the targets herein, please see:
11 #?
12 #? make
13 #? make help
14 #?
15 #? For detailled documentation how GNU Make, its syntax and conventions as
16 #? well as some special syntax of macros and targets is used here, please
17 #? refer to Makefile.pod , for example by using "perldoc Makefile.pod" .
18 #? The term "SEE Make:some text" is used to reference to Makefile.pod .
19 #
20 # HACKER's INFO
21 # For the public available targets see below of "well known targets" .
22 #?
23 #? VERSION
24 #? @(#) Makefile 2.19 22/11/19 00:14:07
25 #?
26 #? AUTHOR
27 #? 21-dec-12 Achim Hoffmann
28 #?
29 # -----------------------------------------------------------------------------
30
31 _SID = 2.19
32 # define our own SID as variable, if needed ...
33 # SEE O-Saft:Makefile Version String
34 # Known variables herein (8/2019) to be changed are:
35 # _SID
36 # _INST.text
37 # _INST.is_edit
38
39 ALL.includes := Makefile
40 # must be := to avoid overwrite after includes
41 # each $(TEST.dir)/Makefile* will add itself to ALL.includes
42
43 MAKEFILE = Makefile
44 # define variable for myself, this allows to use some targets
45 # within other makefiles
46 # Note that $(MAKEFILE) is used where any Makefile is possible
47 # and Makefile is used when exactly this file is meant.
48 # $(ALL.Makefiles) is used, when all Makefiles are needed.
49
50 MAKEFLAGS = --no-builtin-variables --no-builtin-rules
51 .SUFFIXES:
52
53 .DEFAULT:
54 @echo "**ERROR: unknown target '$(MAKECMDGOALS)'"
55
56 first-target-is-default: help
57
58 #_____________________________________________________________________________
59 #________________________________________________________________ variables __|
60
61 Project = o-saft
62 ProjectName = O-Saft
63 INSTALL.dir = /usr/local/$(Project)
64
65 # tool source files
66 SRC.lic = yeast.lic
67 DEV.pl = yeast.pl
68 CHK.pl = checkAllCiphers.pl
69 OSD.dir = OSaft/Doc
70 OSD.pm = OSaft/Doc/Data.pm
71 OSD.txt = \
72 coding.txt \
73 glossary.txt \
74 help.txt \
75 links.txt \
76 misc.txt \
77 rfc.txt \
78 tools.txt
79 SRC.txt = $(OSD.txt:%=$(OSD.dir)/%)
80 NET.pm = SSLinfo.pm \
81 SSLhello.pm
82 OSAFT.pm = Ciphers.pm Data.pm Text.pm error_handler.pm
83 USR.pm = \
84 $(Project)-dbx.pm \
85 $(Project)-man.pm \
86 $(Project)-usr.pm
87 SRC.pm = \
88 osaft.pm \
89 $(NET.pm:%=Net/%) \
90 $(OSAFT.pm:%=OSaft/%) \
91 $(USR.pm) \
92 $(OSD.pm)
93 SRC.sh = $(Project)
94 SRC.pl = $(Project).pl
95 SRC.tcl = $(Project).tcl
96 SRC.gui = $(Project).tcl $(Project)-img.tcl
97 SRC.cgi = $(Project).cgi
98 SRC.php = $(Project).php
99 SRC.docker = \
100 $(Project)-docker \
101 $(Project)-docker-dev \
102 Dockerfile
103 SRC.rc = .$(SRC.pl)
104
105 SRC.exe = $(SRC.pl) $(SRC.gui) $(CHK.pl) $(DEV.pl) $(SRC.sh)
106
107 SRC.make = Makefile
108 SRC.misc = README.md CHANGES
109 SRC.inst = $(SRC.contrib.dir)/INSTALL-template.sh
110
111 # contrib files
112 SRC.contrib.dir = contrib
113 SRC.contrib.examples= filter_examples usage_examples
114 SRC.contrib.post.awk= \
115 Cert-beautify.awk \
116 HTML-simple.awk HTML-table.awk \
117 JSON-struct.awk JSON-array.awk \
118 XML-attribute.awk XML-value.awk \
119 lazy_checks.awk
120 SRC.contrib.post = \
121 Cert-beautify.pl \
122 alertscript.pl \
123 alertscript.cfg \
124 bunt.pl \
125 bunt.sh \
126 symbol.pl
127 SRC.contrib.misc = \
128 cipher_check.sh \
129 critic.sh \
130 gen_standalone.sh \
131 distribution_install.sh \
132 install_openssl.sh \
133 install_perl_modules.pl \
134 INSTALL-template.sh \
135 Dockerfile.alpine-3.6
136
137 SRC.contrib.zap = zap_config.sh zap_config.xml
138 # some file should get the $(Project) suffix, which is appended later
139 SRC.contrib.complete= \
140 bash_completion \
141 dash_completion \
142 fish_completion \
143 tcsh_completion
144 SRC.contrib = \
145 $(SRC.contrib.complete:%=$(SRC.contrib.dir)/%_$(Project)) \
146 $(SRC.contrib.examples:%=$(SRC.contrib.dir)/%) \
147 $(SRC.contrib.post.awk:%=$(SRC.contrib.dir)/%) \
148 $(SRC.contrib.post:%=$(SRC.contrib.dir)/%) \
149 $(SRC.contrib.misc:%=$(SRC.contrib.dir)/%) \
150 $(SRC.contrib.zap:%=$(SRC.contrib.dir)/%)
151
152
153 TEST.dir = t
154 TEST.logdir = $(TEST.dir)/log
155 TEST.do = SSLinfo.pl \
156 o-saft_bench.sh \
157 cloc-total.awk \
158 critic_345.sh \
159 test-bunt.pl.txt
160 TEST.critic.rc = .perlcriticrc
161 SRC.test = \
162 $(TEST.do:%=$(TEST.dir)/%) \
163 $(TEST.critic.rc:%=$(TEST.dir)/%)
164 TEST.Makefiles = \
165 Makefile Makefile.inc Makefile.help Makefile.pod \
166 Makefile.gen \
167 Makefile.opt Makefile.cmd Makefile.ext Makefile.exit \
168 Makefile.cgi Makefile.tcl Makefile.misc Makefile.warnings \
169 Makefile.critic Makefile.dev Makefile.etc Makefile.template \
170 Makefile.docker Makefile.FQDN Makefile.examples
171 SRC.Makefiles = $(TEST.Makefiles:%=$(TEST.dir)/%)
172
173 # documentation files
174 DOC.dir = docs
175 DOC.src = o-saft_CLI_data_flow.odg \
176 o-saft_GUI_data_flow.odg \
177 o-saft_docker.de.odg \
178 o-saft_docker.en.odg
179 SRC.doc = $(DOC.src:%=$(DOC.dir)/%)
180 WEB.dir = docs/img
181 WEB.src = \
182 img.css \
183 O-Saft_CLI-cipher.png \
184 O-Saft_CLI-altname.png \
185 O-Saft_GUI-altname.png \
186 O-Saft_GUI-check.png \
187 O-Saft_GUI-cmd--docker.png \
188 O-Saft_GUI-cmd.png \
189 O-Saft_GUI-cmd-0.png \
190 O-Saft_GUI-filter.png \
191 O-Saft_GUI-help-0.png \
192 O-Saft_GUI-help-1.png \
193 O-Saft_GUI-opt.png \
194 O-Saft_GUI-prot.png \
195 O-Saft_GUI-vulns.png \
196 O-Saft_CLI-vulns.png \
197 O-Saft_CLI__faked.txt
198 SRC.web = $(WEB.src:%=$(WEB.dir)/%)
199
200 # generated files
201 TMP.dir = /tmp/$(Project)
202 GEN.html = $(DOC.dir)/$(Project).html
203 GEN.cgi.html = $(DOC.dir)/$(Project).cgi.html
204 GEN.text = $(DOC.dir)/$(Project).txt
205 GEN.wiki = $(DOC.dir)/$(Project).wiki
206 GEN.man = $(DOC.dir)/$(Project).1
207 GEN.pod = $(DOC.dir)/$(Project).pod
208 GEN.src = $(SRC.contrib.dir)/$(Project)-standalone.pl
209 GEN.pdf = $(SRC.doc:%.odg=%.pdf)
210 GEN.inst = INSTALL.sh
211 GEN.tags = tags
212 GEN.rel = $(Project).rel
213
214 GEN.tgz = $(Project).tgz
215 GEN.tmptgz = $(TMP.dir)/$(GEN.tgz)
216
217 # generated files for internal use, i.e. $(SRC.tcl)
218 # TODO: because make does not allow = in target names, the generated targets
219 # should use - instead
220 LIST.DOC_data = --help --help=opts --help=commands --help=glossar --help=alias \
221 --help=data --help=data --help=checks --help=regex --help=rfc \
222 --help=ciphers-html --help=ciphers-text
223 # --help=warnings uses a different command to be generated
224 GEN.DOC.data = $(LIST.DOC_data:%=$(DOC.dir)/$(SRC.pl).%)
225 GEN.DOC.data += $(DOC.dir)/$(SRC.pl).--help=warnings
226
227 # summary variables
228 GEN.docs = $(GEN.pod) $(GEN.html) $(GEN.cgi.html) $(GEN.text) $(GEN.wiki) $(GEN.man)
229 # NOTE: sequence in ALL.Makefiles is important, for example when used in target doc
230 ALL.Makefiles = $(SRC.make) $(SRC.Makefiles)
231 ALL.osaft = $(SRC.pl) $(SRC.gui) $(CHK.pl) $(SRC.pm) $(SRC.sh) $(SRC.txt) $(SRC.rc) $(SRC.docker)
232 ALL.exe = $(SRC.exe) $(SRC.cgi) $(SRC.php) $(GEN.src) $(SRC.docker)
233 ALL.tst = $(SRC.test)
234 ALL.contrib = $(SRC.contrib)
235 ALL.doc = $(SRC.doc) $(SRC.web)
236 ALL.pm = $(SRC.pm)
237 ALL.gen = $(GEN.src) $(GEN.docs) $(GEN.DOC.data)
238 ALL.docs = $(SRC.doc) $(GEN.docs)
239 # NOTE: ALL.docs are the files for user documentation, ALL.doc are SRC-files
240 # $(GEN.wiki) is rarley used but part of ALL.gen for simplicity
241 # # $(GEN.tags) added in t/Makefile.misc
242 ALL.src = \
243 $(ALL.exe) \
244 $(ALL.pm) \
245 $(SRC.txt) \
246 $(SRC.rc) \
247 $(SRC.misc) \
248 $(SRC.doc) \
249 $(ALL.gen) \
250 $(ALL.Makefiles) \
251 $(ALL.tst) \
252 $(ALL.contrib)
253 ALL.tgz = $(ALL.src:%=O-Saft/%)
254 ALL.tgz += O-Saft/$(GEN.inst)
255
256 # internal used make
257 MAKE = $(MAKE_COMMAND)
258 # some rules need to have a command, otherwise they are not evaluated
259 EXE.dummy = /bin/echo -n ""
260 # internal used tools (paths hardcoded!)
261 EXE.single = contrib/gen_standalone.sh
262 EXE.docker = o-saft-docker
263 EXE.pl = $(SRC.pl)
264 # SRC.pl is used for generating a couple of data
265
266 # other tools
267 EXE.office = libreoffice
268
269 # summary variables (mainly used for INSTALL.sh)
270 _ALL.devtools.intern += $(EXE.single)
271 _ALL.devtools.extern += sccs gpg sha256sum docker
272 ALL.tools.optional = aha perldoc pod2html pod2man pod2pdf pod2text pod2usage podman podviewer tkpod stty tput
273 ALL.perlmodules = Net::DNS Net::SSLeay IO::Socket::INET IO::Socket::SSL Time::Local
274 ALL.devtools = $(_ALL.devtools.intern) $(_ALL.devtools.extern)
275 ALL.devmodules = $(_ALL.devmodules.intern) $(_ALL.devmodules.extern)
276 # defined in t/Makefile.misc
277 ALL.osaftmodules= osaft $(NET.pm:%.pm=Net::%) $(OSAFT.pm:%.pm=OSaft::%) OSaft::Doc::Data
278
279 # following for documentation, not yet used (2022)
280 #_ALL.tools.dbian.pkg = aha libtk-pod-perl perl-doc perl-doc-html pod2pdf
281
282 # INSTALL.sh must not contain duplicate files, hence the variable's content
283 # is sorted using make's built-in sort which removes duplicates
284 _INST.osaft_cgi = $(sort $(SRC.cgi) $(SRC.php) $(GEN.cgi.html))
285 _INST.osaft_doc = $(sort $(GEN.pod) $(GEN.man) $(GEN.html))
286 _INST.contrib = $(sort $(ALL.contrib))
287 _INST.osaft = $(sort $(ALL.osaft))
288 _INST.devtools = $(sort $(ALL.devtools))
289 _INST.tools_int = $(sort $(_ALL.devtools.intern))
290 _INST.tools_ext = $(sort $(_ALL.devtools.extern))
291 _INST.tools_opt = $(sort $(ALL.tools.optional))
292 _INST.tools_other = $(sort $(ALL.tools.ssl))
293 _INST.devmodules= $(sort $(ALL.devmodules))
294 _INST.genbytext = generated data by Makefile 2.19 from $(SRC.inst)
295 _INST.gen_text = generated data from Makefile 2.19
296 EXE.install = sed -e 's@INSERTED_BY_MAKE_INSTALLDIR@$(INSTALL.dir)@' \
297 -e 's@INSERTED_BY_MAKE_CONTRIBDIR@$(SRC.contrib.dir)@' \
298 -e 's@INSERTED_BY_MAKE_CONTRIB@$(_INST.contrib)@' \
299 -e 's@INSERTED_BY_MAKE_TOOLS_OTHER@$(_INST.tools_other)@' \
300 -e 's@INSERTED_BY_MAKE_TOOLS_OPT@$(_INST.tools_opt)@' \
301 -e 's@INSERTED_BY_MAKE_DEVTOOLSINT@$(_INST.tools_int)@' \
302 -e 's@INSERTED_BY_MAKE_DEVTOOLSEXT@$(_INST.tools_ext)@' \
303 -e 's@INSERTED_BY_MAKE_DEVMODULES@$(_INST.devmodules)@' \
304 -e 's@INSERTED_BY_MAKE_PERL_MODULES@$(ALL.perlmodules)@' \
305 -e 's@INSERTED_BY_MAKE_OSAFT_SH@$(SRC.sh)@' \
306 -e 's@INSERTED_BY_MAKE_OSAFT_PL@$(SRC.pl)@' \
307 -e 's@INSERTED_BY_MAKE_OSAFT_GUI@$(SRC.tcl)@' \
308 -e 's@INSERTED_BY_MAKE_OSAFT_CGI@$(_INST.osaft_cgi)@' \
309 -e 's@INSERTED_BY_MAKE_OSAFT_STAND@$(GEN.src)@' \
310 -e 's@INSERTED_BY_MAKE_OSAFT_DOCKER@$(EXE.docker)@' \
311 -e 's@INSERTED_BY_MAKE_OSAFT_DOC@$(_INST.osaft_doc)@' \
312 -e 's@INSERTED_BY_MAKE_OSAFT_MODULES@$(ALL.osaftmodules)@' \
313 -e 's@INSERTED_BY_MAKE_OSAFT@$(_INST.osaft)@' \
314 -e 's@INSERTED_BY_MAKE_FROM@$(_INST.genbytext)@' \
315 -e 's@INSERTED_BY_MAKE@$(_INST.gen_text)@'
316 # note that the sequence of the -e commands is important
317 # last substitude is fallback to ensure everything is changed
318
319 # generate f- targets to print HELP text for each target
320 _HELP.my_targets= $(shell $(EXE.eval) $(MAKEFILE))
321 _HELP.alltargets= $(shell $(EXE.eval) $(ALL.includes))
322 _HELP.help = $(ALL.help:%=f-%)
323 # quick&dirty because each target calls make (see below)
324
325 #_____________________________________________________________________________
326 #___________________________________________________________ default target __|
327
328 # define header part of default target
329 help: HELP_HEAD = $(HELP_RULE)
330 help.all: HELP_HEAD = $(HELP_RULE)
331 help.log: HELP_HEAD = $(HELP_RULE)
332 help.all.log: HELP_HEAD = $(HELP_RULE)
333 doc: HELP_HEAD = $(HELP_RULE)
334 doc.all: HELP_HEAD = $(HELP_RULE)
335
336 # define body part of default target
337 # TODO: adapt _help_* macros and targets according own naming convention
338 _help_also_ = _help_also
339 _help_body_ = _help_body_me
340 _help_list_ =
341 help.all: _help_body_ = _help_body_all
342 help.all: _help_list_ = _help_list
343 doc: _help_body_ = _eval_body_me
344 doc.all: _help_body_ = _eval_body_all
345 doc: _help_also_ =
346 doc.all: _help_also_ =
347 doc.all: _help_list_ = _help_list
348
349 # for targets defined in Makefile.help
350 help.all%: _help_body_ = _help_body_all
351 help.all%: _help_list_ = _help_list
352 %.all-v: _help_text-v =
353 _help_text-v = \# to see Makefile, where targets are defined, use: $(MAKE_COMMAND) $(MAKECMDGOALS)-v
354
355 #_____________________________________________________________________________
356 #_________________________________________________________ internal targets __|
357
358 # SEE Make:.SECONDEXPANSION
359 .SECONDEXPANSION:
360
361 # If variables, like $(_HELP.*targets), contain duplicate target names (which
362 # is intended), only one will be executed by $(MAKE), hence the 2nd occurance
363 # is missing.
364 _eval_body_me:
365 @$(MAKE) -s $(_HELP.my_targets)
366 @echo "$(HELP_LINE)"
367
368 _eval_body_all:
369 @$(MAKE) -s $(_HELP.alltargets)
370
371 _help_body_me:
372 @$(EXE.help) $(MAKEFILE)
373 @echo "$(HELP_LINE)"
374
375 _help_body_all:
376 @$(EXE.help) $(ALL.includes)
377
378 _help_list:
379 @echo ""
380 @echo " #___________ targets for information about test targets... _"
381 @$(MAKE) $(_HELP.help)
382 @echo "$(HELP_LINE)"
383 @echo "$(_help_text-v)"
384
385 _help_also:
386 @echo "# to expand variables, use: $(MAKE_COMMAND) doc"
387
388 # ensure that target help: from this file is used and not help%
389 help help.all doc doc.all: _help.HEAD $$(_help_body_) $$(_help_list_) $$(_help_also_)
390 @$(TRACE.target)
391
392 help.all-v help.all-vv: help.all
393 @$(EXE.dummy)
394 #doc.all-v doc.all-vv: help.all # TODO: not implemented yet
395
396 .PHONY: help help.all doc doc.all
397
398 #_____________________________________________________________________________
399 #__________________________________________________________________ targets __|
400
401 HELP-_known = _______________________________________ well known targets _
402 HELP-all = does nothing; alias for help
403 HELP-clean = remove all generated files '$(ALL.gen) $(GEN.tags)'
404 HELP-release = generate signed '$(GEN.tgz)' from sources
405 HELP-install = install tool in '$(INSTALL.dir)' using '$(GEN.inst)', $(INSTALL.dir) must exist
406 HELP-uninstall = remove installtion directory '$(INSTALL.dir)' completely
407
408 $(INSTALL.dir):
409 @$(TRACE.target)
410 mkdir $(_INSTALL_FORCE_) $(INSTALL.dir)
411
412 all: help
413
414 clean: clean.tmp clean.tar clean.gen
415 clear: clean
416
417 # target calls installed $(SRC.pl) to test general functionality
418 install: $(GEN.inst) $(INSTALL.dir)
419 @$(TRACE.target)
420 $(GEN.inst) $(INSTALL.dir) \
421 && $(INSTALL.dir)/$(SRC.pl) --no-warning --tracearg +quit > /dev/null
422 install-f: _INSTALL_FORCE_ = -p
423 install-f: install
424
425 uninstall:
426 @$(TRACE.target)
427 -rm -r --interactive=never $(INSTALL.dir)
428
429 _RELEASE = $(shell perl -nle '/^\s*sub _VERSION/ && do { s/.*?"([^"]*)".*/$$1/;print }' $(SRC.pl))
430
431 release.show:
432 @echo "Release: $(_RELEASE)"
433
434 release: $(GEN.tgz)
435 @$(TRACE.target)
436 mkdir -p $(_RELEASE)
437 sha256sum $(GEN.tgz) > $(_RELEASE)/$(GEN.tgz).sha256
438 @cat $(_RELEASE)/$(GEN.tgz).sha256
439 gpg --local-user o-saft -a --detach-sign $(GEN.tgz)
440 gpg --verify $(GEN.tgz).asc $(GEN.tgz)
441 mv $(GEN.tgz).asc $(_RELEASE)/
442 mv $(GEN.tgz) $(_RELEASE)/
443 @echo "# don't forget:"
444 @echo "# # change digest: sha256:... in README.md; upload to github"
445 @echo "# # change digest: sha256:... in Dockerfile; upload to github"
446 @echo "# make docker"
447 @echo "# make test.docker"
448 @echo "# make docker.push"
449 # TODO: check if files are edited or missing
450
451 # Generating a release file, containing all files with their SID.
452 # This file should be easily readable by humans and easily parsable by scripts,
453 # hence following format is used (one per line):
454 # SID\tdate\ttime\tfilename\tfull_path
455 # How it works:
456 # "sccs what" returns multiple lines, at least 2, these look like:
457 # path/filename:
458 # o-saft.pl 1.823 18/11/18 23:42:23
459 # this is resorted to have the fixed-width field SID, date and time at the
460 # beginning (left), followed by the filename and the full path.
461 # what may also return lines like:
462 # @(#) filename 1.245 19/11/19 12:23:42',
463 # @(#) filename generated by 1.227 19/11/19 10:12:13
464 # The perl script takes care of them and ignores or pretty prints the strings.
465 # The "generated by" may occour i.e. in o-saft.tcl.
466 # NOTE: only files available in the repository are used, therefore the variable
467 # $(ALL.src) is used. Because $(ALL.src) also contains $(ALL.gen), which
468 # is wrong here, $(ALL.gen) is set empty for this target.
469 # o-saft.pl is generated from yeast.pl, but o-saft.pl is not a repository
470 # file, hence yeast is substituded by o-saft (should occour only once).
471 $(GEN.rel): ALL.gen =
472 $(GEN.rel): $(ALL.src)
473 @sccs what $(ALL.src) | \
474 perl -anle '/ generated by /&&next;/^(.*):$$/&&do{$$f=$$m=$$1;$$m=~s#.*/##;next;};/.*?($$m|%[M]%)/&&do{$$f=~s/yeast/o-saft/;$$F[0]=~s/yeast/o-saft/;$$t=$$F[3];$$q=chr(0x27);$$t=~s#["$$q,]##g;printf("%s\t%s\t%s\t%s\t%s\n",$$F[1],$$F[2],$$t,$$F[0],$$f)};'
475 rel :$(GEN.rel)
476
477 $(_RELEASE).rel: Makefile
478 @$(MAKE) -s $(GEN.rel) > $@
479
480
481 .PHONY: all clean install install-f uninstall release.show release rel
482
483 variables = \$$(variables)
484 # # define literal string $(variables) for "make doc"
485 HELP-_project = ____________________________________ targets for $(Project) _
486 HELP-help = print common targets for O-Saft (this help)
487 HELP-doc = same as help, but evaluates '$(variables)'
488 HELP-pl = generate '$(SRC.pl)' from managed source files
489 HELP-cgi = generate HTML page for use with CGI '$(GEN.cgi.html)'
490 HELP-man = generate MAN format help '$(GEN.man)'
491 HELP-pod = generate POD format help '$(GEN.pod)'
492 HELP-html = generate HTML format help '$(GEN.html)'
493 HELP-text = generate plain text help '$(GEN.text)'
494 HELP-wiki = generate mediawiki format help '$(GEN.wiki)'
495 HELP-docs = generate '$(GEN.docs)'; see also target doc.data
496 HELP-tar = generate '$(GEN.tgz)' from all source prefixed with O-Saft/
497 HELP-tmptar = generate '$(GEN.tmptgz)' from all sources without prefix
498 HELP-doc.data = generate '$(GEN.DOC.data)' for $(SRC.tcl)
499 HELP-gen.all = generate most "generatable" file
500 HELP-docker = generate local docker image (release version) and add updated files
501 HELP-docker.dev = generate local docker image (development version)
502 HELP-docker.push= install local docker image at Docker repository
503 HELP-clean.tmp = remove '$(TMP.dir)'
504 HELP-clean.tar = remove '$(GEN.tgz)'
505 HELP-clean.gen = remove '$(ALL.gen)' '$(GEN.inst)' '$(GEN.tags)'
506 HELP-clean.all = remove '$(ALL.gen)' '$(GEN.inst)' '$(GEN.tags)' '$(GEN.tgz)'
507 HELP-install-f = install tool in '$(INSTALL.dir)' using '$(GEN.inst)', '$(INSTALL.dir)' may exist
508 HELP-o-saft.rel = generate '$(GEN.rel)'
509 # # HELP-o-saft.rel hardcoded, grrr
510
511
512 HELP-_vv1 = ___________ any target may be used with following suffixes _
513 HELP--v = verbose: print target and newer dependencies also
514 HELP--vv = verbose: print target and all dependencies also
515
516 HELP-_project2 = __________________ targets to get more help and information _
517 HELP-help.all = print all targets, including most test and development targets
518 # # defined in t/Makefile.help also
519 HELP-help.help = print targets to get information/documentation from Makefiles
520
521 # alias targets
522 pl: $(SRC.pl)
523 cgi: $(GEN.cgi.html)
524 man: $(GEN.man)
525 pdf: $(GEN.pdf)
526 pod: $(GEN.pod)
527 html: $(GEN.html)
528 text: $(GEN.text)
529 wiki: $(GEN.wiki)
530 docs: $(GEN.docs)
531 standalone: $(GEN.src)
532 tar: $(GEN.tgz)
533 _INST.is_edit = 2.19
534 tar: _INST.is_edit = 2.19
535 tmptar: _INST.is_edit = something which hopefully does not exist in the file
536 tmptar: $(GEN.tmptgz)
537 tmptgz: $(GEN.tmptgz)
538 cleangen: clean.gen
539 cleantar: clean.tar
540 cleantgz: clean.tar
541 cleantmp: clean.tmp
542 cleartar: clean.tar
543 cleartgz: clean.tar
544 cleartmp: clean.tmp
545 clear.all: clean.tar clean
546 clean.all: clean.tar clean
547 tgz: tar
548 gen.all: $(ALL.gen)
549 doc.data: $(GEN.DOC.data)
550 docdata: $(GEN.DOC.data)
551 tcl.data:
552 @echo "**ERROR: ancient target; please use 'doc.data'"
553 tcldata: tcl.data
554
555 # docker target uses project's own script to build and remove the image
556 docker.build:
557 @$(TRACE.target)
558 $(EXE.docker) -OSAFT_VERSION=$(_RELEASE) build
559 $(EXE.docker) cp Dockerfile
560 $(EXE.docker) cp README.md
561 docker: docker.build
562
563 docker.rm:
564 @$(TRACE.target)
565 $(EXE.docker) rmi
566
567 docker.dev:
568 @$(TRACE.target)
569 docker build --force-rm --rm \
570 --build-arg "OSAFT_VM_SRC_OSAFT=https://github.com/OWASP/O-Saft/archive/master.tar.gz" \
571 --build-arg "OSAFT_VERSION=$(_RELEASE)" \
572 -f Dockerfile -t owasp/o-saft .
573
574 # TODO: docker.push should depend on docker.build (above), but docker.build
575 # is not a file and creates a Docker image; means that this target itself
576 # has no dependency. Make then executes the target always, which fails if
577 # a Docker image already exists. Need a target, which checks the current
578 # Docker image for the proper version.
579 docker.push:
580 @$(TRACE.target)
581 docker push owasp/o-saft:latest
582
583 .PHONY: pl cgi man pod html wiki standalone tar tmptar tmptgz cleantar cleantmp help
584 .PHONY: docker docker.rm docker.dev docker.push
585
586 clean.gen:
587 @$(TRACE.target)
588 rm -rf $(ALL.gen) $(GEN.inst)
589 clean.tmp:
590 @$(TRACE.target)
591 rm -rf $(TMP.dir)
592 clean.tar:
593 @$(TRACE.target)
594 rm -rf $(GEN.tgz)
595 clean.tgz: clean.tar
596 clean.docker: docker.rm
597
598 # avoid matching implicit rule help% in some of following targets
599 $(OSD.dir)/help.txt:
600 @$(TRACE.target)
601
602 #_____________________________________________________________________________
603 #_______________________________________________ targets for generated files__|
604
605 # targets for generation
606 $(TMP.dir)/Net $(TMP.dir)/OSaft $(TMP.dir)/OSaft/Doc $(TMP.dir)/$(SRC.contrib.dir) $(TMP.dir)/$(TEST.dir):
607 @$(TRACE.target)
608 mkdir -p $@
609
610 # cp fails if SRC.pl is read-only, hence we remove it; it is generated anyway
611 $(SRC.pl): $(DEV.pl)
612 @$(TRACE.target)
613 rm -f $@
614 cp $< $@
615
616 # generation fails if GEN.src is read-only, hence we remove it; it is generated anyway
617 $(GEN.src): $(EXE.single) $(SRC.pl) $(ALL.pm)
618 @$(TRACE.target)
619 @rm -rf $@
620 $(EXE.single) --s > $@
621 @chmod 555 $@
622
623 $(GEN.man): $(SRC.pl) $(OSD.pm) $(USR.pm) $(SRC.txt) $(GEN.pod)
624 @$(TRACE.target)
625 $(SRC.pl) --no-rc --no-warning --help=gen-man > $@
626
627 $(GEN.pod): $(SRC.pl) $(OSD.pm) $(USR.pm) $(SRC.txt)
628 @$(TRACE.target)
629 $(SRC.pl) --no-rc --no-warning --help=gen-pod > $@
630
631 $(GEN.text): $(SRC.pl) $(OSD.pm) $(USR.pm) $(SRC.txt)
632 @$(TRACE.target)
633 $(SRC.pl) --no-rc --no-warning --help > $@
634
635 $(GEN.wiki): $(SRC.pl) $(OSD.pm) $(USR.pm) $(SRC.txt)
636 @$(TRACE.target)
637 $(SRC.pl) --no-rc --no-warning --help=gen-wiki > $@
638
639 $(GEN.html): $(SRC.pl) $(OSD.pm) $(USR.pm) $(SRC.txt)
640 @$(TRACE.target)
641 $(SRC.pl) --no-rc --no-warning --help=gen-html > $@
642
643 $(GEN.cgi.html): $(SRC.pl) $(OSD.pm) $(USR.pm) $(SRC.txt)
644 @$(TRACE.target)
645 $(SRC.pl) --no-rc --no-warning --help=gen-cgi > $@
646
647 $(GEN.inst): $(SRC.inst) Makefile
648 @$(TRACE.target)
649 $(EXE.install) $(SRC.inst) > $@
650 chmod +x $@
651
652 $(GEN.tgz)--to-noisy: $(ALL.src)
653 @$(TRACE.target)
654 @grep -q '$(_INST.is_edit)' $? \
655 && echo "file(s) being edited or with invalid SID" \
656 || echo tar zcf $@ $^
657
658 # generating file containing our messages uses target from t/Makefile.warnings
659 # hence make is called recursively for this special file
660 # TODO: this is a dirty hack, because no Makefiles from t/ should be used here
661 # most files could also be generated with: $(SRC.pl) --gen-docs
662 # SEE GNU Make:Pattern Rule
663 $(DOC.dir)/$(SRC.pl).%warnings: $(SRC.pl)
664 @$(TRACE.target)
665 $(MAKE_COMMAND) -s warnings-info > $@
666
667 $(DOC.dir)/$(SRC.pl).%: $(SRC.pl)
668 @$(TRACE.target)
669 $(SRC.pl) --no-rc $* > $@
670
671 # use libreoffice to generate PDF from .odg
672 # unfortunately libreoffice has no option to specify the name of the output,
673 # hence we need to use its --outdir option instead of make's $@
674 # ancient libreoffice (before 5.0) may also need following option:
675 # -env:UserInstallation=file:///tmp/dummy${USER}
676 # FIXME: (11/2021) libreoffice --headless generates a file slighly different
677 # compared to the file generated interactively (reason yet unknown)
678 # we keep the generation here, to avoid missing files
679 $(DOC.dir)/%.pdf: %.odg
680 @$(TRACE.target)
681 $(EXE.office) --headless --nologo --nolockcheck --norestore --convert-to pdf:draw_pdf_Export --outdir $(DOC.dir)/ $^
682
683 # Special target to check for edited files; it only checks the source files of
684 # the tool (o-saft.pl) but no other source files.
685 _notedit: $(SRC.exe) $(SRC.pm) $(SRC.rc) $(SRC.txt)
686 @$(TRACE.target)
687 @grep -q '$(_INST.is_edit)' $? \
688 && echo "file(s) being edited or with invalid SID" \
689 && exit 1 \
690 || echo "# no edits"
691
692 .PHONY: _notedit
693
694 #$(GEN.tgz): _notedit $(ALL.src) # not working properly
695 # tar: _notedit: Funktion stat failed: file or directory not found
696
697 # .tgz is tricky: as all members should have the directory prefixed, tar needs
698 # to be executed in the parent directory and use $(ALL.tgz) as members.
699 # The target itself is called in the current directory, hence the dependencies
700 # are local to that which is $(ALL.src). Note that $(ALL.tgz) is generated from
701 # $(ALL.src), so it contains the same members. Executing tar in the parent dir
702 # would generate the tarball there also, hence the tarball is specified as full
703 # path with $(PWD).
704 # The directory prefix in the tarball is the current directory, aka $(PWD) .
705 $(GEN.tgz): $(ALL.src) $(GEN.tags) $(GEN.inst)
706 @$(TRACE.target)
707 cd .. && tar zcf $(PWD)/$@ $(ALL.tgz)
708
709 $(GEN.tmptgz): $(ALL.src) $(GEN.tags)
710 @$(TRACE.target)
711 tar zcf $@ $^
712
713 #_____________________________________________________________________________
714 #__________________________________________________________ verbose targets __|
715
716 # verbose/trace command
717 # TRACE.target is the command to be used to print the target's name
718 # it is epmty by default
719 # TRACE.target can be set as environment variable, or used on command
720 # line when calling make
721 # it is also used internal for the -v targets, see below
722 # examples:
723 # TRACE.target = echo "\# --Target: $@--"
724 # TRACE.target = echo "\# --Target: $@: newer dependencies: $? --"
725 # TRACE.target = echo "\# --Target: $@: all dependencies: $^ --"
726
727 # verbose targets
728 # NOTE: need at least one command for target execution
729 %-v: TRACE.target = echo "\# $@: $?"
730 %-v: %
731 @$(EXE.dummy)
732
733 %-vv: TRACE.target = echo "\# $@: $^"
734 %-vv: %
735 @$(EXE.dummy)
736
737 # the traditional way, when target-dependent variables do not work
738 #%-v:
739 # @$(MAKE) $(MFLAGS) $(MAKEOVERRIDES) $* 'TRACE.target=echo \# $$@: $$?'
740 #
741 #%-vv:
742 # @$(MAKE) $(MFLAGS) $(MAKEOVERRIDES) $* 'TRACE.target=echo \# $$@: $$^'
743
744 #_____________________________________________________________________________
745 #_____________________________________________ targets for testing and help __|
746
747 include $(TEST.dir)/Makefile
748 # Note that $(TEST.dir)/Makefile includes all other Makefile.* there
749