Commit 6034ebb9 authored by Weijia Wang's avatar Weijia Wang Committed by sternenseemann
Browse files

gprbuild: fix rpath only when targeting darwin

parent a8eea709
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -53,7 +53,14 @@ stdenv.mkDerivation {
  # introducing a wrapper for it in the future remains TODO.
  # For the moment this doesn't matter since we have no situation
  # were gprbuild is used to build something used at build time.
  setupHook = ./gpr-project-path-hook.sh;
  setupHooks = [
    ./gpr-project-path-hook.sh
  ] ++ lib.optionals stdenv.targetPlatform.isDarwin [
    # This setupHook replaces the paths of shared libraries starting
    # with @rpath with the absolute paths on Darwin, so that the
    # binaries can be run without additional setup.
    ./gpr-project-darwin-rpath-hook.sh
  ];

  installPhase = ''
    runHook preInstall
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ stdenv.mkDerivation {
  inherit (gprbuild-boot)
    version
    src
    setupHook
    setupHooks
    meta
    ;

+10 −0
Original line number Diff line number Diff line
fixGprProjectDarwinRpath() {
    for f in $(find $out -type f -executable); do
        install_name_tool -id $f $f || true
        for rpath in $(otool -L $f | grep @rpath | awk '{print $1}'); do
            install_name_tool -change $rpath ${!outputLib}/lib/$(basename $rpath) $f || true
        done
    done
}

preFixupPhases+=" fixGprProjectDarwinRpath"
+0 −13
Original line number Diff line number Diff line
@@ -6,16 +6,3 @@ addAdaObjectsPath() {
}

addEnvHooks "$targetOffset" addAdaObjectsPath

fixDarwinRpath() {
    for f in $(find $out -type f -executable); do
        install_name_tool -id $f $f || true
        for rpath in $(otool -L $f | grep rpath | awk '{print $1}'); do
            install_name_tool -change $rpath $out/lib/$(basename $rpath) $f || true
        done
    done
}

if [ "$(uname)" = "Darwin" ]; then
    preFixupPhases+=" fixDarwinRpath"
fi