From 238ed1fe120b1a71898a9d412f67376c9f01cb30 Mon Sep 17 00:00:00 2001 From: Hajime Tazaki Date: Thu, 30 Mar 2017 10:13:16 +0900 Subject: [PATCH] initial support for building linux kernel with buildrump.sh This commit introduces a new options for buildrump.sh, which is '-l' option to specify which rumpkernel (netbsd or linux) is used (default: netbsd). Linux kernel is based on Linux Kernel Library (LKL) with non-upstreamed patches to implement with rump hypercall interfaces. Since LKL is not yet upstreamed to Linus tree and development is still ongoing, the commit tries to minimize future modifications to this script (buildrump.sh) by specifying interfaces to build Linux kernel. The new rumpkernel support involves the script structure refactor to split each rumpkernel dependent commands into separate files (netbsd.sh and linux.sh). Currently, when '-l' option is specified, NetBSD rump kernel code will be also built in addition to Linux kernel build since Linux part requires headers files (i.e., include/rump) to build it. A few more travis tests are also added though it's only build tests and no execution tests for Linux at this moment though. Plus, clang build is marked as 'allow_failure' since Linux kernel isn't able to build with clang so far. There are still a couple of limitations: - LKL_SRCDIR is hardcoded, which uses the current dir of the (root) script. - only build with standalone buildrump.sh. standalone execution (i.e., without rumprun or frankenlibc) are not implemented since LKL itself has to do it. - thus, no standalone test are implemented either. Signed-off-by: Hajime Tazaki --- .travis.yml | 21 +++++- buildrump.sh | 206 ++++++++------------------------------------------- checkout.sh | 43 +++++++++++ linux.sh | 93 +++++++++++++++++++++++ netbsd.sh | 175 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 361 insertions(+), 177 deletions(-) create mode 100644 linux.sh create mode 100644 netbsd.sh diff --git a/.travis.yml b/.travis.yml index fe475dd..2cf6f86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,12 @@ language: c +addons: + apt: + packages: + - bc + - libfuse-dev + - libarchive-dev + - xfsprogs + - btrfs-tools compiler: - gcc @@ -7,7 +15,7 @@ compiler: sudo: false before_script: - - ./buildrump.sh checkout + - ./buildrump.sh ${RUMPKERNEL} checkout env: - NAME='static' LIBTYPE='MKPIC=no' BUILDTYPE='' TESTS='tests' @@ -15,9 +23,18 @@ env: - NAME='debug' LIBTYPE='MKSTATICLIB=no' BUILDTYPE='-DDD' TESTS='tests' - NAME='release' LIBTYPE='MKSTATICLIB=no' BUILDTYPE='-r' TESTS='tests' - NAME='fibers' LIBTYPE='MKSTATICLIB=no' BUILDTYPE='-V RUMPUSER_THREADS=fiber -V RUMP_CURLWP=hypercall' TESTS='' + - NAME='dynamic' LIBTYPE='MKSTATICLIB=no' BUILDTYPE='' TESTS='' RUMPKERNEL='-l linux' + - NAME='fibers' LIBTYPE='MKSTATICLIB=no' BUILDTYPE='-V RUMPUSER_THREADS=fiber -V RUMP_CURLWP=hypercall' TESTS='' RUMPKERNEL='-l linux' + +matrix: + allow_failures: + - compiler: clang + env: NAME='dynamic' LIBTYPE='MKSTATICLIB=no' BUILDTYPE='' TESTS='' RUMPKERNEL='-l linux' + - compiler: clang + env: NAME='fibers' LIBTYPE='MKSTATICLIB=no' BUILDTYPE='-V RUMPUSER_THREADS=fiber -V RUMP_CURLWP=hypercall' TESTS='' RUMPKERNEL='-l linux' script: - - ./buildrump.sh -o obj.${NAME} -d rump.${NAME} -qq -j16 -V ${LIBTYPE} ${BUILDTYPE} fullbuild ${TESTS} + - ./buildrump.sh ${RUMPKERNEL} -o obj.${NAME} -d rump.${NAME} -qq -j16 -V ${LIBTYPE} ${BUILDTYPE} fullbuild ${TESTS} notifications: irc: diff --git a/buildrump.sh b/buildrump.sh index e5f3a93..0a71209 100755 --- a/buildrump.sh +++ b/buildrump.sh @@ -69,6 +69,7 @@ helpme () printf "\t-r: release build (no -g, DIAGNOSTIC, etc.). default: no\n" printf "\t-D: increase debugginess. default: -O2 -g\n" printf "\t-k: only kernel (no POSIX hypercalls). default: all\n" + printf "\t-l: choose a rumpkernel: netbsd or linux. default: netbsd\n" echo printf "\t-H: ignore diagnostic checks (expert-only). default: no\n" printf "\t-V: specify -V arguments to NetBSD build (expert-only)\n" @@ -289,19 +290,6 @@ doesitcxx () -x c++ - -o /dev/null $* > /dev/null 2>&1 } -checkcheckout () -{ - - [ -x "${SRCDIR}/build.sh" ] || die "Cannot find ${SRCDIR}/build.sh!" - - [ ! -z "${TARBALLMODE}" ] && return - - if ! ${BRDIR}/checkout.sh checkcheckout ${SRCDIR} \ - && ! ${TITANMODE}; then - die 'revision mismatch, run checkout (or -H to override)' - fi -} - checkcompiler () { @@ -556,6 +544,7 @@ int main() {gzopen(NULL, NULL); return 0;}' -lz \ else cppname=cpp fi + # NB: we need rumpmake to build libbmk_*, but rumpmake needs --netbsd TOOLTUPLES tname=${BRTOOLDIR}/bin/${MACHINE_GNU_ARCH}--netbsd${TOOLABI}-${cppname} printf '#!/bin/sh\n\nexec %s -E -x c "${@}"\n' ${CC} > ${tname} chmod 755 ${tname} @@ -616,8 +605,8 @@ EOF appendmkconf Cmd yes RUMPKERN_ONLY fi - if ${KERNONLY} && ! cppdefines __NetBSD__; then - appendmkconf 'Cmd' '-D__NetBSD__' 'CPPFLAGS' + + if ${KERNONLY} && ! cppdefines ${RUMPKERN_CPPFLAGS}; then + appendmkconf 'Cmd' "${RUMPKERN_CPPFLAGS}" 'CPPFLAGS' + appendmkconf 'Probe' "${RUMPKERN_UNDEF}" 'CPPFLAGS' + else appendmkconf 'Probe' "${RUMPKERN_UNDEF}" "RUMPKERN_UNDEF" @@ -654,8 +643,8 @@ EOF exec 3>&1 1>${BRTOOLDIR}/toolchain-conf.mk printf 'BUILDRUMP_TOOL_CFLAGS=%s\n' "${EXTRA_CFLAGS}" printf 'BUILDRUMP_TOOL_CXXFLAGS=%s\n' "${EXTRA_CFLAGS}" - printf 'BUILDRUMP_TOOL_CPPFLAGS=-D__NetBSD__ %s %s\n' \ - "${EXTRA_CPPFLAGS}" "${RUMPKERN_UNDEF}" + printf 'BUILDRUMP_TOOL_CPPFLAGS=%s %s %s\n' \ + "${RUMPKERN_CPPFLAGS}" "${EXTRA_CPPFLAGS}" "${RUMPKERN_UNDEF}" exec 1>&3 3>&- chkcrt begins @@ -754,120 +743,6 @@ makemake () [ $? -ne 0 ] && die build.sh ${cmd} failed } -makebuild () -{ - - checkcheckout - - # ensure we're in SRCDIR, in case "tools" wasn't run - cd ${SRCDIR} - - targets="obj includes dependall install" - - # - # Building takes 4 passes, just like when - # building NetBSD the regular way. The passes are: - # 1) obj - # 2) includes - # 3) dependall - # 4) install - # - - DIRS_first='lib/librumpuser' - DIRS_second='lib/librump' - DIRS_third="lib/librumpdev lib/librumpnet lib/librumpvfs - sys/rump/dev sys/rump/fs sys/rump/kern sys/rump/net - sys/rump/include ${BRDIR}/brlib" - - # sys/rump/share was added to ${SRCDIR} 11/2014 - [ -d ${SRCDIR}/sys/rump/share ] \ - && appendvar DIRS_second ${SRCDIR}/sys/rump/share - - if [ ${MACHINE} = "i386" -o ${MACHINE} = "amd64" \ - -o ${MACHINE#evbearm} != ${MACHINE} \ - -o ${MACHINE#evbppc} != ${MACHINE} ]; then - DIRS_emul=sys/rump/kern/lib/libsys_linux - fi - ${SYS_SUNOS} && appendvar DIRS_emul sys/rump/kern/lib/libsys_sunos - if ${HIJACK}; then - DIRS_final="lib/librumphijack" - else - DIRS_final= - fi - - DIRS_third="${DIRS_third} ${DIRS_emul}" - - if ${KERNONLY}; then - mkmakefile ${OBJDIR}/Makefile.all \ - sys/rump ${DIRS_emul} ${BRDIR}/brlib - else - DIRS_third="lib/librumpclient ${DIRS_third}" - - mkmakefile ${OBJDIR}/Makefile.first ${DIRS_first} - mkmakefile ${OBJDIR}/Makefile.second ${DIRS_second} - mkmakefile ${OBJDIR}/Makefile.third ${DIRS_third} - mkmakefile ${OBJDIR}/Makefile.final ${DIRS_final} - mkmakefile ${OBJDIR}/Makefile.all \ - ${DIRS_first} ${DIRS_second} ${DIRS_third} ${DIRS_final} - fi - - # try to minimize the amount of domake invocations. this makes a - # difference especially on systems with a large number of slow cores - for target in ${targets}; do - if [ ${target} = "dependall" ] && ! ${KERNONLY}; then - domake ${OBJDIR}/Makefile.first ${target} - domake ${OBJDIR}/Makefile.second ${target} - domake ${OBJDIR}/Makefile.third ${target} - domake ${OBJDIR}/Makefile.final ${target} - else - domake ${OBJDIR}/Makefile.all ${target} - fi - done - - if ! ${KERNONLY}; then - mkmakefile ${OBJDIR}/Makefile.utils \ - usr.bin/rump_server usr.bin/rump_allserver \ - usr.bin/rump_wmd - for target in ${targets}; do - domake ${OBJDIR}/Makefile.utils ${target} - done - fi -} - -makeinstall () -{ - - # ensure we run this in a directory that does not have a - # Makefile that could confuse rumpmake - stage=$(cd ${BRTOOLDIR} && ${RUMPMAKE} -V '${BUILDRUMP_STAGE}') - (cd ${stage}/usr ; tar -cf - .) | (cd ${DESTDIR} ; tar -xf -) -} - -# -# install kernel headers. -# Note: Do _NOT_ do this unless you want to install a -# full rump kernel application stack -# -makekernelheaders () -{ - - dodirs=$(cd ${SRCDIR}/sys && \ - ${RUMPMAKE} -V '${SUBDIR:Narch:Nmodules:Ncompat:Nnetnatm}' includes) - # missing some architectures - appendvar dodirs arch/amd64/include arch/i386/include arch/x86/include - appendvar dodirs arch/arm/include arch/arm/include/arm32 - appendvar dodirs arch/evbarm64/include arch/aarch64/include - appendvar dodirs arch/evbppc/include arch/powerpc/include - appendvar dodirs arch/evbmips/include arch/mips/include - appendvar dodirs arch/riscv/include - for dir in ${dodirs}; do - (cd ${SRCDIR}/sys/${dir} && ${RUMPMAKE} obj) - (cd ${SRCDIR}/sys/${dir} && ${RUMPMAKE} includes) - done - # create machine symlink - (cd ${SRCDIR}/sys/arch && ${RUMPMAKE} NOSUBDIR=1 includes) -} - settool () { @@ -1036,7 +911,9 @@ evaltoolchain () case ${CC_TARGET} in *-linux*) - RUMPKERN_UNDEF='-Ulinux -U__linux -U__linux__ -U__gnu_linux__' + if [ ${RUMPKERNEL} != "linux" ]; then + RUMPKERN_UNDEF='-Ulinux -U__linux -U__linux__ -U__gnu_linux__' + fi cppdefines _BIG_ENDIAN \ && appendvar RUMPKERN_UNDEF -U_BIG_ENDIAN cppdefines _LITTLE_ENDIAN \ @@ -1353,12 +1230,14 @@ parseargs () NOISE=2 debugginess=0 KERNONLY=false + RUMPKERNEL=netbsd OBJDIR=./obj DESTDIR=./rump SRCDIR=./src + LKL_SRCDIR=./linux JNUM=4 - while getopts 'd:DhHj:ko:qrs:T:V:F:' opt; do + while getopts 'd:DhHj:kl:o:qrs:T:V:F:' opt; do case "$opt" in d) DESTDIR=${OPTARG} @@ -1419,6 +1298,9 @@ parseargs () k) KERNONLY=true ;; + l) + RUMPKERNEL=${OPTARG} + ;; o) OBJDIR=${OPTARG} ;; @@ -1451,6 +1333,14 @@ parseargs () done shift $((${OPTIND} - 1)) + # load rump kernel specific scripts + if [ ${RUMPKERNEL} != "netbsd" -a ${RUMPKERNEL} != "linux" ]; then + echo '>> ERROR:' + echo '>> -l option (RUMPKERNEL) must be netbsd or linux' + exit 1 + fi + . ${BRDIR}/${RUMPKERNEL}.sh + DBG="${F_DBG:-${DBG}}" BEQUIET="-N${NOISE}" @@ -1508,6 +1398,10 @@ parseargs () docheckout=true checkoutstyle=cvs fi + if ${docheckout} && [ ${RUMPKERNEL} = "linux" ] ; then + docheckout=true + checkoutstyle=linux-git + fi # sanity checks if [ ! -z "${TARBALLMODE}" ]; then @@ -1542,6 +1436,7 @@ resolvepaths () abspath BRTOOLDIR abspath SRCDIR + [ "${RUMPKERNEL}" = "linux" ] && abspath LKL_SRCDIR RUMPMAKE="${BRTOOLDIR}/bin/brrumpmake" BRIMACROS="${BRTOOLDIR}/include/opt_buildrump.h" @@ -1572,40 +1467,7 @@ resolvepaths () done } -# create the makefiles used for building -mkmakefile () -{ - makefile=$1 - shift - exec 3>&1 1>${makefile} - printf '# GENERATED FILE, MIGHT I SUGGEST NOT EDITING?\n' - printf 'SUBDIR=' - for dir in $*; do - case ${dir} in - /*) - printf ' %s' ${dir} - ;; - *) - printf ' %s' ${SRCDIR}/${dir} - ;; - esac - done - - printf '\n.include \n' - exec 1>&3 3>&- -} - -domake () -{ - - mkfile=${1}; shift - mktarget=${1}; shift - - [ ! -x ${RUMPMAKE} ] && die "No rumpmake (${RUMPMAKE}). Forgot tools?" - ${RUMPMAKE} $* -j ${JNUM} -f ${mkfile} ${mktarget} - [ $? -eq 0 ] || die "make $mkfile $mktarget" -} ### ### @@ -1624,7 +1486,7 @@ done parseargs "$@" -${docheckout} && { ${BRDIR}/checkout.sh ${checkoutstyle} ${SRCDIR} || exit 1; } +${docheckout} && { ${BRDIR}/checkout.sh ${checkoutstyle} ${SRCDIR} ${LKL_SRCDIR} || exit 1; } if ${doprobe} || ${dotools} || ${dobuild} || ${dokernelheaders} \ || ${doinstall} || ${dotests}; then @@ -1635,20 +1497,14 @@ if ${doprobe} || ${dotools} || ${dobuild} || ${dokernelheaders} \ ${KERNONLY} || evalplatform + export RUMPKERNEL ${doprobe} && writeproberes ${dotools} && maketools ${dobuild} && makebuild ${dokernelheaders} && makekernelheaders ${doinstall} && makeinstall - if ${dotests}; then - if ${KERNONLY}; then - diagout 'Kernel-only; skipping tests (no hypervisor)' - else - . ${BRDIR}/tests/testrump.sh - alltests - fi - fi + ${dotests} && maketests fi diagout buildrump.sh ran successfully diff --git a/checkout.sh b/checkout.sh index 18fba2b..6d660f7 100755 --- a/checkout.sh +++ b/checkout.sh @@ -64,6 +64,7 @@ NBSRC_EXTRA_usr='' GITREPO='https://github.com/rumpkernel/src-netbsd' GITREPOPUSH='git@github.com:rumpkernel/src-netbsd' +GITREPO_LKL='https://github.com/libos-nuse/lkl-linux' GITREVFILE='.srcgitrev' checkoutcvs () @@ -198,6 +199,37 @@ checkoutgit () die 'Could not checkout correct git revision. Wrong repo?' } +# Check out Linux (LKL) sources. +LKL_REV=rump-hypcall-upstream +checkoutgitlinux () +{ + + echo ">> Fetching Linux/LKL sources to ${LKL_SRCDIR} using git" + + if [ -e "${LKL_SRCDIR}" -a ! -e "${LKL_SRCDIR}/.git" ]; then + echo '>>' + echo ">> NOTICE: Not a buildrump.sh-based git repo in ${LKL_SRCDIR}" + echo '>> Cannot verify repository version. Proceeding ...' + echo '>>' + return 0 + fi + + gitrev=${LKL_REV} + [ $? -eq 0 ] || die Cannot determine relevant git revision + if [ -e ${LKL_SRCDIR}/.git ] ; then + cd ${LKL_SRCDIR} +# [ -z "$(${GIT} status --porcelain)" ] \ +# || die "Cloned repo in ${LKL_SRCDIR} is not clean, aborting." + ${GIT} fetch origin ${LKL_REV} || die Failed to fetch repo + else + ${GIT} clone -n ${GITREPO_LKL} ${LKL_SRCDIR} || die Clone failed + cd ${LKL_SRCDIR} + fi + + ${GIT} checkout -q ${gitrev} || \ + die 'Could not checkout correct git revision. Wrong repo?' +} + hubdateonebranch () { @@ -354,6 +386,7 @@ BRDIR=$(dirname $0) [ $# -lt 2 ] && die Invalid usage. Run this script via buildrump.sh SRCDIR=${2} +LKL_SRCDIR=${3} # default to the most secure source for githubdate if [ -z "${BUILDRUMP_CVSROOT}" ]; then @@ -398,6 +431,16 @@ git) checkoutgit echo '>> checkout done' ;; +linux-git) + setgit || die "require working git" + curdir="$(pwd)" + # XXX: currently linux build requires src-netbsd + checkoutgit + cd "${curdir}" + checkoutgitlinux + cd "${curdir}" + echo '>> checkout done' + ;; githubdate) [ $(dirname $0) != '.' ] && die Script must be run as ./checkout.sh setgit || die "require working git" diff --git a/linux.sh b/linux.sh new file mode 100644 index 0000000..9cc1ddc --- /dev/null +++ b/linux.sh @@ -0,0 +1,93 @@ +RUMPKERN_CPPFLAGS="-D__linux__ -DCONFIG_LKL" + +checkcheckout () +{ + + [ -f "${LKL_SRCDIR}/arch/lkl/Makefile" ] || \ + die "Cannot find ${LKL_SRCDIR}/arch/lkl/Makefile!" + + [ ! -z "${TARBALLMODE}" ] && return + + if ! ${BRDIR}/checkout.sh checkcheckout ${LKL_SRCDIR} \ + && ! ${TITANMODE}; then + die 'revision mismatch, run checkout (or -H to override)' + fi +} + +makebuild () +{ + set -e + echo "=== Linux build LKLSRC=${LKL_SRCDIR} ===" + cd ${LKL_SRCDIR} + LKL_VERBOSE="V=0" + if [ ${NOISE} -gt 1 ] ; then + LKL_VERBOSE="V=1" + fi + + LKL_CROSS=$(${CC} -dumpmachine) + if [ ${LKL_CROSS} = "$(gcc -dumpmachine)" ] + then + LKL_CROSS= + else + LKL_CROSS=${LKL_CROSS}- + fi + + LKL_EXT_OPT=${LKL_EXT_OPT:-} + + export LKL_VERBOSE + export LKL_CROSS + export LKL_EXT_OPT + + # need proper RUMP_PREFIX and RUMP_INCLUDE configuration from caller + if [ -z "${RUMP_PREFIX:-}" ]; then + echo "No RUMP_PREFIX env configured. Use the default one." + export RUMP_PREFIX=${SRCDIR}/sys/rump + fi + + mkdir -p ${OBJDIR}/linux + + cd tools/lkl + rm -f ${OBJDIR}/linux/tools/lkl/lib/lkl.o + make CROSS_COMPILE=${LKL_CROSS} ${LKL_EXT_OPT} -j ${JNUM} ${LKL_VERBOSE} O=${OBJDIR}/linux + + cd ../../ + make CROSS_COMPILE=${LKL_CROSS} ${LKL_EXT_OPT} headers_install ARCH=lkl O=${DESTDIR}/ \ + PREFIX=/ INSTALL_HDR_PATH=${DESTDIR}/ ${LKL_VERBOSE} + + set +e +} + +makeinstall () +{ + set -e + # XXX for app-tools + mkdir -p ${DESTDIR}/bin/ + mkdir -p ${DESTDIR}/include/rumprun + + # need proper RUMP_PREFIX and RUMP_INCLUDE configuration from caller + make CROSS_COMPILE=${LKL_CROSS} ${LKL_EXT_OPT} headers_install libraries_install DESTDIR=${DESTDIR}\ + -C ./tools/lkl/ O=${OBJDIR}/linux PREFIX=/ ${LKL_VERBOSE} + # XXX: for netconfig.h + mkdir -p ${DESTDIR}/include/rump/ + cp -pf ${BRDIR}/brlib/libnetconfig/rump/netconfig.h ${DESTDIR}/include/rump/ + + set +e +} + +# +# install kernel headers. +# Note: Do _NOT_ do this unless you want to install a +# full rump kernel application stack +# +makekernelheaders () +{ + return +} + +maketests () +{ + printf 'SKIP: Linux test currently not implemented yet ... \n' + return + printf 'Linux test ... \n' + make -C ${LKL_SRCDIR}/tools/lkl test O=${OBJDIR}/linux || die LKL test failed +} diff --git a/netbsd.sh b/netbsd.sh new file mode 100644 index 0000000..8212a3d --- /dev/null +++ b/netbsd.sh @@ -0,0 +1,175 @@ +RUMPKERN_CPPFLAGS="-D__NetBSD__" + +checkcheckout () +{ + + [ -x "${SRCDIR}/build.sh" ] || die "Cannot find ${SRCDIR}/build.sh!" + + [ ! -z "${TARBALLMODE}" ] && return + + if ! ${BRDIR}/checkout.sh checkcheckout ${SRCDIR} \ + && ! ${TITANMODE}; then + die 'revision mismatch, run checkout (or -H to override)' + fi +} + +# create the makefiles used for building +mkmakefile () +{ + + makefile=$1 + shift + exec 3>&1 1>${makefile} + printf '# GENERATED FILE, MIGHT I SUGGEST NOT EDITING?\n' + printf 'SUBDIR=' + for dir in $*; do + case ${dir} in + /*) + printf ' %s' ${dir} + ;; + *) + printf ' %s' ${SRCDIR}/${dir} + ;; + esac + done + + printf '\n.include \n' + exec 1>&3 3>&- +} + +domake () +{ + + mkfile=${1}; shift + mktarget=${1}; shift + + [ ! -x ${RUMPMAKE} ] && die "No rumpmake (${RUMPMAKE}). Forgot tools?" + ${RUMPMAKE} $* -j ${JNUM} -f ${mkfile} ${mktarget} + [ $? -eq 0 ] || die "make $mkfile $mktarget" +} + +makebuild () +{ + + checkcheckout + + # ensure we're in SRCDIR, in case "tools" wasn't run + cd ${SRCDIR} + + targets="obj includes dependall install" + + # + # Building takes 4 passes, just like when + # building NetBSD the regular way. The passes are: + # 1) obj + # 2) includes + # 3) dependall + # 4) install + # + + DIRS_first='lib/librumpuser' + DIRS_second='lib/librump' + DIRS_third="lib/librumpdev lib/librumpnet lib/librumpvfs + sys/rump/dev sys/rump/fs sys/rump/kern sys/rump/net + sys/rump/include ${BRDIR}/brlib" + + # sys/rump/share was added to ${SRCDIR} 11/2014 + [ -d ${SRCDIR}/sys/rump/share ] \ + && appendvar DIRS_second ${SRCDIR}/sys/rump/share + + if [ ${MACHINE} = "i386" -o ${MACHINE} = "amd64" \ + -o ${MACHINE#evbearm} != ${MACHINE} \ + -o ${MACHINE#evbppc} != ${MACHINE} ]; then + DIRS_emul=sys/rump/kern/lib/libsys_linux + fi + ${SYS_SUNOS} && appendvar DIRS_emul sys/rump/kern/lib/libsys_sunos + if ${HIJACK}; then + DIRS_final="lib/librumphijack" + else + DIRS_final= + fi + + DIRS_third="${DIRS_third} ${DIRS_emul}" + + if ${KERNONLY}; then + mkmakefile ${OBJDIR}/Makefile.all \ + sys/rump ${DIRS_emul} ${BRDIR}/brlib + else + DIRS_third="lib/librumpclient ${DIRS_third}" + + mkmakefile ${OBJDIR}/Makefile.first ${DIRS_first} + mkmakefile ${OBJDIR}/Makefile.second ${DIRS_second} + mkmakefile ${OBJDIR}/Makefile.third ${DIRS_third} + mkmakefile ${OBJDIR}/Makefile.final ${DIRS_final} + mkmakefile ${OBJDIR}/Makefile.all \ + ${DIRS_first} ${DIRS_second} ${DIRS_third} ${DIRS_final} + fi + + # try to minimize the amount of domake invocations. this makes a + # difference especially on systems with a large number of slow cores + for target in ${targets}; do + if [ ${target} = "dependall" ] && ! ${KERNONLY}; then + domake ${OBJDIR}/Makefile.first ${target} + domake ${OBJDIR}/Makefile.second ${target} + domake ${OBJDIR}/Makefile.third ${target} + domake ${OBJDIR}/Makefile.final ${target} + else + domake ${OBJDIR}/Makefile.all ${target} + fi + done + + if ! ${KERNONLY}; then + mkmakefile ${OBJDIR}/Makefile.utils \ + usr.bin/rump_server usr.bin/rump_allserver \ + usr.bin/rump_wmd + for target in ${targets}; do + domake ${OBJDIR}/Makefile.utils ${target} + done + fi +} + +makeinstall () +{ + + # ensure we run this in a directory that does not have a + # Makefile that could confuse rumpmake + stage=$(cd ${BRTOOLDIR} && ${RUMPMAKE} -V '${BUILDRUMP_STAGE}') + (cd ${stage}/usr ; tar -cf - .) | (cd ${DESTDIR} ; tar -xf -) + +} + +# +# install kernel headers. +# Note: Do _NOT_ do this unless you want to install a +# full rump kernel application stack +# +makekernelheaders () +{ + + dodirs=$(cd ${SRCDIR}/sys && \ + ${RUMPMAKE} -V '${SUBDIR:Narch:Nmodules:Ncompat:Nnetnatm}' includes) + # missing some architectures + appendvar dodirs arch/amd64/include arch/i386/include arch/x86/include + appendvar dodirs arch/arm/include arch/arm/include/arm32 + appendvar dodirs arch/evbarm64/include arch/aarch64/include + appendvar dodirs arch/evbppc/include arch/powerpc/include + appendvar dodirs arch/evbmips/include arch/mips/include + appendvar dodirs arch/riscv/include + for dir in ${dodirs}; do + (cd ${SRCDIR}/sys/${dir} && ${RUMPMAKE} obj) + (cd ${SRCDIR}/sys/${dir} && ${RUMPMAKE} includes) + done + # create machine symlink + (cd ${SRCDIR}/sys/arch && ${RUMPMAKE} NOSUBDIR=1 includes) +} + +maketests () +{ + + if ${KERNONLY}; then + diagout 'Kernel-only; skipping tests (no hypervisor)' + else + . ${BRDIR}/tests/testrump.sh + alltests + fi +}