1 # Makefile for the open-source release of adventure 2.5
3 # You will need Python 3 YAML. Under Debian or ubuntu:
5 # apt-get install python3-yaml
7 # If you have pip installed,
11 # If you are using MacPorts on OS X:
12 # port install py3{5,6}-yaml as appropriate for your Python 3 version.
14 # To build with save/resume disabled, pass CCFLAGS="-D ADVENT_NOSAVE"
16 VERS=$(shell sed -n <NEWS '/^[0-9]/s/:.*//p' | head -1)
18 .PHONY: debug indent release refresh dist linty html clean
19 .PHONY: check coverage
22 CCFLAGS+=-std=c99 -D_DEFAULT_SOURCE -DVERSION=\"$(VERS)\" -Wpedantic -O2
24 UNAME_S := $(shell uname -s)
25 ifeq ($(UNAME_S),Linux)
29 OBJS=main.o init.o actions.o score.o misc.o saveresume.o
30 CHEAT_OBJS=cheat.o init.o actions.o score.o misc.o saveresume.o
31 SOURCES=$(OBJS:.o=.c) advent.h adventure.yaml Makefile control make_dungeon.py
34 $(CC) $(CCFLAGS) $(DBX) -c $<
36 advent: $(OBJS) dungeon.o
37 $(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) dungeon.o $(LDFLAGS) $(LIBS)
39 main.o: advent.h dungeon.h
41 init.o: advent.h dungeon.h
43 actions.o: advent.h dungeon.h
45 score.o: advent.h dungeon.h
47 misc.o: advent.h dungeon.h
49 cheat.o: advent.h dungeon.h
51 saveresume.o: advent.h dungeon.h
53 dungeon.o: dungeon.c dungeon.h
54 $(CC) $(CCFLAGS) $(DBX) -c dungeon.c
56 dungeon.c dungeon.h: make_dungeon.py adventure.yaml
57 python3 make_dungeon.py
60 rm -f *.o advent cheat *.html *.gcno *.gcda
61 rm -f dungeon.c dungeon.h
62 rm -f README advent.6 MANIFEST *.tar.gz
65 rm -rf coverage advent.info
66 cd tests; $(MAKE) --quiet clean
69 cheat: $(CHEAT_OBJS) dungeon.o
70 $(CC) $(CCFLAGS) $(DBX) -o cheat $(CHEAT_OBJS) dungeon.o $(LDFLAGS) $(LIBS)
73 cd tests; $(MAKE) --quiet
76 cd tests; $(MAKE) coverage --quiet
78 .SUFFIXES: .adoc .html .6
80 # Requires asciidoc and xsltproc/docbook stylesheets.
82 a2x --doctype manpage --format manpage $<
88 html: advent.html history.html hints.html
90 # README.adoc exists because that filename is magic on GitLab.
91 DOCS=COPYING NEWS README.adoc TODO advent.adoc history.adoc notes.adoc hints.adoc advent.6
92 TESTFILES=tests/*.log tests/*.chk tests/README tests/decheck tests/Makefile
94 # Can't use GNU tar's --transform, needs to build under Alpine Linux.
95 # This is a requirement for testing dist in GitLab's CI pipeline
96 advent-$(VERS).tar.gz: $(SOURCES) $(DOCS)
97 @find $(SOURCES) $(DOCS) $(TESTFILES) -print | sed s:^:advent-$(VERS)/: >MANIFEST
98 @(ln -s . advent-$(VERS))
99 (tar -T MANIFEST -czvf advent-$(VERS).tar.gz)
103 astyle -n -A3 --pad-header --min-conditional-indent=1 --pad-oper *.c
105 release: advent-$(VERS).tar.gz advent.html history.html hints.html notes.html
106 shipper version=$(VERS) | sh -e -x
108 refresh: advent.html notes.html history.html
109 shipper -N -w version=$(VERS) | sh -e -x
111 dist: advent-$(VERS).tar.gz
114 linty: CCFLAGS += -Wall
115 linty: CCFLAGS += -Wextra
116 linty: CCFLAGS += -Wundef
117 linty: CCFLAGS += -Wstrict-prototypes
118 linty: CCFLAGS += -Wmissing-prototypes
119 linty: CCFLAGS += -Wmissing-declarations
120 linty: CCFLAGS += -Wshadow
121 linty: CCFLAGS += -Wfloat-equal
122 linty: CCFLAGS += -Wcast-align
123 linty: CCFLAGS += -Wwrite-strings
124 linty: CCFLAGS += -Waggregate-return
125 linty: CCFLAGS += -Wcast-qual
126 linty: CCFLAGS += -Wswitch-enum
127 linty: CCFLAGS += -Wwrite-strings
128 linty: CCFLAGS += -Wunreachable-code
129 linty: CCFLAGS += -Winit-self
130 linty: CCFLAGS += -Wpointer-arith
133 debug: CCFLAGS += -O0 --coverage -ggdb