| | 378 | function fakerelay() { |
|---|
| | 379 | lib="$1" |
|---|
| | 380 | libname=$( echo $( basename "$lib" ) | sed 's/\.so.*//' | tr '-' '_' | tr '.' '_' ) |
|---|
| | 381 | soname=$( objdump -x "$lib" |grep SONAME | awk '{print $2}' ) |
|---|
| | 382 | outfile="$outdir/`basename "$soname"`.stub.c" |
|---|
| | 383 | |
|---|
| | 384 | echo -n "$outfile" |
|---|
| | 385 | |
|---|
| | 386 | cat <<EOF >"$outfile" |
|---|
| | 387 | /* automatically generated: `date` by `id -un`@`uname -n`, do not edit |
|---|
| | 388 | * |
|---|
| | 389 | * Built by relaytool, a program for building delay-load jumptables |
|---|
| | 390 | * relaytool is (C) 2004 Mike Hearn <mike@navi.cx> |
|---|
| | 391 | * See http://autopackage.org/ for details. |
|---|
| | 392 | */ |
|---|
| | 393 | |
|---|
| | 394 | #ifdef __cplusplus |
|---|
| | 395 | extern "C" { |
|---|
| | 396 | #endif |
|---|
| | 397 | |
|---|
| | 398 | /* 1 if present, 0 if not */ |
|---|
| | 399 | int ${libname}_is_present = 1; |
|---|
| | 400 | |
|---|
| | 401 | /* 1 if present, 0 if not, 0 with warning to stderr if lib not present or symbol not found */ |
|---|
| | 402 | int ${libname}_symbol_is_present(char * s) |
|---|
| | 403 | { |
|---|
| | 404 | return 1; |
|---|
| | 405 | } |
|---|
| | 406 | |
|---|
| | 407 | #ifdef __cplusplus |
|---|
| | 408 | } |
|---|
| | 409 | #endif |
|---|
| | 410 | EOF |
|---|
| | 411 | |
|---|
| | 412 | } |
|---|
| | 413 | |
|---|
| 494 | | libname=$( echo $( basename "$lib" ) | sed 's/\.so.*//' | tr '-' '_' | tr '.' '_' ) |
|---|
| 495 | | echo -n "-Dlib${libname}_is_present='1' -Dlib${libname}_symbol_is_present(sym)='1' $a " |
|---|
| | 530 | # yes, so let's find its absolute filename by checking in each search path directory |
|---|
| | 531 | spfound=false |
|---|
| | 532 | for d in ${searchpath[@]}; do |
|---|
| | 533 | if [ -e "$d/lib$lib.so" ]; then |
|---|
| | 534 | |
|---|
| | 535 | absname=$( readfinallink "$d/lib$lib.so" ) |
|---|
| | 536 | if [ $? != 0 ] || [ ! -f "$absname" ]; then |
|---|
| | 537 | error broken symlink "$absname" |
|---|
| | 538 | fi |
|---|
| | 539 | |
|---|
| | 540 | # Create a stub C source that just contains dummy |
|---|
| | 541 | # libwhatever_... support functions |
|---|
| | 542 | stubfile=$( fakerelay "$absname" ) |
|---|
| | 543 | |
|---|
| | 544 | # now we have to compile the stub |
|---|
| | 545 | if [ $? == 0 ]; then |
|---|
| | 546 | stubobj=$( echo "$stubfile" | sed 's/\.c$/\.o/' ) |
|---|
| | 547 | # remove -include flags from CFLAGS, if any |
|---|
| | 548 | CFLAGS=$( echo $CFLAGS | sed 's/-include .*\.h//g' ) |
|---|
| | 549 | ${CC:-gcc} ${CFLAGS} -fPIC -c -o "$stubobj" "$stubfile" 2>/dev/tty |
|---|
| | 550 | echo -n "$stubobj " |
|---|
| | 551 | fi |
|---|
| | 552 | |
|---|
| | 553 | if $no_replace; then |
|---|
| | 554 | echo -n "-l$lib " |
|---|
| | 555 | fi |
|---|
| | 556 | |
|---|
| | 557 | spfound=true |
|---|
| | 558 | break; |
|---|
| | 559 | fi |
|---|
| | 560 | done |
|---|
| | 561 | |
|---|
| | 562 | if ! $spfound; then |
|---|
| | 563 | error could not find "$lib" in search path |
|---|
| | 564 | fi |
|---|