style: Silenced Cppcheck warnings
[para.git] / Makefile.in
blob012fae1a7d7bd673ffafde273aedea2295e11b65
1 .POSIX:
5 # Special targets
8 .PHONY: \
9 all \
10 check \
11 clean \
12 coverage \
13 dist \
14 distclean \
15 docs \
16 install \
17 install-strip \
18 installcheck \
19 installdirs \
20 lint \
21 maintainer-clean \
22 mostlyclean \
23 mrproper \
24 quickcheck \
25 quicklint \
26 tags \
27 tidy \
28 uninstall \
29 valgrind
31 .SUFFIXES:
33 .SUFFIXES: .c .c.o
35 all: para
39 # General Macros
42 # Build
43 CC = cc
44 CFLAGS = -O1
45 CPPFLAGS = -DNAUTOTESTS -DNDEBUG
46 LDFLAGS =
47 LDLIBS =
49 # GNU
50 SHELL = /bin/sh
51 VPATH = $(srcdir)
55 # Inference rules
58 .c:
59 $(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) -o$@ $< $(LDLIBS)
61 .c.o:
62 $(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) -c -o$@ $< $(LDLIBS)
66 # Makefile
69 configs = conf/develrc conf/posixrc conf/prodrc
70 makefile = Makefile
71 savedconfig = config.status
72 scriptbaseurl = https://git.savannah.gnu.org/cgit/config.git/plain
74 $(makefile): Makefile.in ./configure $(configs)
75 ./$(savedconfig) || [ $$? -eq 127 ]
77 config.guess.swp config.sub.swp:
78 -$(CURL) -o $@ "$(scriptbaseurl)/$(@:.swp=)"
80 config.guess: config.guess.swp
82 config.sub: config.sub.swp
84 config.guess config.sub:
85 if [ -e $@.swp ]; then \
86 if cmp $@ $@.swp; \
87 then rm $@.swp; \
88 else mv $@.swp $@; \
89 fi; \
94 # Build
97 srcs = para.c
98 objs = para.o
99 bins = $(srcs:.c=)
101 para: para.c
105 # Installation
108 DESTDIR =
109 INSTALL = install
110 INSTALL_PROGRAM = $(INSTALL)
111 PREFIX = /usr/local
113 bindir = $(exec_prefix)/bin
114 exec_prefix = $(prefix)
115 instdirs = $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir)
116 instlog = install.log
117 man1dir = $(mandir)/man1
118 man1ext = .1
119 mandir = $(datarootdir)/man
120 prefix = $(PREFIX)
121 srcdir = .
123 install: pre-install installdirs $(DESTDIR)$(bindir)/para install-man
125 installdirs: $(instdirs)
127 uninstall: uninstallfiles uninstalldirs post-uninstall
129 install-man: installdirs $(DESTDIR)$(man1dir)/para$(man1ext)
131 install-strip:
132 $(MAKE) -e -f$(makefile) \
133 INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
135 post-uninstall:
136 $(POST_UNINSTALL)
137 rm -f $(instlog)
139 pre-install:
140 $(PRE_INSTALL)
141 set -C && : >$(instlog)
143 uninstalldirs:
144 $(POST_UNINSTALL)
145 - sed -n 's/^dir: //p' $(instlog) | xargs -E '' rmdir -pv
147 uninstallfiles:
148 $(NORMAL_UNINSTALL)
149 sed -n 's/^file: //p' $(instlog) | xargs -E '' rm -f
151 installcheck:
152 mkdir -p dest
153 $(MAKE) -e -f$(makefile) DESTDIR=root instlog=instchk.log install
154 root/$(bindir)/para -V | grep -Fq '$(package) $(version)'
155 man root/$(man1dir)/para.1 | col -b | grep -Fq para
156 $(MAKE) -e -f$(makefile) instlog=instchk.log uninstall
158 $(instdirs):
159 $(PRE_INSTALL)
160 mkdir -pm 0755 $@
161 printf 'dir: %s\n' $@ >>$(instlog)
163 $(DESTDIR)$(bindir)/para: para
164 $(INSTALL_PROGRAM) para $@
165 printf 'file: %s\n' $@ >>$(instlog)
167 $(DESTDIR)$(man1dir)/para$(man1ext): para.1
168 $(POST_INSTALL)
169 $(INSTALL) -m u=rw,go=r para.1 $@
170 printf 'file: %s\n' $@ >>$(instlog)
174 # Distribution
177 GPG = gpg -ab
178 GPGFLAGS = -q --batch --yes
179 PATHCHK = pathchk
180 PATHCHKFLAGS = -Pp
181 TAR = pax -w -s:^:$(dist)/: -xustar
182 UNTAR = pax -r
183 UNZIP = gunzip -c
184 ZIP = gzip -9
186 dist = $(package)-$(version)
187 distar = $(dist).tgz
188 distfiles = \
189 $(configs) \
190 $(integtestrcs) \
191 $(integtestscripts) \
192 $(checkscripts) \
193 $(srcs) \
194 $(unittesthdrs) \
195 $(unittestsrcs) \
196 .clang-tidy \
197 .githooks/pre-commit \
198 .githooks/pre-push \
199 .valgrindrc \
200 LICENSE.rst \
201 Makefile.in \
202 NEWS.rst \
203 README.rst \
204 SECURITY.rst \
205 config.guess \
206 config.sub \
207 configure \
208 cppcheck/bsd.cfg \
209 cppcheck/c99.cfg \
210 cppcheck/cert.py \
211 cppcheck/gnuc.cfg \
212 cppcheck/para.cfg \
213 cppcheck/posix.cfg \
214 cppcheck/suppress.txt \
215 docs/Makefile \
216 docs/_static/custom.css \
217 docs/build.rst \
218 docs/changelog.rst \
219 docs/conf.py \
220 docs/contrib.rst \
221 docs/feedback.rst \
222 docs/index.rst \
223 docs/install.rst \
224 docs/license.rst \
225 docs/links.rst \
226 docs/manual.rst \
227 docs/security.rst \
228 docs/sphinx.txt \
229 docs/testing.rst \
230 installc \
231 libutil.sh \
232 para.1 \
233 scripts/mkvars \
234 scripts/mkwords \
235 tests/README.rst \
236 tests/main \
237 tests/putvar.x \
238 tests/wordsplit.x \
239 valgrind.supp
240 package = para
241 version = 0.11
243 dist: lint check memcheck shellcheck $(distar) $(distar).asc
245 distcheck: dist
246 rm -rf $(dist)
247 $(UNZIP) $(distar) | $(UNTAR)
248 cd $(dist) && ./configure && $(MAKE) check lint installcheck
249 rm -rf $(dist)
251 $(distar): $(distfiles)
252 $(PATHCHK) $(PATHCHKFLAGS) $(distfiles) || [ $$? -eq 127 ]
253 $(TAR) $(distfiles) | $(ZIP) >$@
255 $(distar).asc: $(distar)
256 $(GPG) $(GPGFLAGS) $(distar) || [ $$? -eq 127 ]
260 # Cleanup
263 clean: mostlyclean
264 rm -f $(dirsentinels)
265 - rmdir $(dirs)
266 find . '(' -name .git -o -name python -o -name 'tmp-*' ')' -prune -o \
267 -name '*.dSYM' -exec rm -rf -- {} +
268 find . '(' -name .git -o -name python -o -name 'tmp-*' ')' -prune -o \
269 -name '*.info' -exec rm -f -- {} +
271 distclean: mrproper
272 rm -f $(makefile) $(savedconfig)
274 maintainer-clean: distclean
275 @echo '$@ is for maintainers only!'
276 @echo 'It deletes files that cannot be built with standard tools'
277 rm -rf $(covfiles)
278 rm -f config.guess config.sub para.1 tests/*.x
280 mostlyclean: tidy
281 rm -f -- $(bins) $(objs) $(unittestbins) $(unittestobjs) -.* a--.*
282 find . '(' -name .git -o -name python -o -name 'tmp-*' ')' -prune -o \
283 '(' \
284 -name '*.gcda' -o \
285 -name '*.gcno' -o \
286 -name '*.gcov' -o \
287 -name '*.o' \
288 ')' -exec rm -f -- {} +
290 mrproper: clean
291 rm -rf cppcheck/build
292 rm -f cscope.out tags
293 find . '(' -name .git -o -name python -o -name 'tmp-*' ')' -prune -o \
294 '(' -name '*.asc' -o -name '*.tgz' ')' -exec rm -f -- {} +
296 tidy:
297 find . '(' -name .git -o -name python ')' -prune -o \
298 -name 'tmp-*' -prune -exec sh -c ' \
299 for file; do \
300 pid="$${file#*-}"; \
301 if ! kill -0 "$$pid" 2>/dev/null; then \
302 rm -rf "$$file"; \
303 fi; \
304 done \
305 ' -- {} +
306 find . '(' -name .git -o -name python -o -name 'tmp-*' ')' -prune -o \
307 '(' \
308 -name '*.bak' -o \
309 -name '*.log' -o \
310 -name '*.swp' \
311 ')' -exec rm -f -- {} +
315 # Tests
318 TESTCFLAGS = -O0
320 checks = $(integtestbins) $(unittestbins)
321 checkscripts = \
322 $(srcdir)/scripts/checkchain \
323 $(srcdir)/scripts/checkcomps \
324 $(srcdir)/scripts/checkmakes \
325 $(srcdir)/scripts/checkshells \
326 $(srcdir)/scripts/runleaks \
327 $(srcdir)/scripts/runtests \
328 $(srcdir)/scripts/runvalgrind \
330 integtestbins = $(srcdir)/tests/main
331 integtestrcs = \
332 $(srcdir)/tests/integration/environ/argtoolong \
333 $(srcdir)/tests/integration/environ/changevar \
334 $(srcdir)/tests/integration/environ/compwvar \
335 $(srcdir)/tests/integration/environ/envfull \
336 $(srcdir)/tests/integration/environ/leaddigit \
337 $(srcdir)/tests/integration/environ/leaddot \
338 $(srcdir)/tests/integration/environ/leadeq \
339 $(srcdir)/tests/integration/environ/leadunder \
340 $(srcdir)/tests/integration/environ/onevar \
341 $(srcdir)/tests/integration/environ/toomanyvars \
342 $(srcdir)/tests/integration/environ/twovars \
343 $(srcdir)/tests/integration/examples/compose \
344 $(srcdir)/tests/integration/examples/continue \
345 $(srcdir)/tests/integration/examples/environ \
346 $(srcdir)/tests/integration/examples/redirect \
347 $(srcdir)/tests/integration/examples/rename \
348 $(srcdir)/tests/integration/examples/simple \
349 $(srcdir)/tests/integration/examples/suppress \
350 $(srcdir)/tests/integration/options/V \
351 $(srcdir)/tests/integration/options/eempty \
352 $(srcdir)/tests/integration/options/enan \
353 $(srcdir)/tests/integration/options/enanbeg \
354 $(srcdir)/tests/integration/options/enanend \
355 $(srcdir)/tests/integration/options/enil \
356 $(srcdir)/tests/integration/options/eover \
357 $(srcdir)/tests/integration/options/eunder \
358 $(srcdir)/tests/integration/options/gempty \
359 $(srcdir)/tests/integration/options/gmax \
360 $(srcdir)/tests/integration/options/gmin \
361 $(srcdir)/tests/integration/options/gnan \
362 $(srcdir)/tests/integration/options/gnanbeg \
363 $(srcdir)/tests/integration/options/gnanend \
364 $(srcdir)/tests/integration/options/gneg \
365 $(srcdir)/tests/integration/options/gnil \
366 $(srcdir)/tests/integration/options/gover \
367 $(srcdir)/tests/integration/options/gunder \
368 $(srcdir)/tests/integration/options/h \
369 $(srcdir)/tests/integration/options/hnoext \
370 $(srcdir)/tests/integration/options/iempty \
371 $(srcdir)/tests/integration/options/imax \
372 $(srcdir)/tests/integration/options/imin \
373 $(srcdir)/tests/integration/options/inan \
374 $(srcdir)/tests/integration/options/inanbeg \
375 $(srcdir)/tests/integration/options/inanend \
376 $(srcdir)/tests/integration/options/inil \
377 $(srcdir)/tests/integration/options/iover \
378 $(srcdir)/tests/integration/options/iunder \
379 $(srcdir)/tests/integration/options/izero \
380 $(srcdir)/tests/integration/options/jempty \
381 $(srcdir)/tests/integration/options/jmax \
382 $(srcdir)/tests/integration/options/jmin \
383 $(srcdir)/tests/integration/options/jnan \
384 $(srcdir)/tests/integration/options/jnanbeg \
385 $(srcdir)/tests/integration/options/jnanend \
386 $(srcdir)/tests/integration/options/jnil \
387 $(srcdir)/tests/integration/options/jover \
388 $(srcdir)/tests/integration/options/junder \
389 $(srcdir)/tests/integration/options/jzero \
390 $(srcdir)/tests/integration/options/kempty \
391 $(srcdir)/tests/integration/options/kmax \
392 $(srcdir)/tests/integration/options/kmulfew \
393 $(srcdir)/tests/integration/options/kmulmany \
394 $(srcdir)/tests/integration/options/kmulsingle \
395 $(srcdir)/tests/integration/options/knil \
396 $(srcdir)/tests/integration/options/knoplace \
397 $(srcdir)/tests/integration/options/kover \
398 $(srcdir)/tests/integration/options/kquotes \
399 $(srcdir)/tests/integration/options/ksyn \
400 $(srcdir)/tests/integration/options/ldisabled \
401 $(srcdir)/tests/integration/options/lempty \
402 $(srcdir)/tests/integration/options/lfloat \
403 $(srcdir)/tests/integration/options/lmax \
404 $(srcdir)/tests/integration/options/lmin \
405 $(srcdir)/tests/integration/options/lnan \
406 $(srcdir)/tests/integration/options/lnanbeg \
407 $(srcdir)/tests/integration/options/lnanend \
408 $(srcdir)/tests/integration/options/lneg \
409 $(srcdir)/tests/integration/options/lnil \
410 $(srcdir)/tests/integration/options/lover \
411 $(srcdir)/tests/integration/options/lunder \
412 $(srcdir)/tests/integration/options/rmax \
413 $(srcdir)/tests/integration/options/rnil \
414 $(srcdir)/tests/integration/options/rover \
415 $(srcdir)/tests/integration/options/suppress \
416 $(srcdir)/tests/integration/options/tempty \
417 $(srcdir)/tests/integration/options/tmin \
418 $(srcdir)/tests/integration/options/tnan \
419 $(srcdir)/tests/integration/options/tnanbeg \
420 $(srcdir)/tests/integration/options/tnanend \
421 $(srcdir)/tests/integration/options/tover \
422 $(srcdir)/tests/integration/options/tunder \
423 $(srcdir)/tests/integration/options/tzero \
424 $(srcdir)/tests/integration/options/usage \
425 $(srcdir)/tests/integration/reporting/finish \
426 $(srcdir)/tests/integration/reporting/ignore \
427 $(srcdir)/tests/integration/reporting/nil \
428 $(srcdir)/tests/integration/reporting/suppress \
429 $(srcdir)/tests/integration/reporting/verbose \
430 $(srcdir)/tests/integration/signals/jobhup \
431 $(srcdir)/tests/integration/signals/jobint \
432 $(srcdir)/tests/integration/signals/jobstop \
433 $(srcdir)/tests/integration/signals/jobstopnkill \
434 $(srcdir)/tests/integration/signals/jobterm \
435 $(srcdir)/tests/integration/signals/jobtstp \
436 $(srcdir)/tests/integration/signals/parahup \
437 $(srcdir)/tests/integration/signals/paraint \
438 $(srcdir)/tests/integration/signals/parastop \
439 $(srcdir)/tests/integration/signals/paraterm \
440 $(srcdir)/tests/integration/signals/paratstp \
441 $(srcdir)/tests/integration/signals/parausr1 \
442 $(srcdir)/tests/integration/start/cmdtoolong \
443 $(srcdir)/tests/integration/start/compcmd \
444 $(srcdir)/tests/integration/start/compdblrepl \
445 $(srcdir)/tests/integration/start/compemptyrpl \
446 $(srcdir)/tests/integration/start/compmanyargs \
447 $(srcdir)/tests/integration/start/compmanyrepl \
448 $(srcdir)/tests/integration/start/comprepl \
449 $(srcdir)/tests/integration/start/compsimple \
450 $(srcdir)/tests/integration/start/highload \
451 $(srcdir)/tests/integration/start/manycmds \
452 $(srcdir)/tests/integration/start/maxcmdlen \
453 $(srcdir)/tests/integration/start/muchoutput \
454 $(srcdir)/tests/integration/start/nocmds \
455 $(srcdir)/tests/integration/start/nosuchcmd \
456 $(srcdir)/tests/integration/start/onecmd \
457 $(srcdir)/tests/integration/start/sixcmds \
458 $(srcdir)/tests/integration/stop/continue \
459 $(srcdir)/tests/integration/stop/finish \
460 $(srcdir)/tests/integration/stop/grandchild \
461 $(srcdir)/tests/integration/stop/highretval \
462 $(srcdir)/tests/integration/stop/ignore \
463 $(srcdir)/tests/integration/stop/killmany \
464 $(srcdir)/tests/integration/stop/killnograce \
465 $(srcdir)/tests/integration/stop/killsingle \
466 $(srcdir)/tests/integration/stop/killtimeout \
467 $(srcdir)/tests/integration/stop/nograce \
468 $(srcdir)/tests/integration/stop/simple \
469 $(srcdir)/tests/integration/stop/single \
470 $(srcdir)/tests/integration/stop/timeout \
471 $(srcdir)/tests/integration/wordsplit/backslash \
472 $(srcdir)/tests/integration/wordsplit/dquo \
473 $(srcdir)/tests/integration/wordsplit/dquoleft \
474 $(srcdir)/tests/integration/wordsplit/dquoright \
475 $(srcdir)/tests/integration/wordsplit/empty \
476 $(srcdir)/tests/integration/wordsplit/escape \
477 $(srcdir)/tests/integration/wordsplit/esyntax \
478 $(srcdir)/tests/integration/wordsplit/flanknsp \
479 $(srcdir)/tests/integration/wordsplit/flankntab \
480 $(srcdir)/tests/integration/wordsplit/flanknws \
481 $(srcdir)/tests/integration/wordsplit/flanksp \
482 $(srcdir)/tests/integration/wordsplit/flanktab \
483 $(srcdir)/tests/integration/wordsplit/flankws \
484 $(srcdir)/tests/integration/wordsplit/leadnsp \
485 $(srcdir)/tests/integration/wordsplit/leadntab \
486 $(srcdir)/tests/integration/wordsplit/leadnws \
487 $(srcdir)/tests/integration/wordsplit/leadsp \
488 $(srcdir)/tests/integration/wordsplit/leadtab \
489 $(srcdir)/tests/integration/wordsplit/leadws \
490 $(srcdir)/tests/integration/wordsplit/manywords \
491 $(srcdir)/tests/integration/wordsplit/nestquo \
492 $(srcdir)/tests/integration/wordsplit/qdeepnest \
493 $(srcdir)/tests/integration/wordsplit/single \
494 $(srcdir)/tests/integration/wordsplit/sngdquo \
495 $(srcdir)/tests/integration/wordsplit/sngsquo \
496 $(srcdir)/tests/integration/wordsplit/squo \
497 $(srcdir)/tests/integration/wordsplit/squoleft \
498 $(srcdir)/tests/integration/wordsplit/squoright \
499 $(srcdir)/tests/integration/wordsplit/trailnsp \
500 $(srcdir)/tests/integration/wordsplit/trailntab \
501 $(srcdir)/tests/integration/wordsplit/trailnws \
502 $(srcdir)/tests/integration/wordsplit/trailsp \
503 $(srcdir)/tests/integration/wordsplit/trailtab \
504 $(srcdir)/tests/integration/wordsplit/trailws
505 integtestscripts = \
506 $(srcdir)/tests/scripts/colorize \
507 $(srcdir)/tests/scripts/highload \
508 $(srcdir)/tests/scripts/jobstop \
509 $(srcdir)/tests/scripts/jobstopnkill \
510 $(srcdir)/tests/scripts/parastop \
511 $(srcdir)/tests/scripts/paratstp \
512 $(srcdir)/tests/scripts/parausr1 \
513 $(srcdir)/tests/scripts/redirect \
514 $(srcdir)/tests/scripts/rename
516 unittesthdrs = tests/tests.h
517 unittestobjs = $(unittestsrcs:.c=.o)
518 unittestbins = $(unittestobjs:.o=)
519 unittestsrcs = \
520 tests/calloc_s.c \
521 tests/jobskill.c \
522 tests/jobswait.c \
523 tests/putvar.c \
524 tests/termln.c \
525 tests/wordsadd.c \
526 tests/wordsfree.c \
527 tests/wordsinit.c \
528 tests/wordsjoin.c \
529 tests/wordsrealloc.c \
530 tests/wordsplit.c
532 checkenv = \
533 ASAN_OPTIONS=allocator_may_return_null=1:check_initialization_order=1:detect_stack_use_after_return=1:strict_init_order=1:strict_string_checks=1:verbose=1 \
534 BUILDDIR="$$(pwd)" \
535 SRCDIR="$$(cd $(srcdir) && pwd)" \
536 MallocCheckZeroOnFreeCorruption=1 \
537 MallocDebugReport=crash \
538 MallocErrorAbort=1 \
539 MallocGuardEdges=1 \
540 MallocNanoZone=0 \
541 MallocScribble=1 \
542 MallocStackLogging=1 \
543 MallocZeroOnFree=1
545 quickcheckenv = \
546 ASAN_OPTIONS=allocator_may_return_null=1 \
547 BUILDDIR="$$$$(pwd)" \
548 SRCDIR="$$$$(cd $$(srcdir) && pwd)" \
549 MallocNanoZone=0
551 check: para $(checks)
552 $(checkenv) $(srcdir)/scripts/runtests $(RUNTESTFLAGS) $(checks) || [ $$? -eq 2 ]
554 quickcheck:
555 QUICKCHECK=y $(MAKE) -e -f$(makefile) checkenv='$(quickcheckenv)' check
557 tests/calloc_s: tests/calloc_s.o
559 tests/calloc_s.o: tests/calloc_s.c
561 tests/jobskill: tests/jobskill.o
563 tests/jobskill.o: tests/jobskill.c
565 tests/jobswait: tests/jobswait.o
567 tests/jobswait.o: tests/jobswait.c
569 tests/putvar: tests/putvar.o
571 tests/putvar.o: tests/putvar.c tests/putvar.x
573 tests/putvar.x:
574 $(srcdir)/scripts/mkvars -o$@
576 tests/termln: tests/termln.o
578 tests/termln.o: tests/termln.c
580 tests/wordsadd: tests/wordsadd.o
582 tests/wordsadd.o: tests/wordsadd.c
584 tests/wordsfree: tests/wordsfree.o
586 tests/wordsfree.o: tests/wordsfree.c
588 tests/wordsinit: tests/wordsinit.o
590 tests/wordsinit.o: tests/wordsinit.c
592 tests/wordsjoin: tests/wordsjoin.o
594 tests/wordsjoin.o: tests/wordsjoin.c
596 tests/wordsplit: tests/wordsplit.o
598 tests/wordsplit.o: tests/wordsplit.c tests/wordsplit.x
600 tests/wordsplit.x:
601 $(srcdir)/scripts/mkwords -o$@
603 tests/wordsrealloc: tests/wordsrealloc.o
605 tests/wordsrealloc.o: tests/wordsrealloc.c
607 para.o: para.c
608 $(CC) $(LDFLAGS) $(CPPFLAGS) -DPARA_C_AS_OBJ $(CFLAGS) -c -o$@ \
609 $(srcdir)/$(@:.o=.c) $(LDLIBS)
611 $(unittestbins): para.o tests/.sentinel
612 $(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) \
613 -o$@ $@.o para.o $(LDLIBS)
615 $(unittestobjs): $(unittesthdrs) tests/.sentinel
616 $(CC) $(LDFLAGS) $(CPPFLAGS) -Itests $(CFLAGS) $(TESTCFLAGS) \
617 -c -o$@ $(srcdir)/$(@:.o=.c) $(LDLIBS)
621 # Linting and Code Analysis
624 CLANGTIDY = clang-tidy
625 CLANGTIDYFLAGS = --quiet
626 CPPCHECK = cppcheck
627 CPPCHECKFLAGS = \
628 --force \
629 --quiet \
630 --cppcheck-build-dir=cppcheck/build \
631 --language=c \
632 --std=c99 \
633 --library=posix \
634 --library=cppcheck/c99.cfg \
635 --library=cppcheck/gnuc.cfg \
636 --library=cppcheck/posix.cfg \
637 --library=cppcheck/bsd.cfg \
638 --library=cppcheck/para.cfg \
639 --suppressions-list=cppcheck/suppress.txt \
640 --inline-suppr \
641 --enable=all \
642 --check-level=exhaustive \
643 --addon=cppcheck/cert.py \
644 --addon=misra.py \
645 --error-exitcode=1
646 FLAWFINDER = flawfinder
647 FLAWFINDERFLAGS = --dataonly --falsepositive --error-level=1 --quiet
648 RATS = rats
649 RATSFLAGS = --resultsonly --quiet --warning 3
650 SHELLCHECK = shellcheck
651 SHELLCHECKFLAGS = -x
653 lint = para.c $(unittestsrcs)
655 shellcheck = \
656 $(checkscripts) \
657 $(integtestscripts) \
658 .githooks/pre-commit \
659 .githooks/pre-push \
660 configure \
661 installc \
662 libutil.sh \
663 tests/main \
665 lint: cppcheck/build/.sentinel quicklint
666 $(CLANGTIDY) $(CLANGTIDYFLAGS) $(lint) -- $(CPPFLAGS) || [ $$? -eq 127 ]
667 $(CPPCHECK) $(CPPCHECKFLAGS) $(CPPFLAGS) $(lint) || [ $$? -eq 127 ]
669 quicklint:
670 $(FLAWFINDER) $(FLAWFINDERFLAGS) $(lint) || [ $$? -eq 127 ]
671 $(RATS) $(RATSFLAGS) $(lint) || [ $$? -eq 127 ]
673 shellcheck:
674 $(SHELLCHECK) $(SHELLCHECKFLAGS) $(shellcheck) || [ $$? -eq 127 ]
678 # Memory checks
681 memcheck: para
682 $(MAKE) -e CFLAGS='-O1 -g' LDFLAGS= mostlyclean para; \
683 export BUILDDIR=. SRCDIR=$(srcdir); \
684 if command -v valgrind >/dev/null 2>&1; \
685 then $(srcdir)/scripts/runvalgrind -o "$(VALGRINDFLAGS)" $(memcheck); \
686 elif command -v leaks >/dev/null 2>&1; \
687 then $(srcdir)/scripts/runleaks -o "$(LEAKSFLAGS)" $(memcheck); \
692 # Documentation
695 CURL = curl
696 GCOV = gcov
697 LCOV = lcov
698 LCOVFLAGS = --gcov-tool=$(GCOV)
699 SPHINX = sphinx-build
701 covbadgecol = lightgrey
702 covbadgeurl = https://img.shields.io/badge/coverage-{}%25-$(covbadgecol)
703 covfiles = docs/_static/coverage.svg docs/_static/coverage/index.html
704 covinfo = lcov.info
706 coverage: $(covfiles)
708 docs: $(covfiles) para.1
709 cd docs && $(MAKE) -e html
711 para.1: docs/conf.py docs/manual.rst
712 $(SPHINX) $(SPHINXFLAGS) -Dmanpages_url= -b man docs .
714 docs/_static/coverage/index.html: $(covinfo) docs/_static/coverage/.sentinel
715 genhtml -o docs/_static/coverage \
716 --config-file=$(srcdir)/lcovrc $(covinfo)
718 docs/_static/coverage.svg: $(covinfo)
719 $(LCOV) $(LCOVFLAGS) --summary $(covinfo) | \
720 awk '/lines/ {gsub(/%$$/, "", $$2); print($$2)}' | \
721 xargs -I {} $(CURL) -o $@ $(covbadgeurl)
723 lcov.info: integrat.info unit.info
724 $(LCOV) $(LCOVFLAGS) -a integrat.info -a unit.info -o $@
726 integrat.info: para.c $(srcdir)/tests/main $(integtestrcs)
727 $(MAKE) -e -f$(makefile) LDFLAGS='' CFLAGS='-DCOV -O0 -g --coverage' \
728 checks=$(srcdir)/tests/main mostlyclean check
729 $(LCOV) $(LCOVFLAGS) -c -d $(srcdir) -o $@ \
730 --config-file=$(srcdir)/lcovrc --include=para.c
731 $(MAKE) -e -f$(makefile) mostlyclean
733 unit.info: para.c
734 $(MAKE) -e -f$(makefile) \
735 LDFLAGS='' CFLAGS='-DCOV -O0 -g --coverage' RUNTESTFLAGS=-j1 \
736 checks='$(unittestbins)' mostlyclean check
737 $(LCOV) $(LCOVFLAGS) -c -d $(srcdir) -o $@ \
738 --config-file=$(srcdir)/lcovrc --include=para.c
739 $(MAKE) -e -f$(makefile) mostlyclean
743 # Tags
746 CTAGS = ctags
748 TAGS: tags
750 tags: $(srcs) $(unittestsrcs)
751 $(CTAGS) $(CTAGSFLAGS) $(srcs) $(unittestsrcs)
755 # Directories
758 dirs = \
759 cppcheck/build \
760 docs/_static/coverage \
761 tests \
763 dirsentinels = $(dirs:=/.sentinel)
765 $(dirsentinels):
766 dirname $@ | xargs mkdir -p
767 touch $@
770 # Override
773 # If ./configure fails, re-run it as
775 # ./configure >config.mk
777 # and then uncomment the next line:
778 #include config.mk