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