1 { lib, stdenv, crossStageStatic, langD ? false, libcCross, threadsCross }:
4 inherit (stdenv) hostPlatform targetPlatform;
8 # For non-cross builds these flags are currently assigned in builder.sh.
9 # It would be good to consolidate the generation of makeFlags
10 # ({C,CXX,LD}FLAGS_FOR_{BUILD,TARGET}, etc...) at some point.
11 EXTRA_FLAGS_FOR_TARGET = let
12 mkFlags = dep: langD: lib.optionals (targetPlatform != hostPlatform && dep != null && !langD) ([
13 "-O2 -idirafter ${lib.getDev dep}${dep.incdir or "/include"}"
14 ] ++ lib.optionals (! crossStageStatic) [
15 "-B${lib.getLib dep}${dep.libdir or "/lib"}"
17 in mkFlags libcCross langD
18 ++ lib.optionals (!crossStageStatic) (mkFlags threadsCross langD)
21 EXTRA_LDFLAGS_FOR_TARGET = let
22 mkFlags = dep: lib.optionals (targetPlatform != hostPlatform && dep != null) ([
23 "-Wl,-L${lib.getLib dep}${dep.libdir or "/lib"}"
24 ] ++ (if crossStageStatic then [
25 "-B${lib.getLib dep}${dep.libdir or "/lib"}"
27 "-Wl,-rpath,${lib.getLib dep}${dep.libdir or "/lib"}"
28 "-Wl,-rpath-link,${lib.getLib dep}${dep.libdir or "/lib"}"
31 ++ lib.optionals (!crossStageStatic) (mkFlags threadsCross)