sdksyms.sh revision 1b5d61b8
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#ifdef XINERAMA
62# include "panoramiXsrv.h"
63# include "panoramiX.h"
64#endif
65
66/* glx/Makefile.am */
67#ifdef GLX
68#include "vndserver.h"
69#endif
70
71/* hw/xfree86/int10/Makefile.am -- module */
72/*
73#include "xf86int10.h"
74 */
75
76
77/* hw/xfree86/i2c/Makefile.am -- "mostly" modules */
78#include "xf86i2c.h"
79/*
80#include "bt829.h"
81#include "fi1236.h"
82#include "msp3430.h"
83#include "tda8425.h"
84#include "tda9850.h"
85#include "tda9885.h"
86#include "uda1380.h"
87#include "i2c_def.h"
88 */
89
90
91/* hw/xfree86/modes/Makefile.am */
92#include "xf86Crtc.h"
93#include "xf86Modes.h"
94#include "xf86RandR12.h"
95/* #include "xf86Rename.h" */
96
97
98/* hw/xfree86/ddc/Makefile.am */
99#include "edid.h"
100#include "xf86DDC.h"
101
102
103/* hw/xfree86/dri2/Makefile.am -- module */
104#ifdef DRI2
105# include "dri2.h"
106#endif
107
108# include "dri3.h"
109
110/* hw/xfree86/vgahw/Makefile.am -- module */
111/*
112#include "vgaHW.h"
113 */
114
115
116/* hw/xfree86/fbdevhw/Makefile.am -- module */
117/*
118#include "fbdevhw.h"
119 */
120
121
122/* hw/xfree86/common/Makefile.am */
123#include "compiler.h"
124#include "fourcc.h"
125#include "xf86.h"
126#include "xf86Module.h"
127#include "xf86Opt.h"
128#ifdef XSERVER_LIBPCIACCESS
129 #include "xf86VGAarbiter.h"
130#endif
131#include "xf86Priv.h"
132#include "xf86Privstr.h"
133#include "xf86cmap.h"
134#include "xf86fbman.h"
135#include "xf86str.h"
136#include "xf86Xinput.h"
137#include "xisb.h"
138#ifdef XV
139# include "xf86xv.h"
140# include "xf86xvmc.h"
141# include "xf86xvpriv.h"
142#endif
143#include "xorgVersion.h"
144#if defined(__sparc__) || defined(__sparc)
145# include "xf86sbusBus.h"
146#endif
147
148
149/* hw/xfree86/ramdac/Makefile.am */
150#include "BT.h"
151#include "IBM.h"
152#include "TI.h"
153#include "xf86Cursor.h"
154#include "xf86RamDac.h"
155
156
157/* hw/xfree86/shadowfb/Makefile.am -- module */
158/*
159#include "shadowfb.h"
160 */
161
162
163/* hw/xfree86/os-support/solaris/Makefile.am */
164#if defined(sun386)
165# include "agpgart.h"
166#endif
167
168
169/* hw/xfree86/os-support/Makefile.am */
170#include "xf86_OSproc.h"
171#include "xf86_OSlib.h"
172
173
174/* hw/xfree86/os-support/bus/Makefile.am */
175#ifdef XSERVER_LIBPCIACCESS
176# include "xf86Pci.h"
177#endif
178#if defined(__sparc__) || defined(__sparc)
179# include "xf86Sbus.h"
180#endif
181
182
183/* hw/xfree86/parser/Makefile.am */
184#include "xf86Parser.h"
185#include "xf86Optrec.h"
186
187
188/* hw/xfree86/vbe/Makefile.am -- module */
189/*
190#include "vbe.h"
191#include "vbeModes.h"
192 */
193
194
195/* hw/xfree86/dri/Makefile.am -- module */
196#ifdef XF86DRI
197# include "dri.h"
198# include "sarea.h"
199# include "dristruct.h"
200#endif
201
202
203/* mi/Makefile.am */
204#include "micmap.h"
205#include "miline.h"
206#include "mipointer.h"
207#include "mi.h"
208#include "migc.h"
209#include "mipointrst.h"
210#include "mizerarc.h"
211#include "micoord.h"
212#include "mifillarc.h"
213#include "mistruct.h"
214#include "mioverlay.h"
215
216
217/* randr/Makefile.am */
218#include "randrstr.h"
219#include "rrtransform.h"
220
221
222/* dbe/Makefile.am -- module */
223#ifdef DBE
224#include "dbestruct.h"
225#endif
226
227
228/* exa/Makefile.am -- module */
229/*
230#include "exa.h"
231 */
232
233#ifdef COMPOSITE
234#include "compositeext.h"
235#endif
236
237/* xfixes/Makefile.am */
238#include "xfixes.h"
239
240
241/* include/Makefile.am */
242#include "XIstubs.h"
243#include "Xprintf.h"
244#include "closestr.h"
245#include "closure.h"
246#include "colormap.h"
247#include "colormapst.h"
248#include "hotplug.h"
249#include "client.h"
250#include "cursor.h"
251#include "cursorstr.h"
252#include "dix.h"
253#include "dixaccess.h"
254#include "dixevents.h"
255#define _FONTPROTO_H
256#include "dixfont.h"
257#include "dixfontstr.h"
258#include "dixgrabs.h"
259#include "dixstruct.h"
260#include "exevents.h"
261#include "extension.h"
262#include "extnsionst.h"
263#include "gc.h"
264#include "gcstruct.h"
265#include "globals.h"
266#include "input.h"
267#include "inputstr.h"
268/* already included */
269/*
270#include "misc.h"
271#include "miscstruct.h"
272 */
273#include "opaque.h"
274#include "os.h"
275#include "pixmap.h"
276#include "pixmapstr.h"
277#include "privates.h"
278#include "property.h"
279#include "propertyst.h"
280#include "ptrveloc.h"
281#include "region.h"
282#include "regionstr.h"
283#include "registry.h"
284#include "resource.h"
285#include "rgb.h"
286#include "screenint.h"
287#include "scrnintstr.h"
288#include "selection.h"
289#include "servermd.h"
290#include "site.h"
291#include "validate.h"
292#include "window.h"
293#include "windowstr.h"
294#include "xace.h"
295#include "xkbfile.h"
296#include "xkbsrv.h"
297#include "xkbstr.h"
298#include "xkbrules.h"
299#include "xserver-properties.h"
300
301EOF
302
303topdir=$(readlink -f $1)
304shift
305LC_ALL=C
306export LC_ALL
307${CPP:-cpp} "$@" sdksyms.c > /dev/null || exit $?
308${CPP:-cpp} "$@" sdksyms.c | ${AWK:-awk} -v topdir=$topdir '
309BEGIN {
310    sdk = 0;
311    print("/*");
312    print(" * These symbols are referenced to ensure they");
313    print(" * will be available in the X Server binary.");
314    print(" */");
315    printf("/* topdir=%s */\n", topdir);
316    print("_X_HIDDEN void *xorg_symbols[] = {");
317
318    printf("sdksyms.c:") > "sdksyms.dep";
319}
320/^# [0-9]+ "/ {
321    # Match preprocessor linemarkers which have the form:
322    # # linenum "filename" flags
323    #
324    # Only process text for sdk exports where the linemarker filename has a
325    # relative path, or an absolute path matching $top_srcdir.
326    #
327
328    # canonicalize filename
329    if ($3 in canonicalized) {
330	c = canonicalized[$3]
331    } else {
332	cmd = "readlink -f " $3
333	cmd | getline c
334	close(cmd)
335        canonicalized[$3] = c
336    }
337    # note that index() starts at 1; 0 means no match.
338    sdk = $3 !~ /^"\// || index(c, topdir) == 1;
339
340    if (sdk && $3 ~ /\.h"$/) {
341	# remove quotes
342	gsub(/"/, "", $3);
343	line = $2;
344	header = $3;
345	if (! headers[$3]) {
346	    printf(" \\\n  %s", $3) >> "sdksyms.dep";
347	    headers[$3] = 1;
348	}
349    }
350    next;
351}
352
353/^extern[ 	]/  {
354    if (sdk) {
355	n = 3;
356
357        # skip line numbers GCC 5 adds before __attribute__
358        while ($n == "" || $0 ~ /^# [0-9]+ "/) {
359           getline;
360           n = 1;
361        }
362
363	# skip attribute, if any
364	while ($n ~ /^(__attribute__|__global)/ ||
365	    # skip modifiers, if any
366	    $n ~ /^\*?(unsigned|const|volatile|struct|_X_EXPORT)$/ ||
367	    # skip pointer
368	    $n ~ /^[a-zA-Z0-9_]*\*$/) {
369	    n++;
370            # skip line numbers GCC 5 adds after __attribute__
371            while ($n == "" || $0 ~ /^# [0-9]+ "/) {
372               getline;
373               n = 1;
374            }
375        }
376	# hack: pid_t becomes __pid_t on NetBSD, same for uint32_t -> __uint32_t.
377	# GCC 5 inserts additional lines around this.
378        if (($1 == "__pid_t" || $1 == "__uint32_t") && NF == 1) {
379            getline;
380            n++;
381            # skip line numbers GCC 5 adds (after typedef return type?)
382            while ($n == "" || $0 ~ /^# [0-9]+ "/) {
383               getline;
384               n = 1;
385            }
386	}
387
388	# type specifier may not be set, as in
389	#   extern _X_EXPORT unsigned name(...)
390	if ($n !~ /[^a-zA-Z0-9_]/)
391	    n++;
392
393	# go back if we are at the parameter list already
394	if ($n ~ /^[(]([^*].*)?$/)
395	    n--;
396
397	# match
398	#    extern _X_EXPORT type (* name[])(...)
399	if ($n ~ /^[^a-zA-Z0-9_]+$/)
400	    n++;
401
402	# match
403	#	extern _X_EXPORT const name *const ...
404	if ($n ~ /^([^a-zA-Z0-9_]+)?const$/)
405	    n++;
406
407	# actual name may be in the next line, as in
408	#   extern _X_EXPORT type
409	# possibly ending with a *
410	#   name(...)
411	if ($n == "" || $n ~ /^\*+$/) {
412	    getline;
413	    n = 1;
414	    # indent may have inserted a blank link
415	    if ($0 == "")
416		getline;
417	}
418
419	# dont modify $0 or $n
420	symbol = $n;
421
422	# remove starting non word chars
423	sub(/^[^a-zA-Z0-9_]+/, "",symbol);
424
425	# remove from first non word to end of line
426	sub(/[^a-zA-Z0-9_].*/, "", symbol);
427
428	#print;
429	if (symbol != "")
430	    printf("    (void *) &%-50s /* %s:%s */\n", symbol ",", header, line);
431    }
432}
433
434{
435    line++;
436}
437
438END {
439    print("};");
440
441    print("") >> "sdksyms.dep";
442}' > _sdksyms.c
443
444STATUS=$?
445
446cat _sdksyms.c >> sdksyms.c
447rm _sdksyms.c
448
449[ $? != 0 ] && exit $?
450
451exit $STATUS
452