summary refs log tree commit diff
path: root/pkgs/tools/misc/mandoc
diff options
context:
space:
mode:
authorsternenseemann <sternenseemann@systemli.org>2021-09-19 19:49:29 +0200
committersternenseemann <sternenseemann@systemli.org>2021-09-23 21:24:10 +0200
commita43f48b710cde16db55a950e77b8cca26e1268af (patch)
tree05fb904221d385cd8245acd810893cfeb9af2c08 /pkgs/tools/misc/mandoc
parent35e8d91d921b412c9e6046e59ee279738dc43050 (diff)
downloadnixpkgs-a43f48b710cde16db55a950e77b8cca26e1268af.tar
nixpkgs-a43f48b710cde16db55a950e77b8cca26e1268af.tar.gz
nixpkgs-a43f48b710cde16db55a950e77b8cca26e1268af.tar.bz2
nixpkgs-a43f48b710cde16db55a950e77b8cca26e1268af.tar.lz
nixpkgs-a43f48b710cde16db55a950e77b8cca26e1268af.tar.xz
nixpkgs-a43f48b710cde16db55a950e77b8cca26e1268af.tar.zst
nixpkgs-a43f48b710cde16db55a950e77b8cca26e1268af.zip
mandoc: support cross as far as possible
mandoc can't be cross compiled easily since all configure checks rely on
executing a binary built using $CC. We can however still do “native”
cross compilation like pkgsStatic and pkgsLLVM. To facilitate this, the
following changes are required:

* Set the correct AR to use in configure.local

* Inform users that cross compilation will fail via a throw if the build
  platform can't execute the host platform's binaries.
Diffstat (limited to 'pkgs/tools/misc/mandoc')
-rw-r--r--pkgs/tools/misc/mandoc/default.nix12
1 files changed, 11 insertions, 1 deletions
diff --git a/pkgs/tools/misc/mandoc/default.nix b/pkgs/tools/misc/mandoc/default.nix
index 5eae82c14a5..75c6ac8b41b 100644
--- a/pkgs/tools/misc/mandoc/default.nix
+++ b/pkgs/tools/misc/mandoc/default.nix
@@ -1,6 +1,12 @@
 { lib, stdenv, fetchurl, zlib, perl }:
 
 let
+  # check if we can execute binaries for the host platform on the build platform
+  # even though the platforms aren't the same. mandoc can't be cross compiled
+  # (easily) because of its configurePhase, but we want to allow “native” cross
+  # such as pkgsLLVM and pkgsStatic.
+  executableCross = stdenv.hostPlatform.isCompatible stdenv.buildPlatform;
+
   # Name of an UTF-8 locale _always_ present at runtime, used for UTF-8 support
   # (locale set by the user may differ). This would usually be C.UTF-8, but
   # darwin has no such locale.
@@ -10,6 +16,9 @@ let
     else "C.UTF-8";
 in
 
+assert executableCross ||
+  throw "mandoc relies on executing compiled programs in configurePhase, can't cross compile";
+
 stdenv.mkDerivation rec {
   pname = "mandoc";
   version = "1.14.6";
@@ -27,6 +36,7 @@ stdenv.mkDerivation rec {
     PREFIX="$out"
     LD_OHASH="-lutil"
     CC=${stdenv.cc.targetPrefix}cc
+    AR=${stdenv.cc.bintools.targetPrefix}ar
     # Bypass the locale(1)-based check for UTF-8 support since it causes trouble:
     # * We only have meaningful locale(1) implementations for glibc and macOS
     # * NetBSD's locale(1) (used for macOS) depends on mandoc
@@ -40,7 +50,7 @@ stdenv.mkDerivation rec {
     printf '%s' "$configureLocal" > configure.local
   '';
 
-  doCheck = stdenv.hostPlatform == stdenv.buildPlatform;
+  doCheck = executableCross;
   checkTarget = "regress";
   checkInputs = [ perl ];
   preCheck = "patchShebangs --build regress/regress.pl";