From c401e515b0bbe734fc39517a4d25c96ce487bef4 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 4 Jan 2010 22:45:45 +0000 Subject: Copy binaries into app dir along with libraries. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1788 --- pkg/osx/cp-with-libs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 pkg/osx/cp-with-libs (limited to 'pkg/osx/cp-with-libs') 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 + -- cgit v1.2.3 From 37325bbfc1f71111715cf2f4ef2918b6cc5c0ff1 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 4 Jan 2010 22:53:44 +0000 Subject: Fix single space error when listing libraries. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1789 --- pkg/osx/cp-with-libs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkg/osx/cp-with-libs') diff --git a/pkg/osx/cp-with-libs b/pkg/osx/cp-with-libs index 902ae079..bb4fa001 100755 --- a/pkg/osx/cp-with-libs +++ b/pkg/osx/cp-with-libs @@ -10,7 +10,7 @@ cp "$BINARY" "$DEST" # Copy libraries; only those with libSDL in the name -otool -L "$BINARY" | grep libSDL | sed 's/^.//; s/(.*//' | while read; do +otool -L "$BINARY" | grep libSDL | sed 's/^.//; s/ (.*//' | while read; do cp "$REPLY" "$DEST" done -- cgit v1.2.3 From da950e23214018c7dc80dff0cb5566ad46bf30cf Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 10 Jan 2010 18:42:35 +0000 Subject: Recursively copy library dependencies into destination package. Identify libraries to be installed based on the path in which they are located, rather than whether there is "libSDL" in the name. Use install_name_tool to change the search path so that the system looks for libraries in @executable_path@ rather than their location on the machine upon which the program was built. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1796 --- pkg/osx/cp-with-libs | 102 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 93 insertions(+), 9 deletions(-) (limited to 'pkg/osx/cp-with-libs') diff --git a/pkg/osx/cp-with-libs b/pkg/osx/cp-with-libs index bb4fa001..18274172 100755 --- a/pkg/osx/cp-with-libs +++ b/pkg/osx/cp-with-libs @@ -1,16 +1,100 @@ -#!/bin/sh +#!/bin/bash # # Copy a program to the specified destination, along -# with SDL libraries it depends upon. +# with libraries it depends upon. -BINARY=$1 -DEST=$2 +src_bin=$1 +dest_dir=$2 -cp "$BINARY" "$DEST" +# Returns true if the specified file is a dylib. -# Copy libraries; only those with libSDL in the name +is_dylib() { + case "$1" in + *.dylib) + true + ;; + *) + false + ;; + esac +} -otool -L "$BINARY" | grep libSDL | sed 's/^.//; s/ (.*//' | while read; do - cp "$REPLY" "$DEST" -done +# Returns true if the specified file is in a system location +# (/System or /usr): + +is_sys_lib() { + case "$1" in + /System/*) + true + ;; + /usr/*) + true + ;; + *) + false + ;; + esac +} + +# Install the specified file to the location in dest_dir, along with +# any libraries it depends upon (recursively): + +install_with_deps() { + local src_file + local bin_name + local dest_file + local lib_name + + src_file=$1 + bin_name=$(basename "$src_file") + dest_file="$dest_dir/$bin_name" + + # Already copied into the package? Don't copy again. + # Prevents endless recursion. + + if [ -e "$dest_file" ]; then + return + fi + + echo "Installing $bin_name..." + + # Copy file into package. + + cp "$src_file" "$dest_file" + + # Copy libraries that this file depends on: + + otool -L "$src_file" | tail -n +2 | sed 's/^.//; s/ (.*//' | while read; do + + # Don't copy system libraries + + if is_sys_lib "$REPLY"; then + continue + fi + + #echo " - $bin_name depends on $REPLY" + + # Copy this library into the package, and: + # recursively install any libraries that _this_ library depends on: + + install_with_deps "$REPLY" + + # Change destination binary to depend on the + # copy inside the package: + + lib_name=$(basename "$REPLY") + install_name_tool -change "$REPLY" "@executable_path@/$lib_name" \ + "$dest_file" + done + + # If this is a library that we have installed, change its id: + + if is_dylib "$dest_file"; then + install_name_tool -id "@executable_path@/$bin_name" "$dest_file" + fi +} + +# Install the file, and recursively install any libraries: + +install_with_deps "$src_bin" -- cgit v1.2.3 From 213b88ef3557f680233c6165b5dc6f2185c0f482 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 10 Jan 2010 20:46:15 +0000 Subject: Change "@executable_path@" to "@executable_path" Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1799 --- pkg/osx/cp-with-libs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pkg/osx/cp-with-libs') diff --git a/pkg/osx/cp-with-libs b/pkg/osx/cp-with-libs index 18274172..04fb5bc6 100755 --- a/pkg/osx/cp-with-libs +++ b/pkg/osx/cp-with-libs @@ -83,14 +83,14 @@ install_with_deps() { # copy inside the package: lib_name=$(basename "$REPLY") - install_name_tool -change "$REPLY" "@executable_path@/$lib_name" \ + install_name_tool -change "$REPLY" "@executable_path/$lib_name" \ "$dest_file" done # If this is a library that we have installed, change its id: if is_dylib "$dest_file"; then - install_name_tool -id "@executable_path@/$bin_name" "$dest_file" + install_name_tool -id "@executable_path/$bin_name" "$dest_file" fi } -- cgit v1.2.3