From: <fl...@us...> - 2011-12-25 22:41:09
|
Revision: 5305 http://freedroid.svn.sourceforge.net/freedroid/?rev=5305&view=rev Author: fluzz Date: 2011-12-25 22:41:02 +0000 (Sun, 25 Dec 2011) Log Message: ----------- macosx: Add stuff needed to create a macosx app, and add a dist-macosx make target Modified Paths: -------------- Makefile.am Added Paths: ----------- macosx/ macosx/Info.plist.in macosx/app.icns macosx/pkgApp.pl Modified: Makefile.am =================================================================== --- Makefile.am 2011-12-25 22:19:34 UTC (rev 5304) +++ Makefile.am 2011-12-25 22:41:02 UTC (rev 5305) @@ -69,3 +69,17 @@ rm -f freedroidRPG.nsi win32/install_file_lists.py win32/freedroidRPG.nsi.in $(win_dir) > freedroidRPG.nsi makensis -V1 -DPRODUCT_VERSION="$(VERSION)" -DSRC_DIR="${win_dir}" freedroidRPG.nsi + +macosx_dir = freedroidRPG.app +dist-macosx: src/freedroidRPG + rm -rf $(macosx_dir) + mkdir -p $(macosx_dir)/Contents + mkdir -p $(macosx_dir)/Contents/MacOS + mkdir -p $(macosx_dir)/Contents/Resources + mkdir -p $(macosx_dir)/Contents/Frameworks + cp macosx/app.icns $(macosx_dir)/Contents/Resources/Icon.icns + cp src/freedroidRPG $(macosx_dir)/Contents/MacOS + sed -e "s/__#PROGNAME#__/$(PACKAGE_NAME)/" -e "s/__#VERSION#__/$(PACKAGE_VERSION)/" macosx/Info.plist.in > $(macosx_dir)/Contents/Info.plist + echo "APPL????" > $(macosx_dir)/Contents/PkgInfo + rsync -ar --exclude=.svn dialogs graphics map sound $(macosx_dir)/Contents + perl macosx/pkgApp.pl $(macosx_dir)/Contents MacOS/freedroidRPG Frameworks Added: macosx/Info.plist.in =================================================================== --- macosx/Info.plist.in (rev 0) +++ macosx/Info.plist.in 2011-12-25 22:41:02 UTC (rev 5305) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>__#PROGNAME#__</string> + <key>CFBundleIconFile</key> + <string>Icon.icns</string> + <key>CFBundleIdentifier</key> + <string>org.freedroid.FreedroidRPG</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>freedroidRPG</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>__#VERSION#__</string> + <key>NSHumanReadableCopyright</key> + <string>Copyright 2011 FreedroidRPG developers, GNU General Public License.</string> + <key>LSMinimumSystemVersion</key> + <string>10.5</string> +</dict> +</plist> Added: macosx/app.icns =================================================================== (Binary files differ) Property changes on: macosx/app.icns ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: macosx/pkgApp.pl =================================================================== --- macosx/pkgApp.pl (rev 0) +++ macosx/pkgApp.pl 2011-12-25 22:41:02 UTC (rev 5305) @@ -0,0 +1,173 @@ +#!/usr/bin/perl +# +# Script from http://www.stellarium.org/ +# under GPL General Public License +# + +use strict; +use Cwd; + +my $inmt = "/usr/bin/install_name_tool"; +my $ch_inmt = qq{$inmt -change \%s \%s \%s}; +my $id_inmt = qq{$inmt -id \%s \%s}; + +my $otool = qq{/usr/bin/otool -L \%s}; + +my $appdir = shift(@ARGV); +chdir $appdir; +my $main_executable = shift(@ARGV); +my $frameworks_dir = shift(@ARGV); +my $current_arch = `/usr/bin/arch`; +chomp($current_arch); + +if ( ! -e "$frameworks_dir/$current_arch" ) { + `mkdir -p $frameworks_dir/$current_arch`; +} + +&recurse( $main_executable, $frameworks_dir, $current_arch ); + +sub recurse { + my($main_executable, $frameworks_dir, $current_arch) = @_; + + my $cmd1 = sprintf($otool, $main_executable); + my($app, @names) = `$cmd1`; + + my $name; + NAME_LOOP: + foreach $name ( @names ) { + chomp($name); + $name =~ s,^\s*,,; + $name =~ s,\s*\(compa.+$,,; + + ## we've already dealt with this name on this executable, ie, itself + if ( index($name, $main_executable) >= 0 || + index($main_executable, $name) >= 0 ) { + next NAME_LOOP; + } + + ## leave sys libraries alone and dont include them + if ( $name =~ m,^(/System/Library|/usr/lib|\@executable_name), && + $name !~ m,^(/usr/lib/libiconv), ){ + next NAME_LOOP; + } + + ## a rooted Framework + + ## an unrooted Framework + if ( $name =~ m,^([^/]+\.framework)/(\S+)$, ) { + my $fwname = $1; + my $binary = $2; + + my $absname = &locateFramework($fwname); + my $arch = &architecture("$absname/$binary"); + + if ( $arch eq $current_arch || $arch eq 'fat' ) { + my $relPath = "\@executable_path/../Frameworks/$fwname/$binary"; + my $fwPath = "$frameworks_dir/$fwname/$binary"; + + my $not_existed = 1; + if ( ! -e $fwPath ) { + my $c = "cp -RP -p $absname $frameworks_dir/$fwname"; + `$c`; + } else { + $not_existed = 0; + } + + my $c = sprintf($id_inmt, $relPath, $fwPath); + `$c`; + $c = sprintf($ch_inmt, $name, $relPath, $main_executable); + `$c`; + + if ( $not_existed ) { + &recurse($fwPath, $frameworks_dir, $current_arch); + } + } else { + warn qq{$0: [1] for $main_executable: what to do about $absname being $arch!!!!!\n}; + } + next NAME_LOOP; + } + + ## a rooted dylib + if ( $name =~ m,^/.+?([^/]+\.dylib)$, ) { + my $basename = $1; + my $absname = $name; + + my $arch = &architecture($absname); + + if ( $arch eq $current_arch || $arch eq 'fat' ) { + my $relPath = "\@executable_path/../Frameworks/$current_arch/$basename"; + my $fwPath = "$frameworks_dir/$current_arch/$basename"; + + my $not_existed = 1; + if ( ! -e $fwPath ) { + my $c = "cp -P $absname $frameworks_dir/$current_arch"; + `$c`; + } else { + $not_existed = 0; + } + + my $c = sprintf($id_inmt, $relPath, $fwPath); + `$c`; + $c = sprintf($ch_inmt, $absname, $relPath, $main_executable); + `$c`; + + if ( $not_existed ) { + &recurse($fwPath, $frameworks_dir, $current_arch); + } + } else { + warn qq{$0: [2] for $main_executable: what to do about $name being $arch!!!\n}; + } + next NAME_LOOP; + } + + ## something else? + warn qq{$0: [3] for $main_executable: what to do with $name?!?!?\n}; + } +} + + +sub architecture { + my $file = shift; + my(@output) = `/usr/bin/file $file`; + + if ( grep(m/^${file}: symbolic link to ([^\']+)/, @output) ) { + my($r, @junk) = grep(m/^${file}: symbolic link to ([^\']+)/, @output); + $r =~ m,^(.+)/([^/]+.dylib): symbolic link to ([^\']+),; + my $root = $1; + my $base = $2; + my $target = $3; + + if ( $target =~ m,^/, ) { + return &architecture("$target"); + } else { + return &architecture("$root/$target"); + } + } + + my $retval = undef; + # file with 2 architectures + + if ( grep(m/(universal binary|fat file) with [0-9] architectures/i, @output)) { + $retval = 'fat'; + } + elsif ( grep(m/ppc/, @output) ) { + $retval = 'ppc'; + } + elsif ( grep(m/i386/, @output) ) { + $retval = 'i386'; + } + # warn qq{$0: $file isa '$retval' arch\n}; + return $retval; +} + +sub locateFramework { + my $fname = shift; + my $lib; + foreach $lib ( '~/Library/Frameworks', '/Library/Frameworks', '/usr/local/Trolltech/Qt-4.5.0/lib' ) { + if ( -e "$lib/$fname" ) { + return "$lib/$fname"; + } + } + warn qq{$0: couldnt find $fname!!!!\n}; + return undef; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |