1 # Makefile for the open-source release of adventure 2.5
3 # To build with save/resume disabled, pass CCFLAGS="-D ADVENT_NOSAVE"
5 VERS=$(shell sed -n <NEWS '/^[0-9]/s/:.*//p' | head -1)
7 .PHONY: debug indent release refresh dist linty html clean
11 CCFLAGS+=-std=c99 -D_DEFAULT_SOURCE -DVERSION=\"$(VERS)\" -O2
12 LIBS=$(shell pkg-config --libs libedit)
13 INC+=$(shell pkg-config --cflags libedit)
15 OBJS=main.o init.o actions.o score.o misc.o saveresume.o
16 CHEAT_OBJS=cheat.o init.o actions.o score.o misc.o saveresume.o
17 SOURCES=$(OBJS:.o=.c) advent.h adventure.yaml Makefile control make_dungeon.py
20 $(CC) $(CCFLAGS) $(INC) $(DBX) -c $<
22 advent: $(OBJS) dungeon.o
23 $(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) dungeon.o $(LDFLAGS) $(LIBS)
25 main.o: advent.h dungeon.h
27 init.o: advent.h dungeon.h
29 actions.o: advent.h dungeon.h
31 score.o: advent.h dungeon.h
33 misc.o: advent.h dungeon.h
35 cheat.o: advent.h dungeon.h
37 saveresume.o: advent.h dungeon.h
39 dungeon.o: dungeon.c dungeon.h
40 $(CC) $(CCFLAGS) $(DBX) -c dungeon.c
42 dungeon.c dungeon.h: make_dungeon.py adventure.yaml
43 python3 make_dungeon.py
46 rm -f *.o advent cheat *.html *.gcno *.gcda
47 rm -f dungeon.c dungeon.h
48 rm -f README advent.6 MANIFEST *.tar.gz
51 rm -rf coverage advent.info
52 cd tests; $(MAKE) --quiet clean
55 cheat: $(CHEAT_OBJS) dungeon.o
56 $(CC) $(CCFLAGS) $(DBX) -o cheat $(CHEAT_OBJS) dungeon.o $(LDFLAGS) $(LIBS)
59 cd tests; $(MAKE) --quiet
62 cd tests; $(MAKE) coverage --quiet
64 .SUFFIXES: .adoc .html .6
66 # Requires asciidoc and xsltproc/docbook stylesheets.
68 a2x --doctype manpage --format manpage $<
74 html: advent.html history.html hints.html
76 # README.adoc exists because that filename is magic on GitLab.
77 DOCS=COPYING NEWS README.adoc TODO advent.adoc history.adoc notes.adoc hints.adoc advent.6
78 TESTFILES=tests/*.log tests/*.chk tests/README tests/decheck tests/Makefile
80 # Can't use GNU tar's --transform, needs to build under Alpine Linux.
81 # This is a requirement for testing dist in GitLab's CI pipeline
82 advent-$(VERS).tar.gz: $(SOURCES) $(DOCS)
83 @find $(SOURCES) $(DOCS) $(TESTFILES) -print | sed s:^:advent-$(VERS)/: >MANIFEST
84 @(ln -s . advent-$(VERS))
85 (tar -T MANIFEST -czvf advent-$(VERS).tar.gz)
89 astyle -n -A3 --pad-header --min-conditional-indent=1 --pad-oper *.c
91 release: advent-$(VERS).tar.gz advent.html history.html hints.html notes.html
92 shipper version=$(VERS) | sh -e -x
94 refresh: advent.html notes.html history.html
95 shipper -N -w version=$(VERS) | sh -e -x
97 dist: advent-$(VERS).tar.gz
100 linty: CCFLAGS += -Wall
101 linty: CCFLAGS += -Wextra
102 linty: CCGLAGS += -Wpedantic
103 linty: CCFLAGS += -Wundef
104 linty: CCFLAGS += -Wstrict-prototypes
105 linty: CCFLAGS += -Wmissing-prototypes
106 linty: CCFLAGS += -Wmissing-declarations
107 linty: CCFLAGS += -Wshadow
108 linty: CCFLAGS += -Wfloat-equal
109 linty: CCFLAGS += -Wcast-align
110 linty: CCFLAGS += -Wwrite-strings
111 linty: CCFLAGS += -Waggregate-return
112 linty: CCFLAGS += -Wcast-qual
113 linty: CCFLAGS += -Wswitch-enum
114 linty: CCFLAGS += -Wwrite-strings
115 linty: CCFLAGS += -Wunreachable-code
116 linty: CCFLAGS += -Winit-self
117 linty: CCFLAGS += -Wpointer-arith
120 debug: CCFLAGS += -O0 --coverage -ggdb
124 CSUPPRESSIONS = --suppress=missingIncludeSystem --suppress=invalidscanf
126 cppcheck -I. --template gcc --enable=all $(CSUPPRESSIONS) *.[ch]