aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile.in
blob: 1b4f77074070fbfd3be6b57862fb428e31b341a0 (plain) (blame)
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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
#################################################
# @PACKAGE_STRING@
# @configure_input@
#################################################

@SET_MAKE@
SHELL = /bin/sh

#################################################
# Standard definitions
#################################################

prefix      ?= @prefix@
exec_prefix ?= @exec_prefix@
bindir      ?= @bindir@
datarootdir ?= @datarootdir@
datadir     ?= @datadir@
libdir      ?= @libdir@
docdir      ?= @docdir@
pdfdir      ?= @pdfdir@
mandir      ?= @mandir@
# project root-dir (directory of configure script)
top_srcdir  ?= @top_srcdir@
# project src-dir (directory of the current Makefile)
srcdir      ?= @srcdir@

# file-type suffix of executables (e.g. ".exe" in windows)
EXEEXT ?= @EXEEXT@

#################################################
# Tools
#################################################

# recursive dir creation tool (mkdir -p)
MKDIR        ?= @MKDIR_P@
RM           ?= rm -f
RM_REC       ?= $(RM) -r

# install tool
INSTALL         ?= @INSTALL@
INSTALL_DATA    ?= @INSTALL_DATA@
INSTALL_PROGRAM ?= @INSTALL_PROGRAM@

#################################################
# General package configuration
#################################################

USDX_PACKAGE_NAME := @PACKAGE_NAME@
USDX_VERSION := @PACKAGE_VERSION@
USDX_TARNAME := @PACKAGE_TARNAME@

#################################################
# USDX Paths
#################################################

USDX_SRC_DIR   := $(top_srcdir)/src
USDX_GAME_DIR  := $(top_srcdir)/game
USDX_TOOLS_DIR := $(top_srcdir)/tools
USDX_BUILD_DIR := $(top_srcdir)/build
USDX_LIB_DIR   := $(USDX_SRC_DIR)/lib
USDX_PLUGIN_DIR   := $(top_srcdir)/plugins

INSTALL_DATADIR := $(datadir)/$(USDX_PACKAGE_NAME)

#################################################
# Binary name
#################################################

# name of executable
USDX_BIN_NAME ?= ultrastardx$(EXEEXT)
USDX_BIN := $(USDX_GAME_DIR)/$(USDX_BIN_NAME)

#################################################
# ProjectM
#################################################

PROJECTM_CWRAPPER_DIR := $(USDX_LIB_DIR)/projectM/cwrapper
USE_PROJECTM_CWRAPPER = @USE_PROJECTM_CWRAPPER@

#################################################
# Dependencies
#################################################

DEPS :=
ifeq ($(USE_PROJECTM_CWRAPPER), yes)
DEPS += $(PROJECTM_CWRAPPER_DIR)
endif

#################################################
# general targets
#################################################

##
# IMPORTANT:
# Always assure that this Makefile still works with the -jN 
# parameter set. This is important as Gentoo uses parallel 
# make (-j2) by default.
# If parallel execution is enabled you cannot rely on a 
# specific order the prerequisites are build. 
#
# Example:
#   target: dependency dependant
#
# will first build "dependency" and "dependant" afterwards with a
# sequential execution (-j1). With parallel execution "dependant"
# might be started before "dependency" is finished and make will
# crash.
#
# If it is not possible, add the virtual .NOTPARALLEL target.
# This will disable parallel execution for ALL targets.
##

BUILD_TARGETS = all debug release rebuild build
.PHONY: $(BUILD_TARGETS)
$(BUILD_TARGETS): all-deps
	$(MAKE) -C $(USDX_SRC_DIR) $@
	$(MAKE) -C $(USDX_PLUGIN_DIR) all

.PHONY: all-deps
all-deps:
	@for dir in $(DEPS); do \
	  $(MAKE) -C "$$dir" all; \
	done

.PHONY: clean
clean: clean-src clean-deps

.PHONY: clean-src
clean-src:
	$(MAKE) -C $(USDX_SRC_DIR) clean

.PHONY: clean-deps
clean-deps:
	@for dir in $(DEPS); do \
	  $(MAKE) -C "$$dir" clean; \
	done

.PHONY: clean-game
clean-game:
	$(RM) $(USDX_GAME_DIR)/*.log
	$(RM) $(USDX_GAME_DIR)/*.db
	$(RM) $(USDX_GAME_DIR)/*.ini
	-rmdir $(USDX_GAME_DIR)/screenshots
	-rmdir $(USDX_GAME_DIR)/plugins
	-rmdir $(USDX_GAME_DIR)/playlists
	-rmdir $(USDX_GAME_DIR)/songs

# just clean the game build data but no dependencies (libs, tools, ...)
.PHONY: mostlyclean
mostlyclean: clean-src

.PHONY: distclean
distclean: clean clean-game
	$(RM) config.log config.status aclocal.m4 
	$(RM_REC) autom4te.cache
	$(RM) $(USDX_SRC_DIR)/config.inc 
	$(RM) $(srcdir)/Makefile $(USDX_SRC_DIR)/Makefile $(PROJECTM_CWRAPPER_DIR)/Makefile

.PHONY: maintainer-clean
maintainer-clean: distclean

# remove temporary and backup files
.PHONY: tidy
tidy:
# FPC stuff
	find $(srcdir) -name "*.compiled" | xargs $(RM)
# Delphi stuff
	find $(srcdir) -name "__history" | xargs $(RM_REC)
	find $(srcdir) -name "*.identcache" -o -name "*.dcu" | xargs $(RM)
# Backup files
	find $(srcdir) -name "*~" -o -name "*.bak" -o -name "*.orig" | xargs $(RM)


#################################################
# auto-update
#################################################

Makefile: $(srcdir)/Makefile.in $(USDX_SRC_DIR)/Makefile.in $(USDX_SRC_DIR)/config.inc.in $(PROJECTM_CWRAPPER_DIR)/Makefile.in config.status
	@echo "-----------------------------------"
	@echo "Performing reconfiguration..."
	./config.status
	@echo "-----------------------------------"

config.status: configure
	./config.status --recheck

.PHONY: reconf
reconf:
	./autogen.sh

#################################################
# install/uninstall
#################################################

##
# For information on directory and install conventions see
#   "info autoconf", Section 4.8.2. Installation Directory Variables
#                    Section 4.8.1, 4.8.3 and 4.8.4 
# Notes:
# - "make install" must not rebuild, so do not depend on all.
# - use the DESTDIR variable as prefix for installation directories, 
#   otherwise Gentoo will not be able to install as it uses a sandbox.
##

.PHONY: install
install: install-all
	@echo "--------------------------------"
	@echo "$(USDX_PACKAGE_NAME) installed."
	@echo "Start with: $(bindir)/$(USDX_BIN_NAME)"
	@echo "--------------------------------"

# strip binaries during install
install-strip:
	$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
                install

.PHONY: install-all
install-all: install-exec install-plugins install-data

.PHONY: install-exec
install-exec:
	$(MKDIR) "$(DESTDIR)$(bindir)"
	$(INSTALL_PROGRAM) "$(USDX_BIN)" "$(DESTDIR)$(bindir)"

# FPC target platform and processor
PPLATFORM  := @FPC_PLATFORM@
PPROCESSOR := @FPC_PROCESSOR@

.PHONY: install-plugins
install-plugins:
	$(MKDIR) "$(DESTDIR)$(INSTALL_DATADIR)/plugins"
	$(INSTALL) "$(USDX_GAME_DIR)/plugins"/* "$(DESTDIR)$(INSTALL_DATADIR)/plugins"

.PHONY: install-data
install-data:
	$(MAKE) RECURSIVE_SRC_DIR="artwork" \
            RECURSIVE_DST_DIR="$(DESTDIR)$(INSTALL_DATADIR)/artwork" \
            install-data-recursive
	$(MAKE) RECURSIVE_SRC_DIR="$(USDX_GAME_DIR)/languages" \
            RECURSIVE_DST_DIR="$(DESTDIR)$(INSTALL_DATADIR)/languages" \
            install-data-recursive
	$(MAKE) RECURSIVE_SRC_DIR="$(USDX_GAME_DIR)/sounds" \
            RECURSIVE_DST_DIR="$(DESTDIR)$(INSTALL_DATADIR)/sounds" \
            install-data-recursive
	$(MAKE) RECURSIVE_SRC_DIR="$(USDX_GAME_DIR)/themes" \
            RECURSIVE_DST_DIR="$(DESTDIR)$(INSTALL_DATADIR)/themes" \
            install-data-recursive
	$(MAKE) RECURSIVE_SRC_DIR="$(USDX_GAME_DIR)/fonts" \
            RECURSIVE_DST_DIR="$(DESTDIR)$(INSTALL_DATADIR)/fonts" \
            install-data-recursive
	$(MAKE) RECURSIVE_SRC_DIR="$(USDX_GAME_DIR)/resources" \
            RECURSIVE_DST_DIR="$(DESTDIR)$(INSTALL_DATADIR)/resources" \
            install-data-recursive
	$(INSTALL_DATA) "COPYING.txt" "$(DESTDIR)$(INSTALL_DATADIR)/COPYING.txt"

.PHONY: install-data-recursive
install-data-recursive:
# Note: the project contains filesnames with whitespace 
	$(MKDIR) "$(RECURSIVE_DST_DIR)"
	@for file in "$(RECURSIVE_SRC_DIR)"/*; do \
	  if test -f "$$file"; then \
	    filename=`basename "$$file"`; \
	    echo "$(INSTALL_DATA) \"$$file\" \"$(RECURSIVE_DST_DIR)/$$filename\""; \
	    $(INSTALL_DATA) "$$file" "$(RECURSIVE_DST_DIR)/$$filename" || exit 1; \
	  fi; \
	  if test -d "$$file"; then \
	    subdir="$$file"; \
	    subdirname=`basename "$$subdir"`; \
	    $(MAKE) RECURSIVE_SRC_DIR="$$subdir" \
	            RECURSIVE_DST_DIR="$(RECURSIVE_DST_DIR)/$$subdirname" \
	            install-data-recursive || exit 1; \
	  fi; \
	done

.PHONY: uninstall
uninstall: uninstall-all

.PHONY: uninstall-all
uninstall-all: uninstall-data uninstall-exec uninstall-plugins

.PHONY: uninstall-data
uninstall-data:
	$(RM_REC) "$(DESTDIR)$(INSTALL_DATADIR)/artwork"
	$(RM_REC) "$(DESTDIR)$(INSTALL_DATADIR)/languages"
	$(RM_REC) "$(DESTDIR)$(INSTALL_DATADIR)/sounds"
	$(RM_REC) "$(DESTDIR)$(INSTALL_DATADIR)/themes"
	$(RM_REC) "$(DESTDIR)$(INSTALL_DATADIR)/fonts"
	$(RM_REC) "$(DESTDIR)$(INSTALL_DATADIR)/resources"
	$(RM)     "$(DESTDIR)$(INSTALL_DATADIR)/COPYING.txt"
	-rmdir "$(DESTDIR)$(INSTALL_DATADIR)"

.PHONY: uninstall-exec
uninstall-exec:
	$(RM) "$(DESTDIR)$(bindir)/$(USDX_BIN_NAME)"

.PHONY: uninstall-plugins
uninstall-plugins:
	$(RM_REC) "$(DESTDIR)$(INSTALL_DATADIR)/plugins"

#################################################
# Distributable source-package (TODO)
#################################################

#disttmpdir := $(USDX_PACKAGE_NAME)-$(USDX_VERSION)-src
disttmpdir := $(USDX_PACKAGE_NAME)-1.1_alpha-src
# choose all files in SVN that are not deleted
svn-files := svn status -v | grep -v "^[?D]" | cut -c8- | tr -s " " | cut -f5- -d" "

.PHONY: dist
dist:
	@$(svn-files) | while read FILE; do \
	  if test -d "$$FILE"; then \
	    echo "MKDIR: $(disttmpdir)/$$FILE"; \
	    $(MKDIR) "$(disttmpdir)/$$FILE" || exit 1; \
	  else \
	    echo "COPY:  $$FILE"; \
	    cp "$$FILE" "$(disttmpdir)/$$FILE" || exit 1; \
	  fi; \
	done
	tar cvf $(disttmpdir).tar $(disttmpdir)
	gzip $(disttmpdir).tar
	$(RM_REC) $(disttmpdir)

#################################################
# Debian package
#################################################

debpkgdir    ?= dists/debian
debpkgtmpdir := $(debpkgdir)/deb-package
debpkgprefix := $(USDX_PACKAGE_NAME)
debpkgname   := $(debpkgprefix)_$(USDX_VERSION)_$(PPROCESSOR).deb

.PHONY: deb
deb: all
	$(RM_REC) $(debpkgtmpdir)

	$(MKDIR) $(debpkgdir)
	$(MKDIR) $(debpkgtmpdir)/DEBIAN

	$(MAKE) DESTDIR=$(debpkgtmpdir)/ install-all

	$(INSTALL_DATA) $(debpkgdir)/$(debpkgprefix).control $(debpkgtmpdir)/DEBIAN/control

	dpkg-deb --build $(debpkgtmpdir)
	mv $(debpkgtmpdir)/../deb-package.deb $(debpkgdir)/$(debpkgname)

	$(RM_REC) $(debpkgtmpdir)

#################################################
# RPM (TODO)
#################################################

.PHONY: rpm
rpm: all
	@echo "Coming soon"


#################################################
# Mac OS X defines
#################################################

# otool: Mac OS X object file displaying tool
OTOOL := /usr/bin/otool 
# install_name_tool: Mac OS X tool to change dynamic shared library install names
INSTALL_NAME_TOOL := /usr/bin/install_name_tool
# hdiutil: Mac OS X disk image tool
HDIUTIL := /usr/bin/hdiutil

#################################################
# Mac OS X app-bundle
#################################################

macosx_bundle_path := UltraStarDeluxe.app/Contents
.PHONY: macosx-app
macosx-app: all 
# Create double clickable Mac OS X application.

	@echo ""
	@echo "Creating the Mac OS X application"
	@echo ""

	$(MKDIR) $(macosx_bundle_path)

# Put the icon file into its particular place. 
# Must be done BEFORE info.plist is created.
	$(MKDIR) $(macosx_bundle_path)/resources
	$(INSTALL_DATA) icons/ultrastardx.icns $(macosx_bundle_path)/resources/

# the info.plist file
	$(INSTALL_DATA) $(USDX_SRC_DIR)/macosx/Info.plist $(macosx_bundle_path)/

# Copy the resources. 
	$(MAKE) install-all INSTALL_DATADIR=$(macosx_bundle_path) bindir=$(macosx_bundle_path)/MacOS

# Create the song directory. 
	$(MKDIR) $(macosx_bundle_path)/songs

# final messages
	@echo ""
	@echo "Mac OS X application created."
	@echo "Please report issues to the developer team, preferably mischi."
	@echo "Have fun."
	@echo ""

.PHONY: macosx-standalone-app
macosx-standalone-app: macosx-app 
# Create double clickable standalone (does not need fink) Mac OS X 
# application. Not fully test, but should work on 10.5.

	@echo ""
	@echo "Creating the standalone Mac OS X application"
	@echo ""

# copy the dylib and change its install names

define install_osx_libraries
    $(shell $(INSTALL) -m 755 $(dylib) $(macosx_bundle_path)/MacOS)
    $(shell $(INSTALL_NAME_TOOL) -change $(dylib) @executable_path/$(notdir $(dylib)) $(macosx_bundle_path)/MacOS/ultrastardx)
    $(shell $(INSTALL_NAME_TOOL) -id @executable_path/$(notdir $(dylib)) $(macosx_bundle_path)/MacOS/$(notdir $(dylib)))
    $(foreach linked_dylibs_2,$(shell $(OTOOL) -L $(dylib) | grep version | cut -f 1 -d ' ' | grep -v \/System\/Library | grep -v \usr\/lib | grep -v executable_path),$(rename_secondary_osx_libraries))
endef

define rename_secondary_osx_libraries
    $(shell $(INSTALL_NAME_TOOL) -change $(linked_dylibs_2) @executable_path/$(notdir $(linked_dylibs_2)) $(macosx_bundle_path)/MacOS/$(notdir $(dylib)))
endef

# work on the dylibs in $(macosx_bundle_path)/MacOS/ultrastardx
	$(foreach dylib,$(shell $(OTOOL) -L $(macosx_bundle_path)/MacOS/ultrastardx | grep version | cut -f 1 -d ' ' | grep -v \/System\/Library | grep -v \/usr\/lib),$(install_osx_libraries))

# work on the secondary dylibs from ffmpeg
# libavcodec references all tertiary libraries of the ffmpeg libs
	$(foreach dylib,$(shell $(OTOOL) -L /sw/lib/libavcodec.dylib   | grep version | cut -f 1 -d ' ' | grep -v \/System\/Library | grep -v \/usr\/lib),$(install_osx_libraries))
# same procedure in libfaac. it gets libgnugetopt
	$(foreach dylib,$(shell $(OTOOL) -L /sw/lib/libfaac.dylib      | grep version | cut -f 1 -d ' ' | grep -v \/System\/Library | grep -v \/usr\/lib),$(install_osx_libraries))

# same procedure for tertiary libs in SDL_image
	$(foreach dylib,$(shell $(OTOOL) -L /sw/lib/libSDL_image.dylib | grep version | cut -f 1 -d ' ' | grep -v \/System\/Library | grep -v \/usr\/lib),$(install_osx_libraries))

# X11 libs as well, because users may not have installed it on 10.4
	$(foreach dylib,$(shell $(OTOOL) -L /usr/X11R6/lib/libX11.dylib  | grep version | cut -f 1 -d ' ' | grep -v \/System\/Library | grep -v \/usr\/lib),$(install_osx_libraries))

# final messages
	@echo "Standalone Mac OS X application created."
	@echo ""

.PHONY: macosx-dmg
macosx-dmg: macosx-standalone-app
	$(RM) UltraStarDeluxe.dmg
	$(RM) UltraStarDeluxe.sparseimage
	$(HDIUTIL) create -type SPARSE -size 100m -fs HFS+ -volname UltraStarDeluxe -ov UltraStarDeluxe.sparseimage
	$(HDIUTIL) attach UltraStarDeluxe.sparseimage
	/bin/cp -R UltraStarDeluxe.app /Volumes/UltraStarDeluxe
#	/bin/cp ultrastardx/icons/UltraStarDeluxeVolumeIcon.icns /Volumes/UltraStarDeluxe/.VolumeIcon.icns
#	/Developer/Tools/SetFile -a C /Volumes/UltraStarDeluxe/.VolumeIcon.icns /Volumes/UltraStarDeluxe
	$(HDIUTIL) detach /Volumes/UltraStarDeluxe
	$(HDIUTIL) convert UltraStarDeluxe.sparseimage -format UDBZ -o UltraStarDeluxe.dmg
	$(RM) UltraStarDeluxe.sparseimage

# remove Mac OS X apllication bundle and disk image
.PHONY: clean-macosx
clean-macosx: clean-macosx-app clean-macosx-dmg

.PHONY: clean-macosx-app
clean-macosx-app:
	$(RM_REC) UltraStarDeluxe.app 

.PHONY: clean-macosx-dmg
clean-macosx-dmg:
	$(RM) UltraStarDeluxe.dmg 
	$(RM) UltraStarDeluxe.sparseimage