foxygit / doom Log in
commit c401e515b0bbe734fc39517a4d25c96ce487bef4
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Mon Jan 4 22:45:45 2010 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Mon Jan 4 22:45:45 2010 +0000

    Copy binaries into app dir along with libraries.

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 1788
---
 pkg/osx/GNUmakefile  | 15 +++++++++++++--
 pkg/osx/cp-with-libs | 16 ++++++++++++++++
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/pkg/osx/GNUmakefile b/pkg/osx/GNUmakefile
index 82c353fe..b060f483 100644
--- a/pkg/osx/GNUmakefile
+++ b/pkg/osx/GNUmakefile
@@ -1,6 +1,9 @@

 include config.make

+CC=gcc
+STRIP=strip
+
 STAGING_DIR=staging
 DMG=$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).dmg
 DOC_FILES=\
@@ -25,15 +28,23 @@ endif
 # Staging dir build for package:

 APP_DIR=$(STAGING_DIR)/$(PACKAGE_NAME).app
+APP_BIN_DIR=$(APP_DIR)/Contents/MacOS/

 $(STAGING_DIR): launcher
 	rm -rf $(STAGING_DIR)
 	mkdir $(STAGING_DIR)
+
 	cp -R app-skeleton "$(APP_DIR)"
 	cp Info.plist "$(APP_DIR)/Contents/"
-	cp launcher "$(APP_DIR)/Contents/MacOS/"
-	# TODO: copy Doom and setup binaries into app dir
+	cp launcher "$(APP_BIN_DIR)/"
+
+	./cp-with-libs ../../src/chocolate-doom "$(APP_BIN_DIR)"
+	$(STRIP) "$(APP_BIN_DIR)/chocolate-doom"
+	./cp-with-libs ../../setup/chocolate-setup "$(APP_BIN_DIR)"
+	$(STRIP) "$(APP_BIN_DIR)/chocolate-setup"
+
 	for d in $(DOC_FILES); do cp ../../$$d $(STAGING_DIR)/; done
+
 	find $(STAGING_DIR) -name .svn -delete -exec rm -rf {} \; || true

 clean : launcher_clean
diff --git a/pkg/osx/cp-with-libs b/pkg/osx/cp-with-libs
new file mode 100755
index 00000000..902ae079
--- /dev/null
+++ b/pkg/osx/cp-with-libs
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# Copy a program to the specified destination, along
+# with SDL libraries it depends upon.
+
+BINARY=$1
+DEST=$2
+
+cp "$BINARY" "$DEST"
+
+# Copy libraries; only those with libSDL in the name
+
+otool -L "$BINARY" | grep libSDL | sed 's/^.//; s/(.*//' | while read; do
+        cp "$REPLY" "$DEST"
+done
+