···
1
-
{ lib, stdenv, fetchurlBoot, enableThreading ? stdenv ? glibc }:
1
+
{ lib, stdenv, fetchurlBoot, buildPackages, enableThreading ? stdenv ? glibc }:
···
libc = if stdenv.cc.libc or null != null then stdenv.cc.libc else "/usr";
libcInc = lib.getDev libc;
libcLib = lib.getLib libc;
22
-
common = { version, sha256 }: stdenv.mkDerivation rec {
22
+
crossCompiling = stdenv.buildPlatform != stdenv.hostPlatform;
23
+
common = { version, sha256 }: stdenv.mkDerivation (rec {
name = "perl-${version}";
···
substituteInPlace dist/PathTools/Cwd.pm \
--replace "/bin/pwd" "$pwd"
54
+
'' + stdenv.lib.optionalString crossCompiling ''
55
+
substituteInPlace cnf/configure_tool.sh --replace "cc -E -P" "cc -E"
# Build a thread-safe Perl with a dynamic libperls.o. We need the
···
# contains the string "perl", Configure would select $out/lib.
# Miniperl needs -lm. perl needs -lrt.
65
+
then [ "-Dlibpth=\"\"" "-Dglibpth=\"\"" ]
66
+
else [ "-de" "-Dcc=cc" ])
"-Dinstallstyle=lib/perl5"
···
++ optional stdenv.isSunOS "-Dcc=gcc"
++ optional enableThreading "-Dusethreads";
72
-
configureScript = "${stdenv.shell} ./Configure";
77
+
configureScript = stdenv.lib.optionalString (!crossCompiling) "${stdenv.shell} ./Configure";
74
-
dontAddPrefix = true;
79
+
dontAddPrefix = !crossCompiling;
76
-
enableParallelBuilding = true;
81
+
enableParallelBuilding = !crossCompiling;
83
+
preConfigure = optionalString (!crossCompiling) ''
configureFlags="$configureFlags -Dprefix=$out -Dman1dir=$out/share/man/man1 -Dman3dir=$out/share/man/man3"
'' + optionalString (stdenv.isArm || stdenv.isMips) ''
configureFlagsArray=(-Dldflags="-lm -lrt")
···
maintainers = [ maintainers.eelco ];
platforms = platforms.all;
128
+
} // stdenv.lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) rec {
129
+
crossVersion = "1.1.8";
131
+
perl-cross-src = fetchurlBoot {
132
+
url = "https://github.com/arsv/perl-cross/releases/download/${crossVersion}/perl-cross-${crossVersion}.tar.gz";
133
+
sha256 = "072j491rpz2qx2sngbg4flqh4lx5865zyql7b9lqm6s1kknjdrh8";
136
+
nativeBuildInputs = [ buildPackages.stdenv.cc ];
139
+
unpackFile ${perl-cross-src}
140
+
cp -R perl-cross-${crossVersion}/* perl-${version}/
143
+
configurePlatforms = [ "build" "host" "target" ];