build: move custom targets to scripts/ and remove from makefile
[platform/upstream/libxkbcommon.git] / scripts / makeheader
1 #!/usr/bin/env python
2
3 from __future__ import print_function
4 import re
5
6
7 HEADERS = [
8     '/usr/include/X11/keysymdef.h',
9     '/usr/include/X11/XF86keysym.h',
10     '/usr/include/X11/Sunkeysym.h',
11     '/usr/include/X11/DECkeysym.h',
12     '/usr/include/X11/HPkeysym.h',
13 ]
14
15 print('''#ifndef _XKBCOMMON_KEYSYMS_H
16 #define _XKBCOMMON_KEYSYMS_H
17
18 /* This file is autogenerated; please do not commit directly. */
19
20 #define XKB_KEY_NoSymbol                    0x000000  /* Special KeySym */
21 ''')
22 for path in HEADERS:
23     with open(path) as header:
24         for line in header:
25             if '#ifdef' in line or '#ifndef' in line or '#endif' in line:
26                 continue
27
28             # Remove #define _OSF_Keysyms and such.
29             if '#define _' in line:
30                 continue
31
32             # Handle a duplicate definition in HPkeysyms.h which kicks in if
33             # it's not already defined.
34             if 'XK_Ydiaeresis' in line and '0x100000ee' in line:
35                 continue
36
37             line = re.sub(r'#define\s*(\w*)XK_', r'#define XKB_KEY_\1', line)
38
39             print(line, end='')
40 print('\n\n#endif')