libvpx: fix build for BSD

This is basically the same approach FreeBSD Ports takes, except they
use a patch instead of the configure flag.  Since we were already
using the configure flag, I decided to go with that.

Usually I'd submit a patch upstream for this sort of thing, but I
didn't in this case because submitting a patch requires creating a
Google account and agreeing to a CLA, and because Google is
notoriously hostile to BSD patches.

Tested building for NetBSD.  For FreeBSD it will work once another fix
I have in the works lands.
This commit is contained in:
Alyssa Ross 2023-01-19 14:52:04 +00:00
parent 89861f1ceb
commit 486c53183d

View File

@ -41,6 +41,25 @@
let
inherit (stdenv) is64bit isMips isDarwin isCygwin;
inherit (lib) enableFeature optional optionals;
# libvpx darwin targets include darwin version (ie. ARCH-darwinXX-gcc, XX being the darwin version)
# See all_platforms: https://github.com/webmproject/libvpx/blob/master/configure
# Darwin versions: 10.4=8, 10.5=9, 10.6=10, 10.7=11, 10.8=12, 10.9=13, 10.10=14
darwinVersion =
/**/ if stdenv.hostPlatform.osxMinVersion == "10.10" then "14"
else if stdenv.hostPlatform.osxMinVersion == "10.9" then "13"
else if stdenv.hostPlatform.osxMinVersion == "10.8" then "12"
else if stdenv.hostPlatform.osxMinVersion == "10.7" then "11"
else if stdenv.hostPlatform.osxMinVersion == "10.6" then "10"
else if stdenv.hostPlatform.osxMinVersion == "10.5" then "9"
else "8";
kernel =
# Build system doesn't understand BSD, so pretend to be Linux.
/**/ if stdenv.isBSD then "linux"
else if stdenv.isDarwin then "darwin${darwinVersion}"
else stdenv.hostPlatform.parsed.kernel.name;
in
assert vp8DecoderSupport || vp8EncoderSupport || vp9DecoderSupport || vp9EncoderSupport;
@ -144,20 +163,8 @@ stdenv.mkDerivation rec {
(enableFeature (experimentalSpatialSvcSupport ||
experimentalFpMbStatsSupport ||
experimentalEmulateHardwareSupport) "experimental")
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
# libvpx darwin targets include darwin version (ie. ARCH-darwinXX-gcc, XX being the darwin version)
# See all_platforms: https://github.com/webmproject/libvpx/blob/master/configure
# Darwin versions: 10.4=8, 10.5=9, 10.6=10, 10.7=11, 10.8=12, 10.9=13, 10.10=14
"--force-target=${stdenv.hostPlatform.parsed.cpu.name}-${stdenv.hostPlatform.parsed.kernel.name}${
if stdenv.hostPlatform.isDarwin then
if stdenv.hostPlatform.osxMinVersion == "10.10" then "14"
else if stdenv.hostPlatform.osxMinVersion == "10.9" then "13"
else if stdenv.hostPlatform.osxMinVersion == "10.8" then "12"
else if stdenv.hostPlatform.osxMinVersion == "10.7" then "11"
else if stdenv.hostPlatform.osxMinVersion == "10.6" then "10"
else if stdenv.hostPlatform.osxMinVersion == "10.5" then "9"
else "8"
else ""}-gcc"
] ++ optionals (stdenv.isBSD || stdenv.hostPlatform != stdenv.buildPlatform) [
"--force-target=${stdenv.hostPlatform.parsed.cpu.name}-${kernel}-gcc"
(if stdenv.hostPlatform.isCygwin then "--enable-static-msvcrt" else "")
] # Experimental features
++ optional experimentalSpatialSvcSupport "--enable-spatial-svc"