Skip to contentSkip to conversation

udev, input/linux.h and cross compilation

DISCUSSION Paul Bender 4 participants 7 messages Jan 20, 2010 – Jan 24, 2010

lore
Share & tools
lore
#0 lore raw

The top level Makefile.am hard codes /usr/include/linux/input.h for use in the generation of extras/keymap/keys.txt. Such hard coding does not work when cross compiling as the linux/input.h file that should be used is the cross environment's linux/include.h not /usr/include/linux/input.h.

I have attached a patch that determines the correct linux/include.h file during configure. The configure change makes use of the AX_ABOLUTE_HEADER http://www.nongnu.org/autoconf-archive/ax_absolute_header.html, which the patch adds to the m4.

#1 lore raw
Quoted 9 lines · Paul Bender

The top level Makefile.am hard codes /usr/include/linux/input.h for use in the generation of extras/keymap/keys.txt. Such hard coding does not work when cross compiling as the linux/input.h file that should be used is the cross environment's linux/include.h not /usr/include/linux/input.h.

I have attached a patch that determines the correct linux/include.h file during configure. The configure change makes use of the AX_ABOLUTE_HEADER
http://www.nongnu.org/autoconf-archive/ax_absolute_header.html, which the patch adds to the m4.

Why is all this magic needed? Can't you just use:
extras/keymap/keys.txt: $(includedir)/linux/input.h

Thanks,
Kay

#2 lore raw
In reply to Paul Bender
Quoted 11 lines · Kay Sievers
Quoted 9 lines · Paul Bender

The top level Makefile.am hard codes /usr/include/linux/input.h for use in the generation of extras/keymap/keys.txt. Such hard coding does not work when cross compiling as the linux/input.h file that should be used is the cross environment's linux/include.h not /usr/include/linux/input.h.

I have attached a patch that determines the correct linux/include.h file during configure. The configure change makes use of the AX_ABOLUTE_HEADER
http://www.nongnu.org/autoconf-archive/ax_absolute_header.html, which the patch adds to the m4.

Quoted 5 lines

Why is all this magic needed? Can't you just use:

   extras/keymap/keys.txt: $(includedir)/linux/input.h

Thanks,
Kay

Using ${includedir} is not sufficient because ${includedir} is in the run time path. The cross build files are installed in ${DESTDIR}${includedir} not ${includedir} on the build system.

For me, ${DESTDIR}${includedir} would be sufficient. However, I figured that depending on a detection macro used by (and therefore fixed for) multiple packages on multiple distributions was better than hard coding ${DESTDIR}${includedir}.

#3 lore raw
In reply to Paul Bender

Hello,

Paul Bender [2010-01-20 10:21 -0800]:

Quoted 5 lines

The top level Makefile.am hard codes /usr/include/linux/input.h for use in the generation of extras/keymap/keys.txt. Such hard coding does not work when cross compiling as the linux/input.h file that should be used is the cross environment's linux/include.h not /usr/include/linux/input.h.

Could we use

  $ echo '#include <linux/input.h>' | cpp -M | xargs -n1 | grep linux/input.h
  /usr/include/linux/input.h

to figure out the real path?

Martin

Signature · 2 lines
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
#4 lore raw
In reply to Paul Bender
Quoted 1 line · Martin Pitt

echo '#include<linux/input.h>' | cpp -M | xargs -n1 | grep linux/input.h

I believe that would work once cpp is replaced with $ac_cpp so that the correct cpp is used (the one pointed to by $CPP) and the correct cpp flags are used (the flags in $CPPFLAGS). However, it adds dependencies on grep and xargs, both of which would need to be tested for.

#5 lore raw
In reply to Paul Bender
Quoted 8 lines · Paul Bender
Quoted 2 lines · Martin Pitt

echo '#include<linux/input.h>' | cpp -M | xargs -n1 | grep linux/input.h

I believe that would work once cpp is replaced with $ac_cpp so that the correct cpp is used (the one pointed to by $CPP) and the correct cpp flags are used (the flags in $CPPFLAGS). However, it adds dependencies on grep and xargs, both of which would need to be tested for.

I'm pretty sure libtool is already using grep. However, here's an alternative just using sed:

echo '#include <linux/input.h>' | cpp -M | sed -n
'/linux\/input.h/s,.* \(.*linux/input.h\).*,\1,p'

--
Dan

#6 lore raw
In reply to Paul Bender
Quoted 10 lines · Dan Nicholson
Quoted 8 lines · Paul Bender
Quoted 2 lines · Martin Pitt

echo '#include<linux/input.h>' | cpp -M | xargs -n1 | grep linux/input.h

I believe that would work once cpp is replaced with $ac_cpp so that the correct cpp is used (the one pointed to by $CPP) and the correct cpp flags are used (the flags in $CPPFLAGS). However, it adds dependencies on grep and xargs, both of which would need to be tested for.

Quoted 5 lines

I'm pretty sure libtool is already using grep. However, here's an alternative just using sed:

echo '#include <linux/input.h>' | cpp -M | sed -n
'/linux\/input.h/s,.* \(.*linux/input.h\).*,\1,p'

Yeah, looks fine. I ended up with:

  $ echo '#include <linux/errno.h>'| \
    cpp -E| \
    sed '/linux\/errno.h/!d; s:.*"\(.*\)/linux/errno.h".*:\1:; /.*/q'
  /usr/include

to find the prefix for the current system include we can use in the Makefile.

Kay