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