@ -1,18 +1,19 @@
{ stdenv , fetchurl , icu , expat , zlib , bzip2 , python , fixDarwinDylibNames , libiconv
, buildPlatform , hostPlatform
, toolset ? if stdenv . cc . isClang then " c l a n g " else null
, which
, buildPackages , buildPlatform , hostPlatform
, toolset ? /* */ if stdenv . cc . isClang then " c l a n g "
else if stdenv . cc . isGNU && hostPlatform != buildPlatform then " g c c - c r o s s "
else null
, enableRelease ? true
, enableDebug ? false
, enableSingleThreaded ? false
, enableMultiThreaded ? true
, enableShared ? ! ( hostPlatform . libc == " m s v c r t " ) # problems for now
, enableStatic ? ! enableShared
, enablePIC ? false
, enableExceptions ? false
, enablePython ? hostPlatform == buildPlatform
, enableNumpy ? false
, taggedLayout ? ( ( enableRelease && enableDebug ) || ( enableSingleThreaded && enableMultiThreaded ) || ( enableShared && enableStatic ) )
, patches ? null
, patches ? [ ]
, mpi ? null
# Attributes inherit from specific versions
@ -21,8 +22,9 @@
} :
# We must build at least one type of libraries
assert ! enableShared -> enableStatic ;
assert enableShared || enableStatic ;
# Python isn't supported when cross-compiling
assert enablePython -> hostPlatform == buildPlatform ;
assert enableNumpy -> enablePython ;
@ -46,86 +48,41 @@ let
# To avoid library name collisions
layout = if taggedLayout then " t a g g e d " else " s y s t e m " ;
cflags = if enablePIC && enableExceptions then
" c f l a g s = \" - f P I C - f e x c e p t i o n s \" c x x f l a g s = - f P I C l i n k f l a g s = - f P I C "
else if enablePIC then
" c f l a g s = - f P I C c x x f l a g s = - f P I C l i n k f l a g s = - f P I C "
else if enableExceptions then
" c f l a g s = - f e x c e p t i o n s "
else
" " ;
withToolset = stdenv . lib . optionalString ( toolset != null ) " - - w i t h - t o o l s e t = ${ toolset } " ;
genericB2Flags = [
b2Args = concatStringsSep " " ( [
" - - i n c l u d e d i r = $ d e v / i n c l u d e "
" - - l i b d i r = $ o u t / l i b "
" - j $ N I X _ B U I L D _ C O R E S "
" - - l a y o u t = ${ layout } "
" v a r i a n t = ${ variant } "
" t h r e a d i n g = ${ threading } "
] ++ optional ( link != " s t a t i c " ) " r u n t i m e - l i n k = ${ runtime-link } " ++ [
" r u n t i m e - l i n k = ${ runtime-link } "
" l i n k = ${ link } "
" ${ cflags } "
] ++ optional ( variant == " r e l e a s e " ) " d e b u g - s y m b o l s = o f f "
++ optional ( ! enablePython ) " - - w i t h o u t - p y t h o n " ;
nativeB2Flags = [
" - s E X P A T _ I N C L U D E = ${ expat . dev } / i n c l u d e "
" - s E X P A T _ L I B P A T H = ${ expat . out } / l i b "
] ++ optional ( toolset != null ) " t o o l s e t = ${ toolset } "
++ optional ( mpi != null ) " - - u s e r - c o n f i g = u s e r - c o n f i g . j a m " ;
nativeB2Args = concatStringsSep " " ( genericB2Flags ++ nativeB2Flags ) ;
crossB2Flags = [
" - s E X P A T _ I N C L U D E = ${ expat . crossDrv } / i n c l u d e "
" - s E X P A T _ L I B P A T H = ${ expat . crossDrv } / l i b "
" - - u s e r - c o n f i g = u s e r - c o n f i g . j a m "
" t o o l s e t = g c c - c r o s s "
] ++ optionals ( hostPlatform . libc == " m s v c r t " ) [
] ++ optional ( variant == " r e l e a s e " ) " d e b u g - s y m b o l s = o f f "
++ optional ( toolset != null ) " t o o l s e t = ${ toolset } "
++ optional ( mpi != null || hostPlatform != buildPlatform ) " - - u s e r - c o n f i g = u s e r - c o n f i g . j a m "
++ optionals ( hostPlatform . libc == " m s v c r t " ) [
" t a r g e t - o s = w i n d o w s "
" t h r e a d a p i = w i n 3 2 "
" b i n a r y - f o r m a t = p e "
" a d d r e s s - m o d e l = ${ toString hostPlatform . parsed . cpu . bits } "
" a r c h i t e c t u r e = x 8 6 "
] ;
crossB2Args = concatStringsSep " " ( genericB2Flags ++ crossB2Flags ) ;
builder = b2Args : ''
./b2 $ { b2Args }
'' ;
installer = b2Args : ''
# boostbook is needed by some applications
mkdir - p $ dev/share/boostbook
cp - a tools/boostbook / { xsl , dtd } $ dev/share/boostbook /
# Let boost install everything else
./b2 $ { b2Args } install
'' ;
commonConfigureFlags = [
" - - i n c l u d e d i r = $ ( d e v ) / i n c l u d e "
" - - l i b d i r = $ ( o u t ) / l i b "
] ;
fixup = ''
# Make boost header paths relative so that they are not runtime dependencies
(
cd " $ d e v "
find include \ ( - name ' * . hpp' - or - name ' * . h' - or - name ' * . ipp' \ ) \
- exec sed ' 1 i #line 1 "{}"' -i '{}' \;
)
'' + o p t i o n a l S t r i n g ( h o s t P l a t f o r m . l i b c = = " m s v c r t " ) ''
$ { stdenv . cc . targetPrefix } ranlib " $ o u t / l i b / " * . a
'' ;
] ) ;
in
stdenv . mkDerivation {
name = " b o o s t - ${ version } " ;
inherit src patches version ;
inherit src ;
patchFlags = optionalString ( hostPlatform . libc == " m s v c r t " ) " - p 0 " ;
patches = patches ++ optional ( hostPlatform . libc == " m s v c r t " ) ( fetchurl {
url = " h t t p s : / / s v n . b o o s t . o r g / t r a c / b o o s t / r a w - a t t a c h m e n t / t i c k a e t / 7 2 6 2 / "
+ " b o o s t - m i n g w . p a t c h " ;
sha256 = " 0 s 3 2 k w l l 6 6 k 5 0 w 6 r 5 n p 1 y 5 g 9 0 7 b 7 l c p s j h f g r 7 r s w 7 q 5 s y h z d d y j " ;
} ) ;
meta = {
homepage = http://boost.org/ ;
@ -142,9 +99,13 @@ stdenv.mkDerivation {
- - replace ' @ rpath / $ ( < [ 1 ] : D = ) ' " $ o u t / l i b / \$ ( < [ 1 ] : D = ) " ;
fi ;
'' + o p t i o n a l S t r i n g ( m p i ! = n u l l ) ''
cat < < EOF > user-config . jam
cat < < EOF > > user-config . jam
using mpi : $ { mpi } /bin/mpiCC ;
EOF
'' + o p t i o n a l S t r i n g ( h o s t P l a t f o r m ! = b u i l d P l a t f o r m ) ''
cat < < EOF > > user-config . jam
using gcc : cross : $ { stdenv . cc . targetPrefix } c ++ ;
EOF
'' ;
NIX_CFLAGS_LINK = stdenv . lib . optionalString stdenv . isDarwin
@ -152,6 +113,7 @@ stdenv.mkDerivation {
enableParallelBuilding = true ;
nativeBuildInputs = [ which buildPackages . stdenv . cc ] ;
buildInputs = [ expat zlib bzip2 libiconv ]
++ optional ( hostPlatform == buildPlatform ) icu
++ optional stdenv . isDarwin fixDarwinDylibNames
@ -159,39 +121,35 @@ stdenv.mkDerivation {
++ optional enableNumpy python . pkgs . numpy ;
configureScript = " . / b o o t s t r a p . s h " ;
configureFlags = commonConfigureFlags
++ [ " - - w i t h - p y t h o n = ${ python . interpreter } " ]
++ optional ( hostPlatform == buildPlatform ) " - - w i t h - i c u = ${ icu . dev } "
++ optional ( toolset != null ) " - - w i t h - t o o l s e t = ${ toolset } " ;
configurePlatforms = [ ] ;
configureFlags = [
" - - i n c l u d e d i r = $ ( d e v ) / i n c l u d e "
" - - l i b d i r = $ ( o u t ) / l i b "
( if enablePython then " - - w i t h - p y t h o n = ${ python . interpreter } " else " - - w i t h o u t - p y t h o n " )
( if hostPlatform == buildPlatform then " - - w i t h - i c u = ${ icu . dev } " else " - - w i t h o u t - i c u " )
] ++ optional ( toolset != null ) " - - w i t h - t o o l s e t = ${ toolset } " ;
buildPhase = builder nativeB2Args ;
buildPhase = ''
./b2 $ { b2Args }
'' ;
installPhase = ''
# boostbook is needed by some applications
mkdir - p $ dev/share/boostbook
cp - a tools/boostbook / { xsl , dtd } $ dev/share/boostbook /
installPhase = installer nativeB2Args ;
# Let boost install everything else
./b2 $ { b2Args } install
'' ;
postFixup = fixup ;
postFixup = ''
# Make boost header paths relative so that they are not runtime dependencies
find " $ d e v / i n c l u d e " \ ( - name ' * . hpp' - or - name ' * . h' - or - name ' * . ipp' \ ) \
- exec sed ' 1 i #line 1 "{}"' -i '{}' \;
'' + o p t i o n a l S t r i n g ( h o s t P l a t f o r m . l i b c = = " m s v c r t " ) ''
$ RANLIB " $ o u t / l i b / " * . a
'' ;
outputs = [ " o u t " " d e v " ] ;
setOutputFlags = false ;
crossAttrs = rec {
# We want to substitute the contents of configureFlags, removing thus the
# usual --build and --host added on cross building.
preConfigure = ''
export configureFlags = " - - w i t h o u t - i c u ${ concatStringsSep " " commonConfigureFlags } "
cat < < EOF > user-config . jam
using gcc : cross : $ crossConfig-g ++ ;
EOF
'' ;
buildPhase = builder crossB2Args ;
installPhase = installer crossB2Args ;
postFixup = fixup ;
} // optionalAttrs ( hostPlatform . libc == " m s v c r t " ) {
patches = fetchurl {
url = " h t t p s : / / s v n . b o o s t . o r g / t r a c / b o o s t / r a w - a t t a c h m e n t / t i c k e t / 7 2 6 2 / "
+ " b o o s t - m i n g w . p a t c h " ;
sha256 = " 0 s 3 2 k w l l 6 6 k 5 0 w 6 r 5 n p 1 y 5 g 9 0 7 b 7 l c p s j h f g r 7 r s w 7 q 5 s y h z d d y j " ;
} ;
patchFlags = " - p 0 " ;
} ;
}