|
1 | | -{ lib, stdenv, fetchurlBoot, buildPackages, enableThreading ? stdenv ? glibc, fetchpatch }: |
| 1 | +{ lib, stdenv, fetchurlBoot, buildPackages |
| 2 | +, enableThreading ? stdenv ? glibc, fetchpatch, makeWrapper |
| 3 | +}: |
2 | 4 |
|
3 | 5 | with lib; |
4 | 6 |
|
|
29 | 31 | }; |
30 | 32 |
|
31 | 33 | # TODO: Add a "dev" output containing the header files. |
32 | | - outputs = [ "out" "man" "devdoc" ]; |
| 34 | + outputs = [ "out" "man" "devdoc" ] ++ |
| 35 | + stdenv.lib.optional crossCompiling "dev"; |
33 | 36 | setOutputFlags = false; |
34 | 37 |
|
35 | 38 | patches = |
|
45 | 48 | }) |
46 | 49 | ++ optional stdenv.isSunOS ./ld-shared.patch |
47 | 50 | ++ optional stdenv.isDarwin ./cpp-precomp.patch |
48 | | - ++ optional (stdenv.isDarwin && versionAtLeast version "5.24") ./sw_vers.patch; |
| 51 | + ++ optional (stdenv.isDarwin && versionAtLeast version "5.24") ./sw_vers.patch |
| 52 | + ++ optional crossCompiling ./MakeMaker-cross.patch; |
49 | 53 |
|
50 | 54 | postPatch = '' |
51 | 55 | pwd="$(type -P pwd)" |
|
117 | 121 | if stdenv.cc.cc or null != null then stdenv.cc.cc else "/no-such-path" |
118 | 122 | }" /no-such-path \ |
119 | 123 | --replace "$man" /no-such-path |
| 124 | + '' + stdenv.lib.optionalString crossCompiling |
| 125 | + '' |
| 126 | + mkdir -p $dev/lib/perl5/cross_perl/${version} |
| 127 | + for dir in cnf/{stub,cpan}; do |
| 128 | + cp -r $dir/* $dev/lib/perl5/cross_perl/${version} |
| 129 | + done |
| 130 | +
|
| 131 | + mkdir -p $dev/bin |
| 132 | + install -m755 miniperl $dev/bin/perl |
| 133 | +
|
| 134 | + export runtimeArch="$(ls $out/lib/perl5/site_perl/${version})" |
| 135 | + # wrapProgram should use a runtime-native SHELL by default, but |
| 136 | + # it actually uses a buildtime-native one. If we ever fix that, |
| 137 | + # we'll need to fix this to use a buildtime-native one. |
| 138 | + # |
| 139 | + # Adding the arch-specific directory is morally incorrect, as |
| 140 | + # miniperl can't load the native modules there. However, it can |
| 141 | + # (and sometimes needs to) load and run some of the pure perl |
| 142 | + # code there, so we add it anyway. When needed, stubs can be put |
| 143 | + # into $dev/lib/perl5/cross_perl/${version}. |
| 144 | + wrapProgram $dev/bin/perl --prefix PERL5LIB : \ |
| 145 | + "$dev/lib/perl5/cross_perl/${version}:$out/lib/perl5/${version}:$out/lib/perl5/${version}/$runtimeArch" |
120 | 146 | ''; # */ |
121 | 147 |
|
122 | 148 | meta = { |
|
139 | 165 | sha256 = "1gh8w9m5if2s0lrx2x8f8grp74d1l6d46m8jglpjm5a1kf55j810"; |
140 | 166 | }; |
141 | 167 |
|
142 | | - depsBuildBuild = [ buildPackages.stdenv.cc ]; |
| 168 | + depsBuildBuild = [ buildPackages.stdenv.cc makeWrapper ]; |
143 | 169 |
|
144 | 170 | postUnpack = '' |
145 | 171 | unpackFile ${perl-cross-src} |
|
150 | 176 | ''; |
151 | 177 |
|
152 | 178 | configurePlatforms = [ "build" "host" "target" ]; |
| 179 | + |
| 180 | + inherit version; |
| 181 | + |
| 182 | + # TODO merge setup hooks |
| 183 | + setupHook = ./setup-hook-cross.sh; |
153 | 184 | }); |
154 | 185 | in rec { |
155 | 186 | perl = perl524; |
|
0 commit comments