summary refs log tree commit diff
path: root/pkgs/development/compilers/gcc/common/extra-target-flags.nix
blob: 1c2fad8fbc5123f6b5905606c0af784bf86e7456 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{ stdenv, crossStageStatic, libcCross }:

let
  inherit (stdenv) lib hostPlatform targetPlatform;
in

{
  EXTRA_TARGET_FLAGS = let
      mkFlags = dep: lib.optionals (targetPlatform != hostPlatform && dep != null) ([
        "-idirafter ${lib.getDev dep}${dep.incdir or "/include"}"
      ] ++ stdenv.lib.optionals (! crossStageStatic) [
        "-B${lib.getLib dep}${dep.libdir or "/lib"}"
      ]);
    in mkFlags libcCross
    ;

  EXTRA_TARGET_LDFLAGS = let
      mkFlags = dep: lib.optionals (targetPlatform != hostPlatform && dep != null) ([
        "-Wl,-L${lib.getLib dep}${dep.libdir or "/lib"}"
      ] ++ (if crossStageStatic then [
          "-B${lib.getLib dep}${dep.libdir or "/lib"}"
        ] else [
          "-Wl,-rpath,${lib.getLib dep}${dep.libdir or "/lib"}"
          "-Wl,-rpath-link,${lib.getLib dep}${dep.libdir or "/lib"}"
      ]));
    in mkFlags libcCross
    ;
}