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 VERS=$(shell sed -n <NEWS '/^[0-9]/s/:.*//p' | head -1)
29 .PHONY: debug indent release refresh dist linty html clean
30 .PHONY: check coverage
33 CCFLAGS+=-std=c99 -D_DEFAULT_SOURCE -DVERSION=\"$(VERS)\" -Wpedantic -O2
35 UNAME_S := $(shell uname -s)
36 ifeq ($(UNAME_S),Linux)
40 OBJS=main.o init.o actions.o score.o misc.o saveresume.o
41 CHEAT_OBJS=cheat.o init.o actions.o score.o misc.o saveresume.o
42 SOURCES=$(OBJS:.o=.c) advent.h adventure.yaml Makefile control linenoise/linenoise.[ch] make_dungeon.py
45 $(CC) $(CCFLAGS) $(DBX) -c $<
47 advent: $(OBJS) linenoise.o dungeon.o
48 $(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) dungeon.o linenoise.o $(LDFLAGS) $(LIBS)
50 main.o: advent.h dungeon.h linenoise.o
52 init.o: advent.h dungeon.h
54 actions.o: advent.h dungeon.h
56 score.o: advent.h dungeon.h
58 misc.o: advent.h dungeon.h
60 cheat.o: advent.h dungeon.h linenoise.o
62 saveresume.o: advent.h dungeon.h
64 dungeon.o: dungeon.c dungeon.h
65 $(CC) $(CCFLAGS) $(DBX) -c dungeon.c
67 dungeon.c dungeon.h: make_dungeon.py adventure.yaml
68 python3 make_dungeon.py
70 linenoise.o: linenoise/linenoise.h
71 @test -s linenoise/linenoise.h || { echo -e "linenoise not present. Try:\n\
72 git submodule update --recursive --remote --init"; exit 1; }
73 $(CC) -c linenoise/linenoise.c
75 linenoise-dbg: linenoise/linenoise.h
76 @test -s linenoise/linenoise.h || { echo -e "linenoise not present. Try:\n\
77 git submodule update --recursive --remote --init"; exit 1; }
78 $(CC) $(CCFLAGS) -c linenoise/linenoise.c
81 rm -f *.o advent cheat *.html *.gcno *.gcda
82 rm -f dungeon.c dungeon.h
83 rm -f README advent.6 MANIFEST *.tar.gz
86 rm -rf coverage advent.info
87 cd tests; $(MAKE) --quiet clean
90 cheat: $(CHEAT_OBJS) linenoise.o dungeon.o
91 $(CC) $(CCFLAGS) $(DBX) -o cheat $(CHEAT_OBJS) linenoise.o dungeon.o $(LDFLAGS) $(LIBS)
94 cd tests; $(MAKE) --quiet
97 cd tests; $(MAKE) coverage --quiet
99 .SUFFIXES: .adoc .html .6
101 # Requires asciidoc and xsltproc/docbook stylesheets.
103 a2x --doctype manpage --format manpage $<
109 html: advent.html history.html hints.html
111 # README.adoc exists because that filename is magic on GitLab.
112 DOCS=COPYING NEWS README.adoc TODO advent.adoc history.adoc notes.adoc hints.adoc advent.6
113 TESTFILES=tests/*.log tests/*.chk tests/README tests/decheck tests/Makefile
115 # Can't use GNU tar's --transform, needs to build under Alpine Linux.
116 # This is a requirement for testing dist in GitLab's CI pipeline
117 advent-$(VERS).tar.gz: $(SOURCES) $(DOCS)
118 @find $(SOURCES) $(DOCS) $(TESTFILES) -print | sed s:^:advent-$(VERS)/: >MANIFEST
119 @(ln -s . advent-$(VERS))
120 (tar -T MANIFEST -czvf advent-$(VERS).tar.gz)
124 astyle -n -A3 --pad-header --min-conditional-indent=1 --pad-oper *.c
126 release: advent-$(VERS).tar.gz advent.html history.html hints.html notes.html
127 shipper version=$(VERS) | sh -e -x
129 refresh: advent.html notes.html history.html
130 shipper -N -w version=$(VERS) | sh -e -x
132 dist: advent-$(VERS).tar.gz
135 linty: CCFLAGS += -Wall
136 linty: CCFLAGS += -Wextra
137 linty: CCFLAGS += -Wundef
138 linty: CCFLAGS += -Wstrict-prototypes
139 linty: CCFLAGS += -Wmissing-prototypes
140 linty: CCFLAGS += -Wmissing-declarations
141 linty: CCFLAGS += -Wshadow
142 linty: CCFLAGS += -Wfloat-equal
143 linty: CCFLAGS += -Wcast-align
144 linty: CCFLAGS += -Wwrite-strings
145 linty: CCFLAGS += -Waggregate-return
146 linty: CCFLAGS += -Wcast-qual
147 linty: CCFLAGS += -Wswitch-enum
148 linty: CCFLAGS += -Wwrite-strings
149 linty: CCFLAGS += -Wunreachable-code
150 linty: CCFLAGS += -Winit-self
151 linty: CCFLAGS += -Wpointer-arith
154 debug: CCFLAGS += -O0 --coverage -ggdb
158 debug-ln: linenoise-dbg debug