Commit ab53f6cd authored by Charlie Jacobsen's avatar Charlie Jacobsen Committed by Vikram Narayanan
Browse files

build-refactor: Build setup for microkernel and kliblcd.

Set up out-of-source build for microkernel and kliblcd. This is
necessary because the common/ sources will be built for non-isolated
and isolated worlds (hence we can't do the in-source build - can't
build same source files with different configs in the same directory).

Developing a better solution for the liblcd config and hacks
so we can abstract the build over whether the source file is
built for non-isolated or isolated. Each environment defines a
pre- and post- hook header that should be placed appropriately
in source files for which we want to build for both environments.

For now, non-isolated pre- and post-hooks are empty since we don't
need to do any kernel build config hacks.
parent 0a075cda
#
# Top level makefile (this isn't touched by the kernel
# since we have a kbuild file)
# Top-level makefile for building everything LCD-related.
#
export LCD_DOMAINS_SRC_DIR=$(PWD)
export LCD_DOMAINS_INCLUDE=$(PWD)/include
export LCD_DOMAINS_CFLAGS=-Werror \
-I$(LCD_DOMAINS_INCLUDE) \
-DLCD_DOMAINS \
-DCONFIG_LAZY_THC \
-DLCD_TEST_MODS_PATH="\"$(PWD)/test-mods\""
LCD_DOMAINS_TOP_SRC_DIR=$(PWD)
export LCD_DOMAINS_TOP_SRC_DIR
# Don't print "Entering directory..." etc.
MAKEFLAGS += --no-print-directory
#all: liblcd the_rest
all: the_rest
#the_rest: liblcd libcap.microkernel
the_rest: libcap.microkernel
$(MAKE) -C .. M=$(PWD) -j8
liblcd: libcap.lcd
$(MAKE) -C .. M=$(PWD)/liblcd -j8
libcap.lcd: libcap.build.lcd/Makefile
$(MAKE) -C libcap.build.lcd && \
$(MAKE) -C libcap.build.lcd install
libcap.build.lcd/Makefile: libcap/configure | libcap.build.lcd libcap.out.lcd
cd libcap.build.lcd && \
../libcap/configure PLATFORM=kernel --disable-test-build \
--with-kernel-headers=$(PWD)/.. \
--disable-kernel-module \
--prefix=$(PWD)/libcap.out.lcd
libcap.build.lcd:
mkdir -p libcap.build.lcd
libcap.out.lcd:
mkdir -p libcap.out.lcd
libcap.microkernel: libcap.build.microkernel/Makefile
$(MAKE) -C libcap.build.microkernel && \
$(MAKE) -C libcap.build.microkernel install
libcap.build.microkernel/Makefile: libcap/configure | libcap.build.microkernel \
libcap.out.microkernel
cd libcap.build.microkernel && \
../libcap/configure PLATFORM=kernel --disable-test-build \
# Since we aren't hooked into the Linux build, we need
# to define this so we can use it in this file. (The
# kernel build system will have it def'd when it sucks
# in our Kbuild files.)
ARCH=x86
# ------------------------------------------------------------
# Microkernel build setup
MICROKERNEL_BUILD_DIR=$(LCD_DOMAINS_TOP_SRC_DIR)/microkernel_build
export MICROKERNEL_BUILD_DIR
MICROKERNEL_DIRS= \
microkernel \
kliblcd \
libcap.build \
libcap.install \
common \
arch/$(ARCH)/microkernel
MICROKERNEL_BUILD_DIRS=$(foreach dir,$(MICROKERNEL_DIRS),\
$(MICROKERNEL_BUILD_DIR)/$(dir))
microkernel: libcap.microkernel $(MICROKERNEL_BUILD_DIR)/Kbuild | \
$(MICROKERNEL_BUILD_DIRS)
$(MAKE) -C .. M=$(PWD)/$(MICROKERNEL_BUILD_DIR) -j8
libcap.microkernel: $(MICROKERNEL_BUILD_DIR)/libcap.build/Makefile \
| $(MICROKERNEL_BUILD_DIRS)
$(MAKE) -C $(MICROKERNEL_BUILD_DIR)/libcap.build && \
$(MAKE) -C $(MICROKERNEL_BUILD_DIR)/libcap.build install
$(MICROKERNEL_BUILD_DIR)/libcap.build/Makefile: libcap/configure
cd $(MICROKERNEL_BUILD_DIR)/libcap.build && \
$(LCD_DOMAINS_TOP_SRC_DIR)/libcap/configure && \
PLATFORM=kernel --disable-test-build \
--disable-global-cap-types \
--with-kernel-headers=$(PWD)/.. \
--with-kernel-headers=$(LCD_DOMAINS_TOP_SRC_DIR)/.. \
--disable-kernel-module \
--prefix=$(PWD)/libcap.out.microkernel
--prefix=$(MICROKERNEL_BUILD_DIR)/libcap.install
libcap.build.microkernel:
mkdir -p libcap.build.microkernel
$(MICROKERNEL_BUILD_DIR)/Kbuild: $(MICROKERNEL_BUILD_DIRS)
cp scripts/Kbuild.microkernel $(MICROKERNEL_BUILD_DIR)/Kbuild
libcap.out.microkernel:
mkdir -p libcap.out.microkernel
$(MICROKERNEL_BUILD_DIRS):
mkdir -p $@
# ------------------------------------------------------------
# Some libcap tidbits
libcap/configure:
cd libcap && ./autogen.sh
# ------------------------------------------------------------
# clean
clean:
$(MAKE) -C .. M=$(PWD) clean
$(MAKE) -C .. M=$(PWD)/liblcd clean
if test -d libcap.build.lcd; then $(MAKE) -C libcap.build.lcd clean; fi
if test -d libcap.build.microkernel; then $(MAKE) -C libcap.build.microkernel clean; fi
distclean: clean
if test -d libcap.build.lcd; then $(MAKE) -C libcap.build.lcd distclean; fi
if test -d libcap.build.microkernel; then \
$(MAKE) -C libcap.build.microkernel distclean; fi
rm -rf libcap.build.microkernel libcap.out.microkernel
rm -rf libcap.build.lcd libcap.out.lcd
.PHONY: all the_rest liblcd libcap.microkernel libcap.lcd
$(MAKE) -C .. M=$(PWD)/$(MICROKERNEL_BUILD_DIR) clean
if test -d $(MICROKERNEL_BUILD_DIR)/libcap.build; then \
$(MAKE) -C $(MICROKERNEL_BUILD_DIR)/libcap.build clean; \
fi
distclean:
rm -rf $(MICROKERNEL_BUILD_DIR)
# ------------------------------------------------------------
# phonies
.PHONY: microkernel libcap.microkernel clean distclean
#
# Top level makefile (this isn't touched by the kernel
# since we have a kbuild file)
#
export LCD_DOMAINS_INCLUDE=$(PWD)/include
export LCD_DOMAINS_CFLAGS=-Werror \
-I$(LCD_DOMAINS_INCLUDE) \
-DLCD_DOMAINS \
-DCONFIG_LAZY_THC
# Don't print "Entering directory..." etc.
MAKEFLAGS += --no-print-directory
all: liblcd the_rest
the_rest: liblcd libcap.microkernel
$(MAKE) -C .. M=$(PWD) -j8
liblcd: libcap.lcd
$(MAKE) -C .. M=$(PWD)/liblcd -j8
libcap.lcd: libcap.build.lcd/Makefile
$(MAKE) -C libcap.build.lcd && \
$(MAKE) -C libcap.build.lcd install
libcap.build.lcd/Makefile: libcap/configure | libcap.build.lcd libcap.out.lcd
cd libcap.build.lcd && \
../libcap/configure PLATFORM=kernel --disable-test-build \
--with-kernel-headers=$(PWD)/.. \
--disable-kernel-module \
--prefix=$(PWD)/libcap.out.lcd
libcap.build.lcd:
mkdir -p libcap.build.lcd
libcap.out.lcd:
mkdir -p libcap.out.lcd
libcap.microkernel: libcap.build.microkernel/Makefile
$(MAKE) -C libcap.build.microkernel && \
$(MAKE) -C libcap.build.microkernel install
libcap.build.microkernel/Makefile: libcap/configure | libcap.build.microkernel \
libcap.out.microkernel
cd libcap.build.microkernel && \
../libcap/configure PLATFORM=kernel --disable-test-build \
--disable-global-cap-types \
--with-kernel-headers=$(PWD)/.. \
--disable-kernel-module \
--prefix=$(PWD)/libcap.out.microkernel
libcap.build.microkernel:
mkdir -p libcap.build.microkernel
libcap.out.microkernel:
mkdir -p libcap.out.microkernel
libcap/configure:
cd libcap && ./autogen.sh
clean:
$(MAKE) -C .. M=$(PWD) clean
$(MAKE) -C .. M=$(PWD)/liblcd clean
if test -d libcap.build.lcd; then $(MAKE) -C libcap.build.lcd clean; fi
if test -d libcap.build.microkernel; then $(MAKE) -C libcap.build.microkernel clean; fi
distclean: clean
if test -d libcap.build.lcd; then $(MAKE) -C libcap.build.lcd distclean; fi
if test -d libcap.build.microkernel; then \
$(MAKE) -C libcap.build.microkernel distclean; fi
rm -rf libcap.build.microkernel libcap.out.microkernel
rm -rf libcap.build.lcd libcap.out.lcd
.PHONY: all the_rest liblcd libcap.microkernel libcap.lcd
......@@ -7,6 +7,13 @@
* Copyright: University of Utah
*/
#include <lcd_config/pre_hook.h>
#include <libcap.h>
#include <lcd-domains/liblcd.h>
#include <lcd_config/post_hook.h>
static int do_grant_and_map_for_mem(cptr_t lcd, struct lcd_create_ctx *ctx,
void *mem, gpa_t map_base,
cptr_t *dest)
......
......@@ -7,12 +7,16 @@
* Copyright: University of Utah
*/
#include <lcd_config/pre_hook.h>
#include <linux/slab.h>
#include <linux/interval_tree.h>
#include <linux/rb_tree.h>
#include <libcap.h>
#include <lcd-domains/liblcd.h>
#include <lcd_config/post_hook.h>
int lcd_resource_tree_init(struct lcd_resource_tree *t)
{
/*
......
/*
* post_hook.h
*
* This file is included after all of the headers
* in a source file.
*/
#ifndef LCD_CONFIG_POST_HOOK_H
#define LCD_CONFIG_POST_HOOK_H
/* For non-isolated, there is nothing we need to include. */
#endif /* LCD_CONFIG_POST_HOOK_H */
/*
* pre_hook.h
*
* This file is included before all of the headers
* in a source file.
*/
#ifndef LCD_CONFIG_PRE_HOOK_H
#define LCD_CONFIG_PRE_HOOK_H
/* For non-isolated, there is nothing we need to include. */
#endif /* LCD_CONFIG_PRE_HOOK_H */
#
# Build file for microkernel
# Kernel build file for microkernel
#
# Paths are all relative to the microkernel build dir.
# Main target (lcd_domains.ko)
obj-m += lcd_domains.o
# Arch independent code
lcd_domains-y += \
lcd_domains-y += $(addprefix microkernel/, \
cap_types.o \
console.o \
create.o \
......@@ -14,20 +16,16 @@ lcd_domains-y += \
main.o \
mem.o \
mem_itree.o \
run.o
run.o \
)
# Arch dependent code
lcd_domains-y += arch/$(ARCH)/main.o
lcd_domains-y += arch/$(ARCH)/traps.o
# libcap
lcd_domains-y += ../libcap.out.microkernel/lib/libcap.a
lcd_domains-y += $(addprefix arch/$(ARCH)/microkernel,
main.o \
)
# add libcap headers to include path
ccflags-y += -I$(LCD_DOMAINS_SRC_DIR)/libcap.out.microkernel/include
# kliblcd
lcd_domains-y += $(addprefix ../kliblcd/, \
# kliblcd (built into microkernel .ko)
lcd_domains-y += $(addprefix kliblcd/, \
boot_info.o \
cap.o \
console.o \
......@@ -39,3 +37,13 @@ lcd_domains-y += $(addprefix ../kliblcd/, \
sync_ipc.o \
)
# libcap (microkernel and kliblcd share libcap. We get away with this
# because this build of libcap does not use global cap types.)
lcd_domains-y += libcap.install/lib/libcap.a
# Extra includes
ccflags-y += \
-I$(LCD_DOMAINS_TOP_SRC_DIR)/include \
-I$(LCD_DOMAINS_TOP_SRC_DIR)/arch/$(ARCH)/include \
-I$(MICROKERNEL_BUILD_DIR)/libcap.install/include \
-I$(LCD_DOMAINS_TOP_SRC_DIR)/config/non_isolated
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment