diff -urN opengl-0.32g.old/glu.c opengl-0.32g.new/glu.c
--- opengl-0.32g.old/glu.c	2005-08-27 01:04:19.000000000 +0900
+++ opengl-0.32g.new/glu.c	2010-09-17 22:52:05.470075188 +0900
@@ -1312,9 +1312,9 @@
         if (type_size == -1 || format_size == -1)
             return Qnil;
         size = type_size*format_size*height*width;
-        if (RSTRING(arg7)->len < size)
-            rb_raise(rb_eArgError, "string length:%d",RSTRING(arg7)->len);
-        data = RSTRING(arg7)->ptr;
+        if (RSTRING_LEN(arg7) < size)
+            rb_raise(rb_eArgError, "string length:%d",RSTRING_LEN(arg7));
+        data = RSTRING_PTR(arg7);
     } else 
         rb_raise(rb_eTypeError, "type mismatch:%s",rb_class2name(arg7));
     return INT2NUM(gluBuild2DMipmaps(target, components, width, height, format, type, data));
@@ -1347,9 +1347,9 @@
         if (type_size == -1 || format_size == -1)
             return Qnil;
         size = type_size*format_size*heightin*widthin;
-        if (RSTRING(arg5)->len < size)
-            rb_raise(rb_eArgError, "string length:%d",RSTRING(arg5)->len);
-        datain = RSTRING(arg5)->ptr;
+        if (RSTRING_LEN(arg5) < size)
+            rb_raise(rb_eArgError, "string length:%d",RSTRING_LEN(arg5));
+        datain = RSTRING_PTR(arg5);
     } else 
         rb_raise(rb_eTypeError, "type mismatch:%s",rb_class2name(arg5));
 
@@ -1359,7 +1359,7 @@
     type_size = gltype_size(typeout) / 8;
     ret = allocate_buffer_with_string(widthout*heightout*format_size*type_size);
     gluScaleImage(format, widthin, heightin, typein, datain,
-		widthout, heightout, typeout, (GLvoid*)RSTRING(ret)->ptr);
+		widthout, heightout, typeout, (GLvoid*)RSTRING_PTR(ret));
     return ret;
 }
 
diff -urN opengl-0.32g.old/glut.c opengl-0.32g.new/glut.c
--- opengl-0.32g.old/glut.c	2005-08-27 01:04:19.000000000 +0900
+++ opengl-0.32g.new/glut.c	2010-09-17 22:50:36.390261906 +0900
@@ -107,7 +107,7 @@
 {
     if (TYPE(arg1) != T_STRING)
 	rb_raise(rb_eTypeError, "GLUT.InitDisplay:%s",rb_class2name(CLASS_OF(arg1)));
-    glutInitDisplayString(RSTRING(arg1)->ptr);
+    glutInitDisplayString(RSTRING_PTR(arg1));
     return Qnil;
 }
 #endif
@@ -183,7 +183,7 @@
         title = rb_eval_string("$0");
     if (TYPE(title) != T_STRING)
 	rb_raise(rb_eTypeError, "GLUT.CreateWindow:%s", rb_class2name(CLASS_OF(title)));
-    ret = glutCreateWindow(RSTRING(title)->ptr);
+    ret = glutCreateWindow(RSTRING_PTR(title));
 
     /* setup callback */
 /*
@@ -275,7 +275,7 @@
 {
     if (TYPE(arg1) != T_STRING)
 	rb_raise(rb_eTypeError, "GLUT.SetWindowTitle:%s", rb_class2name(CLASS_OF(arg1)));
-    glutSetWindowTitle(RSTRING(arg1)->ptr);
+    glutSetWindowTitle(RSTRING_PTR(arg1));
     return Qnil;
 }
 
@@ -285,7 +285,7 @@
 {
     if (TYPE(arg1) != T_STRING)
 	rb_raise(rb_eTypeError, "GLUT.IconTitle:%s", rb_class2name(CLASS_OF(arg1)));
-    glutSetIconTitle(RSTRING(arg1)->ptr);
+    glutSetIconTitle(RSTRING_PTR(arg1));
     return Qnil;
 }
 
@@ -513,7 +513,7 @@
     rb_ary_store(arg_pair, 0, INT2FIX(curmenuid));
     rb_ary_store(arg_pair, 1, arg2);
     rb_ary_push(arg_ary, arg_pair);
-    glutAddMenuEntry(RSTRING(arg1)->ptr, arg_pair);
+    glutAddMenuEntry(RSTRING_PTR(arg1), arg_pair);
     return Qnil;
 }
 
@@ -525,7 +525,7 @@
     if (TYPE(arg1) != T_STRING) rb_raise(rb_eTypeError, "GLUT.AddSubMenu:%s",
               rb_class2name(CLASS_OF(arg1)));
     value = NUM2INT(arg2);
-    glutAddSubMenu(RSTRING(arg1)->ptr, value);
+    glutAddSubMenu(RSTRING_PTR(arg1), value);
     return Qnil;
 }
 
@@ -549,7 +549,7 @@
     rb_ary_store(arg_pair, 0, INT2FIX(curmenuid));
     rb_ary_store(arg_pair, 1, arg2);
     rb_ary_store(arg_ary, item, arg_pair);
-    glutChangeToMenuEntry(item, RSTRING(arg2)->ptr, arg_pair);
+    glutChangeToMenuEntry(item, RSTRING_PTR(arg2), arg_pair);
     return Qnil;
 }
 
@@ -562,7 +562,7 @@
     submenu = NUM2INT(arg3);
     if (TYPE(arg2) != T_STRING) rb_raise(rb_eTypeError, "GLUT.ChangeToSubMenu:%s",
               rb_class2name(CLASS_OF(arg1)));
-    glutChangeToSubMenu(item, RSTRING(arg2)->ptr, submenu);
+    glutChangeToSubMenu(item, RSTRING_PTR(arg2), submenu);
     return Qnil;
 }
 
@@ -915,7 +915,7 @@
     int ret;
     if (TYPE(arg1) != T_STRING) rb_raise(rb_eTypeError, "glutExtensionSupported:%s",
               rb_class2name(CLASS_OF(arg1)));
-    ret = glutExtensionSupported(RSTRING(arg1)->ptr);
+    ret = glutExtensionSupported(RSTRING_PTR(arg1));
     return INT2NUM(ret);
 }
 #endif
@@ -997,7 +997,7 @@
     if (TYPE(arg2) != T_STRING) rb_raise(rb_eTypeError, "glutBitmapLength:%s",
               rb_class2name(CLASS_OF(arg2)));
     font = NUM2INT(arg1);
-    ret = glutBitmapLength((void *)font, (const unsigned char*)RSTRING(arg2)->ptr);
+    ret = glutBitmapLength((void *)font, (const unsigned char*)RSTRING_PTR(arg2));
     return INT2NUM(ret);
 }
 static VALUE
@@ -1009,7 +1009,7 @@
     if (TYPE(arg2) != T_STRING) rb_raise(rb_eTypeError, "glutStrokeLength:%s",
               rb_class2name(CLASS_OF(arg2)));
     font = NUM2INT(arg1);
-    ret = glutStrokeLength((void *)font, (const unsigned char*)RSTRING(arg2)->ptr);
+    ret = glutStrokeLength((void *)font, (const unsigned char*)RSTRING_PTR(arg2));
     return INT2NUM(ret);
 }
 #endif
diff -urN opengl-0.32g.old/Makefile opengl-0.32g.new/Makefile
--- opengl-0.32g.old/Makefile	2005-08-27 01:04:19.000000000 +0900
+++ opengl-0.32g.new/Makefile	1970-01-01 09:00:00.000000000 +0900
@@ -1,29 +0,0 @@
-SHELL = /bin/sh
-srcdir = .
-VPATH = $(srcdir)
-
-all: glut.so opengl.so
-
-opengl.so: rbogl.c ogl.c glu.c rbogl.h
-	@echo Now Making opengl extend module
-	@$(MAKE) -f Makefile.ogl
-
-glut.so: glut.c
-	@echo Now Making glut extend module
-	@$(MAKE) -f Makefile.glut
-
-clean:
-	@$(MAKE) -f Makefile.ogl clean
-	@$(MAKE) -f Makefile.glut clean
-
-distclean:
-	@$(MAKE) -f Makefile.ogl distclean
-	@$(MAKE) -f Makefile.glut distclean
-
-install: glut.so opengl.so
-	@$(MAKE) -f Makefile.ogl install
-	@$(MAKE) -f Makefile.glut install
-
-site-install: glut.so opengl.so
-	@$(MAKE) -f Makefile.ogl site-install
-	@$(MAKE) -f Makefile.glut site-install
diff -urN opengl-0.32g.old/Makefile.glut opengl-0.32g.new/Makefile.glut
--- opengl-0.32g.old/Makefile.glut	2005-08-27 01:04:19.000000000 +0900
+++ opengl-0.32g.new/Makefile.glut	2010-09-17 22:58:28.783429592 +0900
@@ -4,117 +4,170 @@
 #### Start of system configuration section. ####
 
 srcdir = .
-topdir = $(rubylibdir)/$(arch)
-hdrdir = $(rubylibdir)/$(arch)
-VPATH = $(srcdir)
-prefix = $(DESTDIR)/usr/local
+topdir = /usr/include/ruby-1.9.0
+hdrdir = /usr/include/ruby-1.9.0
+arch_hdrdir = /usr/include/ruby-1.9.0/$(arch)
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+prefix = $(DESTDIR)/usr
 exec_prefix = $(prefix)
-sitedir = $(prefix)/lib/ruby/site_ruby
-rubylibdir = $(libdir)/ruby/$(ruby_version)
-builddir = $(ac_builddir)
-archdir = $(rubylibdir)/$(arch)
-sbindir = $(exec_prefix)/sbin
-compile_dir = $(DESTDIR)/home/Kusano/ruby-1.8.0
-datadir = $(prefix)/share
-includedir = $(prefix)/include
-infodir = $(prefix)/info
-top_builddir = $(ac_top_builddir)
-sysconfdir = $(prefix)/etc
-mandir = $(prefix)/man
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/ruby-$(ruby_version)
+vendordir = $(libdir)/ruby/vendor_ruby
+sitedir = $(DESTDIR)/usr/local/lib/site_ruby
+mandir = $(prefix)/share/man
+localedir = $(datarootdir)/locale
 libdir = $(exec_prefix)/lib
-sharedstatedir = $(prefix)/com
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(prefix)/share/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
 oldincludedir = $(DESTDIR)/usr/include
-sitearchdir = $(sitelibdir)/$(sitearch)
+includedir = $(prefix)/include
+localstatedir = $(DESTDIR)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(DESTDIR)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(prefix)/lib/ruby1.9
+sbindir = $(exec_prefix)/sbin
 bindir = $(exec_prefix)/bin
-localstatedir = $(prefix)/var
+rubylibdir = $(libdir)/ruby/$(ruby_version)
+archdir = $(rubylibdir)/$(arch)
 sitelibdir = $(sitedir)/$(ruby_version)
-libexecdir = $(exec_prefix)/libexec
+sitearchdir = $(sitelibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
 
-CC = gcc
-LIBRUBY = lib$(LIBRUBY_SO).a
+CC = cc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
 LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
 LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
 LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
+OUTFLAG = -o 
+COUTFLAG = -o 
 
-CFLAGS   =  -DWIN32
-CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)  
-CXXFLAGS = $(CFLAGS) 
-DLDFLAGS =   -Wl,--enable-auto-import,--export-all 
-LDSHARED = gcc -shared -s
+RUBY_EXTCONF_H = 
+cflags   = $(optflags) $(debugflags) $(warnflags)
+optflags = -O2
+debugflags = -g
+warnflags = -Wall -Wno-parentheses
+CFLAGS   =  -fPIC -fno-strict-aliasing -g -g -O2 $(cflags)  -fPIC 
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
+DEFS     = -D_FILE_OFFSET_BITS=64
+CPPFLAGS =  -I/usr/X11R6/include  $(DEFS) $(cppflags) -I.
+CXXFLAGS = $(CFLAGS) -fno-strict-aliasing -g $(cxxflags)
+ldflags  = -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic
+dldflags = 
+archflag = 
+DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
 AR = ar
-EXEEXT = .exe
+EXEEXT = 
 
-RUBY_INSTALL_NAME = ruby
-RUBY_SO_NAME = cygwin-$(RUBY_INSTALL_NAME)18
-arch = i386-cygwin
-sitearch = i386-cygwin
-ruby_version = 1.8
-RUBY = ruby
-RM = $(RUBY) -run -e rm -- -f
-MAKEDIRS = $(RUBY) -run -e mkdir -- -p
-INSTALL_PROG = $(RUBY) -run -e install -- -vpm 0755
-INSTALL_DATA = $(RUBY) -run -e install -- -vpm 0644
+RUBY_INSTALL_NAME = ruby1.9
+RUBY_SO_NAME = ruby1.9
+arch = i486-linux
+sitearch = i486-linux
+ruby_version = 1.9.0
+ruby = /usr/bin/ruby1.9
+RUBY = $(ruby)
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+MAKEDIRS = mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
 
 #### End of system configuration section. ####
 
+preload = 
 
-LIBPATH =  -L"$(libdir)"
+libpath = . $(libdir) /usr/X11R6/lib
+LIBPATH =  -L. -L$(libdir) -L/usr/X11R6/lib
 DEFFILE = 
 
-CLEANFILES = 
+CLEANFILES = mkmf.log
 DISTCLEANFILES = 
 
+extout = 
+extout_prefix = 
 target_prefix = 
 LOCAL_LIBS = 
-LIBS = $(LIBRUBYARG_SHARED) -lglut32 -lglu32 -lopengl32  -lcrypt  
+LIBS = $(LIBRUBYARG_SHARED) -lglut -lGLU -lGL -lX11 -lXext -lXi  -lpthread -lrt -ldl -lcrypt -lm   -lc
+SRCS = glu.c ogl.c rbogl.c
 OBJS = glut.o
 TARGET = glut
 DLLIB = $(TARGET).so
+EXTSTATIC = 
+STATIC_LIB = 
 
+BINDIR        = $(bindir)
 RUBYCOMMONDIR = $(sitedir)$(target_prefix)
 RUBYLIBDIR    = $(sitelibdir)$(target_prefix)
 RUBYARCHDIR   = $(sitearchdir)$(target_prefix)
+HDRDIR        = $(rubyhdrdir)/ruby$(target_prefix)
+ARCHHDRDIR    = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
 
-CLEANLIBS     = "$(TARGET).{lib,exp,il?,tds,map}" $(DLLIB)
-CLEANOBJS     = "*.{o,a,s[ol],pdb,bak}"
+TARGET_SO     = $(DLLIB)
+CLEANLIBS     = $(TARGET).so 
+CLEANOBJS     = *.o  *.bak
 
 all:		$(DLLIB)
+static:		$(STATIC_LIB)
 
 clean:
-		@$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
+		@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
 
 distclean:	clean
-		@$(RM) Makefile extconf.h conftest.* mkmf.log
-		@$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+		@-$(RM_RF) conftest.dSYM
+		@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+		@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
 
 realclean:	distclean
-install: $(RUBYARCHDIR)
-install: $(RUBYARCHDIR)/$(DLLIB)
-$(RUBYARCHDIR)/$(DLLIB): $(DLLIB) $(RUBYARCHDIR)
-	@$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
+	$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
 $(RUBYARCHDIR):
-	@$(MAKEDIRS) $(RUBYARCHDIR)
+	$(MAKEDIRS) $@
 
-site-install: install
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
 
-.SUFFIXES: .c .cc .m .cxx .cpp .C .o
+.SUFFIXES: .c .m .cc .cxx .cpp .C .o
 
 .cc.o:
-	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
-
-.cpp.o:
-	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
+	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
 
 .cxx.o:
-	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
+	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.o:
+	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
 
 .C.o:
-	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
+	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
 
 .c.o:
-	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
+	$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
 
 $(DLLIB): $(OBJS)
-	@-$(RM) $@
-	$(LDSHARED) $(DLDFLAGS) $(LIBPATH) -o $(DLLIB) $(OBJS) $(LOCAL_LIBS) $(LIBS)
+	@-$(RM) $(@)
+	$(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+
 
+$(OBJS): ruby.h defines.h
diff -urN opengl-0.32g.old/Makefile.ogl opengl-0.32g.new/Makefile.ogl
--- opengl-0.32g.old/Makefile.ogl	2005-08-27 01:04:19.000000000 +0900
+++ opengl-0.32g.new/Makefile.ogl	2010-09-17 22:58:28.597886805 +0900
@@ -4,117 +4,170 @@
 #### Start of system configuration section. ####
 
 srcdir = .
-topdir = $(rubylibdir)/$(arch)
-hdrdir = $(rubylibdir)/$(arch)
-VPATH = $(srcdir)
-prefix = $(DESTDIR)/usr/local
+topdir = /usr/include/ruby-1.9.0
+hdrdir = /usr/include/ruby-1.9.0
+arch_hdrdir = /usr/include/ruby-1.9.0/$(arch)
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+prefix = $(DESTDIR)/usr
 exec_prefix = $(prefix)
-sitedir = $(prefix)/lib/ruby/site_ruby
-rubylibdir = $(libdir)/ruby/$(ruby_version)
-builddir = $(ac_builddir)
-archdir = $(rubylibdir)/$(arch)
-sbindir = $(exec_prefix)/sbin
-compile_dir = $(DESTDIR)/home/Kusano/ruby-1.8.0
-datadir = $(prefix)/share
-includedir = $(prefix)/include
-infodir = $(prefix)/info
-top_builddir = $(ac_top_builddir)
-sysconfdir = $(prefix)/etc
-mandir = $(prefix)/man
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/ruby-$(ruby_version)
+vendordir = $(libdir)/ruby/vendor_ruby
+sitedir = $(DESTDIR)/usr/local/lib/site_ruby
+mandir = $(prefix)/share/man
+localedir = $(datarootdir)/locale
 libdir = $(exec_prefix)/lib
-sharedstatedir = $(prefix)/com
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(prefix)/share/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
 oldincludedir = $(DESTDIR)/usr/include
-sitearchdir = $(sitelibdir)/$(sitearch)
+includedir = $(prefix)/include
+localstatedir = $(DESTDIR)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(DESTDIR)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(prefix)/lib/ruby1.9
+sbindir = $(exec_prefix)/sbin
 bindir = $(exec_prefix)/bin
-localstatedir = $(prefix)/var
+rubylibdir = $(libdir)/ruby/$(ruby_version)
+archdir = $(rubylibdir)/$(arch)
 sitelibdir = $(sitedir)/$(ruby_version)
-libexecdir = $(exec_prefix)/libexec
+sitearchdir = $(sitelibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
 
-CC = gcc
-LIBRUBY = lib$(LIBRUBY_SO).a
+CC = cc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
 LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
 LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
 LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
+OUTFLAG = -o 
+COUTFLAG = -o 
 
-CFLAGS   =  -DWIN32
-CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)  
-CXXFLAGS = $(CFLAGS) 
-DLDFLAGS =   -Wl,--enable-auto-import,--export-all 
-LDSHARED = gcc -shared -s
+RUBY_EXTCONF_H = 
+cflags   = $(optflags) $(debugflags) $(warnflags)
+optflags = -O2
+debugflags = -g
+warnflags = -Wall -Wno-parentheses
+CFLAGS   =  -fPIC -fno-strict-aliasing -g -g -O2 $(cflags)  -fPIC 
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
+DEFS     = -D_FILE_OFFSET_BITS=64
+CPPFLAGS =  -I/usr/X11R6/include  $(DEFS) $(cppflags) -I.
+CXXFLAGS = $(CFLAGS) -fno-strict-aliasing -g $(cxxflags)
+ldflags  = -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic
+dldflags = 
+archflag = 
+DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
 AR = ar
-EXEEXT = .exe
+EXEEXT = 
 
-RUBY_INSTALL_NAME = ruby
-RUBY_SO_NAME = cygwin-$(RUBY_INSTALL_NAME)18
-arch = i386-cygwin
-sitearch = i386-cygwin
-ruby_version = 1.8
-RUBY = ruby
-RM = $(RUBY) -run -e rm -- -f
-MAKEDIRS = $(RUBY) -run -e mkdir -- -p
-INSTALL_PROG = $(RUBY) -run -e install -- -vpm 0755
-INSTALL_DATA = $(RUBY) -run -e install -- -vpm 0644
+RUBY_INSTALL_NAME = ruby1.9
+RUBY_SO_NAME = ruby1.9
+arch = i486-linux
+sitearch = i486-linux
+ruby_version = 1.9.0
+ruby = /usr/bin/ruby1.9
+RUBY = $(ruby)
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+MAKEDIRS = mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
 
 #### End of system configuration section. ####
 
+preload = 
 
-LIBPATH =  -L"$(libdir)"
+libpath = . $(libdir) /usr/X11R6/lib
+LIBPATH =  -L. -L$(libdir) -L/usr/X11R6/lib
 DEFFILE = 
 
-CLEANFILES = 
+CLEANFILES = mkmf.log
 DISTCLEANFILES = 
 
+extout = 
+extout_prefix = 
 target_prefix = 
 LOCAL_LIBS = 
-LIBS = $(LIBRUBYARG_SHARED) -lglu32 -lopengl32  -lcrypt  
+LIBS = $(LIBRUBYARG_SHARED) -lGLU -lGL -lX11 -lXext -lXi  -lpthread -lrt -ldl -lcrypt -lm   -lc
+SRCS = glu.c ogl.c rbogl.c
 OBJS = glu.o ogl.o rbogl.o
 TARGET = opengl
 DLLIB = $(TARGET).so
+EXTSTATIC = 
+STATIC_LIB = 
 
+BINDIR        = $(bindir)
 RUBYCOMMONDIR = $(sitedir)$(target_prefix)
 RUBYLIBDIR    = $(sitelibdir)$(target_prefix)
 RUBYARCHDIR   = $(sitearchdir)$(target_prefix)
+HDRDIR        = $(rubyhdrdir)/ruby$(target_prefix)
+ARCHHDRDIR    = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
 
-CLEANLIBS     = "$(TARGET).{lib,exp,il?,tds,map}" $(DLLIB)
-CLEANOBJS     = "*.{o,a,s[ol],pdb,bak}"
+TARGET_SO     = $(DLLIB)
+CLEANLIBS     = $(TARGET).so 
+CLEANOBJS     = *.o  *.bak
 
 all:		$(DLLIB)
+static:		$(STATIC_LIB)
 
 clean:
-		@$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
+		@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
 
 distclean:	clean
-		@$(RM) Makefile extconf.h conftest.* mkmf.log
-		@$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+		@-$(RM_RF) conftest.dSYM
+		@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+		@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
 
 realclean:	distclean
-install: $(RUBYARCHDIR)
-install: $(RUBYARCHDIR)/$(DLLIB)
-$(RUBYARCHDIR)/$(DLLIB): $(DLLIB) $(RUBYARCHDIR)
-	@$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
+	$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
 $(RUBYARCHDIR):
-	@$(MAKEDIRS) $(RUBYARCHDIR)
+	$(MAKEDIRS) $@
 
-site-install: install
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
 
-.SUFFIXES: .c .cc .m .cxx .cpp .C .o
+.SUFFIXES: .c .m .cc .cxx .cpp .C .o
 
 .cc.o:
-	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
-
-.cpp.o:
-	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
+	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
 
 .cxx.o:
-	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
+	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.o:
+	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
 
 .C.o:
-	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
+	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
 
 .c.o:
-	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
+	$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
 
 $(DLLIB): $(OBJS)
-	@-$(RM) $@
-	$(LDSHARED) $(DLDFLAGS) $(LIBPATH) -o $(DLLIB) $(OBJS) $(LOCAL_LIBS) $(LIBS)
+	@-$(RM) $(@)
+	$(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+
 
+$(OBJS): ruby.h defines.h
diff -urN opengl-0.32g.old/ogl.c opengl-0.32g.new/ogl.c
--- opengl-0.32g.old/ogl.c	2005-08-27 01:04:19.000000000 +0900
+++ opengl-0.32g.new/ogl.c	2010-09-17 22:57:20.555098210 +0900
@@ -186,9 +186,9 @@
 	    mask[i] = (GLubyte)NUM2INT(ary->ptr[i]);
     }
     else if (TYPE(arg1) == T_STRING) {
-	if (RSTRING(arg1)->len < 128)
-	    rb_raise(rb_eArgError, "string length:%d", RSTRING(arg1)->len);
-	memcpy(mask, RSTRING(arg1)->ptr, 128);
+	if (RSTRING_LEN(arg1) < 128)
+	    rb_raise(rb_eArgError, "string length:%d", RSTRING_LEN(arg1));
+	memcpy(mask, RSTRING_PTR(arg1), 128);
     }
     else
 	rb_raise(rb_eTypeError, "type mismatch:%s", rb_class2name(arg1));
@@ -715,8 +715,8 @@
     GLvoid *lists;
     if (TYPE(arg1) == T_STRING) {
 	type = GL_BYTE;
-	lists = RSTRING(arg1)->ptr;
-	n = RSTRING(arg1)->len;
+	lists = RSTRING_PTR(arg1);
+	n = RSTRING_PTR(arg1);
     }
     else if (TYPE(arg1) == T_ARRAY) {
 	type = GL_INT;
@@ -2145,9 +2145,9 @@
     ymove = (GLfloat)NUM2DBL(arg6);
     if (TYPE(arg7) != T_STRING)
 	rb_raise(rb_eTypeError, "type mismatch:%s", rb_class2name(CLASS_OF(arg7)));
-    if (RSTRING(arg7)->len < (width * height / 8))
-	rb_raise(rb_eArgError, "string length:%d", RSTRING(arg7)->len);
-    bitmap = (const GLubyte*)RSTRING(arg7)->ptr;
+    if (RSTRING_LEN(arg7) < (width * height / 8))
+	rb_raise(rb_eArgError, "string length:%d", RSTRING_LEN(arg7));
+    bitmap = (const GLubyte*)RSTRING_PTR(arg7);
     glBitmap(width, height, xorig, yorig, xmove, ymove, bitmap);
     return Qnil;
 }
@@ -2174,7 +2174,7 @@
 	type_size = gltype_size(type) / 8;
 	format_size = glformat_size(format);
         pixels = allocate_buffer_with_string(width*height*format_size*type_size);
-	glReadPixels(x,y,width,height,format,type,(GLvoid*)RSTRING(pixels)->ptr);
+	glReadPixels(x,y,width,height,format,type,(GLvoid*)RSTRING_PTR(pixels));
 	return pixels;
     }
     return Qnil;
@@ -2195,9 +2195,9 @@
     if (format != -1 && type != -1) {
 	if (TYPE(arg5) != T_STRING)
 	    rb_raise(rb_eTypeError, "type mismatch:%s", rb_class2name(arg5));
-	if (RSTRING(arg5)->len < width * height * glformat_size(format) * gltype_size(type) / 8)
-	    rb_raise(rb_eArgError, "string length:%d", RSTRING(arg5)->len);
-	pixels = RSTRING(arg5)->ptr;
+	if (RSTRING_LEN(arg5) < width * height * glformat_size(format) * gltype_size(type) / 8)
+	    rb_raise(rb_eArgError, "string length:%d", RSTRING_LEN(arg5));
+	pixels = RSTRING_PTR(arg5);
 	glDrawPixels(width,height,format,type,pixels);
     }
     return Qnil;
@@ -2422,9 +2422,9 @@
 	if (type_size == -1 || format_size == -1)
 	    return Qnil;
 	size = type_size*format_size*height*width;
-	if (RSTRING(arg9)->len < size)
-	    rb_raise(rb_eArgError, "string length:%d",RSTRING(arg9)->len);
- 	pixels = RSTRING(arg9)->ptr;
+	if (RSTRING_LEN(arg9) < size)
+	    rb_raise(rb_eArgError, "string length:%d",RSTRING_LEN(arg9));
+ 	pixels = RSTRING_PTR(arg9);
     } else if (NIL_P(arg9)) {
 	type_size = gltype_size(type) / 8;
 	format_size = glformat_size(format);
@@ -2732,7 +2732,7 @@
     }
     g_current_feed_buffer = allocate_buffer_with_string(sizeof(GLfloat)*size);
     rb_str_freeze(g_current_feed_buffer);
-    glFeedbackBuffer(size, type, (GLfloat*)RSTRING(g_current_feed_buffer)->ptr);
+    glFeedbackBuffer(size, type, (GLfloat*)RSTRING_PTR(g_current_feed_buffer));
     return g_current_feed_buffer;
 }
 static VALUE g_current_sel_buffer;
@@ -2750,7 +2750,7 @@
 	size = (GLsizei)NUM2INT(args);
     g_current_sel_buffer = allocate_buffer_with_string(sizeof(GLuint)*size);
     rb_str_freeze(g_current_sel_buffer);
-    glSelectBuffer(size, (GLuint*)RSTRING(g_current_sel_buffer)->ptr);
+    glSelectBuffer(size, (GLuint*)RSTRING_PTR(g_current_sel_buffer));
     return g_current_sel_buffer;
 }
 
@@ -2827,7 +2827,7 @@
     Check_Type(arg4, T_STRING); \
     rb_str_freeze(arg4); \
     g_##_func_##_ptr = arg4; \
-    gl##_func_##Pointer(size, type, stride, (const GLvoid*)RSTRING(arg4)->ptr); \
+    gl##_func_##Pointer(size, type, stride, (const GLvoid*)RSTRING_PTR(arg4)); \
     return Qnil; \
 }
 
@@ -2848,7 +2848,7 @@
     Check_Type(arg3, T_STRING);
     rb_str_freeze(arg3);
     g_Normal_ptr = arg3;
-    glNormalPointer(type, stride, (const GLvoid*)RSTRING(arg3)->ptr);
+    glNormalPointer(type, stride, (const GLvoid*)RSTRING_PTR(arg3));
     return Qnil;
 }
 static VALUE
@@ -2862,7 +2862,7 @@
     Check_Type(arg3, T_STRING);
     rb_str_freeze(arg3);
     g_Index_ptr = arg3;
-    glIndexPointer(type, stride, (const GLvoid*)RSTRING(arg3)->ptr);
+    glIndexPointer(type, stride, (const GLvoid*)RSTRING_PTR(arg3));
     return Qnil;
 }
 static VALUE
@@ -2874,7 +2874,7 @@
     Check_Type(arg2, T_STRING);
     rb_str_freeze(arg2);
     g_EdgeFlag_ptr = arg2;
-    glEdgeFlagPointer(stride, (const GLboolean*)RSTRING(arg2)->ptr);
+    glEdgeFlagPointer(stride, (const GLboolean*)RSTRING_PTR(arg2));
     return Qnil;
 }
 static VALUE
@@ -2938,7 +2938,7 @@
     count = (GLsizei)NUM2INT(arg2);
     type = (GLenum)NUM2INT(arg3);
     Check_Type(arg4, T_STRING);
-    glDrawElements(mode, count, type, (const GLvoid*)RSTRING(arg4)->ptr);
+    glDrawElements(mode, count, type, (const GLvoid*)RSTRING_PTR(arg4));
     return Qnil;
 }
 static VALUE
@@ -2950,7 +2950,7 @@
     format = (GLenum)NUM2INT(arg1);
     stride = (GLsizei)NUM2INT(arg2);
     Check_Type(arg3, T_STRING);
-    glInterleavedArrays(format, stride, (const GLvoid*)RSTRING(arg3)->ptr);
+    glInterleavedArrays(format, stride, (const GLvoid*)RSTRING_PTR(arg3));
     return Qnil;
 }
 static VALUE
@@ -3041,9 +3041,9 @@
 	if (type_size == -1 || format_size == -1)
 	    return Qnil;
 	size = type_size*format_size*height*width;
-	if (RSTRING(arg9)->len < size)
-	    rb_raise(rb_eArgError, "string length:%d",RSTRING(arg9)->len);
- 	pixels = RSTRING(arg9)->ptr;
+	if (RSTRING_LEN(arg9) < size)
+	    rb_raise(rb_eArgError, "string length:%d",RSTRING_LEN(arg9));
+ 	pixels = RSTRING_PTR(arg9);
     } else
 	rb_raise(rb_eTypeError, "type mismatch:%s",rb_class2name(arg9));
     glTexSubImage2D(target,level,xoffset,yoffset,width,height,
@@ -3154,7 +3154,7 @@
     count = (GLsizei)NUM2INT(arg4);
     type = (GLenum)NUM2INT(arg5);
     Check_Type(arg6, T_STRING);
-    glDrawRangeElements(mode, start, end, count, type, RSTRING(arg6)->ptr);
+    glDrawRangeElements(mode, start, end, count, type, RSTRING_PTR(arg6));
     return Qnil;
 }
 VALUE
@@ -3188,11 +3188,11 @@
     if (type_size == -1 || format_size == -1)
         return Qnil;
     size = type_size*format_size*height*width*depth;
-    if (RSTRING(arg10)->len < size)
-        rb_raise(rb_eArgError, "string length:%d",RSTRING(arg10)->len);
+    if (RSTRING_LEN(arg10) < size)
+        rb_raise(rb_eArgError, "string length:%d",RSTRING_LEN(arg10));
     glTexImage3D( target, level, internalFormat, width, height,
                   depth, border, format, type,
-                  (const GLvoid*)RSTRING(arg10)->ptr);
+                  (const GLvoid*)RSTRING_PTR(arg10));
     return Qnil;
 }
 VALUE
@@ -3228,11 +3228,11 @@
     if (type_size == -1 || format_size == -1)
         return Qnil;
     size = type_size*format_size*height*width*depth;
-    if (RSTRING(arg11)->len < size)
-        rb_raise(rb_eArgError, "string length:%d",RSTRING(arg11)->len);
+    if (RSTRING_LEN(arg11) < size)
+        rb_raise(rb_eArgError, "string length:%d",RSTRING_LEN(arg11));
     glTexSubImage3D( target, level, xoffset, yoffset, zoffset,
             width, height, depth,
-            format, type, RSTRING(arg11)->ptr);
+            format, type, RSTRING_PTR(arg11));
     return Qnil;
 }
 VALUE

