Commit 095a7f4cf07e78016a5ba56a6f8e2d427ecc245a

David Herrmann 2012-09-11T16:49:04

xkbcommon-keysyms: Add header protection As there is currently no stable release of xkbcommon, other projects might want to include a copy of the keysyms so they can be used even though libxkbcommon may not be available on the machine. However, if xkbcommon.h is still included, conflicts will occur. Hence, to avoid nasty hacks, simply include a header protection in xkbcommon upstream. [daniels: Added protection to Makefile.am's update-keysyms, as well as XKB_KEY_NoSymbol, and a comment noting that it shouldn't be updated directly.] Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Daniel Stone <daniel@fooishbar.org>

diff --git a/Makefile.am b/Makefile.am
index bfe6c4f..b83d992 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -156,7 +156,11 @@ KEYSYMDEFS = \
 	 $(X11_INCLUDEDIR)/DECkeysym.h \
 	 $(X11_INCLUDEDIR)/HPkeysym.h
 update-keysyms:
-	sed -e '/XK_Ydiaeresis\s*0x100000ee/d; /#define _/d; s/#define\s*\(\w*\)XK_/#define XKB_KEY_\1/; /\(#ifdef\|#ifndef\|#endif\)/d' $(KEYSYMDEFS) > xkbcommon/xkbcommon-keysyms.h
+	echo -en '#ifndef _XKBCOMMON_KEYSYMS_H\n#define _XKBCOMMON_KEYSYMS_H\n\n' > $(top_srcdir)/xkbcommon/xkbcommon-keysyms.h
+	echo -en '/* This file is autogenerated from Makefile.am; please do not commit directly. */\n\n' >> $(top_srcdir)/xkbcommon/xkbcommon-keysyms.h
+	echo -en '#define XKB_KEY_NoSymbol                    0x000000  /* Special KeySym */\n\n' >> $(top_srcdir)/xkbcommon/xkbcommon-keysyms.h
+	sed -e '/XK_Ydiaeresis\s*0x100000ee/d; /#define _/d; s/#define\s*\(\w*\)XK_/#define XKB_KEY_\1/; /\(#ifdef\|#ifndef\|#endif\)/d' $(KEYSYMDEFS) >> $(top_srcdir)/xkbcommon/xkbcommon-keysyms.h
+	echo -en '\n\n#endif\n' >> $(top_srcdir)/xkbcommon/xkbcommon-keysyms.h
 
 # Android stuff
 
diff --git a/xkbcommon/xkbcommon-keysyms.h b/xkbcommon/xkbcommon-keysyms.h
index 2c1ab95..253ea59 100644
--- a/xkbcommon/xkbcommon-keysyms.h
+++ b/xkbcommon/xkbcommon-keysyms.h
@@ -1,3 +1,10 @@
+#ifndef _XKBCOMMON_KEYSYMS_H
+#define _XKBCOMMON_KEYSYMS_H
+
+/* This file is autogenerated from Makefile.am; please do not commit directly. */
+
+#define XKB_KEY_NoSymbol                    0x000000  /* Special KeySym */
+
 /***********************************************************
 Copyright 1987, 1994, 1998  The Open Group
 
@@ -112,7 +119,6 @@ SOFTWARE.
  *
  */
 
-#define XKB_KEY_NoSymbol                    0x000000  /* Special KeySym */
 #define XKB_KEY_VoidSymbol                  0xffffff  /* Void symbol */
 
 /*
@@ -2993,3 +2999,6 @@ performance, or use of this material.
 #define XKB_KEY_longminus            0x100000f6
 #define XKB_KEY_block                0x100000fc
 
+
+
+#endif