julia03: avoid opaque shell scripts

The old expression used a shell script to set some repetitive
makeFlags. The makeFlags settings were spread out over different parts
of the expression. This deters new contributors. The new expression is
clearer, at the cost of being slightly repetitive.
This commit is contained in:
Thomas Tuegel 2015-06-04 13:31:15 -05:00
parent 1a11b52ffa
commit 6e3eac5c92

View file

@ -35,6 +35,29 @@ stdenv.mkDerivation rec {
};
in [ dsfmt_src ];
prePatch = ''
copy_kill_hash(){
cp "$1" "$2/$(basename "$1" | sed -e 's/^[a-z0-9]*-//')"
}
for i in $extraSrcs; do
copy_kill_hash "$i" deps
done
'';
postPatch = ''
sed -i deps/Makefile \
-e "s@/usr/local/lib@$out/lib@g" \
-e "s@/usr/lib@$out/lib@g" \
-e "s@/usr/include/double-conversion@${double_conversion}/include/double-conversion@g"
patchShebangs . contrib
# ldconfig doesn't seem to ever work on NixOS; system-wide ldconfig cache
# is probably not what we want anyway on non-NixOS
sed -e "s@/sbin/ldconfig@true@" -i src/ccall.*
'';
buildInputs =
[ libunwind llvm readline utf8proc zlib
double_conversion fftw fftwSinglePrec glpk gmp mpfr pcre
@ -68,28 +91,25 @@ stdenv.mkDerivation rec {
"LIBLAPACKNAME=libopenblas"
"USE_SYSTEM_ARPACK=1"
"USE_SYSTEM_FFTW=1"
"USE_SYSTEM_GLPK=1"
"USE_SYSTEM_GMP=1"
"USE_SYSTEM_GRISU=1"
"USE_SYSTEM_LIBUNWIND=1"
"USE_SYSTEM_LLVM=1"
"USE_SYSTEM_MPFR=1"
"USE_SYSTEM_PATCHELF=1"
"USE_SYSTEM_PCRE=1"
"USE_SYSTEM_READLINE=1"
"USE_SYSTEM_SUITESPARSE=1"
"USE_SYSTEM_UTF8PROC=1"
"USE_SYSTEM_ZLIB=1"
];
GLPK_PREFIX = "${glpk}/include";
NIX_CFLAGS_COMPILE = [ "-fPIC" ];
postPatch = ''
sed -i deps/Makefile \
-e "s@/usr/local/lib@$out/lib@g" \
-e "s@/usr/lib@$out/lib@g" \
-e "s@/usr/include/double-conversion@${double_conversion}/include/double-conversion@g"
patchShebangs . contrib
# ldconfig doesn't seem to ever work on NixOS; system-wide ldconfig cache
# is probably not what we want anyway on non-NixOS
sed -e "s@/sbin/ldconfig@true@" -i src/ccall.*
'';
# Julia tries to load these libraries dynamically at runtime, but they can't be found.
# Easier by far to link against them as usual.
# These go in LDFLAGS, where they affect only Julia itself, and not NIX_LDFLAGS,
@ -107,20 +127,7 @@ stdenv.mkDerivation rec {
"-lz"
];
configurePhase = ''
for i in GMP LLVM PCRE READLINE FFTW LIBUNWIND SUITESPARSE GLPK ZLIB MPFR;
do
makeFlags="$makeFlags USE_SYSTEM_$i=1 "
done
copy_kill_hash(){
cp "$1" "$2/$(basename "$1" | sed -e 's/^[a-z0-9]*-//')"
}
for i in $extraSrcs; do
copy_kill_hash "$i" deps
done
preConfigure = ''
export PATH="$PATH:${stdenv.cc.libc}/sbin"
'';