sdksyms.sh 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. #!/bin/sh
  2. cat > sdksyms.c << EOF
  3. /* This file is automatically generated by sdksyms.sh. */
  4. #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  5. #ifdef HAVE_XORG_CONFIG_H
  6. #include <xorg-config.h>
  7. #endif
  8. /* These must be included first */
  9. #include "misc.h"
  10. #include "miscstruct.h"
  11. /* render/Makefile.am */
  12. #include "picture.h"
  13. #include "mipict.h"
  14. #include "glyphstr.h"
  15. #include "picturestr.h"
  16. /* fb/Makefile.am -- module */
  17. /*
  18. #include "fb.h"
  19. #include "fbrop.h"
  20. #include "fboverlay.h"
  21. #include "wfbrename.h"
  22. #include "fbpict.h"
  23. */
  24. /* miext/shadow/Makefile.am -- module */
  25. /*
  26. #include "shadow.h"
  27. */
  28. /* miext/damage/Makefile.am */
  29. #include "damage.h"
  30. #include "damagestr.h"
  31. /* miext/sync/Makefile.am */
  32. #include "misync.h"
  33. #include "misyncstr.h"
  34. #if HAVE_XSHMFENCE
  35. #include "misyncshm.h"
  36. #endif
  37. /* Xext/Makefile.am -- half is module, half is builtin */
  38. #ifdef XV
  39. #include "xvdix.h"
  40. #include "xvmcext.h"
  41. #endif
  42. #include "geext.h"
  43. #include "geint.h"
  44. #ifdef MITSHM
  45. #include "shmint.h"
  46. #endif
  47. #include "syncsdk.h"
  48. #if XINERAMA
  49. # include "panoramiXsrv.h"
  50. # include "panoramiX.h"
  51. #endif
  52. /* hw/xfree86/int10/Makefile.am -- module */
  53. /*
  54. #include "xf86int10.h"
  55. */
  56. /* hw/xfree86/i2c/Makefile.am -- "mostly" modules */
  57. #include "xf86i2c.h"
  58. /*
  59. #include "bt829.h"
  60. #include "fi1236.h"
  61. #include "msp3430.h"
  62. #include "tda8425.h"
  63. #include "tda9850.h"
  64. #include "tda9885.h"
  65. #include "uda1380.h"
  66. #include "i2c_def.h"
  67. */
  68. /* hw/xfree86/modes/Makefile.am */
  69. #include "xf86Crtc.h"
  70. #include "xf86Modes.h"
  71. #include "xf86RandR12.h"
  72. /* #include "xf86Rename.h" */
  73. /* hw/xfree86/ddc/Makefile.am */
  74. #include "edid.h"
  75. #include "xf86DDC.h"
  76. /* hw/xfree86/dri2/Makefile.am -- module */
  77. #if DRI2
  78. # include "dri2.h"
  79. #endif
  80. # include "dri3.h"
  81. /* hw/xfree86/vgahw/Makefile.am -- module */
  82. /*
  83. #include "vgaHW.h"
  84. */
  85. /* hw/xfree86/fbdevhw/Makefile.am -- module */
  86. /*
  87. #include "fbdevhw.h"
  88. */
  89. /* hw/xfree86/common/Makefile.am */
  90. #include "compiler.h"
  91. #include "fourcc.h"
  92. #include "xf86.h"
  93. #include "xf86Module.h"
  94. #include "xf86Opt.h"
  95. #ifdef XSERVER_LIBPCIACCESS
  96. #include "xf86VGAarbiter.h"
  97. #endif
  98. #include "xf86Priv.h"
  99. #include "xf86Privstr.h"
  100. #include "xf86cmap.h"
  101. #include "xf86fbman.h"
  102. #include "xf86str.h"
  103. #include "xf86Xinput.h"
  104. #include "xisb.h"
  105. #if XV
  106. # include "xf86xv.h"
  107. # include "xf86xvmc.h"
  108. # include "xf86xvpriv.h"
  109. #endif
  110. #if XF86VIDMODE
  111. # include "vidmodeproc.h"
  112. #endif
  113. #include "xorgVersion.h"
  114. #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
  115. # include "xf86sbusBus.h"
  116. #endif
  117. /* hw/xfree86/ramdac/Makefile.am */
  118. #include "BT.h"
  119. #include "IBM.h"
  120. #include "TI.h"
  121. #include "xf86Cursor.h"
  122. #include "xf86RamDac.h"
  123. /* hw/xfree86/shadowfb/Makefile.am -- module */
  124. /*
  125. #include "shadowfb.h"
  126. */
  127. /* hw/xfree86/os-support/solaris/Makefile.am */
  128. #if defined(sun386)
  129. # include "agpgart.h"
  130. #endif
  131. /* hw/xfree86/os-support/Makefile.am */
  132. #include "xf86_OSproc.h"
  133. #include "xf86_OSlib.h"
  134. /* hw/xfree86/os-support/bus/Makefile.am */
  135. #ifdef XSERVER_LIBPCIACCESS
  136. # include "xf86Pci.h"
  137. #endif
  138. #if defined(__sparc__) || defined(__sparc)
  139. # include "xf86Sbus.h"
  140. #endif
  141. /* hw/xfree86/dixmods/extmod/Makefile.am -- module */
  142. #ifdef XFreeXDGA
  143. #include "dgaproc.h"
  144. #endif
  145. /* hw/xfree86/parser/Makefile.am */
  146. #include "xf86Parser.h"
  147. #include "xf86Optrec.h"
  148. /* hw/xfree86/vbe/Makefile.am -- module */
  149. /*
  150. #include "vbe.h"
  151. #include "vbeModes.h"
  152. */
  153. /* hw/xfree86/dri/Makefile.am -- module */
  154. #if XF86DRI
  155. # include "dri.h"
  156. # include "sarea.h"
  157. # include "dristruct.h"
  158. #endif
  159. /* mi/Makefile.am */
  160. #include "micmap.h"
  161. #include "miline.h"
  162. #include "mipointer.h"
  163. #include "mi.h"
  164. #include "migc.h"
  165. #include "mipointrst.h"
  166. #include "mizerarc.h"
  167. #include "micoord.h"
  168. #include "mifillarc.h"
  169. #include "mispans.h"
  170. #include "miwideline.h"
  171. #include "mistruct.h"
  172. #include "mifpoly.h"
  173. #include "mioverlay.h"
  174. /* randr/Makefile.am */
  175. #include "randrstr.h"
  176. #include "rrtransform.h"
  177. /* dbe/Makefile.am -- module */
  178. #ifdef DBE
  179. #include "dbestruct.h"
  180. #endif
  181. /* exa/Makefile.am -- module */
  182. /*
  183. #include "exa.h"
  184. */
  185. #ifdef COMPOSITE
  186. #include "compositeext.h"
  187. #endif
  188. /* xfixes/Makefile.am */
  189. #include "xfixes.h"
  190. /* include/Makefile.am */
  191. #include "XIstubs.h"
  192. #include "Xprintf.h"
  193. #include "closestr.h"
  194. #include "closure.h"
  195. #include "colormap.h"
  196. #include "colormapst.h"
  197. #include "hotplug.h"
  198. #include "client.h"
  199. #include "cursor.h"
  200. #include "cursorstr.h"
  201. #include "dix.h"
  202. #include "dixaccess.h"
  203. #include "dixevents.h"
  204. #define _FONTPROTO_H
  205. #include "dixfont.h"
  206. #include "dixfontstr.h"
  207. #include "dixfontstubs.h"
  208. #include "dixgrabs.h"
  209. #include "dixstruct.h"
  210. #include "exevents.h"
  211. #include "extension.h"
  212. #include "extnsionst.h"
  213. #include "gc.h"
  214. #include "gcstruct.h"
  215. #include "globals.h"
  216. #include "input.h"
  217. #include "inputstr.h"
  218. /* already included */
  219. /*
  220. #include "misc.h"
  221. #include "miscstruct.h"
  222. */
  223. #include "opaque.h"
  224. #include "os.h"
  225. #include "pixmap.h"
  226. #include "pixmapstr.h"
  227. #include "privates.h"
  228. #include "property.h"
  229. #include "propertyst.h"
  230. #include "ptrveloc.h"
  231. #include "region.h"
  232. #include "regionstr.h"
  233. #include "registry.h"
  234. #include "resource.h"
  235. #include "rgb.h"
  236. #include "screenint.h"
  237. #include "scrnintstr.h"
  238. #include "selection.h"
  239. #include "servermd.h"
  240. #include "site.h"
  241. #include "swaprep.h"
  242. #include "swapreq.h"
  243. #include "validate.h"
  244. #include "window.h"
  245. #include "windowstr.h"
  246. #include "xace.h"
  247. #include "xkbfile.h"
  248. #include "xkbsrv.h"
  249. #include "xkbstr.h"
  250. #include "xkbrules.h"
  251. #include "xserver-properties.h"
  252. EOF
  253. case `gcc -dumpversion` in
  254. [23].*)
  255. n=2
  256. ;;
  257. 4.*)
  258. n=3
  259. ;;
  260. esac
  261. topdir=$1
  262. shift
  263. LC_ALL=C
  264. export LC_ALL
  265. ${CPP:-cpp} "$@" sdksyms.c > /dev/null || exit $?
  266. ${CPP:-cpp} "$@" sdksyms.c | ${AWK:-awk} -v topdir=$topdir '
  267. BEGIN {
  268. sdk = 0;
  269. print("/*");
  270. print(" * These symbols are referenced to ensure they");
  271. print(" * will be available in the X Server binary.");
  272. print(" */");
  273. printf("/* topdir=%s */\n", topdir);
  274. print("_X_HIDDEN void *xorg_symbols[] = {");
  275. printf("sdksyms.c:") > "sdksyms.dep";
  276. }
  277. /^# [0-9]+ "/ {
  278. # Process text after a include in a relative path or when the
  279. # processed file has a basename matching $top_srcdir.
  280. # Note that indexing starts at 1; 0 means no match, and there
  281. # is a starting ".
  282. sdk = $3 !~ /^"\// || index($3, topdir) == 2;
  283. if (sdk && $3 ~ /\.h"$/) {
  284. # remove quotes
  285. gsub(/"/, "", $3);
  286. line = $2;
  287. header = $3;
  288. if (! headers[$3]) {
  289. printf(" \\\n %s", $3) >> "sdksyms.dep";
  290. headers[$3] = 1;
  291. }
  292. }
  293. next;
  294. }
  295. /^extern[ ]/ {
  296. if (sdk) {
  297. n = 3;
  298. printf("/* %s */\n", $0)
  299. # skip attribute, if any
  300. while ($n ~ /^(__attribute__|__global)/ ||
  301. # skip modifiers, if any
  302. $n ~ /^\*?(unsigned|const|volatile|struct|_X_EXPORT)$/ ||
  303. # skip pointer
  304. $n ~ /^[a-zA-Z0-9_]*\*$/)
  305. n++;
  306. # type specifier may not be set, as in
  307. # extern _X_EXPORT unsigned name(...)
  308. if ($n !~ /[^a-zA-Z0-9_]/)
  309. n++;
  310. # go back if we are at the parameter list already
  311. if ($n ~ /^[(]([^*].*)?$/)
  312. n--;
  313. # match
  314. # extern _X_EXPORT type (* name[])(...)
  315. if ($n ~ /^[^a-zA-Z0-9_]+$/)
  316. n++;
  317. # match
  318. # extern _X_EXPORT const name *const ...
  319. if ($n ~ /^([^a-zA-Z0-9_]+)?const$/)
  320. n++;
  321. # actual name may be in the next line, as in
  322. # extern _X_EXPORT type
  323. # possibly ending with a *
  324. # name(...)
  325. if ($n == "" || $n ~ /^\*+$/) {
  326. getline;
  327. n = 1;
  328. # indent may have inserted a blank link
  329. if ($0 == "")
  330. getline;
  331. }
  332. # dont modify $0 or $n
  333. symbol = $n;
  334. # remove starting non word chars
  335. sub(/^[^a-zA-Z0-9_]+/, "",symbol);
  336. # remove from first non word to end of line
  337. sub(/[^a-zA-Z0-9_].*/, "", symbol);
  338. #print;
  339. printf(" (void *) &%-50s /* %s:%s */\n", symbol ",", header, line);
  340. }
  341. }
  342. {
  343. line++;
  344. }
  345. END {
  346. print("};");
  347. print("") >> "sdksyms.dep";
  348. }' > _sdksyms.c
  349. STATUS=$?
  350. cat _sdksyms.c >> sdksyms.c
  351. rm _sdksyms.c
  352. [ $? != 0 ] && exit $?
  353. exit $STATUS