Added SDLPerl.app bundle to the now fixed Darwin build system
[sdlgit/SDL_perl.git] / make / lib / SDL / Build / Darwin.pm
1 #!/usr/bin/env perl
2 #
3 # Darwin.pm
4 #
5 # Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
6 #
7 # ------------------------------------------------------------------------------
8 #
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.
13
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.
18
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
22 #
23 # ------------------------------------------------------------------------------
24 #
25 # Please feel free to send questions, suggestions or improvements to:
26 #
27 #       David J. Goehrig
28 #       dgoehrig@cpan.org
29 #
30
31 package SDL::Build::Darwin;
32
33 use base 'SDL::Build';
34
35 sub fetch_includes
36 {
37         return (
38         '/usr/local/include/SDL'   => '/usr/local/lib',
39         '/usr/local/include'       => '/usr/local/lib',
40         '/usr/local/include/smpeg' => '/usr/local/lib',
41         '/usr/include/SDL'         => '/usr/lib',
42         '/usr/include'             => '/usr/lib',
43         '/usr/include/smpeg'       => '/usr/lib',
44         '/usr/local/include/GL'    => '/usr/local/lib',
45         '/usr/local/include/gl'    => '/usr/local/lib',
46         '/usr/include/GL'          => '/usr/lib', 
47         '/usr/include/gl'          => '/usr/lib', 
48         '/opt/local/include/SDL'   => '/opt/local/lib',         # Mac Ports
49         '/opt/local/include'   => '/opt/local/lib',             # Mac Ports
50
51         '/System/Library/Frameworks/SDL_mixer.framework/Headers'     => '../../lib',
52         '/System/Library/Frameworks/SDL_image.framework/Headers'     => '../../lib',
53         '/System/Library/Frameworks/SDL_ttf.framework/Headers'       => '../../lib',
54         '/System/Library/Frameworks/libogg.framework/Headers'        => '../../lib',
55         '/System/Library/Frameworks/libvorbis.framework/Headers'     => '../../lib',
56         '/System/Library/Frameworks/libvorbisfile.framework/Headers' => '../../lib',
57         '/System/Library/Frameworks/libvorbisenc.framework/Headers'  => '../../lib',
58         '../../include'                                              => '../../lib',
59         '/System/Library/Frameworks/OpenGL.framework/Headers'        => '/System/Library/Frameworks/OpenGL.framework/Libraries',
60         );
61 }
62
63 sub build_c_sources 
64 {
65         return [qw/ 
66                 launcher.m
67         /];
68 }
69
70 sub build_c_source
71 {
72         return 'MacOSX';
73 }
74
75 sub build_install_base
76 {
77         return "SDLPerl.app/Contents/Resources";        
78 }
79
80 sub build_bundle
81 {
82         $bundle_contents="SDLPerl.app/Contents";
83         system "mkdir -p \"$bundle_contents\"";
84         mkdir "$bundle_contents/MacOS",0755;
85         $cflags = `sdl-config --cflags`;
86         chomp($cflags);
87         $cflags .= ' ' . `perl -MExtUtils::Embed -e ccopts`;
88         chomp($cflags);
89         $libs = `sdl-config  --libs`;
90         chomp($libs);
91         $libs .= ' ' . `perl -MExtUtils::Embed -e ldopts`;
92         chomp($libs);
93         $libs =~ s/-lSDLmain//g;
94         print STDERR "gcc $cflags MacOSX/launcher.m $libs -framework Cocoa -o \"$bundle_contents/MacOS/SDLPerl\"";
95         print STDERR `gcc $cflags MacOSX/launcher.m $libs -framework Cocoa -o \"$bundle_contents/MacOS/SDLPerl\"`;
96         mkdir "$bundle_contents/Resources",0755;
97         system "echo \"APPL????\" > \"$bundle_contents/PkgInfo\"";
98         system "cp MacOSX/Info.plist \"$bundle_contents/\"";
99         system "cp \"MacOSX/SDLPerl.icns\" \"$bundle_contents/Resources\"";
100 }
101
102 1;