Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 539836 - media-libs/glfw should depend on X11 packages only for UNIX systems (non-WIN32 & non-APPLE)
Summary: media-libs/glfw should depend on X11 packages only for UNIX systems (non-WIN3...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Games
Depends on:
Reported: 2015-02-12 00:37 UTC by tschwinger
Modified: 2017-04-29 09:55 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---

Have dependencies depend on the X USE-flag and set it by default (glfw-3.0.4-r666.diff,531 bytes, patch)
2015-02-12 00:38 UTC, tschwinger
Details | Diff
Revised patch (glfw-3.0.4-r666.diff,513 bytes, patch)
2015-02-14 11:27 UTC, tschwinger
Details | Diff
Patched ebuild (glfw-3.0.4-r666.ebuild,807 bytes, text/plain)
2015-02-14 11:27 UTC, tschwinger

Note You need to log in before you can comment on or make changes to this bug.
Description tschwinger 2015-02-12 00:37:05 UTC
The library can build fine in cross-environment, but the ebuild insist on X11. Checking the USE-flag resolves the issue.

Reproducible: Always

Steps to Reproduce:
1.emerge the library targeting x86_64-w64-mingw32
Actual Results:  
Portage tries to build X.

Expected Results:  
Portage just builds the library in the target environment.

The library does not just support Windows but also EGL-enabled platforms.
Comment 1 tschwinger 2015-02-12 00:38:14 UTC
Created attachment 396222 [details, diff]
Have dependencies depend on the X USE-flag and set it by default
Comment 2 tschwinger 2015-02-12 00:38:55 UTC
CC to apparent ebuild maintainer
Comment 3 Mr. Bones. (RETIRED) gentoo-dev 2015-02-13 09:05:44 UTC
Just changing deps without changing something in src_configure is almost always a sign that something's wrong.  In this case, even with USE="-X" the library is built against the X11 stuff if it's available which is not allowed since it makes the dep automagical.  Further patching of the build scripts is necessary if you want to be able to make X optional.  I suggest coordinating with upstream to make the build scripts support what you're trying to do.
Comment 4 tschwinger 2015-02-13 16:11:47 UTC
Upstream build script does certainly support it. We're talking about a cross platform library:

The dependency is the only reason why you can't cross-compile to library to native Windows or embedded targets (in these cases running on platform default libs or EGL, respectively).
Comment 5 Mr. Bones. (RETIRED) gentoo-dev 2015-02-13 16:49:58 UTC
In order for the patch to the ebuild to be ok it would have to result in a package that didn't depend on X when built with USE="-X", even if X is installed.  That's not what happens.  If I apply your patch and build the package with USE="-X" the build system finds that X is installed and builds against it resulting in an implicit dependency.
Comment 6 tschwinger 2015-02-13 17:38:34 UTC
OK, this time it's easier to understand.
I had figured that out rereading your earlier post - excuse my too quick reply. 

It appears the libarary actually does have a hard dependency on X11 on UNIX. So all that's left to do is to detect whether we're cross-compiling to Windows or OSX for now.

There should be USE-flags (at least for Windows) somewhere. Searching...
Comment 7 Mr. Bones. (RETIRED) gentoo-dev 2015-02-13 18:08:26 UTC
maybe someone from toolchain has tips
Comment 8 tschwinger 2015-02-13 18:26:37 UTC
Could say

    !x86-winnt? ( !x64-winnt? ( !x86-macos? ( !x64-macos? ( <X-libs> ) ) ) )

but it looks awkward and maybe there's a nicer way of expressing the same thing.

Also 'x64-winnt' appears to be missing in /usr/portage/profiles/arch.list, so I had to add it in IUSE as a workaround (I have such a profile in my local overlay, but its 'arch.list' apparently gets ignored).
Comment 9 SpanKY gentoo-dev 2015-02-14 04:22:29 UTC
yes, the cmake logic is a bit of a mess -- look for the "Detect and select backend APIs" section

arch lists isn't the way to go.  the kernel_xxx or elibc_xxx flags are probably the closest you'd get, but even that isn't terribly accurate.  the prefix team might have a better suggestion as to what they've been using in cases like this.
Comment 10 tschwinger 2015-02-14 10:51:27 UTC

    REQUIRED_USE="!elibc_Winnt? ( !kernel_Darwin? ( X ) )"

to the original patch should do the trick, no?

Grepping over /usr/portage shows that the common way of detecting those platforms is oddly inconsistent. In particular there are no matches for 'kernel_Winnt', which would seem the more appropriate way of expressing a dependency on the platform.
Actually I would expect seeing things like elibc_msvcrt and elibc_mingw (and someone may know another libc that works on Windows) by common sense.

I remember seeing 'kernel_Winnt' before, somewhere. Also it's in my overlay profile, which is based on 'prefix' in a state of several months ago and I can't remember inventing it...

Did it get removed? Is it another issue? Anyone have a clue?
Comment 11 tschwinger 2015-02-14 11:18:42 UTC
No. OSX/Windows platforms won't respect 'X' USE-flag then. I'm learning :)

    $(cmake-utils_use !X _GLFW_COCOA=no _GLFW_NSGL=no 
                         _GLFW_WIN32=no _GLFW_WGL=no 
                         _GLFW_X11=yes _GLFW_GLX=yes)

Just kidding.
Comment 12 tschwinger 2015-02-14 11:27:12 UTC
Created attachment 396442 [details, diff]
Revised patch
Comment 13 tschwinger 2015-02-14 11:27:50 UTC
Created attachment 396444 [details]
Patched ebuild
Comment 14 tschwinger 2015-02-14 12:02:20 UTC
The patch optimistically contains 'kernel_Winnt'. Would be great if someone could shed some light on its status - else just s/kernel_W/elibc_W/.

Also notified upstream for the Cmake side of the story. There should ideally be choice options to select APIs for windowing and graphics that will override the auto detection.
Comment 15 Mr. Bones. (RETIRED) gentoo-dev 2016-04-25 16:17:56 UTC
prefix happy with the latest patch or is there a better way?
Comment 16 Michael Haubenwallner gentoo-dev 2016-04-25 19:36:57 UTC
As Cygwin (at least in theory, not sure about practice, nor about our preference yet) does support both X11 and Win32-UI, question is whether glfw takes Cygwin as Unix or Win32.

This also feels related to

I can imagine something like:
  IUSE="... aqua w32ui +X"
  RDEPEND="... X? ( x11-libs/libX... )"
  REQUIRED_USE="^^ ( aqua w32ui X )"

Agreed the build system should be forced to either use the selected UI, or yell about the selected UI to be unsupported.

But as Cygwin is in very early state still, I do not really care yet.