From: Martin Lucina Date: Fri, 12 Dec 2014 17:18:50 +0000 (+0100) Subject: Extricate rumprun build system from Mini-OS X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=adc3a7cc769a1034abb5cf0c3f62ea6dc5d01976;p=rumpuser-xen.git Extricate rumprun build system from Mini-OS Moves the Mini-OS Makefile and associated bits to xen/, separating the rumprun and Mini-OS build systems. This will hopefully prepare us better for (possibly) merging with upstream Mini-OS. Further changes arising from this: - All minios and rumprun object files are now built under obj/ - MiniOS build installs the arch-specific ldscript under obj/xen/minios.lds - Rather than separately specifying the arch-specific startfile in app-tools specs we link it into the final minios.o and use that as the startfile. The advantage of this approach is we no longer have to "hunt" for the startfile _OR_ the arch-specific lib in the top-level Makefile. It does mean the resulting application has a different memory layout due to link order but this should not matter. Signed-off-by: Martin Lucina --- diff --git a/.gitignore b/.gitignore index 6106286..f33d61a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,8 +7,8 @@ rump rump-kernel rumpobj rumptools -include/mini-os/machine -include/xen +xen/include/mini-os/machine +xen/include/xen app-tools/specs app-tools/specs.configure diff --git a/Config.mk b/Config.mk deleted file mode 100644 index 21b253e..0000000 --- a/Config.mk +++ /dev/null @@ -1,49 +0,0 @@ -# Useful config stuff - -# Where to find xen headers from. XXX: this can probably be done better -XEN_HEADERS ?= /usr/include/xen - -# from Xen/Config.mk -XEN_COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/ \ - -e s/i86pc/x86_32/ -e s/amd64/x86_64/ -e s/arm.*/arm/) -XEN_TARGET_ARCH ?= $(XEN_COMPILE_ARCH) - -XEN_INTERFACE_VERSION := 0x00030205 -export XEN_INTERFACE_VERSION - -OBJ_DIR= $(MINI-OS_ROOT)/obj - -# Try to find out the architecture family TARGET_ARCH_FAM. -# First check whether x86_... is contained (for x86_32, x86_32y, x86_64). -# If not x86 then use $(XEN_TARGET_ARCH) -> for ia64, ... -ifeq ($(findstring x86_,$(XEN_TARGET_ARCH)),x86_) -TARGET_ARCH_FAM = x86 -else -TARGET_ARCH_FAM = $(XEN_TARGET_ARCH) -endif - -# The architecture family directory below mini-os. -TARGET_ARCH_DIR := arch/$(TARGET_ARCH_FAM) - -# Export these variables for possible use in architecture dependent makefiles. -export TARGET_ARCH_DIR -export TARGET_ARCH_FAM - -# This is used for architecture specific links. -# This can be overwritten from arch specific rules. -ARCH_LINKS = - -# The path pointing to the architecture specific header files. -ARCH_INC := $(TARGET_ARCH_FAM) - -# For possible special header directories. -# This can be overwritten from arch specific rules. -EXTRA_INC = $(ARCH_INC) - -# Include the architecture family's special makerules. -# This must be before include minios.mk! -include $(MINI-OS_ROOT)/xen/$(TARGET_ARCH_DIR)/arch.mk - -extra_incl := $(foreach dir,$(EXTRA_INC),-isystem $(MINI-OS_ROOT)/include/$(dir)) - -DEF_CPPFLAGS += -isystem $(MINI-OS_ROOT)/xen/include diff --git a/Makefile b/Makefile index 8005853..4b7e8df 100644 --- a/Makefile +++ b/Makefile @@ -1,43 +1,32 @@ -# Common Makefile for mini-os. # -# Every architecture directory below mini-os/arch has to have a -# Makefile and a arch.mk. +# Rumprun-xen Makefile. +# Abandon all hope, ye who enter here: +# This is in flux while cleanup and separation from the Mini-OS +# Makefile is being worked out. # - -MINI-OS_ROOT=$(CURDIR) -export MINI-OS_ROOT - -ifeq ($(MINIOS_CONFIG),) -include Config.mk -else -EXTRA_DEPS += $(MINIOS_CONFIG) -include $(MINIOS_CONFIG) -endif - -# Configuration defaults -CONFIG_XENBUS ?= y - -CONFIG_PCI ?= y - -# Export config items as compiler directives -flags-$(CONFIG_XENBUS) += -DCONFIG_XENBUS -flags-$(CONFIG_PCI) += -DCONFIG_PCI - -DEF_CFLAGS += $(flags-y) +OBJ_DIR ?= $(CURDIR)/obj OBJCOPY=objcopy -# Include common mini-os makerules. -include minios.mk +CPPFLAGS = -isystem rump/include -isystem xen/include -I. -nostdinc +CPPFLAGS += -DVIRTIF_BASE=xenif -CFLAGS += -Irump/include -nostdinc -CFLAGS += -DVIRTIF_BASE=xenif -I$(MINI-OS_ROOT) -CFLAGS += -no-integrated-cpp +CFLAGS = -Wall -g +CFLAGS += -fno-builtin -no-integrated-cpp -ifeq ($(CONFIG_PCI),y) -RUMP_LIBS_PCI = -lrumpdev_pci -lrumpdev_pci_if_wm -lrumpdev_miiphy +# This is semi-duplicated from xen/arch/x86/arch.mk, can we avoid that? +TARGET_ARCH := $(shell uname -m | sed -e s/i.86/i386/) +# XXX Which parts of the rumprun source *must* be compiled with these flags? +ifeq ($(TARGET_ARCH),i386) +CFLAGS += -m32 -march=i686 +endif +ifeq ($(TARGET_ARCH),x86_64) +CFLAGS += -m64 -mno-red-zone -fno-reorder-blocks -fno-asynchronous-unwind-tables endif +# TODO: This was never actually enabled in previous builds(?) and needs more +# symbols from Mini-OS. +# RUMP_LIBS_PCI = -lrumpdev_pci -lrumpdev_pci_if_wm -lrumpdev_miiphy RUMP_LIBS_FS = -lrumpfs_ffs -lrumpfs_cd9660 -lrumpdev_disk -lrumpdev -lrumpvfs RUMP_LIBS_NET = -lrumpnet_config -lrumpdev_bpf -lrumpnet_xenif -lrumpnet_netinet RUMP_LIBS_NET+= -lrumpnet_net -lrumpxen_xendev -lrumpnet @@ -46,34 +35,7 @@ RUMP_LIBS_NET+= -lrumpnet_net -lrumpxen_xendev -lrumpnet RUMP_LDLIBS = --whole-archive ${RUMP_LIBS_FS} ${RUMP_LIBS_NET} ${RUMP_LIBS_PCI} -lrump --no-whole-archive RUMP_LDLIBS := ${RUMP_LDLIBS} -lpthread -lc -LDARCHLIB := -l$(ARCH_LIB_NAME) -LDSCRIPT := xen/$(TARGET_ARCH_DIR)/minios-$(XEN_TARGET_ARCH).lds -LDFLAGS_FINAL := -T $(LDSCRIPT) - -LDFLAGS := -L$(abspath $(OBJ_DIR)/xen/$(TARGET_ARCH_DIR)) -L$(abspath rump/lib) - -# Prefixes for global API names. All other symbols in mini-os are localised -# before linking with rumprun applications. -GLOBAL_PREFIXES := _minios_ minios_ HYPERVISOR_ blkfront_ netfront_ pcifront_ xenbus_ -GLOBAL_PREFIXES := $(patsubst %,-G %*, $(GLOBAL_PREFIXES)) - -# Subdirectories common to mini-os -SUBDIRS := lib xen xen/console xen/xenbus - -src-y += xen/blkfront.c -src-y += xen/events.c -src-y += xen/gntmap.c -src-y += xen/gnttab.c -src-y += xen/hypervisor.c -src-y += xen/kernel.c -src-y += xen/mm.c -src-y += xen/netfront.c -src-$(CONFIG_PCI) += xen/pcifront.c -src-y += xen/sched.c -src-$(CONFIG_XENBUS) += xen/xenbus/xenbus.c -src-y += xen/console/console.c -src-y += xen/console/xencons_ring.c -src-y += xen/console/xenbus.c +LDFLAGS := -L$(abspath rump/lib) rump-src-y += lib/__errno.c rump-src-y += lib/emul.c @@ -83,7 +45,8 @@ rump-src-y += lib/_lwp.c rump-src-y += rumphyper_base.c rump-src-y += rumphyper_net.c -rump-src-$(CONFIG_PCI) += rumphyper_pci.c +# TODO: See above. +# rump-src-y += rumphyper_pci.c rump-src-y += rumphyper_synch.c rump-src-y += rumphyper_stubs.c @@ -91,39 +54,27 @@ rump-src-y += callmain.c rump-src-y += netbsd_init.c rump-src-y += rumpconfig.c -# The common mini-os objects to build. -OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(src-y)) # Rump kernel middleware objects to build. RUMP_OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(rump-src-y)) -.PHONY: default -default: objs app-tools minios.o rumprun.o tests rump-kernel - -objs: - mkdir -p $(OBJ_DIR)/lib $(OBJ_DIR)/xen/$(TARGET_ARCH_DIR) - mkdir -p $(OBJ_DIR)/xen/console $(OBJ_DIR)/xen/xenbus +$(OBJ_DIR)/%.o: %.c $(HDRS) $(EXTRA_DEPS) + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ -# Create special architecture specific links. The function arch_links -# has to be defined in arch.mk (see include above). -ifneq ($(ARCH_LINKS),) -$(ARCH_LINKS): - $(arch_links) -endif +.PHONY: default +default: prepare mini-os rumprun app-tools tests rump-kernel -.PHONY: links -links: $(ARCH_LINKS) - [ -e xen/include/xen ] || ln -sf $(XEN_HEADERS) xen/include/xen - [ -e xen/include/mini-os/machine ] || ln -sf $(TARGET_ARCH_FAM) xen/include/mini-os/machine +.PHONY: prepare +prepare: + mkdir -p $(OBJ_DIR)/lib -.PHONY: arch_lib -arch_lib: - $(MAKE) --directory=xen/$(TARGET_ARCH_DIR) OBJ_DIR=$(OBJ_DIR)/xen/$(TARGET_ARCH_DIR) || exit 1; +.PHONY: mini-os +mini-os: + $(MAKE) -C xen OBJ_DIR=$(OBJ_DIR)/xen -minios.o: links $(OBJS) arch_lib - $(LD) -r $(LDFLAGS) $(OBJS) $(LDARCHLIB) $(LDLIBS) -o $@ - $(OBJCOPY) -w $(GLOBAL_PREFIXES) -G _start $@ $@ +.PHONY: rumprun +rumprun: $(OBJ_DIR)/rumprun.o -rumprun.o: $(RUMP_OBJS) +$(OBJ_DIR)/rumprun.o: $(RUMP_OBJS) $(LD) -r $(LDFLAGS) $(RUMP_OBJS) -o $@ APP_TOOLS += rumpapp-xen-cc rumpapp-xen-cc.configure specs specs.configure @@ -132,32 +83,27 @@ APP_TOOLS += rumpapp-xen-configure rumpapp-xen-make rumpapp-xen-gmake .PHONY: app-tools app-tools: $(addprefix app-tools/, $(APP_TOOLS)) -APP_TOOLS_LDLIBS := $(RUMP_LDLIBS) -# XXX: LDARCHLIB isn't really a linker flag, but it needs to -# be always included anyway -APP_TOOLS_LDFLAGS := $(LDFLAGS) $(LDARCHLIB) -APP_TOOLS_OBJS := $(abspath minios.o rumprun.o) - -APP_TOOLS_ARCH := $(subst x86_32,i386, \ - $(subst x86_64,amd64, \ - $(XEN_TARGET_ARCH))) +APP_TOOLS_LDLIBS := $(RUMP_LDLIBS) +APP_TOOLS_LDSCRIPT := $(OBJ_DIR)/xen/minios.lds +APP_TOOLS_LDFLAGS := $(LDFLAGS) +APP_TOOLS_OBJS := $(abspath $(OBJ_DIR)/rumprun.o) APP_TOOLS_CPPFLAGS := $(filter -U%, $(shell \ rumptools/rumpmake -f rumptools/mk.conf -V '$${CPPFLAGS}')) APP_TOOLS_MAKE := $(abspath app-tools/rumpapp-xen-make) -app-tools/%: app-tools/%.in Makefile Config.mk +app-tools/%: app-tools/%.in Makefile sed <$< >$@.tmp \ - -e 's#!ARCH!#$(strip $(APP_TOOLS_ARCH))#g;' \ + -e 's#!ARCH!#$(TARGET_ARCH)#g;' \ -e 's#!BASE!#$(abspath .)#g;' \ -e 's#!APPTOOLS!#$(abspath app-tools)#g;' \ -e 's#!CPPFLAGS!#$(APP_TOOLS_CPPFLAGS)#g;' \ -e 's#!OBJS!#$(APP_TOOLS_OBJS)#g;' \ -e 's#!LDLIBS!#$(APP_TOOLS_LDLIBS)#g;' \ -e 's#!LDFLAGS!#$(APP_TOOLS_LDFLAGS)#g;' \ - -e 's#!HEAD_OBJ!#$(abspath $(HEAD_OBJ))#g;' \ - -e 's#!LDSCRIPT!#$(abspath $(LDSCRIPT))#g;' + -e 's#!HEAD_OBJ!#$(abspath $(OBJ_DIR)/xen/minios.o)#g;' \ + -e 's#!LDSCRIPT!#$(abspath $(APP_TOOLS_LDSCRIPT))#g;' if test -x $<; then chmod +x $@.tmp; fi mv -f $@.tmp $@ @@ -182,16 +128,9 @@ rump-kernel: ${STDTESTS} httpd .PHONY: clean arch_clean app-tools_clean -arch_clean: - $(MAKE) --directory=xen/$(TARGET_ARCH_DIR) OBJ_DIR=$(OBJ_DIR)/xen/$(TARGET_ARCH_DIR) clean || exit 1; - -clean: arch_clean app-tools_clean - for dir in $(addprefix $(OBJ_DIR)/,$(SUBDIRS)); do \ - rm -f $$dir/*.o; \ - done - rm -f $(OBJ_DIR)/*.o *~ $(OBJ_DIR)/core minios.o rumprun.o rump-kernel - rm -f xen/include/xen xen/include/mini-os/machine - rm -f tags TAGS +clean: app-tools_clean + $(MAKE) -C xen OBJ_DIR=$(OBJ_DIR)/xen clean + rm -f $(OBJ_DIR)/*.o $(OBJ_DIR)/lib/*.o rump-kernel $(MAKE) -C httpd -f Makefile.boot clean $(MAKE) -C tests clean @@ -200,20 +139,3 @@ cleanrump: clean distcleanrump: cleanrump -define all_sources - ( find . -follow -name SCCS -prune -o -name '*.[chS]' -print ) -endef - -.PHONY: cscope -cscope: - $(all_sources) > cscope.files - cscope -k -b -q - -.PHONY: tags -tags: - $(all_sources) | xargs ctags - -.PHONY: TAGS -TAGS: - $(all_sources) | xargs etags - diff --git a/app.lds b/app.lds deleted file mode 100644 index 4a48cc8..0000000 --- a/app.lds +++ /dev/null @@ -1,11 +0,0 @@ -SECTIONS -{ - .app.bss : { - __app_bss_start = . ; - *(.bss .bss.*) - *(COMMON) - *(.lbss .lbss.*) - *(LARGE_COMMON) - __app_bss_end = . ; - } -} diff --git a/minios.mk b/minios.mk deleted file mode 100644 index 7edae2a..0000000 --- a/minios.mk +++ /dev/null @@ -1,65 +0,0 @@ -# -# The file contains the common make rules for building mini-os. -# - -debug = y - -# Define some default flags. -# NB. '-Wcast-qual' is nasty, so I omitted it. -DEF_CFLAGS += -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format -Wno-redundant-decls -DEF_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,) -DEF_CFLAGS += $(call cc-option,$(CC),-fgnu89-inline) -DEF_CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline -DEF_CPPFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION) - -DEF_ASFLAGS += -D__ASSEMBLY__ - -ifeq ($(debug),y) -DEF_CFLAGS += -g -#DEF_CFLAGS += -DMM_DEBUG -DEF_CFLAGS += -DGNT_DEBUG -DEF_CFLAGS += -DGNTMAP_DEBUG -else -DEF_CFLAGS += -O3 -endif - -# Build the CFLAGS and ASFLAGS for compiling and assembling. -# DEF_... flags are the common mini-os flags, -# ARCH_... flags may be defined in arch/$(TARGET_ARCH_FAM/rules.mk -CFLAGS := $(DEF_CFLAGS) $(ARCH_CFLAGS) -CPPFLAGS := $(DEF_CPPFLAGS) $(ARCH_CPPFLAGS) -ASFLAGS := $(DEF_ASFLAGS) $(ARCH_ASFLAGS) -LDFLAGS := $(DEF_LDFLAGS) $(ARCH_LDFLAGS) - -# Special build dependencies. -# Rebuild all after touching this/these file(s) -EXTRA_DEPS += $(MINI-OS_ROOT)/minios.mk -EXTRA_DEPS += $(MINI-OS_ROOT)/xen/$(TARGET_ARCH_DIR)/arch.mk - -# Find all header files for checking dependencies. -HDRS := $(wildcard $(MINI-OS_ROOT)/include/*.h) -HDRS += $(wildcard $(MINI-OS_ROOT)/include/xen/*.h) -HDRS += $(wildcard $(ARCH_INC)/*.h) -# For special wanted header directories. -extra_heads := $(foreach dir,$(EXTRA_INC),$(wildcard $(dir)/*.h)) -HDRS += $(extra_heads) - -# Add the special header directories to the include paths. -override CPPFLAGS := $(CPPFLAGS) $(extra_incl) - -# The name of the architecture specific library. -# This is on x86_32: libx86_32.a -# $(ARCH_LIB) has to built in the architecture specific directory. -ARCH_LIB_NAME = $(XEN_TARGET_ARCH) -ARCH_LIB := lib$(ARCH_LIB_NAME).a - -# This object contains the entrypoint for startup from Xen. -# $(HEAD_ARCH_OBJ) has to be built in the architecture specific directory. -HEAD_ARCH_OBJ := $(XEN_TARGET_ARCH).o -HEAD_OBJ := $(OBJ_DIR)/xen/$(TARGET_ARCH_DIR)/$(HEAD_ARCH_OBJ) - -$(OBJ_DIR)/%.o: %.c $(HDRS) $(EXTRA_DEPS) - $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ - -$(OBJ_DIR)/%.o: %.S $(HDRS) $(EXTRA_DEPS) - $(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@ diff --git a/xen/Config.mk b/xen/Config.mk new file mode 100644 index 0000000..e7eb165 --- /dev/null +++ b/xen/Config.mk @@ -0,0 +1,49 @@ +# Useful config stuff + +# Where to find xen headers from. XXX: this can probably be done better +XEN_HEADERS ?= /usr/include/xen + +# from Xen/Config.mk +XEN_COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/ \ + -e s/i86pc/x86_32/ -e s/amd64/x86_64/ -e s/arm.*/arm/) +XEN_TARGET_ARCH ?= $(XEN_COMPILE_ARCH) + +XEN_INTERFACE_VERSION := 0x00030205 +export XEN_INTERFACE_VERSION + +OBJ_DIR ?= $(MINI-OS_ROOT)/obj + +# Try to find out the architecture family TARGET_ARCH_FAM. +# First check whether x86_... is contained (for x86_32, x86_32y, x86_64). +# If not x86 then use $(XEN_TARGET_ARCH) -> for ia64, ... +ifeq ($(findstring x86_,$(XEN_TARGET_ARCH)),x86_) +TARGET_ARCH_FAM = x86 +else +TARGET_ARCH_FAM = $(XEN_TARGET_ARCH) +endif + +# The architecture family directory below mini-os. +TARGET_ARCH_DIR := arch/$(TARGET_ARCH_FAM) + +# Export these variables for possible use in architecture dependent makefiles. +export TARGET_ARCH_DIR +export TARGET_ARCH_FAM + +# This is used for architecture specific links. +# This can be overwritten from arch specific rules. +ARCH_LINKS = + +# The path pointing to the architecture specific header files. +ARCH_INC := $(TARGET_ARCH_FAM) + +# For possible special header directories. +# This can be overwritten from arch specific rules. +EXTRA_INC = $(ARCH_INC) + +# Include the architecture family's special makerules. +# This must be before include minios.mk! +include $(MINI-OS_ROOT)/$(TARGET_ARCH_DIR)/arch.mk + +extra_incl := $(foreach dir,$(EXTRA_INC),-isystem $(MINI-OS_ROOT)/include/$(dir)) + +DEF_CPPFLAGS += -isystem $(MINI-OS_ROOT)/include diff --git a/xen/Makefile b/xen/Makefile new file mode 100644 index 0000000..5aba21f --- /dev/null +++ b/xen/Makefile @@ -0,0 +1,132 @@ +# Common Makefile for mini-os. +# +# Every architecture directory below mini-os/arch has to have a +# Makefile and a arch.mk. +# + +MINI-OS_ROOT=$(CURDIR) +export MINI-OS_ROOT + +ifeq ($(MINIOS_CONFIG),) +include Config.mk +else +EXTRA_DEPS += $(MINIOS_CONFIG) +include $(MINIOS_CONFIG) +endif + +# Configuration defaults +CONFIG_XENBUS ?= y + +CONFIG_PCI ?= y + +# Export config items as compiler directives +flags-$(CONFIG_XENBUS) += -DCONFIG_XENBUS +flags-$(CONFIG_PCI) += -DCONFIG_PCI + +DEF_CFLAGS += $(flags-y) + +OBJCOPY=objcopy + +# Include common mini-os makerules. +include minios.mk + +# TODO: Import rump CPPFLAGS / include directories from top-level Makefile +CFLAGS += -isystem ../rump/include -I.. -nostdinc +CFLAGS += -I$(MINI-OS_ROOT) +CFLAGS += -no-integrated-cpp + +LDARCHLIB := -l$(ARCH_LIB_NAME) +LDSCRIPT := $(TARGET_ARCH_DIR)/minios-$(XEN_TARGET_ARCH).lds +LDFLAGS_FINAL := -T $(LDSCRIPT) + +LDFLAGS := -L$(abspath $(OBJ_DIR)/$(TARGET_ARCH_DIR)) + +# Prefixes for global API names. All other symbols in mini-os are localised +# before linking with rumprun applications. +GLOBAL_PREFIXES := _minios_ minios_ HYPERVISOR_ blkfront_ netfront_ pcifront_ xenbus_ +GLOBAL_PREFIXES := $(patsubst %,-G %*, $(GLOBAL_PREFIXES)) + +# Subdirectories common to mini-os +SUBDIRS := console xenbus + +src-y += blkfront.c +src-y += events.c +src-y += gntmap.c +src-y += gnttab.c +src-y += hypervisor.c +src-y += kernel.c +src-y += mm.c +src-y += netfront.c +src-$(CONFIG_PCI) += pcifront.c +src-y += sched.c +src-$(CONFIG_XENBUS) += xenbus/xenbus.c +src-y += console/console.c +src-y += console/xencons_ring.c +src-y += console/xenbus.c + +# The common mini-os objects to build. +OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(src-y)) + +.PHONY: default +default: objs $(OBJ_DIR)/minios.o $(OBJ_DIR)/minios.lds + +objs: + mkdir -p $(OBJ_DIR)/$(TARGET_ARCH_DIR) + mkdir -p $(OBJ_DIR)/console $(OBJ_DIR)/xenbus + +# Create special architecture specific links. The function arch_links +# has to be defined in arch.mk (see include above). +ifneq ($(ARCH_LINKS),) +$(ARCH_LINKS): + $(arch_links) +endif + +.PHONY: links +links: $(ARCH_LINKS) + [ -e include/xen ] || ln -sf $(XEN_HEADERS) include/xen + [ -e include/mini-os/machine ] || ln -sf $(TARGET_ARCH_FAM) include/mini-os/machine + +.PHONY: arch_lib +arch_lib: + $(MAKE) --directory=$(TARGET_ARCH_DIR) OBJ_DIR=$(OBJ_DIR)/$(TARGET_ARCH_DIR) || exit 1; + +# XXX: Note that HEAD_OBJ is linked into the final minios.o +# This is so that we don't have to hunt for it in the rumprun build of app-tools. +$(OBJ_DIR)/minios.o: links $(OBJS) arch_lib + $(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(OBJS) $(LDARCHLIB) $(LDLIBS) -o $@ + $(OBJCOPY) -w $(GLOBAL_PREFIXES) -G _start $@ $@ + +$(OBJ_DIR)/minios.lds: $(LDSCRIPT) + cp $(LDSCRIPT) $@ + +.PHONY: clean arch_clean + +arch_clean: + $(MAKE) --directory=$(TARGET_ARCH_DIR) OBJ_DIR=$(OBJ_DIR)/$(TARGET_ARCH_DIR) clean || exit 1; + +clean: arch_clean + for dir in $(addprefix $(OBJ_DIR)/,$(SUBDIRS)); do \ + rm -f $$dir/*.o; \ + done + rm -f $(OBJ_DIR)/*.o *~ $(OBJ_DIR)/core + rm -f $(OBJ_DIR)/minios.lds + rm -f include/xen include/mini-os/machine + rm -f tags TAGS + +define all_sources + ( find . -follow -name SCCS -prune -o -name '*.[chS]' -print ) +endef + +.PHONY: cscope +cscope: + $(all_sources) > cscope.files + cscope -k -b -q + +.PHONY: tags +tags: + $(all_sources) | xargs ctags + +.PHONY: TAGS +TAGS: + $(all_sources) | xargs etags + diff --git a/xen/app.lds b/xen/app.lds new file mode 100644 index 0000000..4a48cc8 --- /dev/null +++ b/xen/app.lds @@ -0,0 +1,11 @@ +SECTIONS +{ + .app.bss : { + __app_bss_start = . ; + *(.bss .bss.*) + *(COMMON) + *(.lbss .lbss.*) + *(LARGE_COMMON) + __app_bss_end = . ; + } +} diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 799e156..4f0705f 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -3,7 +3,7 @@ # It's is used for x86_32, x86_32y and x86_64 # -MINI-OS_ROOT=../../.. +MINI-OS_ROOT=../.. export MINI-OS_ROOT include $(MINI-OS_ROOT)/Config.mk @@ -13,7 +13,8 @@ include $(MINI-OS_ROOT)/Config.mk include arch.mk include $(MINI-OS_ROOT)/minios.mk -CFLAGS+= -I$(MINI-OS_ROOT)/rump/include -nostdinc +# TODO: Import rump CPPFLAGS / include directories from top-level Makefile +CFLAGS+= -isystem $(MINI-OS_ROOT)/../rump/include -nostdinc # Sources here are all *.c *.S without $(XEN_TARGET_ARCH).S # This is handled in $(HEAD_ARCH_OBJ) diff --git a/xen/minios.mk b/xen/minios.mk new file mode 100644 index 0000000..e6db96d --- /dev/null +++ b/xen/minios.mk @@ -0,0 +1,65 @@ +# +# The file contains the common make rules for building mini-os. +# + +debug = y + +# Define some default flags. +# NB. '-Wcast-qual' is nasty, so I omitted it. +DEF_CFLAGS += -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format -Wno-redundant-decls +DEF_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,) +DEF_CFLAGS += $(call cc-option,$(CC),-fgnu89-inline) +DEF_CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline +DEF_CPPFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION) + +DEF_ASFLAGS += -D__ASSEMBLY__ + +ifeq ($(debug),y) +DEF_CFLAGS += -g +#DEF_CFLAGS += -DMM_DEBUG +DEF_CFLAGS += -DGNT_DEBUG +DEF_CFLAGS += -DGNTMAP_DEBUG +else +DEF_CFLAGS += -O3 +endif + +# Build the CFLAGS and ASFLAGS for compiling and assembling. +# DEF_... flags are the common mini-os flags, +# ARCH_... flags may be defined in arch/$(TARGET_ARCH_FAM/rules.mk +CFLAGS := $(DEF_CFLAGS) $(ARCH_CFLAGS) +CPPFLAGS := $(DEF_CPPFLAGS) $(ARCH_CPPFLAGS) +ASFLAGS := $(DEF_ASFLAGS) $(ARCH_ASFLAGS) +LDFLAGS := $(DEF_LDFLAGS) $(ARCH_LDFLAGS) + +# Special build dependencies. +# Rebuild all after touching this/these file(s) +EXTRA_DEPS += $(MINI-OS_ROOT)/minios.mk +EXTRA_DEPS += $(MINI-OS_ROOT)/$(TARGET_ARCH_DIR)/arch.mk + +# Find all header files for checking dependencies. +HDRS := $(wildcard $(MINI-OS_ROOT)/include/mini-os/*.h) +HDRS += $(wildcard $(MINI-OS_ROOT)/include/xen/*.h) +HDRS += $(wildcard $(ARCH_INC)/*.h) +# For special wanted header directories. +extra_heads := $(foreach dir,$(EXTRA_INC),$(wildcard $(dir)/*.h)) +HDRS += $(extra_heads) + +# Add the special header directories to the include paths. +override CPPFLAGS := $(CPPFLAGS) $(extra_incl) + +# The name of the architecture specific library. +# This is on x86_32: libx86_32.a +# $(ARCH_LIB) has to built in the architecture specific directory. +ARCH_LIB_NAME = $(XEN_TARGET_ARCH) +ARCH_LIB := lib$(ARCH_LIB_NAME).a + +# This object contains the entrypoint for startup from Xen. +# $(HEAD_ARCH_OBJ) has to be built in the architecture specific directory. +HEAD_ARCH_OBJ := $(XEN_TARGET_ARCH).o +HEAD_OBJ := $(OBJ_DIR)/$(TARGET_ARCH_DIR)/$(HEAD_ARCH_OBJ) + +$(OBJ_DIR)/%.o: %.c $(HDRS) $(EXTRA_DEPS) + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ + +$(OBJ_DIR)/%.o: %.S $(HDRS) $(EXTRA_DEPS) + $(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@