1 # Makefile for the open-source release of adventure 2.5
3 # Note: If you're building from the repository rather than the source tarball,
4 # do this to get the linenoise library where you can use it:
6 # git submodule update --recursive --remote --init
8 # Therafter, you can update it like this:
10 # git submodule update --recursive --remote
12 # but this should seldom be necessary as that library is pretty stable.
14 # You will also need Python 3 YAML. Under Debian or ubuntu:
16 # apt-get install python3-yaml
18 # If you have pip installed,
22 # If you are using MacPorts on OS X:
23 # port install py3{5,6}-yaml as appropriate for your Python 3 version.
25 # To build with save/resume disabled, pass CCFLAGS="-D ADVENT_NOSAVE"
27 .PHONY: debug indent release refresh dist linty html clean
32 CCFLAGS+=-std=c99 -D _DEFAULT_SOURCE -Wpedantic -O2
34 UNAME_S := $(shell uname -s)
35 ifeq ($(UNAME_S),Linux)
39 OBJS=main.o init.o actions.o score.o misc.o saveresume.o
40 CHEAT_OBJS=cheat.o init.o actions.o score.o misc.o saveresume.o
41 SOURCES=$(OBJS:.o=.c) advent.h adventure.yaml Makefile control linenoise/linenoise.[ch] make_dungeon.py
44 $(CC) $(CCFLAGS) $(DBX) -c $<
46 advent: $(OBJS) linenoise.o dungeon.o
47 $(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) dungeon.o linenoise.o $(LDFLAGS) $(LIBS)
49 main.o: advent.h dungeon.h
51 init.o: advent.h dungeon.h
53 actions.o: advent.h dungeon.h
55 score.o: advent.h dungeon.h
57 misc.o: advent.h dungeon.h
59 cheat.o: advent.h dungeon.h
61 saveresume.o: advent.h dungeon.h
63 dungeon.o: dungeon.c dungeon.h
64 $(CC) $(CCFLAGS) $(DBX) -c dungeon.c
66 dungeon.c dungeon.h: make_dungeon.py adventure.yaml
67 python3 make_dungeon.py
69 linenoise.o: linenoise/linenoise.h
70 $(CC) $(CCFLAGS) -c linenoise/linenoise.c
73 rm -f *.o advent cheat *.html *.gcno *.gcda
74 rm -f dungeon.c dungeon.h
75 rm -f README advent.6 MANIFEST *.tar.gz
78 rm -rf coverage advent.info
79 cd tests; $(MAKE) --quiet clean
82 cheat: $(CHEAT_OBJS) linenoise.o dungeon.o
83 $(CC) $(CCFLAGS) $(DBX) -o cheat $(CHEAT_OBJS) linenoise.o dungeon.o $(LDFLAGS) $(LIBS)
86 cd tests; $(MAKE) --quiet
89 cd tests; $(MAKE) coverage --quiet
91 .SUFFIXES: .adoc .html .6
93 # Requires asciidoc and xsltproc/docbook stylesheets.
95 a2x --doctype manpage --format manpage $<
101 html: advent.html history.html hints.html
103 # README.adoc exists because that filename is magic on GitLab.
104 DOCS=COPYING NEWS README.adoc TODO advent.adoc history.adoc notes.adoc hints.adoc advent.6
105 TESTFILES=tests/*.log tests/*.chk tests/README tests/decheck tests/Makefile
107 # Can't use GNU tar's --transform, needs to build under Alpine Linux.
108 # This is a requirement for testing dist in GitLab's CI pipeline
109 advent-$(VERS).tar.gz: $(SOURCES) $(DOCS)
110 @find $(SOURCES) $(DOCS) $(TESTFILES) -print | sed s:^:advent-$(VERS)/: >MANIFEST
111 @(ln -s . advent-$(VERS))
112 (tar -T MANIFEST -czvf advent-$(VERS).tar.gz)
116 astyle -n -A3 --pad-header --min-conditional-indent=1 --pad-oper *.c
118 release: advent-$(VERS).tar.gz advent.html history.html hints.html notes.html
119 shipper version=$(VERS) | sh -e -x
121 refresh: advent.html notes.html history.html
122 shipper -N -w version=$(VERS) | sh -e -x
124 dist: advent-$(VERS).tar.gz
127 linty: CCFLAGS += -Wall
128 linty: CCFLAGS += -Wextra
129 linty: CCFLAGS += -Wundef
130 linty: CCFLAGS += -Wstrict-prototypes
131 linty: CCFLAGS += -Wmissing-prototypes
132 linty: CCFLAGS += -Wmissing-declarations
133 linty: CCFLAGS += -Wshadow
134 linty: CCFLAGS += -Wfloat-equal
135 linty: CCFLAGS += -Wcast-align
136 linty: CCFLAGS += -Wwrite-strings
137 linty: CCFLAGS += -Waggregate-return
138 linty: CCFLAGS += -Wcast-qual
139 linty: CCFLAGS += -Wswitch-enum
140 linty: CCFLAGS += -Wwrite-strings
141 linty: CCFLAGS += -Wunreachable-code
142 linty: CCFLAGS += -Winit-self
143 linty: CCFLAGS += -Wpointer-arith
146 debug: CCFLAGS += -O0 --coverage -ggdb