xorg-server-1.7.7/hw/xfree86/loader/sdksyms.sh
that I have added some debugging lines :
Code: Select all
echo "$0:$@" >compile_sdksyms.text
[ -e sdksyms.c-original ] && cp -f sdksyms.c-original sdksyms.c || cp -a sdksyms.c sdksyms.c-original
${CPP:-cpp} "$@" -DXorgLoader sdksyms.c -o sdksyms.o
RV=$?
echo "
${CPP:-cpp} $@ -DXorgLoader sdksyms.c -o sdksyms.o"" : Returnvalue : $RV" >> compile_sdksyms.text
topdir=$1
shift
echo "TOPDIR topdir='$topdir'" >> compile_sdksyms.text
Code: Select all
topdir=$1
shift
LC_ALL=C
export LC_ALL
${CPP:-cpp} "$@" -DXorgLoader sdksyms.c | ${AWK:-awk} -v topdir=$topdir '
BEGIN {
sdk = 0;
print("/*");
print(" * These symbols are referenced to ensure they");
print(" * will be available in the X Server binary.");
print(" */");
printf("/* topdir=%s */\n", topdir);
print("_X_HIDDEN void *xorg_symbols[] = {");
printf("sdksyms.c:") > "sdksyms.dep";
}
/^# [0-9]+ "/ {
# Process text after a include in a relative path or when the
# processed file has a basename matching $top_srcdir.
# Note that indexing starts at 1; 0 means no match, and there
# is a starting ".
sdk = $3 !~ /^"\// || index($3, topdir) == 2;
if (sdk && $3 ~ /\.h"$/) {
# remove quotes
gsub(/"/, "", $3);
if (! headers[$3]) {
printf(" \\\n %s", $3) >> "sdksyms.dep";
headers[$3] = 1;
}
}
}
/^extern[ ]/ {
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 !~ /[^a-zA-Z0-9_]/)
n++;
# match
# extern _X_EXPORT type (* name[])(...)
if ($n ~ /^[^a-zA-Z0-9_]+$/)
n++;
# match
# extern _X_EXPORT const name *const ...
if ($n ~ /^([^a-zA-Z0-9_]+)?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(/^[^a-zA-Z0-9_]+/, "",symbol);
# remove from first non word to end of line
sub(/[^a-zA-Z0-9_].*/, "", symbol);
#print;
printf(" (void *) &%s,\n", symbol);
}
}
END {
print("};");
print("") >> "sdksyms.dep";
}' > _sdksyms.c
STATUS=$?
cat _sdksyms.c >> sdksyms.c
#rm _sdksyms.c
[ $? != 0 ] && exit $?
exit $STATUS
${CPP:-cpp} "$@" -DXorgLoader sdksyms.c -o sdksyms.o
creates an outputfile with content like
Code: Select all
extern void OsVendorInit(void);
extern void OsBlockSignals (void);
extern void OsReleaseSignals (void);
extern int System(char *);
extern pointer Popen(char *, char *);
thus screwing around three dozend of symbols so that the Xorg binary does not compile .(void *) &OsVendorInit,
(void *) &void,
(void *) &void,
(void *) &System,
(void *) &Popen,