#!/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;