Adjustments for NixOS

This commit is contained in:
Ehmry - 2019-06-12 13:03:57 +02:00
parent c99cc6763f
commit 5b5f66674b
10 changed files with 138 additions and 14 deletions

View File

@ -22,6 +22,14 @@ HOST_INC_DIR += $(shell echo "int main() {return 0;}" |\
sed '/^\#include <\.\.\.> search starts here:/,/^End of search list/!d' |\
grep "include-fixed")
#
# Nix include paths
#
ifneq ($(nativeBuildInputs),)
HOST_INC_DIR += $(shell find $(nativeBuildInputs) -name include)
endif
#
# Add search paths for normal libraries
#
@ -49,6 +57,14 @@ HOST_SO_SEARCH_DIRS := $(sort $(dir $(shell $(LDCONFIG) -p | sed "s/^.* \//\//"
LINK_ARG_PREFIX := -Wl,
CXX_LINK_OPT += $(addprefix $(LINK_ARG_PREFIX)-rpath-link $(LINK_ARG_PREFIX),$(HOST_SO_SEARCH_DIRS))
#
# Nix library paths
#
ifneq ($(nativeBuildInputs),)
HOST_SO_SEARCH_DIRS += $(shell find $(nativeBuildInputs) -name lib)
endif
#
# Make exceptions work
#

View File

@ -11,6 +11,9 @@ HOST_INC_DIR += /usr/include/$(shell gcc -dumpmachine)
HOST_INC_DIR += /usr/include/i386-linux-gnu
HOST_INC_DIR += /usr/include/x86_64-linux-gnu
# NixOS
HOST_INC_DIR += $(foreach NP,$(NIX_PROFILES),$(NP)/include)
#
# Some header files installed on GNU/Linux test for the GNU compiler. For
# example, 'stdio.h' might complain with the following error otherwise:

View File

@ -19,19 +19,19 @@
# package build tool.
#
ifeq ($(filter-out $(SPECS),x86_32),)
CROSS_DEV_PREFIX ?= /opt/genode/toolchain-19.05/bin/genode-x86-
CROSS_DEV_PREFIX ?= genode-x86-
endif
ifeq ($(filter-out $(SPECS),x86_64),)
CROSS_DEV_PREFIX ?= /opt/genode/toolchain-19.05/bin/genode-x86-
CROSS_DEV_PREFIX ?= genode-x86-
endif
ifeq ($(filter-out $(SPECS),arm),)
CROSS_DEV_PREFIX ?= /opt/genode/toolchain-19.05/bin/genode-arm-
CROSS_DEV_PREFIX ?= genode-arm-
endif
ifeq ($(filter-out $(SPECS),riscv),)
CROSS_DEV_PREFIX ?= /opt/genode/toolchain-19.05/bin/genode-riscv-
CROSS_DEV_PREFIX ?= genode-riscv-
endif
ifeq ($(filter-out $(SPECS),arm_64),)
CROSS_DEV_PREFIX ?= /opt/genode/toolchain-19.05/bin/genode-aarch64-
CROSS_DEV_PREFIX ?= genode-aarch64-
endif
#

View File

@ -260,7 +260,7 @@ $(ABI_SO): $(LIB).symbols.o
--end-group --no-whole-archive
$(LIB_CHECKED): $(LIB_SO)
$(VERBOSE)$(BASE_DIR)/../../tool/check_abi $(LIB_SO) $(SYMBOLS)
$(VERBOSE)tclsh $(BASE_DIR)/../../tool/check_abi $(LIB_SO) $(SYMBOLS)
$(LIB_SO).stripped: $(LIB_SO)
$(VERBOSE)$(STRIP) -o $@ $<

View File

@ -291,7 +291,7 @@ gen_deps_and_build_targets: $(INSTALL_DIR) $(DEBUG_DIR) $(LIB_DEP_FILE)
echo " @echo \" \$$(sort \$$(MISSING_PORTS))\""; \
echo " @echo \"\""; \
echo " @echo \"You can prepare respectively update them as follows:\""; \
echo " @echo \" $(GENODE_DIR)/tool/ports/prepare_port \$$(sort \$$(MISSING_PORTS))\""; \
echo " @echo \"make -f $(GENODE_DIR)/tool/ports/prepare_port \$$(sort \$$(MISSING_PORTS))\""; \
echo " @echo \"\""; \
echo " @false"; \
echo "else"; \
@ -321,7 +321,7 @@ RUN_SCRIPT = $(call select_from_repositories,run/$*.run)
run/%: $(call select_from_repositories,run/%.run) $(RUN_ENV)
$(VERBOSE)test -f "$(RUN_SCRIPT)" || (echo "Error: No run script for $*"; exit -1)
$(VERBOSE)$(GENODE_DIR)/tool/run/run --genode-dir $(GENODE_DIR) \
$(VERBOSE)expect $(GENODE_DIR)/tool/run/run --genode-dir $(GENODE_DIR) \
--name $* \
--specs "$(SPECS)" \
--board "$(BOARD)" \

View File

@ -159,7 +159,7 @@ handle_missing_ports = $(if $1,$(VERBOSE)( \
echo -e " $(1)"; \
echo -e ""; \
echo -e "You can prepare respectively update them as follows:"; \
echo -e " $(GENODE_DIR)/tool/ports/prepare_port $(1)"; \
echo -e "make -f $(GENODE_DIR)/tool/ports/prepare_port $(1)"; \
echo -e ""; \
false),)

37
tool/dev-shell.nix Normal file
View File

@ -0,0 +1,37 @@
{ pkgs ? import <nixpkgs> {} }: with pkgs;
stdenv.mkDerivation {
name = "genode-dev-env";
buildInputs =
[ (import ./toolchain.nix { inherit pkgs; })
git
ccache
gnumake which findutils
expect libxml2 syslinux qemu xorriso
# libc
flex bison
# virtualbox
yasm libxslt iasl
# qt5
gperf
# ncurses
mawk
# fb_sdl
pkgconfig
SDL.dev
alsaLib.dev
];
shellHook =
''
export PROMPT_DIRTRIM=2
export PS1="\[\033[1;30m\]Genode-dev [\[\033[1;37m\]\w\[\033[1;30m\]] $\[\033[0m\] "
export PS2="\[\033[1;30m\]>\[\033[0m\] "
'';
}

View File

@ -204,7 +204,7 @@ proc _depot_auto_update { archives } {
# remove duplicates
set archives_to_create [lsort -unique $archives_to_create]
set cmd "[genode_dir]/tool/depot/create $archives_to_create "
set cmd "make -f [genode_dir]/tool/depot/create $archives_to_create "
append cmd "CROSS_DEV_PREFIX=[cross_dev_prefix] "
append cmd "DEPOT_DIR=[depot_dir] "
append cmd "UPDATE_VERSIONS=1 FORCE=1 REBUILD= "
@ -444,12 +444,12 @@ proc check_for_missing_depot_archives { } {
if {[llength $local_user_archives]} {
append create_args " CROSS_DEV_PREFIX=[cross_dev_prefix]"
puts stderr "You may create the following archives locally:\n"
puts stderr " [genode_dir]/tool/depot/create $local_user_archives$create_args\n"
puts stderr "make -f [genode_dir]/tool/depot/create $local_user_archives$create_args\n"
}
if {[llength $foreign_archives]} {
puts stderr "You may try to download the following archives:\n"
puts stderr " [genode_dir]/tool/depot/download $foreign_archives\n"
puts stderr "make -f [genode_dir]/tool/depot/download $foreign_archives\n"
}
exit 1

View File

@ -3,7 +3,7 @@
#
proc get_grub2_dir { } {
set ::env(MAKEFLAGS) s
set grub2_path [exec [genode_dir]/tool/ports/current grub2]
set grub2_path [exec make -f [genode_dir]/tool/ports/current grub2]
if {![file exists $grub2_path]} {
puts ""
@ -11,7 +11,7 @@ proc get_grub2_dir { } {
puts " grub2"
puts ""
puts "You can prepare respectively update it as follows:"
puts " [genode_dir]/tool/ports/prepare_port grub2"
puts "make -f [genode_dir]/tool/ports/prepare_port grub2"
puts ""
exit 1
}

68
tool/toolchain.nix Normal file
View File

@ -0,0 +1,68 @@
{ pkgs ? import <nixpkgs> {} }: with pkgs;
let
genodeVersion = "19.05";
glibcVersion = (builtins.parseDrvName stdenv.glibc.name).version;
in
stdenv.mkDerivation rec {
name = "genode-toolchain-${genodeVersion}";
version = genodeVersion;
src =
if stdenv.isx86_64 then
fetchurl {
url = "https://downloads.sourceforge.net/project/genode/genode-toolchain/${genodeVersion}/genode-toolchain-${genodeVersion}-x86_64.tar.xz";
sha256 = "036czy21zk7fvz1y1p67q3d5hgg8rb8grwabgrvzgdsqcv2ls6l9";
}
else abort "no toolchain for ${stdenv.system}";
buildInputs = [ patchelf ];
dontPatchELF = true;
# installPhase is disabled for now
phases = "unpackPhase fixupPhase";
unpackPhase = ''
mkdir -p $out
echo "unpacking $src..."
tar xf $src --strip-components=5 -C $out
'';
installPhase = ''
cd $out/bin
for platform in arm x86 ; do
dest="$"$platform"/bin"
eval dest=$"$dest"
mkdir -p $dest
for b in genode-$platform-* ; do
eval ln -s $b $dest/$\{b#genode-$platform-\}
done
done
cd -
'';
fixupPhase = ''
interp=${stdenv.glibc.out}/lib/ld-${glibcVersion}.so
if [ ! -f "$interp" ] ; then
echo new interpreter $interp does not exist,
echo cannot patch binaries
exit 1
fi
for f in $(find $out); do
if [ -f "$f" ] && patchelf "$f" 2> /dev/null; then
patchelf --set-interpreter $interp \
--set-rpath $out/lib:${stdenv.glibc.out}/lib:${zlib.out}/lib \
"$f" || true
fi
done
'';
passthru = { libc = stdenv.glibc; };
}