lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v192 107 lines 3.3 kB view raw
1{ stdenv, fetchurl, enableThreading ? stdenv ? glibc }: 2 3# We can only compile perl with threading on platforms where we have a 4# real glibc in the stdenv. 5# 6# Instead of silently building an unthreaded perl if this is not the 7# case, we force callers to disableThreading explicitly, therefore 8# documenting the platforms where the perl is not threaded. 9# 10# In the case of stdenv linux boot stage1 it's not possible to use 11# threading because of the simpleness of the bootstrap glibc, so we 12# use enableThreading = false there. 13assert enableThreading -> (stdenv ? glibc); 14 15let 16 17 libc = if stdenv.cc.libc or null != null then stdenv.cc.libc else "/usr"; 18 19in 20 21with stdenv.lib; 22 23stdenv.mkDerivation rec { 24 name = "perl-5.22.0"; 25 26 src = fetchurl { 27 url = "mirror://cpan/src/5.0/${name}.tar.gz"; 28 sha256 = "0g5bl8sdpzx9gx2g5jq3py4bj07z2ylk7s1qn0fvsss2yl3hhs8c"; 29 }; 30 31 outputs = [ "out" "man" ]; 32 33 patches = 34 [ # Do not look in /usr etc. for dependencies. 35 ./no-sys-dirs.patch 36 ] 37 ++ optional stdenv.isSunOS ./ld-shared.patch 38 ++ stdenv.lib.optional stdenv.isDarwin [ ./cpp-precomp.patch ./no-libutil.patch ]; 39 40 # Build a thread-safe Perl with a dynamic libperls.o. We need the 41 # "installstyle" option to ensure that modules are put under 42 # $out/lib/perl5 - this is the general default, but because $out 43 # contains the string "perl", Configure would select $out/lib. 44 # Miniperl needs -lm. perl needs -lrt. 45 configureFlags = 46 [ "-de" 47 "-Dcc=cc" 48 "-Uinstallusrbinperl" 49 "-Dinstallstyle=lib/perl5" 50 "-Duseshrplib" 51 "-Dlocincpth=${libc}/include" 52 "-Dloclibpth=${libc}/lib" 53 ] 54 ++ optional enableThreading "-Dusethreads"; 55 56 configureScript = "${stdenv.shell} ./Configure"; 57 58 dontAddPrefix = true; 59 60 enableParallelBuilding = true; 61 62 preConfigure = 63 '' 64 65 configureFlags="$configureFlags -Dprefix=$out -Dman1dir=$out/share/man/man1 -Dman3dir=$out/share/man/man3" 66 67 ${optionalString stdenv.isArm '' 68 configureFlagsArray=(-Dldflags="-lm -lrt") 69 ''} 70 '' + optionalString stdenv.isDarwin '' 71 substituteInPlace hints/darwin.sh --replace "env MACOSX_DEPLOYMENT_TARGET=10.3" "" 72 '' + optionalString (!enableThreading) '' 73 # We need to do this because the bootstrap doesn't have a static libpthread 74 sed -i 's,\(libswanted.*\)pthread,\1,g' Configure 75 ''; 76 77 preBuild = optionalString (!(stdenv ? cc && stdenv.cc.nativeTools)) 78 '' 79 # Make Cwd work on NixOS (where we don't have a /bin/pwd). 80 substituteInPlace dist/PathTools/Cwd.pm --replace "'/bin/pwd'" "'$(type -tP pwd)'" 81 ''; 82 83 setupHook = ./setup-hook.sh; 84 85 passthru.libPrefix = "lib/perl5/site_perl"; 86 87 preCheck = '' 88 # Try and setup a local hosts file 89 if [ -f "${libc}/lib/libnss_files.so" ]; then 90 mkdir $TMPDIR/fakelib 91 cp "${libc}/lib/libnss_files.so" $TMPDIR/fakelib 92 sed -i 's,/etc/hosts,/dev/fd/3,g' $TMPDIR/fakelib/libnss_files.so 93 export LD_LIBRARY_PATH=$TMPDIR/fakelib 94 fi 95 ''; 96 97 postCheck = '' 98 unset LD_LIBRARY_PATH 99 ''; 100 101 meta = { 102 homepage = https://www.perl.org/; 103 description = "The standard implementation of the Perl 5 programmming language"; 104 maintainers = [ maintainers.eelco ]; 105 platforms = platforms.all; 106 }; 107}