ibm-sw-tpm2: add Darwin support

The upstream sources ship with a dedicated Makefile for macOS.
This commit conditionally uses the macOS makefile if build on Darwin.
This commit is contained in:
Steffen Vogel 2023-12-09 08:26:58 +01:00 committed by Weijia Wang
parent ad1e07c64b
commit 90ee16016c

View file

@ -4,7 +4,12 @@
, fetchpatch
, openssl
}:
let
makefile =
if stdenv.isDarwin
then "makefile.mac"
else "makefile";
in
stdenv.mkDerivation rec {
pname = "ibm-sw-tpm2";
version = "1682";
@ -30,12 +35,14 @@ stdenv.mkDerivation rec {
sourceRoot = "src";
inherit makefile;
prePatch = ''
# Fix hardcoded path to GCC.
substituteInPlace makefile --replace /usr/bin/gcc "${stdenv.cc}/bin/cc"
substituteInPlace ${makefile} --replace /usr/bin/gcc "${stdenv.cc}/bin/cc"
# Remove problematic default CFLAGS.
substituteInPlace makefile \
substituteInPlace ${makefile} \
--replace -Werror "" \
--replace -O0 "" \
--replace -ggdb ""
@ -49,7 +56,7 @@ stdenv.mkDerivation rec {
meta = with lib; {
description = "IBM's Software TPM 2.0, an implementation of the TCG TPM 2.0 specification";
homepage = "https://sourceforge.net/projects/ibmswtpm2/";
platforms = platforms.linux;
platforms = platforms.linux ++ platforms.darwin;
maintainers = with maintainers; [ delroth ];
license = licenses.bsd3;
};