complete the root dir Makefile
[xonotic/xonotic.git] / Makefile
1 PREFIX ?= /usr/local
2 BINDIR ?= $(PREFIX)/bin
3 LIBDIR ?= $(PREFIX)/lib/xonotic
4 DOCDIR ?= $(PREFIX)/share/doc/xonotic
5 ZIP ?= zip -9
6 INSTALL ?= install
7 ARCH ?= $(shell if [ x"`uname -m`" = x"x86_64" ]; then echo linux64; else echo linux32; fi)
8 LN ?= ln
9 CP ?= cp
10 BINARY ?= yes
11 SUFFIX ?= $(shell if [ -d .git ]; then echo git; elif [ x"$(BINARY)" = x"yes" ]; then echo zip-binary; else echo zip-source; fi)
12
13
14 .PHONY: all
15 all: all-$(SUFFIX)
16
17 .PHONY: all-git
18 all-git:
19         ./all compile -r
20
21 .PHONY: all-zip-binary
22 all-zip-binary:
23         @echo Nothing to do
24
25 .PHONY: all-zip-source
26 all-zip-source:
27         $(MAKE) -C source/fteqcc
28         $(MAKE) -C source/qcsrc FTEQCC=$(CURDIR)/source/fteqcc/fteqcc.bin
29         $(MAKE) -C source/darkplaces sv-release
30         $(MAKE) -C source/darkplaces cl-release
31         $(MAKE) -C source/darkplaces sdl-release
32
33
34 .PHONY: clean
35 clean: clean-$(SUFFIX)
36
37 .PHONY: clean-git
38 clean-git:
39         ./all clean
40
41 .PHONY: clean-zip
42 clean-binary:
43         @echo Nothing to do
44
45 .PHONY: clean-zip
46 clean-source:
47         @echo Sorry, this is not implemented yet
48         @false
49
50
51 .PHONY: install-data
52 install-data: install-data-$(SUFFIX)
53
54 .PHONY: install-data-git
55 install-data-git: all-git
56         $(RM) -rf $(LIBDIR)/data
57         $(INSTALL) -d $(LIBDIR)/data
58         for p in data/*.pk3; do $(INSTALL) $$p $(LIBDIR)/$$p || exit 1; done
59         for p in data/*.pk3dir; do ( cd $$p; $(ZIP) -r $(LIBDIR)/$${p%dir} * ) || exit 1; done
60
61 .PHONY: install-data-zip-binary
62 install-data-zip-binary: all-zip-binary
63         $(RM) -rf $(LIBDIR)/data
64         $(INSTALL) -d $(LIBDIR)/data
65         for p in data/*.pk3; do $(INSTALL) $$p $(LIBDIR)/$$p || exit 1; done
66
67 .PHONY: install-data-zip-source
68 install-data-zip-source: all-zip-source
69         $(RM) -rf $(LIBDIR)/data
70         $(INSTALL) -d $(LIBDIR)/data
71         for p in data/*.pk3; do $(INSTALL) $$p $(LIBDIR)/$$p || exit 1; done
72         for p in data/xonotic-*-data*.pk3; do cd source; $(ZIP) $(LIBDIR)/$$p progs.dat menu.dat csprogs.dat; done
73
74
75 .PHONY: install-engine
76 install-engine: install-engine-$(SUFFIX)
77
78 .PHONY: install-engine-git
79 install-engine-git: all-git
80         $(INSTALL) -d $(LIBDIR)
81         $(INSTALL) xonotic-linux-glx.sh $(LIBDIR)/xonotic-linux-glx.sh
82         $(INSTALL) xonotic-linux-sdl.sh $(LIBDIR)/xonotic-linux-sdl.sh
83         $(INSTALL) xonotic-linux-dedicated.sh $(LIBDIR)/xonotic-linux-dedicated.sh
84         $(INSTALL) darkplaces/darkplaces-sdl $(LIBDIR)/xonotic-$(ARCH)-sdl
85         $(INSTALL) darkplaces/darkplaces-glx $(LIBDIR)/xonotic-$(ARCH)-glx
86         $(INSTALL) darkplaces/darkplaces-dedicated $(LIBDIR)/xonotic-$(ARCH)-dedicated
87
88 .PHONY: install-engine-zip-binary
89 install-engine-zip: all-zip
90         $(INSTALL) -d $(LIBDIR)
91         $(INSTALL) xonotic-linux-glx.sh $(LIBDIR)/xonotic-linux-glx.sh
92         $(INSTALL) xonotic-linux-sdl.sh $(LIBDIR)/xonotic-linux-sdl.sh
93         $(INSTALL) xonotic-linux-dedicated.sh $(LIBDIR)/xonotic-linux-dedicated.sh
94         $(INSTALL) xonotic-$(ARCH)-sdl $(LIBDIR)/xonotic-$(ARCH)-sdl
95         $(INSTALL) xonotic-$(ARCH)-glx $(LIBDIR)/xonotic-$(ARCH)-glx
96         $(INSTALL) xonotic-$(ARCH)-dedicated $(LIBDIR)/xonotic-$(ARCH)-dedicated
97
98 .PHONY: install-engine-zip-source
99 install-engine-zip: all-zip
100         $(INSTALL) -d $(LIBDIR)
101         $(INSTALL) xonotic-linux-glx.sh $(LIBDIR)/xonotic-linux-glx.sh
102         $(INSTALL) xonotic-linux-sdl.sh $(LIBDIR)/xonotic-linux-sdl.sh
103         $(INSTALL) xonotic-linux-dedicated.sh $(LIBDIR)/xonotic-linux-dedicated.sh
104         $(INSTALL) source/darkplaces/xonotic-sdl $(LIBDIR)/xonotic-$(ARCH)-sdl
105         $(INSTALL) source/darkplaces/darkplaces-sdl $(LIBDIR)/xonotic-$(ARCH)-glx
106         $(INSTALL) source/darkplaces/darkplaces-dedicated $(LIBDIR)/xonotic-$(ARCH)-dedicated
107
108
109 .PHONY: install-links
110 install-links:
111         $(INSTALL) -d $(BINDIR)
112         $(LN) -snf $(LIBDIR)/xonotic-linux-sdl.sh $(BINDIR)/xonotic-sdl
113         $(LN) -snf $(LIBDIR)/xonotic-linux-glx.sh $(BINDIR)/xonotic-glx
114         $(LN) -snf $(LIBDIR)/xonotic-linux-dedicated.sh $(BINDIR)/xonotic-dedicated
115
116
117 .PHONY: install-doc
118 install-doc:
119         $(INSTALL) -d $(DOCDIR)/server
120         $(CP) -R Docs/* $(DOCDIR)/
121         $(CP) -R server/* $(DOCDIR)/server
122
123
124 .PHONY: install
125 install: install-data install-engine install-links install-doc