nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib, stdenv, crossStageStatic, langD ? false, libcCross, threadsCross }:
2
3let
4 inherit (stdenv) hostPlatform targetPlatform;
5in
6
7{
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"}"
16 ]);
17 in mkFlags libcCross langD
18 ++ lib.optionals (!crossStageStatic) (mkFlags (threadsCross.package or null) langD)
19 ;
20
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"}"
26 ] else [
27 "-Wl,-rpath,${lib.getLib dep}${dep.libdir or "/lib"}"
28 "-Wl,-rpath-link,${lib.getLib dep}${dep.libdir or "/lib"}"
29 ]));
30 in mkFlags libcCross
31 ++ lib.optionals (!crossStageStatic) (mkFlags (threadsCross.package or null))
32 ;
33}