5 # Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
7 # ------------------------------------------------------------------------------
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public
11 # License as published by the Free Software Foundation; either
12 # version 2.1 of the License, or (at your option) any later version.
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with this library; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 # ------------------------------------------------------------------------------
25 # Please feel free to send questions, suggestions or improvements to:
31 package SDL::Build::Darwin;
33 use base 'SDL::Build';
39 my (@include_path, @lib_path);
44 ($Config{ccflags} =~ /-I(\S+)/g),
45 ($Config{cppflags} =~ /-I(\S+)/g),
47 foreach my $sdl_lib_dir ($_, "$_/SDL") {
48 next unless -f "$sdl_lib_dir/SDL.h";
49 push @include_path, $sdl_lib_dir unless $seen{$sdl_lib_dir}++;
57 ($Config{libpth} =~ /(\S+)/g),
58 ($Config{libsdirs} =~ /(\S+)/g),
59 ($Config{libspath} =~ /(\S+)/g),
60 ($Config{lddlflags} =~ /-I(\S+)/g),
61 ($Config{ldflags} =~ /-I(\S+)/g),
63 next unless -f "$_/libSDL.a";
64 push @lib_path, $_ unless $seen{$_}++;
68 die "Can't find an SDL library" unless @include_path and @lib_path;
69 warn "Found SDL headers in $include_path[0] and library in $lib_path[0]";
72 $include_path[0] => $lib_path[0],
75 '/usr/local/include/smpeg' => '/usr/local/lib',
76 '/usr/local/include/GL' => '/usr/local/lib',
77 '/usr/local/include/gl' => '/usr/local/lib',
80 '/usr/include/smpeg' => '/usr/lib',
81 '/usr/include/GL' => '/usr/lib',
82 '/usr/include/gl' => '/usr/lib',
84 # System-wide frameworks.
85 '/System/Library/Frameworks/libogg.framework/Headers' => '../../lib',
86 '/System/Library/Frameworks/libvorbis.framework/Headers' => '../../lib',
87 '/System/Library/Frameworks/libvorbisfile.framework/Headers' => '../../lib',
88 '/System/Library/Frameworks/libvorbisenc.framework/Headers' => '../../lib',
89 '/System/Library/Frameworks/OpenGL.framework/Headers' => '/System/Library/Frameworks/OpenGL.framework/Libraries',
92 '/System/Library/Frameworks/OpenGL.framework/Headers' => '/System/Library/Frameworks/OpenGL.framework/Libraries',
108 sub build_install_base
110 return "SDLPerl.app/Contents/Resources";
115 $bundle_contents="SDLPerl.app/Contents";
116 system "mkdir -p \"$bundle_contents\"";
117 mkdir "$bundle_contents/MacOS",0755;
118 $cflags = `sdl-config --cflags`;
120 $cflags .= ' ' . `perl -MExtUtils::Embed -e ccopts`;
122 $libs = `sdl-config --libs`;
124 $libs .= ' ' . `perl -MExtUtils::Embed -e ldopts`;
126 $libs =~ s/-lSDLmain//g;
127 print STDERR "gcc $cflags MacOSX/launcher.m $libs -framework Cocoa -o \"$bundle_contents/MacOS/SDLPerl\"";
128 print STDERR `gcc $cflags MacOSX/launcher.m $libs -framework Cocoa -o \"$bundle_contents/MacOS/SDLPerl\"`;
129 mkdir "$bundle_contents/Resources",0755;
130 system "echo \"APPL????\" > \"$bundle_contents/PkgInfo\"";
131 system "cp MacOSX/Info.plist \"$bundle_contents/\"";
132 system "cp \"MacOSX/SDLPerl.icns\" \"$bundle_contents/Resources\"";