pylint cleanup.
[open-adventure.git] / Makefile
1 # Makefile for the open-source release of adventure 2.5
2
3 # To build with save/resume disabled, pass CCFLAGS="-D ADVENT_NOSAVE"
4
5 VERS=$(shell sed -n <NEWS '/^[0-9]/s/:.*//p' | head -1)
6
7 .PHONY: debug indent release refresh dist linty html clean
8 .PHONY: check coverage
9
10 CC?=gcc
11 CCFLAGS+=-std=c99 -D_DEFAULT_SOURCE -DVERSION=\"$(VERS)\" -O2 -D_FORTIFY_SOURCE=2 -fstack-protector-all $(CFLAGS) -g
12 LIBS=$(shell pkg-config --libs libedit)
13 INC+=$(shell pkg-config --cflags libedit)
14
15 # LLVM/Clang on macOS seems to need -ledit flag for linking
16 UNAME_S := $(shell uname -s)
17 ifeq ($(UNAME_S),Darwin)
18     LIBS += -ledit
19 endif
20
21 OBJS=main.o init.o actions.o score.o misc.o saveresume.o
22 CHEAT_OBJS=cheat.o init.o actions.o score.o misc.o saveresume.o
23 SOURCES=$(OBJS:.o=.c) advent.h adventure.yaml Makefile control make_dungeon.py templates/*.tpl
24
25 .c.o:
26         $(CC) $(CCFLAGS) $(INC) $(DBX) -c $<
27
28 advent: $(OBJS) dungeon.o
29         $(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) dungeon.o $(LDFLAGS) $(LIBS)
30
31 main.o:         advent.h dungeon.h
32
33 init.o:         advent.h dungeon.h
34
35 actions.o:      advent.h dungeon.h
36
37 score.o:        advent.h dungeon.h
38
39 misc.o:         advent.h dungeon.h
40
41 cheat.o:        advent.h dungeon.h
42
43 saveresume.o:   advent.h dungeon.h
44
45 dungeon.o:      dungeon.c dungeon.h
46         $(CC) $(CCFLAGS) $(DBX) -c dungeon.c
47
48 dungeon.c dungeon.h: make_dungeon.py adventure.yaml advent.h templates/*.tpl
49         ./make_dungeon.py
50
51 clean:
52         rm -f *.o advent cheat *.html *.gcno *.gcda
53         rm -f dungeon.c dungeon.h
54         rm -f README advent.6 MANIFEST *.tar.gz
55         rm -f *~
56         rm -f .*~
57         rm -rf coverage advent.info
58         cd tests; $(MAKE) --quiet clean
59
60
61 cheat: $(CHEAT_OBJS) dungeon.o
62         $(CC) $(CCFLAGS) $(DBX) -o cheat $(CHEAT_OBJS) dungeon.o $(LDFLAGS) $(LIBS)
63
64 check: advent cheat
65         cd tests; $(MAKE) --quiet
66
67 # After this, run your browser on coverage/open-adventure/index.html
68 # to see coverage results. Browse coverage/adventure.yaml.html
69 # to see symbol coverage over the YAML file.
70 coverage: debug
71         cd tests; $(MAKE) coverage --quiet
72
73 .SUFFIXES: .adoc .html .6
74
75 # Requires asciidoc and xsltproc/docbook stylesheets.
76 .adoc.6:
77         a2x --doctype manpage --format manpage $<
78 .adoc.html:
79         asciidoc $<
80 .adoc:
81         asciidoc $<
82
83 html: advent.html history.html hints.html
84
85 # README.adoc exists because that filename is magic on GitLab.
86 DOCS=COPYING NEWS README.adoc TODO advent.adoc history.adoc notes.adoc hints.adoc advent.6 INSTALL.adoc
87 TESTFILES=tests/*.log tests/*.chk tests/README tests/decheck tests/Makefile
88
89 # Can't use GNU tar's --transform, needs to build under Alpine Linux.
90 # This is a requirement for testing dist in GitLab's CI pipeline
91 advent-$(VERS).tar.gz: $(SOURCES) $(DOCS)
92         @find $(SOURCES) $(DOCS) $(TESTFILES) -print | sed s:^:advent-$(VERS)/: >MANIFEST
93         @(ln -s . advent-$(VERS))
94         (tar -T MANIFEST -czvf advent-$(VERS).tar.gz)
95         @(rm advent-$(VERS))
96
97 indent:
98         astyle -n -A3 --pad-header --min-conditional-indent=1 --pad-oper *.c
99
100 release: advent-$(VERS).tar.gz advent.html history.html hints.html notes.html
101         shipper version=$(VERS) | sh -e -x
102
103 refresh: advent.html notes.html history.html
104         shipper -N -w version=$(VERS) | sh -e -x
105
106 dist: advent-$(VERS).tar.gz
107
108 linty: CCFLAGS += -W
109 linty: CCFLAGS += -Wall
110 linty: CCFLAGS += -Wextra
111 linty: CCGLAGS += -Wpedantic
112 linty: CCFLAGS += -Wundef
113 linty: CCFLAGS += -Wstrict-prototypes
114 linty: CCFLAGS += -Wmissing-prototypes
115 linty: CCFLAGS += -Wmissing-declarations
116 linty: CCFLAGS += -Wshadow
117 linty: CCFLAGS += -Wnull-dereference
118 linty: CCFLAGS += -Wjump-misses-init
119 linty: CCFLAGS += -Wfloat-equal
120 linty: CCFLAGS += -Wcast-align
121 linty: CCFLAGS += -Wwrite-strings
122 linty: CCFLAGS += -Waggregate-return
123 linty: CCFLAGS += -Wcast-qual
124 linty: CCFLAGS += -Wswitch-enum
125 linty: CCFLAGS += -Wwrite-strings
126 linty: CCFLAGS += -Wunreachable-code
127 linty: CCFLAGS += -Winit-self
128 linty: CCFLAGS += -Wpointer-arith
129 linty: advent cheat
130
131 debug: CCFLAGS += -O0
132 debug: CCFLAGS += --coverage
133 debug: CCFLAGS += -ggdb
134 debug: CCFLAGS += -U_FORTIFY_SOURCE
135 debug: CCFLAGS += -fsanitize=address
136 debug: CCFLAGS += -fsanitize=undefined
137 debug: linty
138
139 PYSUPPRESSIONS = --suppress=missingIncludeSystem --suppress=invalidscanf
140 cppcheck:
141         cppcheck -I. --template gcc --enable=all $(CSUPPRESSIONS) *.[ch]
142
143 PYSUPPRESSIONS = line-too-long,invalid-name,missing-function-docstring,too-many-lines,too-many-branches,global-statement,multiple-imports,too-many-locals,too-many-statements,too-many-nested-blocks,no-else-return,raise-missing-from,redefined-outer-name,consider-using-in
144 pylint:
145         @pylint --score=n --disable=$(PYSUPPRESSIONS) *.py */*.py