diff -u -N orig2/Makefile.PL SDL_perl-1.20.3/Makefile.PL --- orig2/Makefile.PL Thu Mar 27 04:17:23 2003 +++ SDL_perl-1.20.3/Makefile.PL Fri May 2 10:21:16 2003 @@ -8,6 +8,7 @@ linux => "Makefile.linux", win32 => "Makefile.win32", freebsd => "Makefile.freebsd", + darwin => "Makefile.darwin", ); # diff -u -N orig2/Makefile.darwin SDL_perl-1.20.3/Makefile.darwin --- orig2/Makefile.darwin Wed Dec 31 18:00:00 1969 +++ SDL_perl-1.20.3/Makefile.darwin Fri May 9 13:34:50 2003 @@ -0,0 +1,162 @@ +#!/usr/bin/env perl + +# This is the script that builds the Makefile for SDL Perl under Mac OS X. +# It was heavily adapted from the Makefile.darwin that was included +# in the Mac OS X port of Frozen Bubble by bob@redivi.com. More details +# about this and other modified files can be found in the README.macosx file. +# +# Written by Thomas Tongue + +use strict; +use ExtUtils::MakeMaker; +use Getopt::Long; + +# +# Configure SDL proper +# + +use vars qw/ $sdl_cflags $sdl_libs @dirs $inc_flags %ext @defs /; + +# +# Configuration detection +# + +# This is really annoying, but the SDL frameworks for Mac OS X do not supply +# an sdl-cflags binary to supply these arguments, so the choices are to +# either hard-code the include paths (as done below), or build the SDL libs +# from scratch. Having done both, hard-coding is *much* better. -TT + + +$sdl_cflags = "-I/System/Library/Frameworks/SDL.framework/Headers ". + "-I/System/Library/Frameworks/SDL_mixer.framework/Headers ". + "-I/System/Library/Frameworks/SDL_image.framework/Headers ". + "-I/System/Library/Frameworks/SDL_ttf.framework/Headers ". + "-I/System/Library/Frameworks/OpenGL.framework/Headers ". + "-I../../include ". +# "-I../../include/smpeg ". +# "-I/System/Library/Frameworks/smpeg.framwork/Headers ", + "-D_THREAD_SAFE"; +$sdl_libs = "-L/System/Library/Frameworks/OpenGL.framework/Libraries ". + "-L../../lib"; + +# +# Search paths +# + +@dirs=( + '/usr/local/include/SDL', + '/usr/local/include', + '/usr/local/include/smpeg', + '/usr/include/SDL', + '/usr/include', + '/usr/include/smpeg', + '/usr/local/include/GL', + '/usr/local/include/gl', + '/usr/include/GL', + '/usr/include/gl', + '/System/Library/Frameworks/OpenGL.framework/Headers', + '/System/Library/Frameworks/SDL.framework/Headers', + '/System/Library/Frameworks/SDL_mixer.framework/Headers', + '/System/Library/Frameworks/SDL_image.framework/Headers', + '/System/Library/Frameworks/SDL_ttf.framework/Headers', +# '/System/Library/Frameworks/smpeg.framework/Headers', + '../../include', +# '../../include/smpeg', +); + +$inc_flags = "-ggdb " . $ENV{DEBUG}; + +# +# Registed extensions +# + +%ext = ( + SDL_image => { inc => 'HAVE_SDL_IMAGE', test => 'SDL_image.h' }, + SDL_mixer => { inc => 'HAVE_SDL_MIXER', test => 'SDL_mixer.h' }, + SDL_net => { inc => 'HAVE_SDL_NET', test => 'SDL_net.h' }, + SDL_ttf => { inc => 'HAVE_SDL_TTF', test => 'SDL_ttf.h' }, + SDL_gfx => { inc => 'HAVE_SDL_GFX', test => 'SDL_gfxPrimitives.h' }, + SDL_console => { inc => 'HAVE_SDL_CONSOLE', test => 'CON_console.h' }, + png => { inc => 'HAVE_PNG', test => 'png.h' }, + jpeg => { inc => 'HAVE_JPEG', test => 'jpeglib.h' }, + GL => { inc => 'HAVE_GL', test => 'gl.h' }, + GLU => { inc => 'HAVE_GLU', test => 'glu.h' }, + smpeg => { inc => 'HAVE_SMPEG', test => 'smpeg.h' }, +); + +# +# Locate optional packages +# + +my ($e,$d); +for $e ( keys %ext ) { + for $d (@dirs) { + $ext{$e}{exists} ||= -e "$d/$ext{$e}{test}" + } +} + +my $usage; +for $e ( keys %ext ) { + $usage .= "\n\t-$e disables $e support"; +} + +for $e ( @ARGV ) { + my $o; + ($o = $e) =~ s/^-*//g; + die "./configure $usage\n" unless exists $ext{$o}; + print "Disabling $o\n"; + $ext{$o}{exists} = 0; +} + +sub found_mod { + printf "%-24s%s\n", "Enabled $_[0]", ( $_[1] ? "yes" : "no" ); +} + +for $e ( sort keys %ext ) { + found_mod ($e,$ext{$e}{exists}); +} + +# +# Get GLU version +# + +if ( $ext{GLU}{exists} ) { + print "Detecting GLU Version\n"; + my $cmd="gcc -o detect detect.c $sdl_cflags -DMACOSX -lGLU -lGL $sdl_libs"; + system ($cmd); + my $version = `./detect` * 10; + push @defs, "-DHAVE_GLU_VERSION=$version"; + system ("rm detect"); +} + + +# +# Specify Makefile options +# + +my %options = ( + 'NAME' => 'SDL_perl', + 'VERSION_FROM' => 'SDL.pm', + 'LIBS' => [ join( " ", "$sdl_libs", + map { $ext{$_}{exists} ? "-l$_" : '' } (sort keys %ext), + ) + ], + 'DEFINE' => join ( " ", "-Ddarwin","-DMACOSX",@defs, map { $ext{$_}{exists} ? "-D$ext{$_}{inc}" : '' } sort keys %ext), + 'INC' => "$inc_flags $sdl_cflags " . join(" ", map { "-I$_" } @dirs), + 'OBJECT' => ( + ($ext{SDL_image}{exists} ? 'SFont.o ' : "") . + 'SDL_perl.o ' . + 'SDL_macosx.o ' . + ($ext{GL}{exists} ? 'OpenGL.o ' : "") + ), + 'dynamic_lib' => {'OTHERLDFLAGS' => '-framework AppKit -framework SDL -framework SDL_image -framework SDL_mixer -framework SDL_ttf -framework OpenGL -ljpeg -lpng -lvorbisfile '}, +); + +# +# Write Makefile +# + +WriteMakefile(%options ); +open FILE, ">>Makefile"; +print FILE 'SDL_macosx$(OBJ_EXT): SDL_macosx.m'; +close FILE; diff -u -N orig2/OpenGL.xs SDL_perl-1.20.3/OpenGL.xs --- orig2/OpenGL.xs Thu Apr 3 10:58:08 2003 +++ SDL_perl-1.20.3/OpenGL.xs Fri May 2 10:21:16 2003 @@ -20,6 +20,14 @@ #include #endif #else +#ifdef MACOSX +#ifdef HAVE_GL +#include +#endif +#ifdef HAVE_GLU +#include +#endif +#else #ifdef HAVE_GL #include #endif @@ -27,7 +35,7 @@ #include #endif #endif - +#endif #ifdef WIN32 diff -u -N orig2/README.dynlib SDL_perl-1.20.3/README.dynlib --- orig2/README.dynlib Wed Dec 31 18:00:00 1969 +++ SDL_perl-1.20.3/README.dynlib Fri May 2 10:21:16 2003 @@ -0,0 +1,2 @@ +In Mac OS X, you need to set DYLD_LIBRARY_PATH to indicate where dynamic +libraries can be loaded from. Otherwise you must statically link everything. diff -u -N orig2/README.macosx SDL_perl-1.20.3/README.macosx --- orig2/README.macosx Wed Dec 31 18:00:00 1969 +++ SDL_perl-1.20.3/README.macosx Fri May 9 14:44:46 2003 @@ -0,0 +1,143 @@ +README.macosx +------------- + +About SDL Perl for Mac OS X +--------------------------- + +This distribution has been modified to compile and install properly under Mac +OS X. It owes a great debt to bob@redivi.com, since he did the initial port +work for SDL Perl 1.1.19 as part of making Frozen Bubble available for Mac OS X. +For more information on Frozen Bubble for Mac OS X, please see + + http://redivi.com/~bob/frozenbubble.html + +This distribution is based on SDL Perl 1.20.3, with the changes from the +original port merged into the latest distribution, and cleaned up a bit. +This README.macosx file has been added to document how to get this module +working. + + +Prerequisites +------------- + +Before SDL Perl will work, the following prerequisites need to be observed: + + 1.) Upgrade the OS and developer tools to their latest versions. I can't + stress this enough. The platform is evolving in subtle ways, and bugs + are being fixed. Having older developer tools or an older version of + the OS is just asking for trouble. I know this distribution works + under Mac OS X 10.2.6 with the December 2002 Developer tools from + Apple. + + 2.) Download the Kitchen sink distribution (which includes this SDL Perl + directory) or download and install the developers edition of the + following Frameworks: + + SDL (www.libsdl.org) + SDL_mixer (www.libsdl.org) + SDL_image (www.libsdl.org) + SDL_ttf (www.libsdl.org) + + To support these frameworks, the following also need to be downloaded and + installed: + + smpeg (www.icculus.org/smpeg) (1) + libvorbis (www.xiph.org) (2) + libpng (www.libpng.org/pub/png/libpng.html) (3) + libjpeg (www.ijg.org) (3) + + (1) The smpeg CVS has a Project Builder directory that will build a + developers framework. There is no binary framework download from + the site however. You only need this if you want SDL_Mixer to work + with MP3 files. NOTE: So far I have not been able to make this work + with SDL Perl, so you might want to skip this one. + + (2) The binaries for Mac OS X don't come in a framework, so the libs + and headers need to be in the search path listed in Makefile.darwin. + You only need this if you want to be able to play OGG encoded music + using SDL_Mixer. + + (3) These libraries need to be built and placed where they can be found + by Makefile.darwin. The builds that I did from the direct sources + worked pretty well out of the box, though I had to run 'ranlib' on + library .a files afterward to make everyone happy. + + NOTE: The Makefile.darwin script is very picky about where files are + installed. The developers frameworks are installed (by default) + in ~/Library/Frameworks, but the script is expecting them in + /System/Library/Frameworks. You can either adjust the script paths + to reflect your own personal Frameworks directory, or move the + installed frameworks to /System/Library/Frameworks. Your choice. + + NOTE: If you install the libraries in a custom directory (or you're + getting "dlyd" errors, you need to add your library directory to + the DYLD_LIBRARY_PATH. The easiest way to do this is to add + the following to your .cshrc (adapt if you use a different shell): + + setenv DYLD_LIBRARY_PATH $DYLD_LIBRARY_PATH:/path/to/lib + + + 3.) With the frameworks and supporting libraries installed, you can build + the perl modules: + + perl Makefile.PL + make + make test + make install + + NOTE: The script does not (yet) honor flags like --prefix, + and will install the perl modules in /Library/Perl/darwin. + + The first step will show you what modules have been successfully detected + and used in building the module. Mine looks like: + + Enabled GL yes + Enabled GLU yes + Enabled SDL_console no + Enabled SDL_gfx no + Enabled SDL_image yes + Enabled SDL_mixer yes + Enabled SDL_net no + Enabled SDL_ttf yes + Enabled jpeg yes + Enabled png yes + Enabled smpeg no + Detecting GLU Version + Checking if your kit is complete... + Looks good + Warning: -L../../lib changed to -L/Users/ttongue/Desktop/SDL2/src/SDL_perl-1.20.3/../../lib + Note (probably harmless): No library found for -lSDL_image + Note (probably harmless): No library found for -lSDL_mixer + Note (probably harmless): No library found for -lSDL_ttf + Writing Makefile for SDL_perl + + Your mileage may vary, but it shouldn't be too far from the above. + After the install is done, you should be able to use SDL in perl! + + +Known Issues: +------------- + + + The Makefile is incredibly picky about paths. A better script is needed, + and should be available soon. + + + The tests phase does produce an error in 1/9 tests for t/sdlpm. It does + not seem to have an impact, but should be investigated. + + + Generating the Application window in SDL spews a large number of errors + to the console, like: + + 2003-05-09 14:31:08.325 perl[15385] *** _NSAutoreleaseNoPool(): Object 0x18bb050 of class NSBitmapImageRep autoreleased with no pool in place - just leaking + + My best guess is that since it's not wrapped with ObjectC/Cocoa, + there are some issues with garbage collection. However, this does not + stop programs from running, so it seems to be a minor issue. + + + smpeg support does not work. The current smpeg distribution states that + there is no longer explicit support for SDL_Mixer, and offers alternative + (C) code for using smpeg with SDL. If someone figures out how to make this + work, let me know. Until then, I know SDL_Mixer will work with OGG and + WAV files. + + +-- Thomas Tongue , 5/9/03 diff -u -N orig2/SDL_macosx.m SDL_perl-1.20.3/SDL_macosx.m --- orig2/SDL_macosx.m Wed Dec 31 18:00:00 1969 +++ SDL_perl-1.20.3/SDL_macosx.m Fri May 2 10:21:16 2003 @@ -0,0 +1,20 @@ +#import +#import +#import +void CPSEnableForegroundOperation(ProcessSerialNumber* psn); +void SDL_macosx_init(void) { + Boolean sameProc; + ProcessSerialNumber myProc, frProc; + if (GetFrontProcess(&frProc) == noErr) + if (GetCurrentProcess(&myProc) == noErr) + if (SameProcess(&frProc, &myProc, &sameProc) == noErr && sameProc == 0) { + /* + NSLog(@"creating bad autorelease pool"); + [[NSAutoreleasePool alloc] init]; + */ + [NSApplication sharedApplication]; + CPSEnableForegroundOperation(&myProc); + } +} +void SDL_macosx_quit(void) { +} diff -u -N orig2/SDL_perl.xs SDL_perl-1.20.3/SDL_perl.xs --- orig2/SDL_perl.xs Thu Mar 27 04:17:23 2003 +++ SDL_perl-1.20.3/SDL_perl.xs Fri May 2 11:06:18 2003 @@ -17,9 +17,18 @@ #include +#ifdef MACOSX +void SDL_macosx_init(void); +void SDL_macosx_quit(void); +#endif + #ifdef HAVE_SDL_IMAGE #include +#ifdef MACOSX +int SFont_TextWidth(char *text); +#else int TextWidth(char *text); +#endif void InitFont(SDL_Surface *Font); void PutString(SDL_Surface *Surface, int x, int y, char *text); #endif @@ -30,12 +39,20 @@ #endif #ifdef HAVE_GL +#ifdef MACOSX +#include +#else #include #endif +#endif #ifdef HAVE_GLU +#ifdef MACOSX +#include +#else #include #endif +#endif #ifdef HAVE_SDL_NET #include @@ -225,6 +242,9 @@ sdl_perl_atexit (void) { SDL_Quit(); +#ifdef MACOSX + SDL_macosx_quit(); +#endif } void boot_SDL(); @@ -255,12 +275,18 @@ Init ( flags ) Uint32 flags CODE: +#ifdef MACOSX + SDL_macosx_init(); +#endif RETVAL = SDL_Init(flags); +/* this is a terrible idea.. make the user SDL->Quit in an END block */ +#if 0 #ifdef HAVE_TLS_CONTEXT Perl_call_atexit(PERL_GET_CONTEXT, (void*)sdl_perl_atexit,0); #else atexit(sdl_perl_atexit); #endif +#endif OUTPUT: RETVAL @@ -282,6 +308,10 @@ Quit () CODE: SDL_Quit(); + #ifdef MACOSX + SDL_macosx_quit(); + #endif + int WasInit ( flags ) @@ -2104,7 +2134,11 @@ TextWidth ( text ) char *text CODE: +#ifdef MACOSX + RETVAL = SFont_TextWidth(text); +#else RETVAL = TextWidth(text); +#endif OUTPUT: RETVAL diff -u -N orig2/SFont.c SDL_perl-1.20.3/SFont.c --- orig2/SFont.c Tue Apr 30 22:40:09 2002 +++ SDL_perl-1.20.3/SFont.c Fri May 2 11:06:01 2003 @@ -4,15 +4,22 @@ #include "stdlib.h" SFont_FontInfo InternalFont; - +#ifdef MACOSX +Uint32 SFont_GetPixel(SDL_Surface *Surface, Sint32 X, Sint32 Y) +#else Uint32 GetPixel(SDL_Surface *Surface, Sint32 X, Sint32 Y) +#endif { Uint8 *bits; Uint32 Bpp; - +#ifdef MACOSX + if (X<0) puts("SFONT ERROR: x too small in SFont_GetPixel. Report this to "); + if (X>=Surface->w) puts("SFONT ERROR: x too big in SFont_GetPixel. Report this to "); +#else if (X<0) puts("SFONT ERROR: x too small in GetPixel. Report this to "); if (X>=Surface->w) puts("SFONT ERROR: x too big in GetPixel. Report this to "); +#endif Bpp = Surface->format->BytesPerPixel; @@ -54,9 +61,17 @@ if (SDL_MUSTLOCK(Font->Surface)) SDL_LockSurface(Font->Surface); while ( x < Font->Surface->w ) { +#ifdef MACOSX + if(SFont_GetPixel(Font->Surface,x,0)==SDL_MapRGB(Font->Surface->format,255,0,255)) { +#else if(GetPixel(Font->Surface,x,0)==SDL_MapRGB(Font->Surface->format,255,0,255)) { +#endif Font->CharPos[i++]=x; +#ifdef MACOSX + while (( x < Font->Surface->w-1) && (SFont_GetPixel(Font->Surface,x,0)==SDL_MapRGB(Font->Surface->format,255,0,255))) +#else while (( x < Font->Surface->w-1) && (GetPixel(Font->Surface,x,0)==SDL_MapRGB(Font->Surface->format,255,0,255))) +#endif x++; Font->CharPos[i++]=x; } @@ -65,7 +80,11 @@ if (SDL_MUSTLOCK(Font->Surface)) SDL_UnlockSurface(Font->Surface); Font->h=Font->Surface->h; +#ifdef MACOSX + SDL_SetColorKey(Font->Surface, SDL_SRCCOLORKEY, SFont_GetPixel(Font->Surface, 0, Font->Surface->h-1)); +#else SDL_SetColorKey(Font->Surface, SDL_SRCCOLORKEY, GetPixel(Font->Surface, 0, Font->Surface->h-1)); +#endif } void InitFont(SDL_Surface *Font) @@ -109,7 +128,11 @@ PutString2(Surface, &InternalFont, x, y, text); } +#ifdef MACOSX +int SFont_TextWidth2(SFont_FontInfo *Font, char *text) +#else int TextWidth2(SFont_FontInfo *Font, char *text) +#endif { int ofs=0; int i=0,x=0; @@ -129,14 +152,25 @@ return x; } +#ifdef MACOSX +int SFont_TextWidth(char *text) +{ + return SFont_TextWidth2(&InternalFont, text); +} +#else int TextWidth(char *text) { return TextWidth2(&InternalFont, text); } +#endif void XCenteredString2(SDL_Surface *Surface, SFont_FontInfo *Font, int y, char *text) { +#ifdef MACOSX + PutString2(Surface, Font, Surface->w/2-SFont_TextWidth2(Font,text)/2, y, text); +#else PutString2(Surface, Font, Surface->w/2-TextWidth2(Font,text)/2, y, text); +#endif } void XCenteredString(SDL_Surface *Surface, int y, char *text) @@ -181,7 +215,11 @@ text[strlen(text)-1]='\0'; else if (ch!='\b') sprintf(text,"%s%c",text,ch); +#ifdef MACOSX + if (SFont_TextWidth2(Font,text)>PixelWidth) text[strlen(text)-1]='\0'; +#else if (TextWidth2(Font,text)>PixelWidth) text[strlen(text)-1]='\0'; +#endif SDL_BlitSurface( Back, NULL, Dest, &rect); PutString2(Dest, Font, x, y, text); SDL_UpdateRects(Dest, 1, &rect); @@ -193,9 +231,15 @@ blink=1-blink; blinktimer=SDL_GetTicks()+500; if (blink) { +#ifdef MACOSX + PutString2(Dest, Font, x+SFont_TextWidth2(Font,text), y, "|"); + SDL_UpdateRects(Dest, 1, &rect); +// SDL_UpdateRect(Dest, x+SFont_TextWidth2(Font,text), y, SFont_TextWidth2(Font,"|"), Font->Surface->h); +#else PutString2(Dest, Font, x+TextWidth2(Font,text), y, "|"); SDL_UpdateRects(Dest, 1, &rect); // SDL_UpdateRect(Dest, x+TextWidth2(Font,text), y, TextWidth2(Font,"|"), Font->Surface->h); +#endif } else { SDL_BlitSurface( Back, NULL, Dest, &rect); PutString2(Dest, Font, x, y, text); diff -u -N orig2/SFont.h SDL_perl-1.20.3/SFont.h --- orig2/SFont.h Sun Mar 31 14:18:27 2002 +++ SDL_perl-1.20.3/SFont.h Fri May 2 11:06:05 2003 @@ -36,8 +36,13 @@ void PutString2(SDL_Surface *Surface, SFont_FontInfo *Font, int x, int y, char *text); // Returns the width of "text" in pixels +#ifdef MACOSX +int SFont_TextWidth(char *text); +int SFont_TextWidth2(SFont_FontInfo *Font, char *text); +#else int TextWidth(char *text); int TextWidth2(SFont_FontInfo *Font, char *text); +#endif // Blits a string to with centered x position void XCenteredString (SDL_Surface *Surface, int y, char *text); diff -u -N orig2/detect.c SDL_perl-1.20.3/detect.c --- orig2/detect.c Thu May 2 19:03:47 2002 +++ SDL_perl-1.20.3/detect.c Fri May 2 10:21:16 2003 @@ -1,7 +1,12 @@ #include #include +#ifdef MACOSX +#include +#include +#else #include #include +#endif int main ( int argc, char **argv ) Common subdirectories: orig2/lib and SDL_perl-1.20.3/lib Common subdirectories: orig2/patches and SDL_perl-1.20.3/patches Common subdirectories: orig2/scripts and SDL_perl-1.20.3/scripts Common subdirectories: orig2/t and SDL_perl-1.20.3/t Common subdirectories: orig2/test and SDL_perl-1.20.3/test Common subdirectories: orig2/win32 and SDL_perl-1.20.3/win32