# HG changeset patch # User nkeynes # Date 1214711493 0 # Node ID e5256202cc9ee9c7788bf64191418afb4cc8cfd9 # Parent 1ef156f221092c53d1cbb655bfce582203164fb7 Add all non-core libraries to the OS X bundle --- a/Makefile.am Sun Jun 29 03:10:19 2008 +0000 +++ b/Makefile.am Sun Jun 29 03:51:33 2008 +0000 @@ -45,6 +45,7 @@ mkdir -p lxdream.app/Contents/Resources cp src/lxdream lxdream.app/Contents/MacOS cp -R pixmaps/* lxdream.app/Contents/Resources + $(srcdir)/bundlelibs.pl lxdream.app/Contents/MacOS/lxdream lxdream.app/Contents/Frameworks @echo --- Done --- endif --- a/Makefile.in Sun Jun 29 03:10:19 2008 +0000 +++ b/Makefile.in Sun Jun 29 03:51:33 2008 +0000 @@ -759,6 +759,7 @@ @GUI_COCOA_TRUE@ mkdir -p lxdream.app/Contents/Resources @GUI_COCOA_TRUE@ cp src/lxdream lxdream.app/Contents/MacOS @GUI_COCOA_TRUE@ cp -R pixmaps/* lxdream.app/Contents/Resources +@GUI_COCOA_TRUE@ $(srcdir)/bundlelibs.pl lxdream.app/Contents/MacOS/lxdream lxdream.app/Contents/Frameworks @GUI_COCOA_TRUE@ @echo --- Done --- bundle: all --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bundlelibs.pl Sun Jun 29 03:51:33 2008 +0000 @@ -0,0 +1,45 @@ +#!/usr/bin/perl +# Script for OS X to copy all non-core library dependencies into the bundle, and fixup the lib naming +# Run after the executable is already in the bundle. + +if( $#ARGV <= 0 ) { + die( "Usage: bundlelibs.pl \n" ); +} + +my $BINARY=shift(); +my $TARGETDIR=shift(); +my $OTOOL="otool"; +my $NTOOL="install_name_tool"; + +mkdir $TARGETDIR; + +my %done=(); +my @worklist = ($BINARY); + +while( $#worklist >= 0 ) { + my $target = shift @worklist; + $done{$target} = 2; + + open FH, "$OTOOL -L $target|" || die "Unable to run otool"; + $skip = ; + + while(){ + $lib = $_; + $lib =~ s/^\s+([^\s]+)\s.*$/$1/s; + if( $lib !~ /^\/System\/Library/ && $lib !~ /^\/usr\/lib/ && $lib !~ /^\@executable_path\// ) { + $libname = $lib; + $libname =~ s#^.*/##; + $targetpath = "$TARGETDIR/$libname"; + $libid = "\@executable_path/../Frameworks/$libname"; + if( !$done{$libname} ) { + $done{libname} = 1; + push @worklist, $targetpath; + system( ("cp", $lib, $targetpath) ) == 0 || die "Failed to copy $lib to $targetpath"; + system( ($NTOOL, "-id", $libid, $targetpath) ) == 0 || die "Failed to set $lib ID to $libid"; + print "Copied $lib => $targetpath\n"; + } + system( ($NTOOL, "-change", $lib, $libid, $target ) ) == 0 || die "Failed to change $lib ID to $libid"; + } + } + close FH; +}