inchi: fix build on darwin

This commit is contained in:
Robert T. McGibbon 2020-12-22 21:55:05 -05:00
parent 86d5d9650d
commit e90ec60e33

View file

@ -1,4 +1,11 @@
{ pkgs, fetchurl, lib, stdenv, unzip }: { pkgs
, fetchurl
, lib
, stdenv
, unzip
, fixDarwinDylibNames
}:
stdenv.mkDerivation { stdenv.mkDerivation {
pname = "inchi"; pname = "inchi";
version = "1.05"; version = "1.05";
@ -7,15 +14,23 @@ stdenv.mkDerivation {
sha1 = "e3872a46d58cb321a98f4fd4b93a989fb6920b9c"; sha1 = "e3872a46d58cb321a98f4fd4b93a989fb6920b9c";
}; };
nativeBuildInputs = [ pkgs.unzip ]; nativeBuildInputs = [ unzip ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
outputs = [ "out" "doc" ]; outputs = [ "out" "doc" ];
enableParallelBuilding = true; enableParallelBuilding = true;
preBuild = '' preConfigure = ''
cd ./INCHI_API/libinchi/gcc cd ./INCHI_API/libinchi/gcc
'' + lib.optionalString stdenv.isDarwin ''
substituteInPlace makefile \
--replace ",--version-script=libinchi.map" "" \
--replace "LINUX_Z_RELRO = ,-z,relro" "" \
--replace "-soname" "-install_name" \
--replace "gcc" $CC
''; '';
installPhase = '' installPhase = ''
runHook preInstall
cd ../../.. cd ../../..
mkdir -p $out/lib mkdir -p $out/lib
mkdir -p $out/include/inchi mkdir -p $out/include/inchi
@ -29,6 +44,10 @@ stdenv.mkDerivation {
runHook postInstall runHook postInstall
''; '';
preFixup = lib.optionalString stdenv.isDarwin ''
fixDarwinDylibNames $(find "$out" -name "*.so.*")
'';
postInstall = postInstall =
let let
src-doc = fetchurl { src-doc = fetchurl {
@ -45,7 +64,6 @@ stdenv.mkDerivation {
homepage = "https://www.inchi-trust.org/"; homepage = "https://www.inchi-trust.org/";
description = "IUPAC International Chemical Identifier library"; description = "IUPAC International Chemical Identifier library";
license = licenses.lgpl2Plus; license = licenses.lgpl2Plus;
platforms = platforms.all;
maintainers = with maintainers; [ rmcgibbo ]; maintainers = with maintainers; [ rmcgibbo ];
}; };
} }