You are not logged in.

#1 2020-11-08 18:56:05

sshaikh
Member
Registered: 2019-07-03
Posts: 53

[SOLVED] Adding an include location to a build

I am trying to build a custom version of the xorgxrdp package otherwise provided here: https://aur.archlinux.org/packages/xorgxrdp/

I want to add the --enable-glamor flag to the ./configure command when building. I have managed to figure that out by downloading and editing the PKGBUILD from the AUR.

However this flag appears to introduce a dependency that isn't found:

  CC       rdpEgl.lo
rdpEgl.c:44:10: fatal error: drm_fourcc.h: No such file or directory
   44 | #include <drm_fourcc.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.

This file is actually available here:

/usr/include/libdrm/drm_fourcc.h

How can I provide this reference to the build? I've tried

CFLAGS="$CFLAGS -I/usr/include/libdrm" make

and even

alias gcc="gcc -I/usr/include/libdrm"

I've also tried editing the source directly but of course they get overwritten by the makepkg process.

My next attempt is to patch the source file (to #include <libdrm/drm_fourcc.h>) before making, but before I fall into that rabbit hole is there a better way/best practise for providing a compilation with the correct include locations?

Last edited by sshaikh (2020-11-08 23:36:30)

Offline

#2 2020-11-08 20:12:15

sshaikh
Member
Registered: 2019-07-03
Posts: 53

Re: [SOLVED] Adding an include location to a build

Unfortunately patching the source didn't work, as there were further related build errors. I did then try patching the Makefile and had some progress:

In file included from xrdpdri2.c:42:
/usr/include/xf86drm.h:40:10: fatal error: drm.h: No such file or directory
   40 | #include <drm.h>
      |          ^~~~~~~

This file appears to be in the same place as the previous one so I'm not sure why it's not being found now.

Last edited by sshaikh (2020-11-08 20:23:02)

Offline

#3 2020-11-08 20:24:24

loqs
Member
Registered: 2014-03-06
Posts: 17,199

Re: [SOLVED] Adding an include location to a build

Try without patching the source:

make EXTRA_FLAGS="-I/usr/include/libdrm"

Edit:
https://github.com/neutrinolabs/xorgxrd … ile.am#L21

Last edited by loqs (2020-11-08 20:26:52)

Offline

#4 2020-11-08 20:52:28

sshaikh
Member
Registered: 2019-07-03
Posts: 53

Re: [SOLVED] Adding an include location to a build

Perfect. That worked.

Just to cement my understanding:

1) Was EXTRA_FLAGS a guess? By convention or previous experience or something? Why should that affect what the compiler sees?
2) What's the significance of the code reference you posted? It adds things to EXTRA_FLAGS, but so what?
3) If EXTRA_FLAGS was set by the Makefile, then I understand this passing of parameter would clobber that. Does that mean we have to check the Makefile first? If so what do you do if EXTRA_FLAGS is used?

Offline

#5 2020-11-08 21:13:30

loqs
Member
Registered: 2014-03-06
Posts: 17,199

Re: [SOLVED] Adding an include location to a build

AM_CFLAGS is used to set the CFLAGS and that is set to:

AM_CFLAGS = \
  $(XORG_SERVER_CFLAGS) \
  $(XRDP_CFLAGS) \
  -DPACKAGE_VERSION_MAJOR=@package_version_major@ \
  -DPACKAGE_VERSION_MINOR=@package_version_minor@ \
  -DPACKAGE_VERSION_PATCHLEVEL=@package_version_patchlevel@ \
  -I$(top_srcdir)/module \
  $(EXTRA_FLAGS)

It does not contain $(XORG_SERVER_GLAMOR_CFLAGS) and the flags are not added in:

if WITH_GLAMOR
EXTRA_FLAGS += -DXORGXRDP_GLAMOR -DGLAMOR_FOR_XORG
EXTRA_SOURCES += rdpEgl.c
EXTRA_HEADERS += rdpEgl.h
EGLLIB += -lepoxy
endif

EXTRA_FLAGS is added to AM_CFLAGS and is set to nothing at the top of  xorgxrdp/module/Makefile.am so as a hack I suggested clobbering as an easy way to add an option to AM_CFLAGS.
You could modify Makefile.am to use XORG_SERVER_GLAMOR_CFLAGS instead.

Offline

#6 2020-11-08 21:44:25

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [SOLVED] Adding an include location to a build

You need to export CFLAGS="$CFLAGS -I/usr/include/libdrm" before running ./configure, not make.

This rule applies to all autotools  ./configure projects, and the similar rule applies for cmake or meson -- the $CFLAGS are picked up by the cmake/meson command to configure the build, not by the "make" or "ninja" command to execute the configured build.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#7 2020-11-08 23:36:00

sshaikh
Member
Registered: 2019-07-03
Posts: 53

Re: [SOLVED] Adding an include location to a build

eschwartz wrote:

You need to export CFLAGS="$CFLAGS -I/usr/include/libdrm" before running ./configure, not make.

This also worked and makes sense as the correct solution. My guess was that this would also overwrite the CFLAG variable set in the Makefile, but it seems that that wasn't the case. Thanks for the help.

Offline

#8 2020-11-08 23:46:06

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [SOLVED] Adding an include location to a build

configure-based projects, or meson/cmake ones, explicitly support the environment CFLAGS as different to the internal ones.

It's the plain Makefiles without a configure script you need to watch out for, because they might or might not overwrite the internal CFLAGS if you change the CFLAGS variable. Depends on how well they're written.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB