http://llvm.org/bugs/show_bug.cgi?id=14905

             Bug #: 14905
           Summary: cmake+shared installation on Darwin needs
                    install_name_tool pass
           Product: Build scripts
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: cmake
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
    Classification: Unclassified


The cmake+shared built shared libraries and executables have been incorrectly
installed since cmake was born.  Simply copying the built binaries to the
install location does not work without having to set other ld/dyld related
environment variables.  The following post-install script is necessary to fix
up dependent shared library paths in binaries (fairly standard recipe for
cmake-built packages).  
(libtool does this correctly at install-time)

I've been using this for a few years, but never bothered to report it before,
as it is more of a deficiency in cmake.
The script can also be trivially modified to work on DESTDIR-staged builds.

========== install-shared.sh ==========
#!/bin/sh -ev
prefix=/usr/local/wherever
make -j1 install/fast

pushd $prefix/lib
for f in *.dylib *.so
do
        if test ! -L $f
        then
        install_name_tool -id "$prefix/lib/$f" "$f"
        case $f in
        *.dylib) filt="sed 1,2d" ;;
        *.so) filt="sed 1d" ;;
        esac
        deplibs=`otool -L $f | $filt | awk '{print $1;}' | tr '\n' ' '`
        for d in $deplibs
        do
        # prefix absolute paths to llvm/clang's lib installation
        case $d in
        /*) ;;
        *) install_name_tool -change "$d" "$prefix/lib/$d" $f ;;
        esac
        done
        fi
done
popd
pushd $prefix/bin
for f in *
do
        if test ! -L $f
        then
        deplibs=`otool -L $f | sed 1d | awk '{print $1;}' | tr '\n' ' '`
        for d in $deplibs
        do
        # consider substituting with relative @executable_path/../lib ?
        case $d in
        /*) ;;
        @*) ;;
        *) install_name_tool -change "$d" "$prefix/lib/$d" $f ;;
        esac
        done
        fi
done
popd

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to