xserver/hw/xfree86/loader/sdksyms.sh
Paulo Cesar Pereira de Andrade b1dac41fb3 Use libtool convenience libraries and better "symbol" table.
All .a libraries were converted to .la, and instead of linking the
Xorg binary with a mix of .a and .la, and adding some libraries more
then once in the command line, etc, now it generates a single libxorg.la
from all the required convenience libraries, and links with a dummy
xorg.c (that should usually be the file with the main function...).
This removes the requirement of some things like libosandcommon and
libinit, that existed to circumvent problems when linking multiple
.a and .la in the final Xorg binary.

  The "symbol table" is now generated dynamically, by a shell script,
with an embedded gawk parser that parses cpp output. The new file
sdksyms.sh is generated by hand by analyzing all Makefile.am's and
making it create a sdksyms.c file, that includes all sdk headers that
will add symbols for the Xorg binary. Module headers aren't read, and
a in 2 files it was required to add a "<hash>ifndef XorgLoader" around
declarations shared between the Xorg binary and libextmod. A few
other changes were added to other sdk headers, like preventing
multiple inclusion, or including other headers to satisfy dependencies.

  This should be a lot more portable, and better (hopefully properly)
using libtool to generate convenience libraries.
2008-12-07 02:22:19 -02:00

392 lines
6.5 KiB
Shell
Executable file

#!/bin/sh
cat > sdksyms.c << EOF
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
/* These must be included first */
#include "misc.h"
#include "miscstruct.h"
/* render/Makefile.am */
#include "picture.h"
#include "mipict.h"
#include "glyphstr.h"
#include "picturestr.h"
#include "renderedge.h"
/* fb/Makefile.am -- module */
/*
#include "fb.h"
#include "fbrop.h"
#include "fboverlay.h"
#include "wfbrename.h"
#include "fbpict.h"
*/
/* miext/shadow/Makefile.am -- module */
/*
#include "shadow.h"
*/
/* miext/damage/Makefile.am */
#include "damage.h"
#include "damagestr.h"
/* Xext/Makefile.am -- half is module, half is builtin */
/*
#include "xvdix.h"
#include "xvmcext.h"
*/
#include "geext.h"
#include "geint.h"
#include "shmint.h"
#if XINERAMA
# include "panoramiXsrv.h"
# include "panoramiX.h"
#endif
/* hw/xfree86/int10/Makefile.am -- module */
/*
#include "xf86int10.h"
*/
/* hw/xfree86/i2c/Makefile.am -- "mostly" modules */
#include "xf86i2c.h"
/*
#include "bt829.h"
#include "fi1236.h"
#include "msp3430.h"
#include "tda8425.h"
#include "tda9850.h"
#include "tda9885.h"
#include "uda1380.h"
#include "i2c_def.h"
*/
/* hw/xfree86/modes/Makefile.am */
#include "xf86Crtc.h"
#include "xf86Modes.h"
#include "xf86RandR12.h"
/* #include "xf86Rename.h" */
/* hw/xfree86/ddc/Makefile.am */
#include "edid.h"
#include "xf86DDC.h"
/* hw/xfree86/dri2/Makefile.am -- module */
/*
#if DRI2
# include "dri2.h"
#endif
*/
/* hw/xfree86/vgahw/Makefile.am -- module */
/*
#include "vgaHW.h"
*/
/* hw/xfree86/fbdevhw/Makefile.am -- module */
/*
#include "fbdevhw.h"
*/
/* hw/xfree86/common/Makefile.am */
#include "compiler.h"
#include "fourcc.h"
#include "xf86.h"
#include "xf86Module.h"
#include "xf86Opt.h"
#include "xf86PciInfo.h"
#include "xf86Priv.h"
#include "xf86Privstr.h"
#include "xf86Resources.h"
#include "xf86cmap.h"
#include "xf86fbman.h"
#include "xf86str.h"
#include "xf86RAC.h"
#include "xf86Xinput.h"
#include "xisb.h"
#if XV
# include "xf86xv.h"
# include "xf86xvmc.h"
# include "xf86xvpriv.h"
#endif
/* XF86VidMode code is in libextmod module */
/*
#if XF86VIDMODE
# include "vidmodeproc.h"
#endif
*/
#include "xorgVersion.h"
#if defined(__sparc__) || defined(__sparc)
# include "xf86sbusBus.h"
#endif
/* hw/xfree86/ramdac/Makefile.am */
#include "BT.h"
#include "IBM.h"
#include "TI.h"
#include "xf86Cursor.h"
#include "xf86RamDac.h"
/* hw/xfree86/shadowfb/Makefile.am -- module */
/*
#include "shadowfb.h"
*/
/* hw/xfree86/os-support/solaris/Makefile.am */
#if defined(sun386)
# include "agpgart.h"
#endif
/* hw/xfree86/os-support/Makefile.am */
#include "xf86_OSproc.h"
#include "xf86_OSlib.h"
/* hw/xfree86/os-support/bus/Makefile.am */
#include "xf86Pci.h"
#if defined(__sparc__) || defined(__sparc)
# include "xf86Sbus.h"
#endif
/* hw/xfree86/xaa/Makefile.am -- module */
/*
#include "xaa.h"
#include "xaalocal.h"
#include "xaarop.h"
#include "xaaWrapper.h"
*/
/* hw/xfree86/dixmods/extmod/Makefile.am -- module */
/*
#include "dgaproc.h"
*/
/* hw/xfree86/parser/Makefile.am */
#include "xf86Parser.h"
#include "xf86Optrec.h"
/* hw/xfree86/vbe/Makefile.am -- module */
/*
#include "vbe.h"
#include "vbeModes.h"
*/
/* hw/xfree86/dri/Makefile.am -- module */
/*
#if XF86DRI
# include "dri.h"
# include "sarea.h"
# include "dristruct.h"
#endif
*/
/* hw/xfree86/xf8_16bpp/Makefile.am -- module */
/*
#include "cfb8_16.h"
*/
/* mi/Makefile.am */
#include "mibank.h"
#include "micmap.h"
#include "miline.h"
#include "mipointer.h"
#include "mi.h"
#include "mibstore.h"
#include "migc.h"
#include "mipointrst.h"
#include "mizerarc.h"
#include "micoord.h"
#include "mifillarc.h"
#include "mispans.h"
#include "miwideline.h"
#include "mistruct.h"
#include "mifpoly.h"
#include "mioverlay.h"
/* randr/Makefile.am */
#include "randrstr.h"
#include "rrtransform.h"
/* dbe/Makefile.am -- module */
/*
#include "dbestruct.h"
*/
/* exa/Makefile.am -- module */
/*
#include "exa.h"
*/
/* xfixes/Makefile.am */
#include "xfixes.h"
/* include/Makefile.am */
#include "XIstubs.h"
#include "bstore.h"
#include "bstorestr.h"
#include "closestr.h"
#include "closure.h"
#include "colormap.h"
#include "colormapst.h"
#include "hotplug.h"
#include "cursor.h"
#include "cursorstr.h"
#include "dix.h"
#include "dixaccess.h"
#include "dixevents.h"
#include "dixfont.h"
#include "dixfontstr.h"
#include "dixgrabs.h"
#include "dixstruct.h"
#include "exevents.h"
#include "extension.h"
#include "extinit.h"
#include "extnsionst.h"
#include "gc.h"
#include "gcstruct.h"
#include "globals.h"
#include "input.h"
#include "inputstr.h"
/* already included */
/*
#include "misc.h"
#include "miscstruct.h"
*/
#include "opaque.h"
#include "os.h"
#include "pixmap.h"
#include "pixmapstr.h"
#include "privates.h"
#include "property.h"
#include "propertyst.h"
#include "ptrveloc.h"
#include "region.h"
#include "regionstr.h"
#include "registry.h"
#include "resource.h"
#include "rgb.h"
#include "screenint.h"
#include "scrnintstr.h"
#include "selection.h"
#include "servermd.h"
#include "site.h"
#include "swaprep.h"
#include "swapreq.h"
#include "validate.h"
#include "window.h"
#include "windowstr.h"
#include "xkbfile.h"
#include "xkbsrv.h"
#include "xkbstr.h"
#include "xkbrules.h"
#include "xserver-properties.h"
EOF
cpp -DXorgLoader $@ sdksyms.c | awk '
BEGIN {
sdk = 0;
print("_X_HIDDEN void *xorg_symbols[] = {");
}
/^# [0-9]+/ {
# only process text after a include in a relative path
sdk = $3 !~ /^"\//;
}
/^extern[[:space:]]/ {
if (sdk) {
n = 3;
# skip attribute, if any
while ($n ~ /^(__attribute__|__global)/ ||
# skip modifiers, if any
$n ~ /^\*?(unsigned|const|volatile|struct)$/ ||
# skip pointer
$n ~ /\*$/)
n++;
# type specifier may not be set, as in
# extern _X_EXPORT unsigned name(...)
if ($n !~ /\W/)
n++;
# match
# extern _X_EXPORT struct name {
if ($n == "{")
n--;
# extern _X_EXPORT type (* name[])(...)
else if ($n ~ /^\W+$/)
n++;
# match
# extern _X_EXPORT const name *const ...
if ($n ~ /^(\W+)?const$/)
n++;
# actual name may be in the next line, as in
# extern _X_EXPORT type
# possibly ending with a *
# name(...)
if ($n == "" || $n ~ /^\*+$/) {
getline;
n = 1;
}
# dont modify $0 or $n
symbol = $n;
# remove starting non word chars
sub(/^\W+/, "",symbol);
# remove from first non word to end of line
sub(/\W.*/, "", symbol);
#print;
printf(" &%s,\n", symbol);
}
}
END {
print("};");
}' > _sdksyms.c
STATUS=$?
cat _sdksyms.c >> sdksyms.c
rm _sdksyms.c
exit $STATUS