aboutsummaryrefslogblamecommitdiffstats
path: root/Makefile.in
blob: 324b0c92c19884aee288f5aebdf6b8494f9ae5e9 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                                                 
                  
                   
                                                 
 
          
 


                                                 
 



                            



                       















                                                          
 
              

                              
 


                                    



















                                                 


                                                 
 
                    

                                             
 


                                                 
 

                                                          
 
                                                 
              

                                                 



                                           
 


                                                 
 



                                               
 







                                   
 


                            
 




                                     
 









                                           



                      
                                
                                                                    
                                         
                                                                                 










                                                                          
 
                                                 
             
                                                 
 











                                                                                                                                  
 



                                                 

               
                           



                                                      
 


                                      
                    
             





                                                                                                                                      
 
                              
                       
                                       
                                                   
                                     

                                                                   







                                                                                                                                
                    
             
                            
                                            
 




                                            
 
                      
               






                                                  
 
                      
               
                                          
 


                                                 
 
                     
 
            
     

                              
                                               

                                                                     
 


                                                 
 



                                                                 
 

           
                                 
 

                                       


                                                        
                                                                                           

                                        
                                                                        
 
                                 
 



                                                 
           
        

                           











                                                                                 


                                                 
 

                                                  





                                                 
 
                                                


                                               
                                                                               

                     
                                                                                

                      
                                                                                                              
 






                                                                              
                             
                                  
































                                                                                                                                                                                                         
                                                                                                                                                                                     




                                                        
                         
                                        
                             
                                                                                                                          
                                                                  

                                                                                                          

                                                                                      
                                         
#################################################
# @PACKAGE_STRING@
# @configure_input@
#################################################

@SET_MAKE@

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

prefix      ?= @prefix@
exec_prefix ?= @exec_prefix@
bindir      ?= @bindir@
datarootdir ?= @datarootdir@
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@

# installation path
INSTALL_DATADIR ?= @INSTALL_DATADIR@

#################################################
# 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_LIB_DIR   := $(USDX_SRC_DIR)/lib
USDX_BUILD_DIR := $(USDX_SRC_DIR)/build

AUTOGEN_DIR := $(top_srcdir)/dists/autogen

#################################################
# 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 := $(USDX_TOOLS_DIR)/ResourceExtractor
ifeq ($(USE_PROJECTM_CWRAPPER), yes)
DEPS += $(PROJECTM_CWRAPPER_DIR)
endif

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

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

.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 src 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

.PHONY: mostlyclean
mostlyclean: clean-src

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

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

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

Makefile: 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

.PHONE: reconf
reconf:
	$(AUTOGEN_DIR)/autogen.sh

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

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

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

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

.PHONY: install-data-recursive
install-data-recursive:
	$(MKDIR) "$(RECURSIVE_DST_DIR)"
	@for file in "$(RECURSIVE_SRC_DIR)"/*; do \
	  if test -f "$$file"; then \
	    echo $(INSTALL_DATA) "$$file" "$(RECURSIVE_DST_DIR)"; \
	    $(INSTALL_DATA) "$$file" "$(RECURSIVE_DST_DIR)"; \
	  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; \
	  fi; \
	done

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

.PHONY: uninstall
uninstall: uninstall-all

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

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

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

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

disttmpdir ?= disttmp

.PHONY: dist
dist:
#	$(MKDIR) $(disttmpdir)
#	cp -R . $(disttmpdir)
#	$(MAKE) -C $(disttmpdir)/src distclean 
#	tar cvzf $(USDX_TARNAME)-$(USDX_VERSION).tar.gz $(disttmpdir)
#	$(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) prefix=$(debpkgtmpdir)/$(prefix) install

	$(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)/Resources

# Put the icon file into its particular place. 
# Must be done BEFORE info.plist is created.
	$(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)/Resources bindir=$(macosx_bundle_path)/MacOS

# 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-disk-image
macosx-disk-image: macosx-standalone-app
	$(RM) ultrastardx.dmg
	$(HDIUTIL) create -type SPARSE -size 30m -fs HFS+ -volname UltraStarDeluxe -ov -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 ultrastardx.dmg
	$(RM) UltraStarDeluxe.sparseimage