| | 370 | function fakerelay() { |
|---|
| | 371 | lib="$1" |
|---|
| | 372 | libname=$( echo $( basename "$lib" ) | sed 's/\.so.*//' | tr '-' '_' | tr '.' '_' ) |
|---|
| | 373 | soname=$( objdump -x "$lib" |grep SONAME | awk '{print $2}' ) |
|---|
| | 374 | outfile="$outdir/`basename "$soname"`.stub.c" |
|---|
| | 375 | |
|---|
| | 376 | echo -n "$outfile" |
|---|
| | 377 | |
|---|
| | 378 | cat <<EOF >"$outfile" |
|---|
| | 379 | /* automatically generated: `date` by `id -un`@`uname -n`, do not edit |
|---|
| | 380 | * |
|---|
| | 381 | * Built by relaytool, a program for building delay-load jumptables |
|---|
| | 382 | * relaytool is (C) 2004 Mike Hearn <mike@navi.cx> |
|---|
| | 383 | * See http://autopackage.org/ for details. |
|---|
| | 384 | */ |
|---|
| | 385 | |
|---|
| | 386 | #ifdef __cplusplus |
|---|
| | 387 | extern "C" { |
|---|
| | 388 | #endif |
|---|
| | 389 | |
|---|
| | 390 | /* 1 if present, 0 if not */ |
|---|
| | 391 | int ${libname}_is_present = 1; |
|---|
| | 392 | |
|---|
| | 393 | /* 1 if present, 0 if not, 0 with warning to stderr if lib not present or symbol not found */ |
|---|
| | 394 | int ${libname}_symbol_is_present(char * s) |
|---|
| | 395 | { |
|---|
| | 396 | return 1; |
|---|
| | 397 | } |
|---|
| | 398 | |
|---|
| | 399 | #ifdef __cplusplus |
|---|
| | 400 | } |
|---|
| | 401 | #endif |
|---|
| | 402 | EOF |
|---|
| | 403 | |
|---|
| | 404 | } |
|---|
| | 405 | |
|---|
| | 509 | echo -n "-l$lib " |
|---|
| | 510 | |
|---|
| | 511 | spfound=true |
|---|
| | 512 | break; |
|---|
| | 513 | fi |
|---|
| | 514 | done |
|---|
| | 515 | |
|---|
| | 516 | if ! $spfound; then |
|---|
| | 517 | error could not find "$lib" in search path |
|---|
| | 518 | fi |
|---|
| | 519 | elif $found && ! $arch_ok; then |
|---|
| | 520 | #echo -n "-Dlib${lib}_is_present -D\"lib${lib}_symbol_is_present(sym)=1\" $a " |
|---|
| | 521 | #libname=$( echo $( basename "$lib" ) | sed 's/\.so.*//' | tr '-' '_' | tr '.' '_' ) |
|---|
| | 522 | #echo -n "-Dlib${libname}_is_present -Dlib${libname}_symbol_is_present(sym)=1 $a " |
|---|
| | 523 | |
|---|
| | 524 | # yes, so let's find its absolute filename by checking in each search path directory |
|---|
| | 525 | spfound=false |
|---|
| | 526 | for d in ${searchpath[@]}; do |
|---|
| | 527 | if [ -e "$d/lib$lib.so" ]; then |
|---|
| | 528 | |
|---|
| | 529 | absname=$( readfinallink "$d/lib$lib.so" ) |
|---|
| | 530 | if [ $? != 0 ] || [ ! -f "$absname" ]; then |
|---|
| | 531 | error broken symlink "$absname" |
|---|
| | 532 | fi |
|---|
| | 533 | |
|---|
| | 534 | stubfile=$( fakerelay "$absname" ) |
|---|
| | 535 | |
|---|
| | 536 | # now we have to compile the stub |
|---|
| | 537 | if [ $? == 0 ]; then |
|---|
| | 538 | stubobj=$( echo "$stubfile" | sed 's/\.c$/\.o/' ) |
|---|
| | 539 | # remove -include flags from CFLAGS, if any |
|---|
| | 540 | CFLAGS=$( echo $CFLAGS | sed 's/-include .*\.h//g' ) |
|---|
| | 541 | ${CC:-gcc} ${CFLAGS} -fPIC -c -o "$stubobj" "$stubfile" 2>/dev/tty |
|---|
| | 542 | echo -n "$stubobj " |
|---|
| | 543 | fi |
|---|
| | 544 | |
|---|