1# type 'make help' for a list/explaination of recipes.
2
3BUILDDIR = bin
4
5MAKEARGS += $(if $(VERBOSE),,--no-print-directory)
6
7.PHONY: default
8default: build
9
10$(BUILDDIR):
11	@echo "call ./configure to initialize the build directory."
12	@echo "also see ./configure --help, and doc/building.md"
13	@echo ""
14	@false
15
16.PHONY: install
17install: $(BUILDDIR)
18	$(MAKE) $(MAKEARGS) -C $(BUILDDIR) install
19
20.PHONY: run
21run: build
22	./run game
23
24.PHONY: test
25test: tests checkfast
26
27.PHONY: tests
28tests: build
29	./run test -a
30
31.PHONY: build
32build: $(BUILDDIR)
33	@$(MAKE) $(MAKEARGS) -C $(BUILDDIR)
34
35.PHONY: ninja
36ninja: $(BUILDDIR)
37	@ninja -C $(BUILDDIR)
38
39.PHONY: libopenage
40libopenage: $(BUILDDIR)
41	@$(MAKE) $(MAKEARGS) -C $(BUILDDIR) libopenage
42
43.PHONY: codegen
44codegen: $(BUILDDIR)
45	$(MAKE) $(MAKEARGS) -C $(BUILDDIR) codegen
46
47.PHONY: pxdgen
48pxdgen: $(BUILDDIR)
49	$(MAKE) $(MAKEARGS) -C $(BUILDDIR) pxdgen
50
51.PHONY: compilepy
52compilepy: $(BUILDDIR)
53	$(MAKE) $(MAKEARGS) -C $(BUILDDIR) compilepy
54
55.PHONY: inplacemodules
56inplacemodules:
57	$(MAKE) $(MAKEARGS) -C $(BUILDDIR) inplacemodules
58
59.PHONY: cythonize
60cythonize: $(BUILDDIR)
61	$(MAKE) $(MAKEARGS) -C $(BUILDDIR) cythonize
62
63.PHONY: doc
64doc: $(BUILDDIR)
65	$(MAKE) $(MAKEARGS) -C $(BUILDDIR) doc
66
67.PHONY: cleanelf
68cleanelf: $(BUILDDIR)
69	@# removes all object files and binaries
70	$(MAKE) $(MAKEARGS) -C $(BUILDDIR) clean
71
72.PHONY: cleancodegen
73cleancodegen: $(BUILDDIR)
74	@# removes all sourcefiles created by codegen
75	$(MAKE) $(MAKEARGS) -C $(BUILDDIR) cleancodegen
76
77.PHONY: cleanpxdgen
78cleanpxdgen: $(BUILDDIR)
79	@# removes all generated .pxd files
80	$(MAKE) $(MAKEARGS) -C $(BUILDDIR) cleanpxdgen
81
82.PHONY: cleancython
83cleancython: $(BUILDDIR)
84	@# removes all .cpp files created by Cython
85	$(MAKE) $(MAKEARGS) -C $(BUILDDIR) cleancython
86
87.PHONY: clean
88clean: $(BUILDDIR) cleancodegen cleanpxdgen cleancython cleanelf
89	@# removes object files, binaries, py modules, generated code
90
91.PHONY: cleaninsourcebuild
92cleaninsourcebuild:
93	@echo "cleaning remains of in-source builds"
94	rm -rf DartConfiguration.tcl codegen_depend_cache codegen_target_cache Doxyfile Testing
95	@find . -not -path "./.bin/*" -type f -name CTestTestfile.cmake              -print -delete
96	@find . -not -path "./.bin/*" -type f -name cmake_install.cmake              -print -delete
97	@find . -not -path "./.bin/*" -type f -name CMakeCache.txt                   -print -delete
98	@find . -not -path "./.bin/*" -type f -name Makefile -not -path "./Makefile" -print -delete
99	@find . -not -path "./.bin/*" -type d -name CMakeFiles                       -print -exec rm -r {} +
100
101.PHONY: cleanbuilddirs
102cleanbuilddirs: cleaninsourcebuild
103	@if test -d bin; then $(MAKE) $(MAKEARGS) -C bin clean cleancython cleanpxdgen cleancodegen || true; fi
104	@echo cleaning symlinks to build directories
105	rm -f bin
106	@echo cleaning build directories
107	rm -rf .bin
108	@echo cleaning cmake-time generated code
109	rm -f Doxyfile py/openage/config.py libopenage/config.h libopenage/config.cpp
110
111.PHONY: mrproper
112mrproper: cleanbuilddirs
113	@echo cleaning converted assets
114	rm -rf userassets
115
116.PHONY: mrproperer
117mrproperer: mrproper
118	@if ! test -d .git; then echo "mrproperer is only available for gitrepos."; false; fi
119	@echo removing ANYTHING that is not checked into the git repo
120	@echo ENTER to confirm
121	@read val
122	git clean -x -d -f
123
124.PHONY: checkfast
125checkfast:
126	python3 -m buildsystem.codecompliance --fast
127
128.PHONY: checkall
129checkall:
130	python3 -m buildsystem.codecompliance --all
131
132.PHONY: checkchanged
133checkchanged:
134	python3 -m buildsystem.codecompliance --all --only-changed-files=origin/master
135
136.PHONY: checkuncommited
137checkuncommited:
138	python3 -m buildsystem.codecompliance --all --only-changed-files=HEAD
139
140.PHONY: checkpy
141checkpy:
142	python3 -m buildsystem.codecompliance --pystyle --pylint
143
144.PHONY: help
145help: $(BUILDDIR)/Makefile
146	@echo "openage Makefile"
147	@echo ""
148	@echo "wrapper that mostly forwards recipes to the cmake-generated Makefile in bin/"
149	@echo ""
150	@echo "targets:"
151	@echo ""
152	@echo "build              -> build entire project"
153	@echo "libopenage         -> build libopenage"
154	@echo "pxdgen             -> generate .pxd files"
155	@echo "cythonize          -> compile .pyx files to .cpp"
156	@echo "compilepy          -> compile .py files to .pyc"
157	@echo "inplacemodules     -> create in-place modules"
158	@echo "codegen            -> generate cpp sources"
159	@echo "doc                -> create documentation files"
160	@echo ""
161	@echo "cleanelf           -> remove C++ ELF files"
162	@echo "cleancodegen       -> undo 'make codegen'"
163	@echo "cleancython        -> undo 'make cythonize inplacemodules'"
164	@echo "cleanpxdgen        -> undo 'make pxdgen'"
165	@echo "clean              -> undo 'make' (all of the above)"
166	@echo "cleanbuilddirs     -> undo 'make' and './configure'"
167	@echo "cleaninsourcebuild -> undo in-source build accidents"
168	@echo "mrproper           -> as above, but additionally delete user assets"
169	@echo "mrproperer         -> leaves nothing but ashes"
170	@echo ""
171	@echo "run                -> run openage"
172	@echo "tests              -> run the tests (py + cpp)"
173	@echo ""
174	@echo "checkall           -> full code compliance check"
175	@echo "checkfast          -> fast checks only"
176	@echo "checkchanged       -> full check for all files changed since origin/master"
177	@echo "checkuncommited    -> full check for all currently uncommited files"
178	@echo "checkpy            -> check python compliance"
179	@echo ""
180	@echo "test               -> tests + checkfast. this is what you should use for regular devbuilds"
181	@echo ""
182	@echo "CMake help:"
183	@test -d $(BUILDDIR) && $(MAKE) -C $(BUILDDIR) help || echo "no builddir is configured"
184