Index: ruby-opengl/ext/gl/mkrf_conf.rb =================================================================== --- ruby-opengl/ext/gl/mkrf_conf.rb (revision 136) +++ ruby-opengl/ext/gl/mkrf_conf.rb (working copy) @@ -18,5 +18,10 @@ Mkrf::Generator.new( 'gl' ) do |g| g.objects << '../common/rbogl.o' - g.include_library( 'GL', 'glVertex3d' ) + case RUBY_PLATFORM + when /darwin/ + g.ldshared << ' -framework OpenGL' + else + g.include_library( 'GL', 'glVertex3d') + end end Index: ruby-opengl/ext/glu/mkrf_conf.rb =================================================================== --- ruby-opengl/ext/glu/mkrf_conf.rb (revision 136) +++ ruby-opengl/ext/glu/mkrf_conf.rb (working copy) @@ -18,6 +18,12 @@ Mkrf::Generator.new( 'glu' ) do |g| g.objects << '../common/rbogl.o' - g.include_library( 'GLU', 'gluLookAt' ) - g.include_library( 'GL', 'glVertex3d' ) + case RUBY_PLATFORM + when /darwin/ + g.ldshared << ' -framework OpenGL' + else + g.include_library( 'GLU', 'gluLookAt' ) + g.include_library( 'GL', 'glVertex3d' ) + end + end Index: ruby-opengl/ext/glut/mkrf_conf.rb =================================================================== --- ruby-opengl/ext/glut/mkrf_conf.rb (revision 136) +++ ruby-opengl/ext/glut/mkrf_conf.rb (working copy) @@ -17,7 +17,12 @@ require 'mkrf' Mkrf::Generator.new( 'glut' ) do |g| - g.include_library( 'glut', 'glutSolidTeapot' ) - g.include_library( 'GLU', 'gluLookAt' ) - g.include_library( 'GL', 'glVertex3d' ) + case RUBY_PLATFORM + when /darwin/ + g.ldshared << ' -framework GLUT -framework OpenGL -framework Cocoa' + else + g.include_library( 'glut', 'glutSolidTeapot' ) + g.include_library( 'GLU', 'gluLookAt' ) + g.include_library( 'GL', 'glVertex3d' ) + end end Index: ruby-opengl/Rakefile =================================================================== --- ruby-opengl/Rakefile (revision 136) +++ ruby-opengl/Rakefile (working copy) @@ -34,6 +34,64 @@ WEBSITE_MKDN = FileList['./doc/*.txt'] << 'README.txt' NICE_HTML_DOCS = WEBSITE_MKDN.ext('html') +case RUBY_PLATFORM +when /darwin/ + LIB_EXT_NAME = 'bundle' +else + LIB_EXT_NAME = 'so' +end + +task :default => :build + +desc 'Build the library, default task.' +task :build do + # Note, mkrf_conf.rb should always generate a new Rakefile, + # so we don't clean out old ones (also, recall that ext/common + # contains a hand-written Rakefile which you wouldn't want to + # remove). + command = <<-EOF + echo "Cleaning up previous build products ..." + + rm ext/common/rbogl.o + rm ext/gl/gl.o + rm ext/glu/glu.o + rm ext/glut/glut.o + + cd ext/common + echo "Building common/rbogl.o ..." + rake + + echo "" + cd ../gl + echo "Making Rakefile for gl ..." + ruby mkrf_conf.rb + echo "Building gl ..." + rake + cp gl.#{LIB_EXT_NAME} ../../lib + + echo "" + cd ../glu + echo "Making Rakefile for glu ..." + ruby mkrf_conf.rb + echo "Building glu ..." + rake + cp glu.#{LIB_EXT_NAME} ../../lib + + echo "" + cd ../glut + echo "Making Rakefile for glut ..." + ruby mkrf_conf.rb + echo "Building glut ..." + rake + cp glut.#{LIB_EXT_NAME} ../../lib + + echo "" + echo "Done. Extension modules built and copied to ./lib." + EOF + + system(command) +end + desc 'Show contents of some variables related to website doc generation.' task :explain_website do puts "WEBSITE_MKDN:"