Skip to contentSkip to conversation

extras/keymap: fix build (GEN keys.txt)

PATCH In review Alan Jenkins 5 participants 10 messages Oct 29, 2009 – Oct 30, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 extras/keymap: fix build (GEN keys.txt)

Commit 7d701b0 "Merge keymap building in the top-level Makefile.am" caused a build failure when extras are enabled.

Specifically, it changed the command used to generate keys.txt in several ways. The most obvious change was that the output was completely empty :). This was probably missed due to stale Makefiles. Hint: to reproduce the build failure, first run "make distclean".

Fix the generation of keys.txt by reverting to the original command.

Also add some dependencies on the Makefile. This means keys.txt will be rebuilt automatically if the command is changed in future.

Build tested only. I don't use udev-keymap, so it would a good idea for someone who does to test it (Diego?) :).

CC Diego Elio 'Flameeyes' Pettenò <[email protected]>
---
 Makefile.am |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
Makefile.am +3 -3
index cf7d364..a439157 100644
@@ -530,10 +530,10 @@ dist_udevkeymap_DATA = \
 	extras/keymap/keymaps/toshiba-satellite_a110 \
 	extras/keymap/keymaps/zepto-znote
 
-extras/keymap/keys.txt: /usr/include/linux/input.h
-	$(AM_V_GEN)$(AWK) '/^#define.*KEY_[^ ]+[[:space:]]+[0-9]/ { if ($$2 != "KEY_MAX") { print $$2 } }' < $< | sed 's/^KEY_COFFEE$$/KEY_SCREENLOCK/' > $@
+extras/keymap/keys.txt: /usr/include/linux/input.h Makefile
+	$(AM_V_GEN)$(AWK) '/^#define.*KEY_/ { if ($$2 != "KEY_MAX" && $$2 != "KEY_CNT") { print $$2 } }' < $< > $@
 
-extras/keymap/keys-from-name.gperf: extras/keymap/keys.txt
+extras/keymap/keys-from-name.gperf: extras/keymap/keys.txt Makefile
 	$(AM_V_GEN)$(AWK) 'BEGIN{ print "struct key { const char* name; unsigned short id; };"; print "%null-strings"; print "%%";} { print $$1 ", " $$1 }' < $< > $@
 
 extras/keymap/keys-from-name.h: extras/keymap/keys-from-name.gperf Makefile
Signature · 1 line
1.5.6.5
#1 lore raw
Quoted 9 lines · Alan Jenkins

Commit 7d701b0 "Merge keymap building in the top-level Makefile.am" caused a build failure when extras are enabled.

Fix the generation of keys.txt by reverting to the original command.

Makefile.am +2 -2
-extras/keymap/keys.txt: /usr/include/linux/input.h
-	$(AM_V_GEN)$(AWK) '/^#define.*KEY_[^ ]+[[:space:]]+[0-9]/ { if ($$2 != "KEY_MAX") { print $$2 } }' < $< | sed 's/^KEY_COFFEE$$/KEY_SCREENLOCK/' > $@
+extras/keymap/keys.txt: /usr/include/linux/input.h Makefile
+	$(AM_V_GEN)$(AWK) '/^#define.*KEY_/ { if ($$2 != "KEY_MAX" &&

$$2 != "KEY_CNT") { print $$2 } }' < $< > $@

The s/^KEY_COFFEE$$/KEY_SCREENLOCK/ you dropped here actually matters. It needs to be kept.

Lennart

Signature · 3 lines
Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/           GnuPG 0x1A015CC4
#2 lore raw
In reply to Alan Jenkins
Quoted 6 lines · Lennart Poettering
Quoted 3 lines · Alan Jenkins

Commit 7d701b0 "Merge keymap building in the top-level Makefile.am" caused a build failure when extras are enabled.

Quoted 11 lines
Quoted 7 lines

Fix the generation of keys.txt by reverting to the original command.

Makefile.am +2 -2
-extras/keymap/keys.txt: /usr/include/linux/input.h
-	$(AM_V_GEN)$(AWK) '/^#define.*KEY_[^ ]+[[:space:]]+[0-9]/ { if ($$2 != "KEY_MAX") { print $$2 } }' < $< | sed 's/^KEY_COFFEE$$/KEY_SCREENLOCK/' > $@
+extras/keymap/keys.txt: /usr/include/linux/input.h Makefile
+	$(AM_V_GEN)$(AWK) '/^#define.*KEY_/ { if ($$2 != "KEY_MAX" &&

$$2 != "KEY_CNT") { print $$2 } }' < $< > $@

The s/^KEY_COFFEE$$/KEY_SCREENLOCK/ you dropped here actually matters. It needs to be kept.

I'm not dropping anything that was ever used, or which ever worked, at least within the main udev tree :-P. This patch just reverts to the last known working version of the command.

I would suggest applying any necessary changes as separate commits. Sorry for not being more explicit about this in the first place :).

Note that this specific sed command doesn't seem to work for my system:

GEN extras/keymap/keys-from-name.gperf
GEN extras/keymap/keys-from-name.h
Key link: "KEY_SCREENLOCK" = "KEY_SCREENLOCK", with key set "cekss". 1 input keys have identical hash values,
use option -D.
make: *** [extras/keymap/keys-from-name.h] Error 1

This is with /usr/include/linux/input.h as provided by debian "linux-libc-dev-2.6.30-8".

Thanks
Alan

#3 lore raw
In reply to Alan Jenkins

Hello Alan,

Alan Jenkins [2009-10-29 14:27 +0000]:

Quoted 4 lines

Specifically, it changed the command used to generate keys.txt in several ways. The most obvious change was that the output was completely empty :). This was probably missed due to stale Makefiles. Hint: to reproduce the build failure, first run "make distclean".

Hm, I'm autoreconfing and/or rebuilding the udev tree all the time, without problems. We also have this in our packages in Ubuntu, and it produces valid and working files.
Can you please give some precise steps how it fails?

Makefile.am dist_udevkeymap_DATA = \ · line 534

Quoted 2 lines
Makefile.am +1 -1
-     $(AM_V_GEN)$(AWK) '/^#define.*KEY_[^ ]+[[:space:]]+[0-9]/ { if ($$2 != "KEY_MAX") { print $$2 } }' < $< | sed 's/^KEY_COFFEE$$/KEY_SCREENLOCK/' > $@
+	$(AM_V_GEN)$(AWK) '/^#define.*KEY_/ { if ($$2 != "KEY_MAX" && $$2 != "KEY_CNT") { print $$2 } }' < $< > $@

As Lennart already pointed out, the COFFEE->SCREENLOCK sed is important to not break existing keymaps (commit 7f06ec2e19). Also, your change drops the check that it's a real key definition instead of an alias definition, and thus generates duplicate hash values. That wasn't changed in the move to single top-level Makefile.am, but was an explicit bug fix (commit 6983c0d0f).

Makefile.am dist_udevkeymap_DATA = \ · line 536

Quoted 5 lines
Makefile.am +2 -2
-extras/keymap/keys.txt: /usr/include/linux/input.h
+extras/keymap/keys.txt: /usr/include/linux/input.h Makefile
 
-extras/keymap/keys-from-name.gperf: extras/keymap/keys.txt
+extras/keymap/keys-from-name.gperf: extras/keymap/keys.txt Makefile

Why is that necessary? You shouldn't change the Makefile manually, it should at most depend on Makefile.am changes (but even that is not necessary since it just calls gperf, which doesn't care about any other file in the tree).

Thanks,

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 Alan Jenkins
Quoted 10 lines · Martin Pitt

Hello Alan,

Alan Jenkins [2009-10-29 14:27 +0000]:

Quoted 5 lines

Specifically, it changed the command used to generate keys.txt in several ways. The most obvious change was that the output was completely empty :). This was probably missed due to stale Makefiles. Hint: to reproduce the build failure, first run "make distclean".

Quoted 5 lines

Hm, I'm autoreconfing and/or rebuilding the udev tree all the time, without problems. We also have this in our packages in Ubuntu, and it produces valid and working files.
Can you please give some precise steps how it fails?

Yup. I tried cloning and building a fresh checkout (./autogen.sh; make), and it failed with the same problem.

Quoted 27 lines

Makefile.am dist_udevkeymap_DATA = \ · line 534

Quoted 4 lines
Makefile.am +1 -1
-     $(AM_V_GEN)$(AWK) '/^#define.*KEY_[^ ]+[[:space:]]+[0-9]/ { if ($$2 != "KEY_MAX") { print $$2 } }' < $< | sed 's/^KEY_COFFEE$$/KEY_SCREENLOCK/' > $@
+	$(AM_V_GEN)$(AWK) '/^#define.*KEY_/ { if ($$2 != "KEY_MAX" && $$2 != "KEY_CNT") { print $$2 } }' < $< > $@

As Lennart already pointed out, the COFFEE->SCREENLOCK sed is important to not break existing keymaps (commit 7f06ec2e19). Also, your change drops the check that it's a real key definition instead of an alias definition, and thus generates duplicate hash values. That wasn't changed in the move to single top-level Makefile.am, but was an explicit bug fix (commit 6983c0d0f).

Makefile.am dist_udevkeymap_DATA = \

Quoted 8 lines
Makefile.am +2 -2
-extras/keymap/keys.txt: /usr/include/linux/input.h
+extras/keymap/keys.txt: /usr/include/linux/input.h Makefile
 
 
 
-extras/keymap/keys-from-name.gperf: extras/keymap/keys.txt
+extras/keymap/keys-from-name.gperf: extras/keymap/keys.txt Makefile

Why is that necessary? You shouldn't change the Makefile manually, it should at most depend on Makefile.am changes (but even that is not necessary since it just calls gperf, which doesn't care about any other file in the tree).

Quoted 4 lines

Thanks,

Martin

Thanks for the corrections Martin. Looks like the real problem is my awk doesn't grok "[[:space:]]".

$ awk '/^#define.*KEY_[^ ]+[[:space:]]+[0-9]/ { if ($2 != "KEY_MAX") { 
print $2 } }' < /usr/include/linux/input.h
$
$ awk '/^#define.*KEY_[^ ]+[[:space:]]/ { if ($2 != "KEY_MAX") { print 
$2 } }' < /usr/include/linux/input.h
$
$ awk '/^#define.*KEY_[^ ]+/ { if ($2 != "KEY_MAX") { print $2 } }' < 
/usr/include/linux/input.h
KEY_RESERVED
KEY_ESC
KEY_1
...

My awk package is mawk-1.3.3-11.1.

Thanks again
Alan

#5 lore raw
In reply to Alan Jenkins

Il giorno Thu, 29/10/2009 alle 20.10 +0000, Alan Jenkins ha scritto:

Quoted 7 lines

Thanks for the corrections Martin. Looks like the real problem is my awk doesn't grok "[[:space:]]".

My awk package is mawk-1.3.3-11.1.

Heh, no wonder then, [[:space:]] is a GNU regexp extension, which is thus only available on GNU awk (gawk); who's going to choose between checking for gawk explicitly or make it use a generic regexp?

Signature · 5 lines
Diego Elio Pettenò — “Flameeyes”
http://blog.flameeyes.eu/

If you found a .asc file in this mail and know not what it is,
it's a GnuPG digital signature: http://www.gnupg.org/
#6 lore raw
In reply to Alan Jenkins
Quoted 11 lines · Diego Elio “Flameeyes”

Il giorno Thu, 29/10/2009 alle 20.10 +0000, Alan Jenkins ha scritto:

Quoted 7 lines

Thanks for the corrections Martin.  Looks like the real problem is my awk doesn't grok "[[:space:]]".

My awk package is mawk-1.3.3-11.1.

Heh, no wonder then, [[:space:]] is a GNU regexp extension, which is thus only available on GNU awk (gawk); who's going to choose between checking for gawk explicitly or make it use a generic regexp?

gawk(1) says that the character classes are a POSIX extension, but whatever. Isn't [ \t] equivalent for this case? That works on my system running gawk with --traditional, but I don't have mawk.

--
Dan

#7 lore raw
In reply to Alan Jenkins

Il giorno Thu, 29/10/2009 alle 13.40 -0700, Dan Nicholson ha scritto:

Quoted 4 lines

gawk(1) says that the character classes are a POSIX extension, but whatever. Isn't [ \t] equivalent for this case? That works on my system running gawk with --traditional, but I don't have mawk.

Ehm yes I noticed now, I thought it was GNU-specific, my bad sorry!

Signature · 5 lines
Diego Elio Pettenò — “Flameeyes”
http://blog.flameeyes.eu/

If you found a .asc file in this mail and know not what it is,
it's a GnuPG digital signature: http://www.gnupg.org/
#8 lore raw
In reply to Alan Jenkins
Quoted 6 lines · Diego Elio “Flameeyes” Pettenò

Il giorno Thu, 29/10/2009 alle 13.40 -0700, Dan Nicholson ha scritto:

Quoted 4 lines

gawk(1) says that the character classes are a POSIX extension, but whatever. Isn't [ \t] equivalent for this case? That works on my system running gawk with --traditional, but I don't have mawk.

Yes, that works fine for mawk.

Thanks
Alan