From 1e96769e49f8f4fb27ea7039c7f1dba4b8af1fe5 Mon Sep 17 00:00:00 2001
From: k-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>
Date: Mon, 18 Aug 2008 10:01:01 +0000
Subject: first try to create a Mac OS X standalone app bundle

git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1273 b956fd51-792f-4845-bead-9b4dfca2ff2c
---
 Game/Code/Makefile.in | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

(limited to 'Game/Code')

diff --git a/Game/Code/Makefile.in b/Game/Code/Makefile.in
index a340518c..0ff80e69 100644
--- a/Game/Code/Makefile.in
+++ b/Game/Code/Makefile.in
@@ -278,6 +278,46 @@ macosx-app: all
 	@echo "Have fun."
 	@echo ""
 
+macosx-app-standalone: 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/X11/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 ""
+
 #################################################
 # clean-up
 #################################################
-- 
cgit v1.2.3