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