Changeset 2427

Show
Ignore:
Timestamp:
12/30/07 14:20:56 (1 year ago)
Author:
taj
Message:

* relaytool: Apply patch from res in ticket #52. Now, if a lib cannot be relaytooled for some reason, a stub that ensures libwhatever_is_present is defined will be generated.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • apbuild/trunk/ChangeLog

    r2422 r2427  
     1Sun Dec 30 19:17:03 UTC 2007  Taj Morton  <tajmorton@gmail.com> 
     2        * relaytool: Apply patch from res in ticket #52. Now, if a lib cannot be relaytooled 
     3          for some reason, a stub that ensures libwhatever_is_present is defined will be 
     4          generated. 
     5 
    16Sun Sep 30 00:29:13 UTC 2007  Taj Morton  <tajmorton@gmail.com> 
    27        * relaytool: When multi-linking, use the first SONAME passed to --multilink 
  • apbuild/trunk/relaytool

    r2422 r2427  
    376376} 
    377377 
     378function 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 */ 
     399int ${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 */ 
     402int ${libname}_symbol_is_present(char * s) 
     403{ 
     404    return 1; 
     405} 
     406 
     407#ifdef __cplusplus 
     408    } 
     409#endif 
     410EOF 
     411     
     412} 
     413 
    378414no_replace=false 
    379415replace_all=false 
     
    492528            fi 
    493529        elif $found && ! $arch_ok; then 
    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 
    496565        else 
    497566            echo -n "$a "