@ -1,8 +1,22 @@
{ stdenv , fetchFromGitHub , autoconf , automake , libtool_2
{ stdenv , fetchFromGitHub , makeWrapper , autoconf , automake , libtool_2
, llvm , libcxx , libcxxabi , clang , libuuid
, libobjc ? null
, libobjc ? null , maloader ? null , xctoolchain ? null
, buildPlatform , hostPlatform , targetPlatform
} :
let
inherit ( stdenv . lib . systems . parse ) isDarwin ;
prefix = stdenv . lib . optionalString
( targetPlatform != hostPlatform )
" ${ targetPlatform . config } - " ;
in
assert isDarwin targetPlatform . parsed ;
# Non-Darwin alternatives
assert ( ! isDarwin hostPlatform . parsed ) -> ( maloader != null && xctoolchain != null ) ;
let
baseParams = rec {
name = " c c t o o l s - p o r t - ${ version } " ;
@ -26,7 +40,14 @@ let
enableParallelBuilding = true ;
configureFlags = stdenv . lib . optionals ( ! stdenv . isDarwin ) [ " C X X F L A G S = - I ${ libcxx } / i n c l u d e / c + + / v 1 " ] ;
configureFlags = stdenv . lib . optionals ( ! stdenv . isDarwin ) [
" C X X F L A G S = - I ${ libcxx } / i n c l u d e / c + + / v 1 "
] ++ stdenv . lib . optionals ( targetPlatform != buildPlatform ) [
# TODO make unconditional next hash break
" - - b u i l d = ${ buildPlatform . config } "
" - - h o s t = ${ hostPlatform . config } "
" - - t a r g e t = ${ targetPlatform . config } "
] ;
postPatch = ''
sed - i - e ' s/addStandardLibraryDirectories = true /addStandardLibraryDirectories = false / ' cctools/ld64/src/ld/Options.cpp
@ -69,33 +90,26 @@ let
popd
'' ;
postInstall =
if isDarwin hostPlatform . parsed
then ''
cat > $ out/bin/dsymutil < < EOF
#!${stdenv.shell}
EOF
chmod + x $ out/bin/dsymutil
''
else ''
for tool in dyldinfo dwarfdump dsymutil ; do
$ { makeWrapper } /bin/makeWrapper " ${ maloader } / b i n / l d - m a c " " $ o u t / b i n / ${ targetPlatform . config } - $ t o o l " \
- - add-flags " ${ xctoolchain } / b i n / $ t o o l "
ln - s " $ o u t / b i n / ${ targetPlatform . config } - $ t o o l " " $ o u t / b i n / $ t o o l "
done
'' ;
meta = {
homepage = " h t t p : / / w w w . o p e n s o u r c e . a p p l e . c o m / s o u r c e / c c t o o l s / " ;
description = " M a c O S X C o m p i l e r T o o l s ( c r o s s - p l a t f o r m p o r t ) " ;
license = stdenv . lib . licenses . apsl20 ;
} ;
} ;
in {
native = stdenv . mkDerivation ( baseParams // {
# A hack for now...
postInstall = ''
cat > $ out/bin/dsymutil < < EOF
#!${stdenv.shell}
EOF
chmod + x $ out/bin/dsymutil
'' ;
} ) ;
cross =
{ cross , maloader , makeWrapper , xctoolchain }: stdenv . mkDerivation ( baseParams // {
configureFlags = baseParams . configureFlags ++ [ " - - t a r g e t = ${ cross . config } " ] ;
postInstall = ''
for tool in dyldinfo dwarfdump dsymutil ; do
$ { makeWrapper } /bin/makeWrapper " ${ maloader } / b i n / l d - m a c " " $ o u t / b i n / ${ cross . config } - $ t o o l " \
- - add-flags " ${ xctoolchain } / b i n / $ t o o l "
ln - s " $ o u t / b i n / ${ cross . config } - $ t o o l " " $ o u t / b i n / $ t o o l "
done
'' ;
} ) ;
}
in stdenv . mkDerivation baseParams