about summary refs log tree commit diff
path: root/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools/default.nix')
-rw-r--r--nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools/default.nix42
1 files changed, 22 insertions, 20 deletions
diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools/default.nix b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools/default.nix
index c4aca823203d..4a9c734981e2 100644
--- a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools/default.nix
@@ -1,5 +1,6 @@
 { lib
 , derivationWithMeta
+, hostPlatform
 , kaem-unwrapped
 , M1
 , M2
@@ -8,13 +9,14 @@
 , m2libc
 , src
 , version
+, platforms
+, m2libcArch
+, baseAddress
 }:
 
 let
-  ARCH = "x86";
-  BLOOD_FLAG = " ";
-  BASE_ADDRESS = "0x8048000";
-  ENDIAN_FLAG = "--little-endian";
+  endianFlag = if hostPlatform.isLittleEndian then "--little-endian" else "--big-endian";
+  bloodFlag = if hostPlatform.is64bit then "--64" else " ";
 
   # We need a few tools from mescc-tools-extra to assemble the output folder
   buildMesccToolsExtraUtil = name:
@@ -26,13 +28,13 @@ let
         "--strict"
         "--file"
         (builtins.toFile "build-${name}.kaem" ''
-          ''${M2} --architecture ''${ARCH} \
+          ''${M2} --architecture ${m2libcArch} \
             -f ''${m2libc}/sys/types.h \
             -f ''${m2libc}/stddef.h \
-            -f ''${m2libc}/''${ARCH}/linux/fcntl.c \
+            -f ''${m2libc}/${m2libcArch}/linux/fcntl.c \
             -f ''${m2libc}/fcntl.c \
-            -f ''${m2libc}/''${ARCH}/linux/unistd.c \
-            -f ''${m2libc}/''${ARCH}/linux/sys/stat.c \
+            -f ''${m2libc}/${m2libcArch}/linux/unistd.c \
+            -f ''${m2libc}/${m2libcArch}/linux/sys/stat.c \
             -f ''${m2libc}/stdlib.c \
             -f ''${m2libc}/stdio.h \
             -f ''${m2libc}/stdio.c \
@@ -42,25 +44,25 @@ let
             --debug \
             -o ${name}.M1
 
-          ''${blood-elf-0} ''${ENDIAN_FLAG} -f ${name}.M1 -o ${name}-footer.M1
+          ''${blood-elf-0} ${endianFlag} ${bloodFlag} -f ${name}.M1 -o ${name}-footer.M1
 
-          ''${M1} --architecture ''${ARCH} \
-            ''${ENDIAN_FLAG} \
-            -f ''${m2libc}/''${ARCH}/''${ARCH}_defs.M1 \
-            -f ''${m2libc}/''${ARCH}/libc-full.M1 \
+          ''${M1} --architecture ${m2libcArch} \
+            ${endianFlag} \
+            -f ''${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1 \
+            -f ''${m2libc}/${m2libcArch}/libc-full.M1 \
             -f ${name}.M1 \
             -f ${name}-footer.M1 \
             -o ${name}.hex2
 
-          ''${hex2} --architecture ''${ARCH} \
-            ''${ENDIAN_FLAG} \
-            -f ''${m2libc}/''${ARCH}/ELF-''${ARCH}-debug.hex2 \
+          ''${hex2} --architecture ${m2libcArch} \
+            ${endianFlag} \
+            -f ''${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2 \
             -f ${name}.hex2 \
-            --base-address ''${BASE_ADDRESS} \
+            --base-address ${baseAddress} \
             -o ''${out}
         '')
       ];
-      inherit version M1 M2 blood-elf-0 hex2 m2libc src ARCH BLOOD_FLAG BASE_ADDRESS ENDIAN_FLAG;
+      inherit version M1 M2 blood-elf-0 hex2 m2libc src;
     };
   mkdir = buildMesccToolsExtraUtil "mkdir";
   cp = buildMesccToolsExtraUtil "cp";
@@ -76,13 +78,13 @@ derivationWithMeta {
     "--file"
     ./build.kaem
   ];
-  inherit version M1 M2 blood-elf-0 hex2 mkdir cp chmod replace m2libc src ARCH BLOOD_FLAG BASE_ADDRESS ENDIAN_FLAG;
+  inherit version M1 M2 blood-elf-0 hex2 mkdir cp chmod replace m2libc src m2libcArch baseAddress bloodFlag endianFlag;
 
   meta = with lib; {
     description = "Collection of tools written for use in bootstrapping";
     homepage = "https://github.com/oriansj/mescc-tools";
     license = licenses.gpl3Plus;
     maintainers = teams.minimal-bootstrap.members;
-    platforms = [ "i686-linux" ];
+    inherit platforms;
   };
 }