summaryrefslogtreecommitdiff
blob: 537b688c7dfb540728b89adb9b34cfe9324975b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
https://github.com/OpenRA/OpenRA/pull/3500

--- a/Makefile
+++ b/Makefile
@@ -1,34 +1,69 @@
+############################# INSTRUCTIONS #############################
+#
+# to compile, run:
+#   make
+#
+# to compile with development tools, run:
+#   make all
+#
+# to install, run:
+#   make [prefix=/foo] [bindir=/bar/bin] install
+#
+# to install with development tools, run:
+#   make [prefix=/foo] [bindir=/bar/bin] install-all
+#
+# to uninstall, run:
+#   make uninstall
+#
+# for help, run:
+#   make help
+#
+# to start the game, run:
+#   openra
+
+
+
+############################## TOOLCHAIN ###############################
+#
 CSC         = gmcs
 CSFLAGS     = -nologo -warn:4 -debug:full -optimize- -codepage:utf8 -unsafe -warnaserror
 DEFINE      = DEBUG;TRACE
 COMMON_LIBS = System.dll System.Core.dll System.Drawing.dll System.Xml.dll thirdparty/ICSharpCode.SharpZipLib.dll thirdparty/FuzzyLogicLibrary.dll thirdparty/Mono.Nat.dll
-PHONY       = core tools package all mods clean distclean dependencies version
+
+
+
+######################### UTILITIES/SETTINGS ###########################
+#
+# install locations
+prefix ?= /usr/local
+datarootdir ?= $(prefix)/share
+datadir ?= $(datarootdir)
+bindir ?= $(prefix)/bin
+BIN_INSTALL_DIR = $(DESTDIR)$(bindir)
+DATA_INSTALL_DIR = $(DESTDIR)$(datadir)/openra
+
+# install tools
+RM = rm
+RM_R = $(RM) -r
+RM_F = $(RM) -f
+CP = cp
+CP_R = $(CP) -r
+INSTALL = install
+INSTALL_DIR = $(INSTALL) -d
+INSTALL_PROGRAM = $(INSTALL) -m755
+INSTALL_DATA = $(INSTALL) -m644
+
+# program targets
+CORE = fileformats rcg rgl rsdl rnull game utility
+TOOLS = editor tsbuild ralint
+
 VERSION     = $(shell git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || echo git-`git rev-parse --short HEAD`)
 
-.SUFFIXES:
-core: game renderers mods utility tsbuild
-tools: editor ralint tsbuild
-package: dependencies core editor docs version
-mods: mod_ra mod_cnc mod_d2k
-all: dependencies core tools
-clean:
-	@-rm -f *.exe *.dll *.mdb mods/**/*.dll mods/**/*.mdb *.resources
-distclean: clean
-dependencies:
-	@ cp -r thirdparty/*.dl* .
-	@ cp -r thirdparty/Tao/* .
-version: mods/ra/mod.yaml mods/cnc/mod.yaml mods/d2k/mod.yaml
-	@for i in $? ; do \
-		awk '{sub("Version:.*$$","Version: $(VERSION)"); print $0}' $${i} > $${i}.tmp && \
-		mv -f $${i}.tmp $${i} ; \
-	done
-default: dependencies core
-
-.DEFAULT_GOAL := default
-
+
+
+######################## PROGRAM TARGET RULES ##########################
 #
 # Core binaries
-#
 fileformats_SRCS	:= $(shell find OpenRA.FileFormats/ -iname '*.cs')
 fileformats_TARGET	= OpenRA.FileFormats.dll
 fileformats_KIND	= library
@@ -39,16 +74,14 @@
 game_SRCS			:= $(shell find OpenRA.Game/ -iname '*.cs')
 game_TARGET			= OpenRA.Game.exe
 game_KIND			= winexe
-game_DEPS			= $(fileformats_TARGET) 
+game_DEPS			= $(fileformats_TARGET)
 game_LIBS			= $(COMMON_LIBS) System.Windows.Forms.dll $(game_DEPS) \
 					thirdparty/Tao/Tao.OpenAl.dll thirdparty/SharpFont.dll
 game_FLAGS			= -win32icon:OpenRA.Game/OpenRA.ico
 PROGRAMS 			+= game
 game: $(game_TARGET)
 
-#
 # Renderer dlls
-#
 rsdl_SRCS			:= $(shell find OpenRA.Renderer.SdlCommon/ -iname '*.cs')
 rsdl_TARGET			= OpenRA.Renderer.SdlCommon.dll
 rsdl_KIND			= library
@@ -82,19 +115,18 @@
 PROGRAMS 			+= rcg rgl rnull rsdl
 renderers: $(rcg_TARGET) $(rgl_TARGET) $(rnull_TARGET) $(rsdl_TARGET)
 
-#
-# Official Mods
-#
-# Red Alert
+
+##### Official Mods #####
 
 STD_MOD_LIBS	= $(fileformats_TARGET) $(game_TARGET)
 STD_MOD_DEPS	= $(STD_MOD_LIBS) $(ralint_TARGET)
 
+# Red Alert
 mod_ra_SRCS			:= $(shell find OpenRA.Mods.RA/ -iname '*.cs')
 mod_ra_TARGET			= mods/ra/OpenRA.Mods.RA.dll
 mod_ra_KIND			= library
-mod_ra_DEPS			= $(STD_MOD_DEPS)
-mod_ra_LIBS			= $(COMMON_LIBS) $(STD_MOD_LIBS)
+mod_ra_DEPS			= $(STD_MOD_DEPS) $(utility_TARGET)
+mod_ra_LIBS			= $(COMMON_LIBS) $(STD_MOD_LIBS) $(utility_TARGET)
 mod_ra_EXTRA_CMDS		= mono --debug RALint.exe ra
 PROGRAMS 			+= mod_ra
 mod_ra: $(mod_ra_TARGET)
@@ -119,9 +151,9 @@
 PROGRAMS 		+= mod_d2k
 mod_d2k: $(mod_d2k_TARGET)
 
-#
-# Tools
-#
+
+##### Tools #####
+
 # Map Editor
 editor_SRCS			:= $(shell find OpenRA.Editor/ -iname '*.cs')
 editor_TARGET			= OpenRA.Editor.exe
@@ -163,13 +195,8 @@
 	resgen2 OpenRA.TilesetBuilder/Surface.resx OpenRA.TilesetBuilder.Surface.resources 1> /dev/null
 tsbuild: OpenRA.TilesetBuilder.frmBuilder.resources OpenRA.TilesetBuilder.frmNew.resources OpenRA.TilesetBuilder.Surface.resources $(tsbuild_TARGET)
 
-#
-# Launchers / Utilities
-#
-# Patches binary headers to work around a mono bug
-fixheader.exe: packaging/fixheader.cs
-	@echo CSC fixheader.exe
-	@$(CSC) packaging/fixheader.cs $(CSFLAGS) -out:fixheader.exe -t:exe $(COMMON_LIBS:%=-r:%)
+
+##### Launchers / Utilities #####
 
 # Backend for the launcher apps - queries game/mod info and applies actions to an install
 utility_SRCS		:= $(shell find OpenRA.Utility/ -iname '*.cs')
@@ -180,11 +207,13 @@
 PROGRAMS 			+= utility
 utility: $(utility_TARGET)
 
-.PHONY: $(PHONY) $(PROGRAMS)
-
-#
+
+# Patches binary headers to work around a mono bug
+fixheader.exe: packaging/fixheader.cs
+	@echo CSC fixheader.exe
+	@$(CSC) packaging/fixheader.cs $(CSFLAGS) -out:fixheader.exe -t:exe $(COMMON_LIBS:%=-r:%)
+
 # Generate build rules for each target defined above in PROGRAMS
-#
 define BUILD_ASSEMBLY
 
 $$($(1)_TARGET): $$($(1)_SRCS) Makefile $$($(1)_DEPS) fixheader.exe
@@ -203,68 +232,67 @@
 $(foreach prog,$(PROGRAMS),$(eval $(call BUILD_ASSEMBLY,$(prog))))
 
 
-#
-# Install / Uninstall for *nix
-#
-prefix ?= /usr/local
-datarootdir ?= $(prefix)/share
-datadir ?= $(datarootdir)
-bindir ?= $(prefix)/bin
-BIN_INSTALL_DIR = $(DESTDIR)$(bindir)
-INSTALL_DIR = $(DESTDIR)$(datadir)/openra
-INSTALL = install
-INSTALL_PROGRAM = $(INSTALL)
-CORE = fileformats rcg rgl rsdl rnull game editor utility tsbuild
+
+########################## MAKE/INSTALL RULES ##########################
+#
+default: dependencies core
+
+core: game renderers mods utility tsbuild
+
+tools: editor tsbuild ralint
+
+package: dependencies core editor docs version
+
+mods: mod_ra mod_cnc mod_d2k
+
+all: dependencies core tools
+
+clean:
+	@-$(RM_F) *.exe *.dll *.mdb mods/**/*.dll mods/**/*.mdb *.resources
+
+distclean: clean
+
+dependencies:
+	@ $(CP_R) thirdparty/*.dl* .
+	@ $(CP_R) thirdparty/Tao/* .
+
+version: mods/ra/mod.yaml mods/cnc/mod.yaml mods/d2k/mod.yaml
+	@for i in $? ; do \
+		awk '{sub("Version:.*$$","Version: $(VERSION)"); print $0}' $${i} > $${i}.tmp && \
+		mv -f $${i}.tmp $${i} ; \
+	done
 
 # Documentation (d2k depends on all mod libraries)
-docs:
+docs: utility
 	@mono --debug OpenRA.Utility.exe --docs d2k > DOCUMENTATION.md
 
-install: all
-	@-echo "Installing OpenRA to $(INSTALL_DIR)"
-	@$(INSTALL_PROGRAM) -d $(INSTALL_DIR)
-	@$(INSTALL_PROGRAM) $(foreach prog,$(CORE),$($(prog)_TARGET)) $(INSTALL_DIR)
-	@$(INSTALL_PROGRAM) -d $(INSTALL_DIR)/mods/cnc
-	@$(INSTALL_PROGRAM) $(mod_cnc_TARGET) $(INSTALL_DIR)/mods/cnc
-	@$(INSTALL_PROGRAM) -d $(INSTALL_DIR)/mods/ra
-	@$(INSTALL_PROGRAM) $(mod_ra_TARGET) $(INSTALL_DIR)/mods/ra
-	@$(INSTALL_PROGRAM) -d $(INSTALL_DIR)/mods/d2k
-	@$(INSTALL_PROGRAM) $(mod_d2k_TARGET) $(INSTALL_DIR)/mods/d2k
-
-	@-cp $(foreach f,$(shell ls mods/cnc --hide=*.dll),mods/cnc/$(f)) $(INSTALL_DIR)/mods/cnc
-	@cp -r mods/cnc/maps $(INSTALL_DIR)/mods/cnc
-	@cp -r mods/cnc/chrome $(INSTALL_DIR)/mods/cnc
-	@cp -r mods/cnc/bits $(INSTALL_DIR)/mods/cnc
-	@cp -r mods/cnc/rules $(INSTALL_DIR)/mods/cnc
-	@cp -r mods/cnc/sequences $(INSTALL_DIR)/mods/cnc
-	@cp -r mods/cnc/tilesets $(INSTALL_DIR)/mods/cnc
-	@cp -r mods/cnc/uibits $(INSTALL_DIR)/mods/cnc
-
-	@-cp $(foreach f,$(shell ls mods/ra --hide=*.dll),mods/ra/$(f)) $(INSTALL_DIR)/mods/ra
-	@cp -r mods/ra/maps $(INSTALL_DIR)/mods/ra
-	@cp -r mods/ra/bits $(INSTALL_DIR)/mods/ra
-	@cp -r mods/ra/chrome $(INSTALL_DIR)/mods/ra
-	@cp -r mods/ra/rules $(INSTALL_DIR)/mods/ra
-	@cp -r mods/ra/tilesets $(INSTALL_DIR)/mods/ra
-	@cp -r mods/ra/uibits $(INSTALL_DIR)/mods/ra
-	
-	@-cp $(foreach f,$(shell ls mods/d2k --hide=*.dll),mods/d2k/$(f)) $(INSTALL_DIR)/mods/d2k
-	@cp -r mods/d2k/maps $(INSTALL_DIR)/mods/d2k
-	@cp -r mods/d2k/bits $(INSTALL_DIR)/mods/d2k
-	@cp -r mods/d2k/chrome $(INSTALL_DIR)/mods/d2k
-	@cp -r mods/d2k/rules $(INSTALL_DIR)/mods/d2k
-	@cp -r mods/d2k/tilesets $(INSTALL_DIR)/mods/d2k
-	@cp -r mods/d2k/uibits $(INSTALL_DIR)/mods/d2k
-
-	@cp -r glsl $(INSTALL_DIR)
-	@cp -r cg $(INSTALL_DIR)
-	@cp *.ttf $(INSTALL_DIR)
-	@cp thirdparty/Tao/* $(INSTALL_DIR)
-	@$(INSTALL_PROGRAM) thirdparty/ICSharpCode.SharpZipLib.dll $(INSTALL_DIR)
-	@$(INSTALL_PROGRAM) thirdparty/FuzzyLogicLibrary.dll $(INSTALL_DIR)
-	@$(INSTALL_PROGRAM) thirdparty/SharpFont.dll $(INSTALL_DIR)
-	@cp thirdparty/SharpFont.dll.config $(INSTALL_DIR)
-	@$(INSTALL_PROGRAM) thirdparty/Mono.Nat.dll $(INSTALL_DIR)
+install: install-core
+
+install-all: install-core install-tools
+
+install-core: default
+	@-echo "Installing OpenRA to $(DATA_INSTALL_DIR)"
+	@$(INSTALL_DIR) "$(DATA_INSTALL_DIR)"
+	@$(INSTALL_PROGRAM) $(foreach prog,$(CORE),$($(prog)_TARGET)) "$(DATA_INSTALL_DIR)"
+	@$(INSTALL_DIR) "$(DATA_INSTALL_DIR)/mods"
+	@$(CP_R) mods/cnc "$(DATA_INSTALL_DIR)/mods/"
+	@$(INSTALL_PROGRAM) $(mod_cnc_TARGET) "$(DATA_INSTALL_DIR)/mods/cnc"
+	@$(CP_R) mods/ra "$(DATA_INSTALL_DIR)/mods/"
+	@$(INSTALL_PROGRAM) $(mod_ra_TARGET) "$(DATA_INSTALL_DIR)/mods/ra"
+	@$(CP_R) mods/d2k "$(DATA_INSTALL_DIR)/mods/"
+	@$(INSTALL_PROGRAM) $(mod_d2k_TARGET) "$(DATA_INSTALL_DIR)/mods/d2k"
+
+	@$(INSTALL_DATA) AUTHORS "$(DATA_INSTALL_DIR)/AUTHORS"
+
+	@$(CP_R) glsl "$(DATA_INSTALL_DIR)"
+	@$(CP_R) cg "$(DATA_INSTALL_DIR)"
+	@$(CP) *.ttf "$(DATA_INSTALL_DIR)"
+	@$(CP) thirdparty/Tao/* "$(DATA_INSTALL_DIR)"
+	@$(INSTALL_PROGRAM) thirdparty/ICSharpCode.SharpZipLib.dll "$(DATA_INSTALL_DIR)"
+	@$(INSTALL_PROGRAM) thirdparty/FuzzyLogicLibrary.dll "$(DATA_INSTALL_DIR)"
+	@$(INSTALL_PROGRAM) thirdparty/SharpFont.dll "$(DATA_INSTALL_DIR)"
+	@$(CP) thirdparty/SharpFont.dll.config "$(DATA_INSTALL_DIR)"
+	@$(INSTALL_PROGRAM) thirdparty/Mono.Nat.dll "$(DATA_INSTALL_DIR)"
 
 	@echo "#!/bin/sh" 				>  openra
 	@echo 'BINDIR=$$(dirname $$(readlink -f $$0))'	>> openra
@@ -273,6 +301,16 @@
 	@echo 'cd "$${DATADIR}/openra"' 		>> openra
 	@echo 'exec mono OpenRA.Game.exe "$$@"' 	>> openra
 
+	@$(INSTALL_DIR) "$(BIN_INSTALL_DIR)"
+	@$(INSTALL_PROGRAM) -m +rx openra "$(BIN_INSTALL_DIR)"
+
+	@-$(RM) openra
+
+install-tools: tools
+	@-echo "Installing OpenRA tools to $(DATA_INSTALL_DIR)"
+	@$(INSTALL_DIR) "$(DATA_INSTALL_DIR)"
+	@$(INSTALL_PROGRAM) $(foreach prog,$(TOOLS),$($(prog)_TARGET)) "$(DATA_INSTALL_DIR)"
+
 	@echo "#!/bin/sh" 				>  openra-editor
 	@echo 'BINDIR=$$(dirname $$(readlink -f $$0))'	>> openra-editor
 	@echo 'ROOTDIR="$${BINDIR%'"$(bindir)"'}"' 	>> openra-editor
@@ -280,14 +318,42 @@
 	@echo 'cd "$${DATADIR}/openra"'			>> openra-editor
 	@echo 'exec mono OpenRA.Editor.exe "$$@"'	>> openra-editor
 
-	@$(INSTALL_PROGRAM) -d $(BIN_INSTALL_DIR)
-	@$(INSTALL_PROGRAM) -m +rx openra $(BIN_INSTALL_DIR)
-	@$(INSTALL_PROGRAM) -m +rx openra-editor $(BIN_INSTALL_DIR)
-
-	@-rm openra
-	@-rm openra-editor
+	@$(INSTALL_DIR) "$(BIN_INSTALL_DIR)"
+	@$(INSTALL_PROGRAM) -m +rx openra-editor "$(BIN_INSTALL_DIR)"
+
+	@-$(RM) openra-editor
 
 uninstall:
-	@-rm -r $(INSTALL_DIR)
-	@-rm $(DESTDIR)$(bindir)/openra
-	@-rm $(DESTDIR)$(bindir)/openra-editor
+	@-$(RM_R) "$(DATA_INSTALL_DIR)"
+	@-$(RM_F) "$(BIN_INSTALL_DIR)/openra"
+	@-$(RM_F) "$(BIN_INSTALL_DIR)/openra-editor"
+
+help:
+	@echo to compile, run:
+	@echo \ \ make
+	@echo
+	@echo to compile with development tools, run:
+	@echo \ \ make all
+	@echo
+	@echo to install, run:
+	@echo \ \ make \[prefix=/foo\] \[bindir=/bar/bin\] install
+	@echo
+	@echo to install with development tools, run:
+	@echo \ \ make \[prefix=/foo\] \[bindir=/bar/bin\] install-all
+	@echo
+	@echo to uninstall, run:
+	@echo \ \ make uninstall
+	@echo
+	@echo to start the game, run:
+	@echo \ \ openra
+
+
+
+
+########################### MAKEFILE SETTINGS ##########################
+#
+.DEFAULT_GOAL := default
+
+.SUFFIXES:
+
+.PHONY: core tools package all mods clean distclean dependencies version $(PROGRAMS)