[perl #57006] [PATCH] add cygwin opengl config quirks

2008-08-19 Thread Reini Urban via RT
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 (L
-
+F, F
 
 =head3 Cygwin/X
 
 Requires a X server.
 
-F, F
+F, F, F
+
+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.
 
+=item * Cygwin to override Mingw.
+
 =item * Darwin.
 
 =back
@@ -173,7 +176,7 @@ supersede the value in C.
 
 =item * C
 
-Libraries to be added where OS is mswin32 and C-compiler is F.
+Libraries to be added where OS is mswin32 or cygwin and C-compiler is F.
 Single whitespace-delimited string.
 
 =item * C
@@ -181,6 +184,12 @@ Single whitespace-delimited string.
 Libraries to be added where OS is mswin32 and C-compiler is not F.
 Single whitespace-delimited string.
 
+=item * C
+
+Optional libraries to be added where OS is cygwin. This overrides C
+if defined.
+Single whitespace-delimited string.
+
 =item * C
 
 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;


Re: [perl #57006] [PATCH] add cygwin opengl config quirks

2008-07-17 Thread Geoffrey Broadwell
On Thu, 2008-07-17 at 22:50 +0200, Reini Urban wrote:
> The problem I had with the w32api libs was -lglut32. with linking 
> directly to the dll /usr/bin/glut32.dll everything works fine, and I'll 
> get rid of freeglut as default.

I'm not sure I understand what you meant here.

> Now I only have to find out whatÄs wrong with that importlib, then I 
> send the revised patch. for now it is:

I'm fine with the patch conceptually, but some details:

> --- origsrc/parrot-0.6.4/config/auto/opengl.pm2008-06-02 
> 
> -
>   =head3 MSVC
> 
> -
>   =head3 MinGW

I find it easier to read raw POD with two lines of blank above headers;
please don't remove these.  :-)

> +=head3 Cygwin/w32api
> 
> -=head3 cygwin
> +The Cygwin/w32api for native opengl support
> 
> - : No details yet
> +F<-lglut32 -lglu32 -lopengl32>

These should be replaced with the actual package names you need to
install (w32api, opengl, ...?)

> +Requires a X server.

In this case, use 'an' instead of 'a'.

Also note that Coke had discussed moving this kind of optional library
requirements documentation to a separate file in docs/ -- if that is
done, then most of the POD from this file can be moved there, leaving
just a stub with a link to make the file in docs/ easy to find.

> +# Prefer Cygwin/w32api over Cygwin/X, but use X when DISPLAY is set

How about:

# Prefer Cygwin/w32api over Cygwin/X unless DISPLAY is set

> + cygwin  => '-lglut -L/usr/X11R6/lib -lGLU -lGL'

Why not just use 'win32_gcc' here?  Otherwise, it's not clear below how
this relates to win32_gcc in the non-X case.

> +} ) } else {

Please uncuddle that else.  :-)

Thanks for your work on this, rurban!


-'f




Re: [perl #57006] [PATCH] add cygwin opengl config quirks

2008-07-17 Thread Reini Urban

Donald Hunter via RT schrieb:

Sorry rurban, this patch will break on my cygwin installation. I think
the problem is caused by more than an assumption that "mingw eq cygwin".
The real problem is that Cygwin hosts three flavours of library for
OpenGL: mingw, cygwin/w32api, cygwin/X11.

All your patch does is switch from Cygwin/w32api to Cygwin/X11.
Please see rt#56628 for more details.


Ah thanks. I missed your recent common on this.
http://rt.perl.org/rt3/Public/Bug/Display.html?id=56628

The problem I had with the w32api libs was -lglut32. with linking 
directly to the dll /usr/bin/glut32.dll everything works fine, and I'll 
get rid of freeglut as default.


Now I only have to find out whatÄs wrong with that importlib, then I 
send the revised patch. for now it is:


--- origsrc/parrot-0.6.4/config/auto/opengl.pm	2008-06-02 
17:35:05.0 +
+++ src/parrot-0.6.4/config/auto/opengl.pm	2008-07-17 19:14:11.0 
+

@@ -89,7 +89,6 @@
 On Windows, Parrot supports three different compiler environments, each of
 which has different requirements for OpenGL support:

-
 =head3 MSVC

 =over 4
@@ -104,16 +103,21 @@

 =back

-
 =head3 MinGW

  : No details yet

+=head3 Cygwin/w32api

-=head3 cygwin
+The Cygwin/w32api for native opengl support

- : No details yet
+F<-lglut32 -lglu32 -lopengl32>
+
+=head3 Cygwin/X
+
+Requires a X server.

+F, F

 =cut

@@ -159,15 +163,23 @@

 my $osname = $conf->data->get_p5('OSNAME');

-$self->_add_to_libs( {
-conf=> $conf,
-osname  => $osname,
-cc  => $cc,
-win32_gcc   => '-lglut32 -lglu32 -lopengl32',
-win32_nongcc=> 'opengl32.lib glu32.lib glut32.lib',
-darwin  => '-framework OpenGL -framework GLUT',
-default => '-lglut -lGLU -lGL',
-} );
+# 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( {
+   conf=> $conf,
+osname  => $osname,
+cc  => $cc,
+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.



[perl #57006] [PATCH] add cygwin opengl config quirks

2008-07-16 Thread via RT
# New Ticket Created by  Reini Urban 
# Please include the string:  [perl #57006]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=57006 >


---
osname= cygwin
osvers= 1.5.25(0.15642)
arch=   cygwin-thread-multi-64int
cc= gcc
---
Flags:
 category=core
 severity=medium
 ack=no
---

Attached patch adds a new cygwin option to 
Parrot::Configure::Step::Methods::_add_to_libs()
to support a cygwin override over the
"interesting" assumption that mingw eq cygwin library wise.

And it fixes the opengl compilation on non-existing mingw libs, which is 
the unfortunate general on cygwin.

---
Summary of my parrot 0.6.4 (r0) configuration:
   configdate='Wed Jul 16 18:18:25 2008 GMT'
   Platform:
 osname=cygwin, archname=cygwin-thread-multi-64int
 jitcapable=1, jitarchname=i386-cygwin,
 jitosname=CYGWIN, jitcpuarch=i386
 execcapable=1
 perl=/usr/bin/perl.exe
   Compiler:
 cc='gcc', ccflags='-U__STRICT_ANSI__  -pipe -I/usr/local/include 
-DHASATTRIBUTE_CONST  -DHASATTRIBUTE_DEPRECATED  -DHASATTRIBUTE_MALLOC 
-DHASATTRIBUTE_NONNULL  -DHASATTRIBUTE_NORETURN  -DHASATTRIBUTE_PURE 
-DHASATTRIBUTE_UNUSED  -DHASATTRIBUTE_WARN_UNUSED_RESULT 
-falign-functions=16 -maccumulate-outgoing-args -W -Wall 
-Waggregate-return -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment 
-Wdisabled-optimization -Wendif-labels -Wextra -Wformat 
-Wformat-extra-args -Wformat-nonliteral -Wformat-security -Wformat-y2k 
-Wimplicit -Wimport -Winit-self -Winline -Winvalid-pch -Wmissing-braces 
-Wno-missing-format-attribute -Wpacked -Wparentheses -Wpointer-arith 
-Wreturn-type -Wsequence-point -Wno-shadow -Wsign-compare 
-Wstrict-aliasing -Wstrict-aliasing=2 -Wswitch -Wswitch-default 
-Wtrigraphs -Wundef -Wunknown-pragmas -Wno-unused -Wwrite-strings 
-Wbad-function-cast -Wdeclaration-after-statement 
-Wimplicit-function-declaration -Wimplicit-int -Wmain 
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wnonnull 
-DDISABLE_GC_DEBUG=1 -DNDEBUG -O3 -DHAS_GETTEXT',
   Linker and Libraries:
 ld='gcc', ldflags=' -Wl,--enable-auto-import 
-Wl,--export-all-symbols -Wl,--stack,8388608 
-Wl,--enable-auto-image-base -L/usr/local/lib',
 cc_ldflags='',
 libs='-ldl -lcrypt -lgmp -lreadline -lpcre -lglut -lGLU -lGL 
-lcrypto -lintl'
   Dynamic Linking:
 share_ext='.dll', ld_share_flags='-shared',
 load_ext='.dll', ld_load_flags='-shared'
   Types:
 iv=long, intvalsize=4, intsize=4, opcode_t=long, opcode_t_size=4,
 ptrsize=4, ptr_alignment=1 byteorder=1234,
 nv=double, numvalsize=8, doublesize=8

---
Environment:
 CYGWIN =server
 HOME =/home/rurban
 LANG  (unset)
 LANGUAGE  (unset)
 LD_LIBRARY_PATH  (unset)
 LOGDIR  (unset)
 PATH
=/usr/src/perl/parrot/parrot-0.6.3-1/build/blib/lib:~/bin:/usr/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/usr/bin:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/Programme/ATI
 


Technologies/ATI.ACE/Core-Static:/usr/local/bin:/usr/lib/gstreamer-0.8:/usr/lib/lapack
 SHELL  (unset)



difforig config/auto/opengl.pm lib/Parrot/Configure/Step/Methods.pm

diff -u config/auto/opengl.pm.orig config/auto/opengl.pm
--- config/auto/opengl.pm.orig	2008-06-02 17:35:05.0 +
+++ config/auto/opengl.pm	2008-07-16 18:52:29.90625 +
@@ -110,10 +110,13 @@
  : No details yet
 
 
-=head3 cygwin
+=head3 cygwin/X
 
- : No details yet
+F, F
 
+The mingw packages for native opengl support will also work,
+but then you will need the mingw headers and libs
+-lglut32 -lglu32 -lopengl32
 
 =cut
 
@@ -166,6 +169,7 @@
 win32_gcc   => '-lglut32 -lglu32 -lopengl32',
 win32_nongcc=> 'opengl32.lib glu32.lib glut32.lib',
 darwin  => '-framework OpenGL -framework GLUT',
+	cygwin  => '-lglut -lGLU -lGL',
 default => '-lglut -lGLU -lGL',
 } );
 
diff -u lib/Parrot/Configure/Step/Methods.pm.orig lib/Parrot/Configure/Step/Methods.pm
--- lib/Parrot/Configure/Step/Methods.pm.orig	2008-06-24 19:59:15.0 +
+++ lib/Parrot/Configure/Step/Methods.pm	2008-07-16 19:01:24.078125000 +
@@ -119,6 +119,7 @@
 cc  => $cc,
 win32_gcc   => '-lalpha32 -lalpha32 -lopenalpha32',
 win32_nongcc=> 'alpha.lib',
+cygwin  => '-lalpha32 -lXalpha32', # optional
 darwin  => 'alphadarwin.lib',
 default => '-lalpha',
 } );
@@ -138,6 +139,8 @@
 
 =item * MSWin32 with any C-compiler other than F.
 
+=item * Cygwin to override Mingw.
+
 =item * Darwin.
 
 =back
@@ -173,7 +176,7 @@
 
 =item * C
 
-Libraries to be added where OS is mswin32 and C-compiler is F.
+Libraries to be added where OS is mswin32 or cygwin and C-compiler is F.
 Single whitespace-delimited string.
 
 =item * C
@@ -181,6 +184,12 @@
 Libraries to be added where OS is mswin32 and C-compile