2004-03-29 17:23:01 +00:00
|
|
|
# The Nix `gcc' stdenv.mkDerivation is not directly usable, since it doesn't
|
2004-03-08 16:02:46 +00:00
|
|
|
# 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
|
2004-03-29 17:23:01 +00:00
|
|
|
# stdenv.mkDerivation provides a wrapper that sets up the right environment
|
2004-03-08 16:02:46 +00:00
|
|
|
# variables so that the compiler and the linker just "work".
|
|
|
|
|
2006-10-24 18:26:23 +00:00
|
|
|
{ name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? ""
|
|
|
|
, gcc ? null, libc ? null, binutils ? null, shell ? ""
|
2004-03-11 17:26:14 +00:00
|
|
|
}:
|
2004-03-08 16:02:46 +00:00
|
|
|
|
2004-03-11 17:26:14 +00:00
|
|
|
assert nativeTools -> nativePrefix != "";
|
|
|
|
assert !nativeTools -> gcc != null && binutils != null;
|
2006-10-24 18:26:23 +00:00
|
|
|
assert !nativeLibc -> libc != null;
|
2004-03-08 16:02:46 +00:00
|
|
|
|
2004-03-29 17:23:01 +00:00
|
|
|
stdenv.mkDerivation {
|
2004-03-08 16:02:46 +00:00
|
|
|
builder = ./builder.sh;
|
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
gccWrapper = ./gcc-wrapper.sh;
|
|
|
|
ldWrapper = ./ld-wrapper.sh;
|
2004-03-12 11:12:18 +00:00
|
|
|
utils = ./utils.sh;
|
2005-02-22 14:32:56 +00:00
|
|
|
addFlags = ./add-flags;
|
2007-05-16 15:15:46 +00:00
|
|
|
|
2006-10-24 18:26:23 +00:00
|
|
|
inherit nativeTools nativeLibc nativePrefix gcc libc binutils;
|
2004-07-05 12:00:19 +00:00
|
|
|
name = if name == "" then gcc.name else name;
|
2004-03-11 17:26:14 +00:00
|
|
|
langC = if nativeTools then true else gcc.langC;
|
|
|
|
langCC = if nativeTools then true else gcc.langCC;
|
|
|
|
langF77 = if nativeTools then false else gcc.langF77;
|
2004-03-30 12:46:52 +00:00
|
|
|
shell = if shell == "" then stdenv.shell else shell;
|
2007-05-16 15:15:46 +00:00
|
|
|
|
2007-05-31 13:00:49 +00:00
|
|
|
meta = if gcc != null && (gcc ? meta) then removeAttrs gcc.meta ["priority"] else
|
2006-03-10 16:12:46 +00:00
|
|
|
{ description = "System C compiler wrapper";
|
|
|
|
};
|
2006-10-24 18:26:23 +00: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 "";
|
|
|
|
}
|