vmlinux: tidy up

module-based-network
Daniel Barlow 2022-09-25 22:07:29 +01:00
parent e29d009b2f
commit f3f51ac6be
2 changed files with 19 additions and 22 deletions

View File

@ -27,7 +27,6 @@ let
phases = [ "unpackPhase" "patchScripts" "installPhase" ]; phases = [ "unpackPhase" "patchScripts" "installPhase" ];
patchScripts = '' patchScripts = ''
patchShebangs scripts/ patchShebangs scripts/
# substituteInPlace Makefile --replace /bin/pwd ${buildPackages.pkgs.coreutils}/bin/pwd
''; '';
installPhase = '' installPhase = ''
mkdir -p $out mkdir -p $out

View File

@ -15,7 +15,7 @@ let writeConfig = name : config: writeText name
(name: value: (if value == "n" then "# CONFIG_${name} is not set" else "CONFIG_${name}=${value}")) (name: value: (if value == "n" then "# CONFIG_${name} is not set" else "CONFIG_${name}=${value}"))
config config
)); ));
kconfigFile = writeConfig "nixwrt_kconfig" config; kconfigFile = writeConfig "kconfig" config;
checkedConfigFile = writeConfig "checked_kconfig" checkedConfig ; checkedConfigFile = writeConfig "checked_kconfig" checkedConfig ;
inherit lib; in inherit lib; in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
@ -26,38 +26,36 @@ stdenv.mkDerivation rec {
(with buildPackages.pkgs; (with buildPackages.pkgs;
[rsync bc bison flex pkgconfig openssl ncurses.all perl]); [rsync bc bison flex pkgconfig openssl ncurses.all perl]);
CC = "${stdenv.cc.bintools.targetPrefix}gcc"; CC = "${stdenv.cc.bintools.targetPrefix}gcc";
HOSTCC = "gcc -I${buildPackages.pkgs.openssl}/include -I${buildPackages.pkgs.ncurses}/include"; HOSTCC = with buildPackages.pkgs;
HOST_EXTRACFLAGS = "-I${buildPackages.pkgs.openssl.dev}/include -L${buildPackages.pkgs.openssl.out}/lib -L${buildPackages.pkgs.ncurses.out}/lib " ; "gcc -I${openssl}/include -I${ncurses}/include";
HOST_EXTRACFLAGS = with buildPackages.pkgs;
"-I${openssl.dev}/include -L${openssl.out}/lib -L${ncurses.out}/lib";
PKG_CONFIG_PATH = "./pkgconfig"; PKG_CONFIG_PATH = "./pkgconfig";
CROSS_COMPILE = stdenv.cc.bintools.targetPrefix; CROSS_COMPILE = stdenv.cc.bintools.targetPrefix;
ARCH = "mips"; # kernel uses "mips" here for both mips and mipsel ARCH = "mips"; # kernel uses "mips" here for both mips and mipsel
dontStrip = true; dontStrip = true;
dontPatchELF = true; dontPatchELF = true;
outputs = ["out" "modulesupport"]; outputs = ["out" "modulesupport"];
phases = ["butcherPkgconfig" phases = [
# "patchScripts" "butcherPkgconfig"
"configurePhase" "configurePhase"
"checkConfigurationPhase" "checkConfigurationPhase"
"buildPhase" "buildPhase"
"installPhase" "installPhase"
]; ];
# this is here to work around what I think is a bug in nixpkgs packaging # this is here to work around what I think is a bug in nixpkgs
# of ncurses: it installs pkg-config data files which don't produce # packaging of ncurses: it installs pkg-config data files which
# any -L options when queried with "pkg-config --lib ncurses". For a # don't produce any -L options when queried with "pkg-config --lib
# regular nixwrt compilation you'll never even notice, this only becomes # ncurses". For a regular build you'll never even notice, this only
# an issue if you do a nix-shell in this derivation and expect "make nconfig" # becomes an issue if you do a nix-shell in this derivation and
# to work. # expect "make nconfig" to work.
butcherPkgconfig = '' butcherPkgconfig = ''
cp -r ${buildPackages.pkgs.ncurses.dev}/lib/pkgconfig . cp -r ${buildPackages.pkgs.ncurses.dev}/lib/pkgconfig .
chmod +w pkgconfig pkgconfig/*.pc chmod +w pkgconfig pkgconfig/*.pc
for i in pkgconfig/*.pc; do test -f $i && sed -i 's/^Libs:/Libs: -L''${libdir} /' $i;done for i in pkgconfig/*.pc; do test -f $i && sed -i 's/^Libs:/Libs: -L''${libdir} /' $i;done
''; '';
# patchScripts = ''
# patchShebangs --build scripts/
# '';
configurePhase = '' configurePhase = ''
export KBUILD_OUTPUT=`pwd` export KBUILD_OUTPUT=`pwd`
cp ${kconfigFile} .config cp ${kconfigFile} .config
@ -74,7 +72,7 @@ stdenv.mkDerivation rec {
echo "OK" echo "OK"
''; '';
KBUILD_BUILD_HOST = "nixwrt.builder"; KBUILD_BUILD_HOST = "liminix.builder";
buildPhase = '' buildPhase = ''
make -C ${tree} vmlinux make -C ${tree} vmlinux
''; '';