2008-06-26 13:07:46 +02:00
|
|
|
# The Nix `gcc' stdenv.mkDerivation is not directly usable, since it doesn't
|
|
|
|
# know where the C library and standard header files are. Therefore
|
|
|
|
# the compiler produced by that package cannot be installed directly
|
|
|
|
# in a user environment and used from the command line. This
|
|
|
|
# stdenv.mkDerivation provides a wrapper that sets up the right environment
|
|
|
|
# variables so that the compiler and the linker just "work".
|
|
|
|
|
2009-04-09 17:24:33 +02:00
|
|
|
{ name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? ""
|
2008-06-26 13:07:46 +02:00
|
|
|
, gcc ? null, libc ? null, binutils ? null, shell ? ""
|
|
|
|
}:
|
|
|
|
|
|
|
|
assert nativeTools -> nativePrefix != "";
|
|
|
|
assert !nativeTools -> gcc != null && binutils != null;
|
|
|
|
assert !nativeLibc -> libc != null;
|
|
|
|
|
2009-04-09 17:24:33 +02:00
|
|
|
let
|
|
|
|
|
|
|
|
gccVersion = (builtins.parseDrvName gcc.name).version;
|
|
|
|
gccName = (builtins.parseDrvName gcc.name).name;
|
|
|
|
|
|
|
|
in
|
2009-03-25 18:34:38 +01:00
|
|
|
|
2008-06-26 13:07:46 +02:00
|
|
|
stdenv.mkDerivation {
|
2009-04-09 17:24:33 +02:00
|
|
|
name =
|
|
|
|
(if name != "" then name else gccName + "-wrapper") +
|
|
|
|
(if gcc != null && gccVersion != "" then "-" + gccVersion else "");
|
2009-03-25 18:34:38 +01:00
|
|
|
|
2008-06-26 13:07:46 +02:00
|
|
|
builder = ./builder.sh;
|
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
gccWrapper = ./gcc-wrapper.sh;
|
|
|
|
ldWrapper = ./ld-wrapper.sh;
|
|
|
|
utils = ./utils.sh;
|
|
|
|
addFlags = ./add-flags;
|
|
|
|
|
|
|
|
inherit nativeTools nativeLibc nativePrefix gcc;
|
|
|
|
libc = if nativeLibc then null else libc;
|
|
|
|
binutils = if nativeTools then null else binutils;
|
|
|
|
|
|
|
|
langC = if nativeTools then true else gcc.langC;
|
|
|
|
langCC = if nativeTools then true else gcc.langCC;
|
2008-06-27 16:43:25 +02:00
|
|
|
langFortran = if nativeTools then false else gcc ? langFortran;
|
2008-06-26 13:07:46 +02:00
|
|
|
shell = if shell == "" then stdenv.shell else shell;
|
|
|
|
|
2009-03-25 19:34:27 +01:00
|
|
|
meta =
|
2009-04-19 18:00:46 +02:00
|
|
|
let gcc_ = if gcc != null then gcc else {}; in
|
|
|
|
(if gcc_ ? meta then removeAttrs gcc.meta ["priority"] else {}) //
|
|
|
|
{ description =
|
|
|
|
stdenv.lib.getAttr ["meta" "description"] "System C compiler" gcc_
|
|
|
|
+ " (wrapper script)";
|
|
|
|
};
|
2008-06-26 13:07:46 +02:00
|
|
|
|
|
|
|
# The dynamic linker has different names on different Linux platforms.
|
|
|
|
dynamicLinker =
|
|
|
|
if !nativeLibc then
|
|
|
|
(if stdenv.system == "i686-linux" then "ld-linux.so.2" else
|
|
|
|
if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else
|
|
|
|
if stdenv.system == "powerpc-linux" then "ld.so.1" else
|
|
|
|
abort "don't know the name of the dynamic linker for this platform")
|
|
|
|
else "";
|
|
|
|
}
|