1 # Makefile for the open-source release of adventure 2.5
3 # The libedit (aka: editline) library is required to build. On
6 # apt-get install libedit-dev
8 # You will also need Python 3 YAML. Under Debian or ubuntu:
10 # apt-get install python3-yaml
12 # If you have pip installed,
16 # If you are using MacPorts on OS X:
17 # port install py3{5,6}-yaml as appropriate for your Python 3 version.
19 # To build with save/resume disabled, pass CCFLAGS="-D ADVENT_NOSAVE"
21 VERS=$(shell sed -n <NEWS '/^[0-9]/s/:.*//p' | head -1)
23 .PHONY: debug indent release refresh dist linty html clean
24 .PHONY: check coverage
27 CCFLAGS+=-std=c99 -D_DEFAULT_SOURCE -DVERSION=\"$(VERS)\" -Wpedantic -O2
29 UNAME_S := $(shell uname -s)
30 ifeq ($(UNAME_S),Linux)
34 OBJS=main.o init.o actions.o score.o misc.o saveresume.o
35 CHEAT_OBJS=cheat.o init.o actions.o score.o misc.o saveresume.o
36 SOURCES=$(OBJS:.o=.c) advent.h adventure.yaml Makefile control make_dungeon.py
39 $(CC) $(CCFLAGS) $(DBX) -c $<
41 advent: $(OBJS) dungeon.o
42 $(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) dungeon.o $(LDFLAGS) $(LIBS)
44 main.o: advent.h dungeon.h
46 init.o: advent.h dungeon.h
48 actions.o: advent.h dungeon.h
50 score.o: advent.h dungeon.h
52 misc.o: advent.h dungeon.h
54 cheat.o: advent.h dungeon.h
56 saveresume.o: advent.h dungeon.h
58 dungeon.o: dungeon.c dungeon.h
59 $(CC) $(CCFLAGS) $(DBX) -c dungeon.c
61 dungeon.c dungeon.h: make_dungeon.py adventure.yaml
62 python3 make_dungeon.py
65 rm -f *.o advent cheat *.html *.gcno *.gcda
66 rm -f dungeon.c dungeon.h
67 rm -f README advent.6 MANIFEST *.tar.gz
70 rm -rf coverage advent.info
71 cd tests; $(MAKE) --quiet clean
74 cheat: $(CHEAT_OBJS) dungeon.o
75 $(CC) $(CCFLAGS) $(DBX) -o cheat $(CHEAT_OBJS) dungeon.o $(LDFLAGS) $(LIBS)
78 cd tests; $(MAKE) --quiet
81 cd tests; $(MAKE) coverage --quiet
83 .SUFFIXES: .adoc .html .6
85 # Requires asciidoc and xsltproc/docbook stylesheets.
87 a2x --doctype manpage --format manpage $<
93 html: advent.html history.html hints.html
95 # README.adoc exists because that filename is magic on GitLab.
96 DOCS=COPYING NEWS README.adoc TODO advent.adoc history.adoc notes.adoc hints.adoc advent.6
97 TESTFILES=tests/*.log tests/*.chk tests/README tests/decheck tests/Makefile
99 # Can't use GNU tar's --transform, needs to build under Alpine Linux.
100 # This is a requirement for testing dist in GitLab's CI pipeline
101 advent-$(VERS).tar.gz: $(SOURCES) $(DOCS)
102 @find $(SOURCES) $(DOCS) $(TESTFILES) -print | sed s:^:advent-$(VERS)/: >MANIFEST
103 @(ln -s . advent-$(VERS))
104 (tar -T MANIFEST -czvf advent-$(VERS).tar.gz)
108 astyle -n -A3 --pad-header --min-conditional-indent=1 --pad-oper *.c
110 release: advent-$(VERS).tar.gz advent.html history.html hints.html notes.html
111 shipper version=$(VERS) | sh -e -x
113 refresh: advent.html notes.html history.html
114 shipper -N -w version=$(VERS) | sh -e -x
116 dist: advent-$(VERS).tar.gz
119 linty: CCFLAGS += -Wall
120 linty: CCFLAGS += -Wextra
121 linty: CCFLAGS += -Wundef
122 linty: CCFLAGS += -Wstrict-prototypes
123 linty: CCFLAGS += -Wmissing-prototypes
124 linty: CCFLAGS += -Wmissing-declarations
125 linty: CCFLAGS += -Wshadow
126 linty: CCFLAGS += -Wfloat-equal
127 linty: CCFLAGS += -Wcast-align
128 linty: CCFLAGS += -Wwrite-strings
129 linty: CCFLAGS += -Waggregate-return
130 linty: CCFLAGS += -Wcast-qual
131 linty: CCFLAGS += -Wswitch-enum
132 linty: CCFLAGS += -Wwrite-strings
133 linty: CCFLAGS += -Wunreachable-code
134 linty: CCFLAGS += -Winit-self
135 linty: CCFLAGS += -Wpointer-arith
138 debug: CCFLAGS += -O0 --coverage -ggdb