]> xenbits.xensource.com Git - osstest/rumprun.git/commitdiff
Destdir builds, part 1
authorAntti Kantee <pooka@iki.fi>
Mon, 12 Oct 2015 13:45:45 +0000 (13:45 +0000)
committerAntti Kantee <pooka@iki.fi>
Mon, 12 Oct 2015 13:45:45 +0000 (13:45 +0000)
Support a -d flag to build-rr.sh.  Make some of the tools use
libraries and headers from that directory instead of a hardcoded
place.

Not everything is installed into destdir yet.  More to come.

app-tools/Makefile.app-tools
app-tools/specs-compile_or_ferment.in
app-tools/specs-stub.in
build-rr.sh
platform/hw/Makefile
platform/xen/Makefile
platform/xen/platform.conf
platform/xen/rumpxendev/Makefile
platform/xen/xen/Makefile
platform/xen/xen/arch/x86/Makefile

index 8b13ab1eb3cf26e6362ddd92b71ff84372a234aa..b54d6f02f56c5617e9926e9784bedb1fd57a1029 100644 (file)
@@ -12,6 +12,8 @@ ifdef _APPTOOLS_MISSING
 $(error ${_APPTOOLS_MISSING} not defined)
 endif
 
+LDFLAGS_BAKE+= -L$(DESTDIR)/lib
+
 APP_TOOL_FILES=                configure make gmake toolchain.cmake recipe.s
 APP_TOOL_COMPILERS=    cc c++
 
@@ -50,6 +52,7 @@ $(APP_TOOLS_DIR)/${2}:                                                        \
                -e 's#!APPTOOLS_CXX!#$(APP_TOOLS_CXX)#g;'               \
                -e 's#!GNUPLATFORM!#$(GNUPLATFORM)#g;'                  \
                -e 's#!BASE_DIR!#$(abspath ../..)#g;'                   \
+               -e 's#!DESTDIR!#$(DESTDIR)#g;'                          \
                -e 's#!APPTOOLS_DIR!#$(APP_TOOLS_DIR)#g;'               \
                -e 's#!APPTOOLS_PLATFORM!#$(APP_TOOLS_PLATFORM)#g;'     \
                -e 's#!CPPFLAGS!#$(BUILDRUMP_TOOL_CPPFLAGS)#g;'         \
index b20b00c9517084cf38473585ffc2a42e3f76940e..36bfdbde6a113aaefaef98f4f4f7d8c07ebd7cbf 100644 (file)
@@ -1,7 +1,7 @@
 %rename cpp_options old_cpp_options
  
 *cpp_options:
--nostdinc -isystem !BASE_DIR!/rumprun/include %{,c++:%{!std=*:-std=c++11}} %{,c++:-isystem !BASE_DIR!/rumprun/include/c++} %(old_cpp_options) !CPPFLAGS! -D__RUMPRUN__
+-nostdinc -isystem !DESTDIR!/include %{,c++:%{!std=*:-std=c++11}} %{,c++:-isystem !DESTDIR!/include/c++} %(old_cpp_options) !CPPFLAGS! -D__RUMPRUN__
 
 %rename cc1_options old_cc1_options
 
@@ -18,7 +18,7 @@
 
 
 *lib:
--L!BASE_DIR!/rumprun/lib
+-L!DESTDIR!/lib
 
 *link:
 %{m64:-m elf_x86_64;mx32:-m elf32_x86_64;m32:-m elf_i386} %:remove-outfile(-lstdc++) %{rdynamic:}
index 0cf4e892a264469b7f0debfba8236e9f9ceee3fd..cd18909000d9e0d248d05aadf1dac958a9327b7a 100644 (file)
@@ -5,7 +5,7 @@
 
 
 *lib:
--L!BASE_DIR!/rumprun/lib --start-group -lpthread -lc --end-group       \
+-L!DESTDIR!/lib --start-group -lpthread -lc --end-group        \
     !BASE_DIR!/platform/pseudolinkstubs.o
 
 *link:
index 09d674790206306dc96f2fa6bbb1d1e4e774cf07..3e38cf571abb757fd42a722886318860d8baf05e 100755 (executable)
@@ -37,10 +37,14 @@ helpme ()
 {
 
        printf "Usage: $0 [-j num] [-k] [-o objdir] [-q] [-s srcdir] hw|xen\n"
-       printf "\t    [-- buildrump.sh opts]\n"
+       printf "\t    [build] [install] [-- buildrump.sh opts]\n"
        printf "\n"
+       printf "\t-d: destination base directory (under construction).\n"
        printf "\t-j: run <num> make jobs simultaneously.\n"
        printf "\t-q: quiet(er) build.  option may be specified twice.\n\n"
+       printf "\tThe default actions are \"build\" and \"install\"\n\n"
+
+       printf "Expert-only options:\n"
        printf "\t-o: use non-default object directory (under development)\n"
        printf "\t-k: build kernel only, without libc or tools (expert-only)\n"
        printf "\t-s: specify alternative src-netbsd location (expert-only)\n\n"
@@ -70,27 +74,48 @@ type ${MAKE} >/dev/null 2>&1 || die '"make" required but not found'
 # SUBROUTINES
 #
 
+abspath ()
+{
+
+       eval mypath=\${$1}
+       case ${mypath} in
+       /*)
+               ;;
+       *)
+               mypath="$(pwd)/${mypath}"
+       esac
+
+       eval ${1}="\${mypath}"
+}
+
 parseargs ()
 {
 
+       DESTDIR=./rumprun
        KERNONLY=false
-       RUMPOBJ=
+       RROBJ=
        RUMPSRC=src-netbsd
        STDJ=-j4
 
+       DObuild=false
+       DOinstall=false
+
        orignargs=$#
-       while getopts '?hj:ko:qs:' opt; do
+       while getopts '?d:hj:ko:qs:' opt; do
                case "$opt" in
                'j')
                        [ -z "$(echo ${OPTARG} | tr -d '[0-9]')" ] \
                            || die argument to -j must be a number
                        STDJ=-j${OPTARG}
                        ;;
+               'd')
+                       DESTDIR="${OPTARG}"
+                       ;;
                'k')
                        KERNONLY=true
                        ;;
                'o')
-                       RUMPOBJ="${OPTARG}"
+                       RROBJ="${OPTARG}"
                        ;;
                's')
                        RUMPSRC=${OPTARG}
@@ -118,12 +143,27 @@ parseargs ()
                die '-k currently only supports "hw" platform'
        fi
 
-       if [ $# -gt 0 ]; then
+       dodefault=true
+       while [ $# -gt 0 ]; do
                if [ $1 = '--' ]; then
                        shift
+                       break
                else
-                       die Invalid argument: $1
+                       case $1 in
+                       build|install)
+                               eval DO${1}=true
+                               ;;
+                       *)
+                               die invalid argument $1
+                               ;;
+                       esac
+                       dodefault=false
+                       shift
                fi
+       done
+       if ${dodefault}; then
+               DObuild=true
+               DOinstall=true
        fi
 
        case ${RUMPSRC} in
@@ -138,7 +178,6 @@ parseargs ()
        export BUILD_QUIET
 
        RUMPTOOLS=${PLATFORMDIR}/rumptools
-       RUMPDEST=${PLATFORMDIR}/rump
 
        ARGSSHIFT=$((${orignargs} - $#))
 }
@@ -197,13 +236,30 @@ checkprevbuilds ()
        fi
 }
 
+setvars ()
+{
+
+       . ${RUMPTOOLS}/proberes.sh
+       MACHINE="${BUILDRUMP_MACHINE}"
+
+       if [ -z "${RROBJ}" ]; then
+               RROBJ="./obj-${PLATFORM}-${MACHINE}"
+       fi
+       STAGING="${RROBJ}/dest.stage"
+       BROBJ="${RROBJ}/buildrump.sh"
+
+       abspath DESTDIR
+       abspath RROBJ
+       abspath RUMPSRC
+}
+
 buildrump ()
 {
 
        # probe
        ${BUILDRUMP}/buildrump.sh -k -s ${RUMPSRC} -T ${RUMPTOOLS} "$@" probe
-       . ${RUMPTOOLS}/proberes.sh
-       MACHINE="${BUILDRUMP_MACHINE}"
+
+       setvars
 
        # Check that a clang build is not attempted.
        [ -z "${BUILDRUMP_HAVE_LLVM}" ] \
@@ -214,13 +270,9 @@ buildrump ()
        extracflags=
        [ "${MACHINE}" = "amd64" ] && extracflags='-F CFLAGS=-mno-red-zone'
 
-       if [ -z "${RUMPOBJ}" ]; then
-               RUMPOBJ="./obj-${PLATFORM}-${MACHINE}"
-       fi
-
        # build tools
        ${BUILDRUMP}/buildrump.sh ${BUILD_QUIET} ${STDJ} -k             \
-           -s ${RUMPSRC} -T ${RUMPTOOLS} -o ${RUMPOBJ} -d ${RUMPDEST}  \
+           -s ${RUMPSRC} -T ${RUMPTOOLS} -o ${BROBJ} -d ${STAGING}     \
            -V MKPIC=no -V RUMP_CURLWP=__thread                         \
            -V RUMP_KERNEL_IS_LIBC=1 -V BUILDRUMP_SYSROOT=yes           \
            ${extracflags} "$@" tools
@@ -256,7 +308,7 @@ EOF
 
        # build rump kernel
        ${BUILDRUMP}/buildrump.sh ${BUILD_QUIET} ${STDJ} -k             \
-           -s ${RUMPSRC} -T ${RUMPTOOLS} -o ${RUMPOBJ} -d ${RUMPDEST}  \
+           -s ${RUMPSRC} -T ${RUMPTOOLS} -o ${BROBJ} -d ${STAGING}     \
            "$@" build kernelheaders install
 
        echo '>>'
@@ -268,7 +320,7 @@ EOF
 builduserspace ()
 {
 
-       usermtree ${RUMPDEST}
+       usermtree ${STAGING}
 
        LIBS="$(stdlibs ${RUMPSRC})"
        ! ${HAVECXX} || LIBS="${LIBS} $(stdlibsxx ${RUMPSRC})"
@@ -337,6 +389,9 @@ makeconfigmk ()
        echo "MACHINE_ARCH=${MACHINE_ARCH}" >> ${1}
        echo "KERNONLY=${KERNONLY}" >> ${1}
 
+       echo "DESTDIR=${DESTDIR}" >> ${1}
+       echo "OBJDIR=${RROBJ}" >> ${1}
+
        # wrap mandatory toolchain bits
        for t in AR AS CC CPP LD NM OBJCOPY OBJDUMP RANLIB READELF \
             SIZE STRINGS STRIP; do
@@ -352,44 +407,67 @@ makeconfigmk ()
        fi
 }
 
+dobuild ()
+{
 
-#
-# BEGIN SCRIPT
-#
+       checksubmodules
 
-parseargs "$@"
-shift ${ARGSSHIFT}
+       . ${BUILDRUMP}/subr.sh
+
+       PLATFORM_MKCONF=
+       . ${PLATFORMDIR}/platform.conf
+
+       buildrump "$@"
+       ${KERNONLY} || builduserspace
 
-checksubmodules
+       # depends on config.mk
+       buildpci
 
-. ${BUILDRUMP}/subr.sh
+       buildkernlibs
 
-PLATFORM_MKCONF=
-. ${PLATFORMDIR}/platform.conf
+       # run routine specified in platform.conf
+       doextras || die 'platforms extras failed.  tillerman needs tea?'
 
-buildrump "$@"
-${KERNONLY} || builduserspace
+       # do final build of the platform bits
+       ( cd ${PLATFORMDIR} && ${MAKE} BUILDRR=true || exit 1)
+       [ $? -eq 0 ] || die platform make failed!
+}
+
+doinstall ()
+{
 
-# depends on config.mk
-buildpci
+       setvars
 
-buildkernlibs
+       # default used to be a symlink, so this is for "compat".
+       # remove in a few months.
+       rm -f ${DESTDIR} > /dev/null 2>&1
 
-# run routine specified in platform.conf
-doextras || die 'platforms extras failed.  tillerman needs tea?'
+       mkdir -p ${DESTDIR} || die cannot create ${DESTDIR}
+       ( cd ${STAGING} ; tar -cf - .) | (cd ${DESTDIR} ; tar -xf -)
+}
+
+#
+# BEGIN SCRIPT
+#
 
-# create high-level link to rumprun components
-ln -sf ${PLATFORMDIR}/rump ./rumprun
+parseargs "$@"
+shift ${ARGSSHIFT}
 
-# do final build of the platform bits
-( cd ${PLATFORMDIR} && ${MAKE} || exit 1)
-[ $? -eq 0 ] || die platform make failed!
+${DObuild} && dobuild "$@"
+${DOinstall} && doinstall
 
 # echo some useful information for the user
 echo
 echo '>>'
-echo ">> Built rumprun for ${PLATFORM} : ${TOOLTUPLE}"
-echo ">> cc: ${TOOLTUPLE}-$(${RUMPMAKE} -f bsd.own.mk -V '${ACTIVE_CC}')"
+echo ">> Finished $0 for ${PLATFORM}"
+if ${DObuild}; then
+       printf ">> ${TOOLTUPLE}"
+       printf ">> cc: %s-%s\n", \
+          ${TOOLTUPLE} "$(${RUMPMAKE} -f bsd.own.mk -V '${ACTIVE_CC}')"
+fi
+if ${DOinstall}; then
+       printf ">> installed to \"%s\"\n" ${DESTDIR}
+fi
 echo '>>'
 echo ">> $0 ran successfully"
 exit 0
index f21190b9e4eadd26791fe4eec59efd09a1ded9d0..96174c15421a09d0a3cc6aa205ae12983797b4a5 100644 (file)
@@ -1,6 +1,5 @@
 PLATFORM=hw
 PLATFORM_DEFAULT_TESTER=qemu
-OBJ_DIR=.
 
 include ../../global.mk
 -include config.mk
@@ -9,7 +8,7 @@ include ${BUILDRUMP_TOOLFLAGS}
 endif
 
 ifneq (${KERNONLY},true)
-TARGETS:= app-tools userlibs buildtest
+TARGETS:= app-tools userlibs buildtest
 else
 TARGETS:= compiler_rt
 endif
@@ -20,9 +19,15 @@ all:  include/hw/machine ${MAINOBJ} platformlibs ${TARGETS}
 
 include ../Makefile.inc
 
-CPPFLAGS=      -Iinclude -Irump/include -I../../include -nostdinc
+CPPFLAGS=      -Iinclude -I../../include -nostdinc
 CFLAGS+=       ${BUILDRUMP_TOOL_CFLAGS}
 
+ifeq (${BUILDRR},true)
+CPPFLAGS+=     -I${OBJDIR}/dest.stage/include
+else
+CPPFLAGS+=     -I${DESTDIR}/include
+endif
+
 # Check if we're building for a supported target.
 supported= false
 HASPCI= y
@@ -45,8 +50,6 @@ endif
 
 ARCHDIR?= ${MACHINE}
 
-LDFLAGS_BAKE+= -L$(abspath rump/lib)
-
 OBJS_BMK+=     intr.o clock_subr.o kernel.o multiboot.o undefs.o
 
 include arch/${ARCHDIR}/Makefile.inc
index 8f15398aaac9ddbb5896b2dd7e0714e18051476c..6f7099d459a62fbd4ac39405522c5171a4df666a 100644 (file)
@@ -18,14 +18,20 @@ MAINOBJ= $(abspath $(OBJ_DIR)/rumprun-xen-$(MACHINE_ARCH).o)
 OBJ_DIR ?= $(CURDIR)/obj
 
 .PHONY: default
-default: prepare commonlibs mini-os $(MAINOBJ) app-tools buildtest
+default: prepare links commonlibs mini-os $(MAINOBJ) app-tools
 
 include ../Makefile.inc
 
-CPPFLAGS = -isystem rump/include -isystem xen/include -I. -I../../include
+CPPFLAGS = -isystem xen/include -I. -I../../include
 CPPFLAGS+= -nostdinc
 CPPFLAGS+= -no-integrated-cpp -nostdinc
 
+ifeq (${BUILDRR},true)
+CPPFLAGS+=     -isystem ${OBJDIR}/dest.stage/include
+else
+CPPFLAGS+=     -isystem ${DESTDIR}/include
+endif
+
 CFLAGS += -fno-builtin ${BUILDRUMP_TOOL_CFLAGS}
 
 # This is semi-duplicated from xen/arch/x86/arch.mk, can we avoid that?
@@ -37,8 +43,6 @@ ifeq ($(MACHINE),x86_64)
 CFLAGS += -mno-red-zone -fno-reorder-blocks -fno-asynchronous-unwind-tables
 endif
 
-LDFLAGS_BAKE+= -L$(abspath rump/lib)
-
 rump-src-y += rumphyper_bio.c
 
 rump-src-y += init.c
index 1f0cfffe74ecf75604e4ef913d3bd233c79fa68f..3006e0d9d8fb5882ab0b80f5816fe12fe50f276e 100644 (file)
@@ -7,8 +7,8 @@ makekernlib ()
        OBJS=`pwd`/rumpobj/$lib
        mkdir -p ${OBJS}
        ( cd ${lib} &&
-               ${RUMPMAKE} MAKEOBJDIRPREFIX=${OBJS} obj &&
-               ${RUMPMAKE} MAKEOBJDIRPREFIX=${OBJS} dependall &&
+               ${RUMPMAKE} MAKEOBJDIRPREFIX=${OBJS} BUILDRR=true obj &&
+               ${RUMPMAKE} MAKEOBJDIRPREFIX=${OBJS} BUILDRR=true dependall &&
                ${RUMPMAKE} MAKEOBJDIRPREFIX=${OBJS} install
        ) || die makekernlib $lib failed
 }
index 3fac085d77d3c9aa2ce55e10a5fd7ebe01183a9b..f1e0161c48dfa90647d77b1861e009832616c4a2 100644 (file)
@@ -9,10 +9,15 @@ RUMPTOP= ${TOPRUMP}
 
 CPPFLAGS+=     -I${RUMPTOP}/librump/rumpkern -I${RUMPTOP}/librump
 CPPFLAGS+=     -I${RUMPTOP}/librump/rumpvfs
-CPPFLAGS+=     -I${.CURDIR} -I${.CURDIR}/../rump/include
+CPPFLAGS+=     -I${.CURDIR}
 CPPFLAGS+=     -I${.CURDIR}/../xen/include -D__RUMP_KERNEL__ -I${.CURDIR}/..
 CPPFLAGS+=     -I${.CURDIR}/../../../include
 
+.if ${BUILDRR:Uno} == "true"
+.include "${.CURDIR}/../config.mk"
+CPPFLAGS+=     -I${OBJDIR}/dest.stage/include
+.endif
+
 RUMP_SYM_NORENAME=xenbus_|HYPERVISOR_|minios_|bmk_
 
 .include "${RUMPTOP}/Makefile.rump"
index ba3030d3eb836424986db69eb23804bd6e8f197b..efdcaee8ac0c7533d412bf31348709d94ee75d26 100644 (file)
@@ -32,10 +32,16 @@ DEF_CFLAGS += $(flags-y)
 include minios.mk
 
 # TODO: Import rump CPPFLAGS / include directories from top-level Makefile
-CFLAGS += -isystem ../rump/include -I.. -I../../../include
+CFLAGS += -I.. -I../../../include
 CFLAGS += -I$(MINI-OS_ROOT)
 CFLAGS += ${BUILDRUMP_TOOL_CFLAGS}
 
+ifeq (${BUILDRR},true)
+CFLAGS+=       -isystem ${OBJDIR}/dest.stage/include
+else
+CFLAGS+=       -isystem ${DESTDIR}/include
+endif
+
 CFLAGS += -nostdinc -no-integrated-cpp
 
 LDARCHLIB := -l$(ARCH_LIB_NAME)
index ac75654f4c5387f4a06d2a56e40a8549533a2acc..39f9405ac8d2b3fad74c0a56a5000c0246d8350c 100644 (file)
@@ -14,9 +14,16 @@ include arch.mk
 include $(MINI-OS_ROOT)/minios.mk
 
 # TODO: Import rump CPPFLAGS / include directories from top-level Makefile
-CFLAGS+= -isystem $(MINI-OS_ROOT)/../rump/include -I $(MINI-OS_ROOT)/../../../include -nostdinc
+CFLAGS+= -I $(MINI-OS_ROOT)/../../../include -nostdinc
 CFLAGS+= ${BUILDRUMP_TOOL_CFLAGS}
 
+-include ../../config.mk
+ifeq (${BUILDRR},true)
+CFLAGS+=        -isystem ${OBJDIR}/dest.stage/include
+else
+CFLAGS+=        -isystem ${DESTDIR}/include
+endif
+
 # Sources here are all *.c *.S without $(XEN_TARGET_ARCH).S
 # This is handled in $(HEAD_ARCH_OBJ)
 ARCH_SRCS := $(wildcard *.c)