Re: [PATCH v3 1/5] drm: Add config for detecting libdrm

Patrik Jakobsson
2015-07-31T09:09:05Z

On Thu, Jul 30, 2015 at 10:04:49AM -0400, Mike Frysinger wrote:
> On 30 Jul 2015 15:30, Patrik Jakobsson wrote:
> > On Thu, Jul 23, 2015 at 05:48:21AM -0400, Mike Frysinger wrote:
> > > On 01 Jul 2015 14:52, Patrik Jakobsson wrote:
> > > > Use pkg-config to try to find libdrm. If that fails use the standard
> > > > include directory for kernel drm headers in /usr/include/drm.
> > > >
> > > > * configure.ac: Use pkg-config to find libdrm
> > > >
> > > > Signed-off-by: Patrik Jakobsson <patrik.jakobsson@linux.intel.com>
> > > > ---
> > > > configure.ac | 4 ++++
> > > > 1 file changed, 4 insertions(+)
> > > >
> > > > diff --git a/configure.ac b/configure.ac
> > > > index bb8bf46..aa63af7 100644
> > > > --- a/configure.ac
> > > > +++ b/configure.ac
> > > > @@ -844,6 +844,10 @@ fi
> > > > AM_CONDITIONAL([USE_LIBUNWIND], [test "x$use_libunwind" = xyes])
> > > > AC_MSG_RESULT([$use_libunwind])
> > > >
> > > > +PKG_CHECK_MODULES([libdrm], [libdrm],
> > > > + [CPPFLAGS="$CPPFLAGS $libdrm_CFLAGS"],
> > > > + [CPPFLAGS="$CPPFLAGS -I/usr/include/drm"])
> > >
> > > yikes, no, this is a really really bad idea. it should read:
> > > PKG_CHECK_MODULES([LIBDRM], [libdrm],
> > > [CPPFLAGS="$CPPFLAGS $LIBDRM_CFLAGS"], [:])
> >
> > I take it you don't want me to fallback on kernel headers and skip
> > compiling with drm support if libdrm is not available?
>
> you cannot hardcode any path at all. if the kernel headers provide all
> of the defines/structs that you need, then just include them directly
> via #include <drm/xxx.h>.
> -mike

The prefered "drm way" is to always use the libdrm headers and never the kernel
headers. I know this is breaking the rules but it's what we got to work with.
Some distros give you the kernel version and others the libdrm version. The
kernel version is wrong and libdrm patches this up since we're not allowed to
break the userspace interface. I think the safest way would be to only compile
drm support for strace if libdrm is present and ignore the kernel headers.

What do you think?

Cheers
Patrik