Skip to content

Commit

Permalink
ghostscript: fix install names on Darwin
Browse files Browse the repository at this point in the history
Fixes #355377.

This should avoid the need to mess around with `install_name_tool`
entirely. This mirrors what is done by Homebrew[^1] and MacPorts[^2].

This should also make the changes in #355853 and #357951 unnecessary.

[^1]: https://github.com/Homebrew/homebrew-core/blob/5ca4f8ce766c69d49321fb7da1d297b8232f40cf/Formula/g/ghostscript.rb#L76
[^2]: https://github.com/macports/macports-ports/blob/d8a05520fa6a81fa5b0365068590aff184976b69/print/ghostscript/Portfile#L114
  • Loading branch information
carlocab committed Nov 22, 2024
1 parent 542a7c0 commit 8b3d3d5
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions pkgs/misc/ghostscript/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ stdenv.mkDerivation rec {
sed "s@^ZLIBDIR=.*@ZLIBDIR=${zlib.dev}/include@" -i configure.ac
autoconf
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
export DARWIN_LDFLAGS_SO_PREFIX=$out/lib/
'';

configureFlags = [
Expand Down Expand Up @@ -140,19 +142,8 @@ stdenv.mkDerivation rec {
done
'';

# dynamic library name only contains maj.min, eg. '9.53'
dylib_version = lib.versions.majorMinor version;
preFixup = lib.optionalString stdenv.isDarwin ''
install_name_tool -change libgs.dylib.$dylib_version $out/lib/libgs.dylib.$dylib_version $out/bin/gs
install_name_tool -change libgs.dylib.$dylib_version $out/lib/libgs.dylib.$dylib_version $out/bin/gsx
'';

# validate dynamic linkage
doInstallCheck = true;
preInstallCheck = if stdenv.hostPlatform.isDarwin then ''
DYLD_LIBRARY_PATH=$out/lib
export DYLD_LIBRARY_PATH
'' else null;
installCheckPhase = ''
runHook preInstallCheck
Expand Down

0 comments on commit 8b3d3d5

Please sign in to comment.