One more fix on this issue on parsing the headers.
X freeglut only if DISPLAY is set, otherwise use native w32api GLUT 
-- 
Reini Urban
difforig config/auto/opengl.pm lib/Parrot/Configure/Step/Methods.pm

header parsing: 
  need to match the linker logic. On cygwin without DISPLAY 
  leave out freeglut.

linking:
  same logic.
  revised to add -L/usr/X11R6/lib and /usr/bin/glut32.dll directly

Index: config/auto/opengl.pm
===================================================================
--- config/auto/opengl.pm.orig
+++ config/auto/opengl.pm
@@ -114,14 +114,16 @@ F<GLUT for Win32> (L<http://www.xmission
 
 The Cygwin/w32api for native opengl support
 
-F<-lglut32 -lglu32 -lopengl32>
-
+F<opengl>, F<w32api>
 
 =head3 Cygwin/X
 
 Requires a X server.
 
-F<freeglut>, F<libglut-devel>
+F<freeglut>, F<libglut-devel>, F<xorg-x11-devel>
+
+This is detected if freeglut is installed and DISPLAY is set.
+It requires an X server.
 
 =cut
 
@@ -168,24 +170,20 @@ sub runstep {
     my $osname = $conf->data->get_p5('OSNAME');
 
     # Prefer Cygwin/w32api over Cygwin/X, but use X when DISPLAY is set
-    if ($^O eq 'cygwin' and $ENV{DISPLAY}) {
-        $self->_add_to_libs( {
-            conf        => $conf,
-            osname      => $osname,
-            cc          => $cc,
-            cygwin      => '-lglut -L/usr/X11R6/lib -lGLU -lGL'
-        } )
-    }
-    else {
-        $self->_add_to_libs( {
+    $self->_add_to_libs( {
             conf            => $conf,
             osname          => $osname,
             cc              => $cc,
+            # Prefer Cygwin/w32api over Cygwin/X, but use X when DISPLAY is set
+            ($^O eq 'cygwin') ?
+             ($ENV{DISPLAY} ? (cygwin => '-lglut -L/usr/X11R6/lib -lGLU -lGL')
+                            : (cygwin => '/usr/bin/glut32.dll -lglu32 -lopengl32'))
+             : (),
             win32_gcc       => '-lglut32 -lglu32 -lopengl32',
             win32_nongcc    => 'opengl32.lib glu32.lib glut32.lib',
             darwin          => '-framework OpenGL -framework GLUT',
             default         => '-lglut -lGLU -lGL',
-    } ) };
+    } );
 
     # On OS X check the presence of the OpenGL headers in the standard
     # Fink/macports locations.
Index: lib/Parrot/Configure/Step/Methods.pm
===================================================================
--- lib/Parrot/Configure/Step/Methods.pm.orig
+++ lib/Parrot/Configure/Step/Methods.pm
@@ -119,6 +119,7 @@ sub _handle_darwin_for_macports {
         cc              => $cc,
         win32_gcc       => '-lalpha32 -lalpha32 -lopenalpha32',
         win32_nongcc    => 'alpha.lib',
+        cygwin          => '-lalpha32 -lXalpha32', # optional
         darwin          => 'alphadarwin.lib',
         default         => '-lalpha',
     } );
@@ -138,6 +139,8 @@ combinations.  We currently support sett
 
 =item * MSWin32 with any C-compiler other than F<gcc>.
 
+=item * Cygwin to override Mingw.
+
 =item * Darwin.
 
 =back
@@ -173,7 +176,7 @@ supersede the value in C<default>.
 
 =item * C<win32_gcc>
 
-Libraries to be added where OS is mswin32 and C-compiler is F<gcc>.
+Libraries to be added where OS is mswin32 or cygwin and C-compiler is F<gcc>.
 Single whitespace-delimited string.
 
 =item * C<win32_nongcc>
@@ -181,6 +184,12 @@ Single whitespace-delimited string.
 Libraries to be added where OS is mswin32 and C-compiler is not F<gcc>.
 Single whitespace-delimited string.
 
+=item * C<cygwin>
+
+Optional libraries to be added where OS is cygwin. This overrides C<win32_gcc>
+if defined.
+Single whitespace-delimited string.
+
 =item * C<darwin>
 
 Libraries to be added where OS is Darwin.  Do not supply a value if the value
@@ -197,7 +206,8 @@ sub _add_to_libs {
     my $args = shift;
     croak "_add_to_libs() takes hashref: $!" unless ref($args) eq 'HASH';
     my $platform =
-          (($args->{osname} =~ /mswin32/i ||
+           $args->{osname} =~ /cygwin/i      ? 'cygwin'
+        :(($args->{osname} =~ /mswin32/i ||
            $args->{osname} =~ /cygwin/i) &&
            $args->{cc} =~ /^gcc/i)          ? 'win32_gcc'
         :  $args->{osname} =~ /mswin32/i    ? 'win32_nongcc'
Index: config/gen/opengl.pm
===================================================================
--- config/gen/opengl.pm.orig
+++ config/gen/opengl.pm
@@ -447,6 +447,9 @@ sub runstep {
 #         "$ENV{HOME}/src/osx-insane/usr/X11R6 1/include/GL/*.h",
     );
 
+    # X freeglut only if DISPLAY is set, otherwise use native w32api GLUT
+    shift @header_globs if $^O eq 'cygwin' and !$ENV{DISPLAY};
+
     print "\nChecking for OpenGL headers using the following globs:\n\t",
         join("\n\t", @header_globs), "\n"
         if $verbose;

Reply via email to