minios,stubdom: Add OBJ_DIR parameter to compile outside sources, which
permits to easily compile mini-os in various flavors. Also clean some
parts of stubdom build.
Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
diff -r 0df3bf8aac1e .hgignore
--- a/.hgignore Mon Jun 16 16:35:17 2008 +0100
+++ b/.hgignore Mon Jun 16 18:40:25 2008 +0100
@@ -90,12 +90,10 @@
^stubdom/ioemu$
^stubdom/libxc$
^stubdom/lwip-.*$
-^stubdom/mini-os$
+^stubdom/mini-os-.*$
^stubdom/newlib-.*$
^stubdom/pciutils-.*$
^stubdom/zlib-.*$
-^stubdom/c/main-c.c$
-^stubdom/caml/main-c.c$
^tools/.*/TAGS$
^tools/.*/build/lib.*/.*\.py$
^tools/blktap/Makefile\.smh$
diff -r 0df3bf8aac1e extras/mini-os/Makefile
--- a/extras/mini-os/Makefile Mon Jun 16 16:35:17 2008 +0100
+++ b/extras/mini-os/Makefile Mon Jun 16 18:40:25 2008 +0100
@@ -6,6 +6,7 @@
export XEN_ROOT = ../..
include $(XEN_ROOT)/Config.mk
+OBJ_DIR ?= $(CURDIR)
ifneq ($(stubdom),y)
include Config.mk
@@ -20,7 +21,7 @@
# Define some default flags for linking.
LDLIBS :=
APP_LDLIBS :=
-LDARCHLIB := -L$(TARGET_ARCH_DIR) -l$(ARCH_LIB_NAME)
+LDARCHLIB := -L$(OBJ_DIR)/$(TARGET_ARCH_DIR) -l$(ARCH_LIB_NAME)
LDFLAGS_FINAL := -T $(TARGET_ARCH_DIR)/minios-$(XEN_TARGET_ARCH).lds
# Prefix for global API names. All other symbols are localised before
@@ -35,14 +36,14 @@
# The common mini-os objects to build.
APP_OBJS :=
-OBJS := $(patsubst %.c,%.o,$(wildcard *.c))
-OBJS += $(patsubst %.c,%.o,$(wildcard lib/*.c))
-OBJS += $(patsubst %.c,%.o,$(wildcard xenbus/*.c))
-OBJS += $(patsubst %.c,%.o,$(wildcard console/*.c))
+OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(wildcard *.c))
+OBJS += $(patsubst %.c,$(OBJ_DIR)/%.o,$(wildcard lib/*.c))
+OBJS += $(patsubst %.c,$(OBJ_DIR)/%.o,$(wildcard xenbus/*.c))
+OBJS += $(patsubst %.c,$(OBJ_DIR)/%.o,$(wildcard console/*.c))
.PHONY: default
-default: $(TARGET)
+default: $(OBJ_DIR)/$(TARGET)
# Create special architecture specific links. The function arch_links
# has to be defined in arch.mk (see include above).
@@ -57,7 +58,7 @@
.PHONY: arch_lib
arch_lib:
- $(MAKE) --directory=$(TARGET_ARCH_DIR) || exit 1;
+ $(MAKE) --directory=$(TARGET_ARCH_DIR)
OBJ_DIR=$(OBJ_DIR)/$(TARGET_ARCH_DIR) || exit 1;
ifeq ($(lwip),y)
# lwIP library
@@ -66,14 +67,14 @@
LWC += lwip-arch.c lwip-net.c
LWO := $(patsubst %.c,%.o,$(LWC))
-lwip.a: $(LWO)
+$(OBJ_DIR)/lwip.a: $(LWO)
$(RM) $@
$(AR) cqs $@ $^
-OBJS += lwip.a
+OBJS += $(OBJ_DIR)/lwip.a
endif
-OBJS := $(filter-out main.o lwip%.o $(LWO), $(OBJS))
+OBJS := $(filter-out $(OBJ_DIR)/lwip%.o $(LWO), $(OBJS))
ifeq ($(libc),y)
APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libxc -whole-archive -lxenguest -lxenctrl
-no-whole-archive
@@ -84,14 +85,14 @@
endif
ifneq ($(APP_OBJS)-$(lwip),-y)
-OBJS := $(filter-out daytime.o, $(OBJS))
+OBJS := $(filter-out $(OBJ_DIR)/daytime.o, $(OBJS))
endif
-$(TARGET)_app.o: $(APP_OBJS) app.lds
- $(LD) -r -d $(LDFLAGS) $^ $(APP_LDLIBS) --undefined app_main -o $@
+$(OBJ_DIR)/$(TARGET)_app.o: $(APP_OBJS) app.lds
+ $(LD) -r -d $(LDFLAGS) $^ $(APP_LDLIBS) --undefined main -o $@
-$(TARGET): links $(OBJS) $(TARGET)_app.o arch_lib
- $(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(TARGET)_app.o $(OBJS) $(LDARCHLIB)
$(LDLIBS) -o $@.o
+$(OBJ_DIR)/$(TARGET): links $(OBJS) $(OBJ_DIR)/$(TARGET)_app.o arch_lib
+ $(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(OBJ_DIR)/$(TARGET)_app.o $(OBJS)
$(LDARCHLIB) $(LDLIBS) -o $@.o
$(OBJCOPY) -w -G $(GLOBAL_PREFIX)* -G _start $@.o $@.o
$(LD) $(LDFLAGS) $(LDFLAGS_FINAL) $@.o $(EXTRA_OBJS) -o $@
gzip -f -9 -c $@ >$@.gz
@@ -99,15 +100,15 @@
.PHONY: clean arch_clean
arch_clean:
- $(MAKE) --directory=$(TARGET_ARCH_DIR) clean || exit 1;
+ $(MAKE) --directory=$(TARGET_ARCH_DIR)
OBJ_DIR=$(OBJ_DIR)/$(TARGET_ARCH_DIR) clean || exit 1;
clean: arch_clean
- for dir in $(SUBDIRS); do \
+ for dir in $(addprefix $(OBJ_DIR)/,$(SUBDIRS)); do \
rm -f $$dir/*.o; \
done
- rm -f *.o *~ core $(TARGET).elf $(TARGET).raw $(TARGET) $(TARGET).gz
- find . -type l | xargs rm -f
- $(RM) lwip.a $(LWO)
+ rm -f $(OBJ_DIR)/*.o *~ $(OBJ_DIR)/core $(OBJ_DIR)/$(TARGET).elf
$(OBJ_DIR)/$(TARGET).raw $(OBJ_DIR)/$(TARGET) $(OBJ_DIR)/$(TARGET).gz
+ find . $(OBJ_DIR) -type l | xargs rm -f
+ $(RM) $(OBJ_DIR)/lwip.a $(LWO)
rm -f tags TAGS
diff -r 0df3bf8aac1e extras/mini-os/arch/ia64/Makefile
--- a/extras/mini-os/arch/ia64/Makefile Mon Jun 16 16:35:17 2008 +0100
+++ b/extras/mini-os/arch/ia64/Makefile Mon Jun 16 18:40:25 2008 +0100
@@ -40,12 +40,13 @@
ARCH_OBJS += __udivdi3.o
ARCH_OBJS += __udivsi3.o
ARCH_OBJS += __divdi3.o
+ARCH_OBJS := $(addprefix $(OBJ_DIR)/,$(ARCH_OBJS))
GEN_OFF_SRC := gen_off.c
GEN_OFF_ASM := gen_off.s
GEN_OFF_H := $(MINI-OS_ROOT)/include/$(ARCH_INC)/offsets.h
-all: $(ARCH_LIB)
+all: $(OBJ_DIR)/$(ARCH_LIB)
$(GEN_OFF_ASM): $(GEN_OFF_SRC)
$(CC) -S -o $@ $(CPPFLAGS) $<
@@ -53,10 +54,10 @@
$(GEN_OFF_H): $(GEN_OFF_ASM)
sed -ne "/^->/ {s/->/#define /; p}" < $< > $@
-$(ARCH_LIB): $(GEN_OFF_H) $(ARCH_OBJS) $(HEAD_ARCH_OBJ)
+$(OBJ_DIR)/$(ARCH_LIB): $(GEN_OFF_H) $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ)
$(AR) rv $(ARCH_LIB) $(ARCH_OBJS)
clean:
- rm -f $(ARCH_LIB) $(ARCH_OBJS) $(HEAD_ARCH_OBJ)
+ rm -f $(OBJ_DIR)/$(ARCH_LIB) $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ)
rm -f $(GEN_OFF_ASM)
rm -f $(GEN_OFF_H)
diff -r 0df3bf8aac1e extras/mini-os/arch/x86/Makefile
--- a/extras/mini-os/arch/x86/Makefile Mon Jun 16 16:35:17 2008 +0100
+++ b/extras/mini-os/arch/x86/Makefile Mon Jun 16 18:40:25 2008 +0100
@@ -17,15 +17,15 @@
ARCH_SRCS := $(wildcard *.c)
# The objects built from the sources.
-ARCH_OBJS := $(patsubst %.c,%.o,$(ARCH_SRCS))
+ARCH_OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(ARCH_SRCS))
-all: $(ARCH_LIB)
+all: $(OBJ_DIR)/$(ARCH_LIB)
# $(HEAD_ARCH_OBJ) is only build here, needed on linking
# in ../../Makefile.
-$(ARCH_LIB): $(ARCH_OBJS) $(HEAD_ARCH_OBJ)
- $(AR) rv $(ARCH_LIB) $(ARCH_OBJS)
+$(OBJ_DIR)/$(ARCH_LIB): $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ)
+ $(AR) rv $(OBJ_DIR)/$(ARCH_LIB) $(ARCH_OBJS)
clean:
- rm -f $(ARCH_LIB) $(ARCH_OBJS) $(HEAD_ARCH_OBJ)
+ rm -f $(OBJ_DIR)/$(ARCH_LIB) $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ)
diff -r 0df3bf8aac1e extras/mini-os/main.c
--- a/extras/mini-os/main.c Mon Jun 16 16:35:17 2008 +0100
+++ b/extras/mini-os/main.c Mon Jun 16 18:40:25 2008 +0100
@@ -4,6 +4,7 @@
* Samuel Thibault <Samuel.Thibault@xxxxxxxxxxxxx>, October 2007
*/
+#ifdef HAVE_LIBC
#include <os.h>
#include <sched.h>
#include <console.h>
@@ -112,7 +113,7 @@
} \
}
- PARSE_ARGS(start_info.cmd_line, argc++, );
+ PARSE_ARGS((char*)start_info.cmd_line, argc++, );
#ifdef CONFIG_QEMU
PARSE_ARGS(domargs, argc++, );
#endif
@@ -121,7 +122,7 @@
argv[0] = "main";
argc = 1;
- PARSE_ARGS(start_info.cmd_line, argv[argc++] = c, *c++ = 0)
+ PARSE_ARGS((char*)start_info.cmd_line, argv[argc++] = c, *c++ = 0)
#ifdef CONFIG_QEMU
PARSE_ARGS(domargs, argv[argc++] = c, *c++ = 0)
#endif
@@ -168,3 +169,4 @@
main_thread = create_thread("main", call_main, si);
return 0;
}
+#endif
diff -r 0df3bf8aac1e extras/mini-os/minios.mk
--- a/extras/mini-os/minios.mk Mon Jun 16 16:35:17 2008 +0100
+++ b/extras/mini-os/minios.mk Mon Jun 16 18:40:25 2008 +0100
@@ -57,13 +57,13 @@
# 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 := $(TARGET_ARCH_DIR)/$(HEAD_ARCH_OBJ)
+HEAD_OBJ := $(OBJ_DIR)/$(TARGET_ARCH_DIR)/$(HEAD_ARCH_OBJ)
-%.o: %.c $(HDRS) Makefile $(EXTRA_DEPS)
+$(OBJ_DIR)/%.o: %.c $(HDRS) Makefile $(EXTRA_DEPS)
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
-%.o: %.S $(HDRS) Makefile $(EXTRA_DEPS)
+$(OBJ_DIR)/%.o: %.S $(HDRS) Makefile $(EXTRA_DEPS)
$(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@
diff -r 0df3bf8aac1e stubdom/Makefile
--- a/stubdom/Makefile Mon Jun 16 16:35:17 2008 +0100
+++ b/stubdom/Makefile Mon Jun 16 18:40:25 2008 +0100
@@ -1,4 +1,5 @@
XEN_ROOT = ..
+MINI_OS = $(XEN_ROOT)/extras/mini-os
export XEN_OS=MiniOS
@@ -38,6 +39,8 @@
export CROSS_COMPILE=$(GNU_TARGET_ARCH)-xen-elf-
export PATH:=$(CROSS_PREFIX)/bin:$(PATH)
+TARGETS=ioemu c caml
+
.PHONY: all
all: ioemu-stubdom c-stubdom
@@ -48,8 +51,8 @@
binutils-$(BINUTILS_VERSION).tar.bz2:
$(WGET) http://ftp.gnu.org/gnu/binutils/$@
binutils-$(BINUTILS_VERSION): binutils-$(BINUTILS_VERSION).tar.bz2
- tar xjf $@.tar.bz2
- ( cd binutils-$(BINUTILS_VERSION) && patch -p1 < ../binutils.patch )
+ tar xjf $<
+ patch -d $@ -p1 < binutils.patch
touch $@
BINUTILS_STAMPFILE=$(CROSS_ROOT)/bin/$(GNU_TARGET_ARCH)-xen-elf-ar
@@ -70,8 +73,8 @@
gcc-$(GCC_VERSION).tar.bz2:
$(WGET)
http://ftp.gnu.org/gnu/gcc/gcc-$(GCC_VERSION)/gcc-$(GCC_VERSION).tar.bz2
gcc-$(GCC_VERSION): gcc-$(GCC_VERSION).tar.bz2
- tar xjf gcc-$(GCC_VERSION).tar.bz2
- ( cd gcc-$(GCC_VERSION) && patch -p1 < ../gcc.patch )
+ tar xjf $<
+ patch -d $@ -p1 < gcc.patch
touch $@
GCC_STAMPFILE=$(CROSS_ROOT)/bin/$(GNU_TARGET_ARCH)-xen-elf-gcc-$(GCC_VERSION)
@@ -91,7 +94,7 @@
newlib-cvs:
cvs -z 9 -d :pserver:anoncvs@xxxxxxxxxxxxxxxxxx:/cvs/src co -D
$(NEWLIB_DATE) newlib
mv src newlib-cvs
- ( cd newlib-cvs && patch -p0 < ../newlib.patch)
+ patch -d $@ -p0 < newlib.patch
NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a
.PHONY: cross-newlib
@@ -147,8 +150,7 @@
######
lwip-cvs:
- cvs -z 9 -d :pserver:anonymous@xxxxxxxxxxxxxxxxxxxxxxx:/sources/lwip co
-D $(LWIP_DATE) lwip
- mv lwip lwip-cvs
+ cvs -z 9 -d :pserver:anonymous@xxxxxxxxxxxxxxxxxxxxxxx:/sources/lwip co
-D $(LWIP_DATE) -d $@ lwip
#######
# Links
@@ -162,29 +164,36 @@
[ -h include ] || ln -sf ../tools/include .
mkdir -p libxc
[ -h libxc/Makefile ] || ( cd libxc && \
- ln -sf ../../tools/libxc/*.h . && \
- ln -sf ../../tools/libxc/*.c . && \
- ln -sf ../../tools/libxc/Makefile . )
+ ln -sf ../$(XEN_ROOT)/tools/libxc/*.h . && \
+ ln -sf ../$(XEN_ROOT)/tools/libxc/*.c . && \
+ ln -sf ../$(XEN_ROOT)/tools/libxc/Makefile . )
mkdir -p libxc/$(XEN_TARGET_ARCH)
[ -h libxc/$(XEN_TARGET_ARCH) ] || ( cd libxc/$(XEN_TARGET_ARCH) && \
- ln -sf ../../tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
- ln -sf ../../tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
- ln -sf ../../tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
+ ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
+ ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
+ ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
mkdir -p ioemu
[ -h ioemu/Makefile ] || ( cd ioemu && \
- ln -sf ../../tools/ioemu/* . && \
+ ln -sf ../$(XEN_ROOT)/tools/ioemu/* . && \
([ ! -h config-host.h ] || rm -f config-host.h) && \
([ ! -h config-host.mak ] || rm -f config-host.mak) )
- [ -h mini-os ] || ln -sf ../extras/mini-os .
- [ -h mini-os/include/xen ] || ln -sf ../../../xen/include/public
mini-os/include/xen
+ $(MAKE) -C $(MINI_OS) links
+
+TARGETS_MINIOS=$(addprefix mini-os-,$(TARGETS))
+$(TARGETS_MINIOS): mini-os-%:
+ [ -d $@ ] || \
+ for i in $$(cd $(MINI_OS) ; find . -type d) ; do \
+ mkdir -p $@/$$i ; \
+ done
#######
# libxc
#######
.PHONY: libxc
-libxc: cross-zlib mk-symlinks
- $(MAKE) -C $@
+libxc: libxc/libxenctrl.a libxc/libxenguest.a
+libxc/libxenctrl.a libxc/libxenguest.a: cross-zlib mk-symlinks
+ $(MAKE) -C libxc
#######
# ioemu
@@ -217,23 +226,23 @@
########
.PHONY: ioemu-stubdom
-ioemu-stubdom: lwip-cvs libxc ioemu
- $(MAKE) -C mini-os TARGET=$@ LWIPDIR=$(CURDIR)/lwip-cvs
APP_OBJS="$(CURDIR)/ioemu/i386-dm-stubdom/qemu.a
$(CURDIR)/ioemu/i386-dm-stubdom/libqemu.a"
+ioemu-stubdom: mini-os-ioemu lwip-cvs libxc ioemu
+ $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-cvs
APP_OBJS="$(CURDIR)/ioemu/i386-dm-stubdom/qemu.a
$(CURDIR)/ioemu/i386-dm-stubdom/libqemu.a" CFLAGS=-DCONFIG_QEMU
CAMLLIB = $(shell ocamlc -where)
.PHONY: caml-stubdom
-caml-stubdom: lwip-cvs libxc caml
- $(MAKE) -C mini-os TARGET=$@ LWIPDIR=$(CURDIR)/lwip-cvs
APP_OBJS="$(CURDIR)/caml/main-c.o $(CURDIR)/caml/main-caml.o
$(CURDIR)/caml/caml.o $(CAMLLIB)/libasmrun.a"
+caml-stubdom: mini-os-caml lwip-cvs libxc caml
+ $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-cvs
APP_OBJS="$(CURDIR)/caml/main-caml.o $(CURDIR)/caml/caml.o
$(CAMLLIB)/libasmrun.a" CFLAGS=-DCONFIG_CAML
.PHONY: c-stubdom
-c-stubdom: lwip-cvs libxc c
- $(MAKE) -C mini-os TARGET=$@ LWIPDIR=$(CURDIR)/lwip-cvs
APP_OBJS=$(CURDIR)/c/main.a
+c-stubdom: mini-os-c lwip-cvs libxc c
+ $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-cvs
APP_OBJS=$(CURDIR)/c/main.a CFLAGS=-DCONFIG_C
#########
# install
#########
-install: mini-os/ioemu-stubdom.gz
+install: mini-os-ioemu/mini-os.gz
$(INSTALL_PROG) stubdom-dm "$(DESTDIR)/usr/lib/xen/bin"
$(INSTALL_PROG) $< "$(DESTDIR)/usr/lib/xen/boot/stubdom.gz"
@@ -244,10 +253,9 @@
# Only clean the libxc/ioemu/mini-os part
.PHONY: clean
clean:
- -$(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip-cvs clean
- -$(MAKE) -C mini-os TARGET=ioemu-stubdom LWIPDIR=$(CURDIR)/lwip-cvs
clean
- -$(MAKE) -C mini-os TARGET=c-stubdom LWIPDIR=$(CURDIR)/lwip-cvs clean
- -$(MAKE) -C mini-os TARGET=caml-stubdom LWIPDIR=$(CURDIR)/lwip-cvs clean
+ rm -fr mini-os-ioemu
+ rm -fr mini-os-c
+ rm -fr mini-os-caml
$(MAKE) -C caml clean
$(MAKE) -C c clean
rm -fr libxc ioemu mini-os include
diff -r 0df3bf8aac1e stubdom/c/Makefile
--- a/stubdom/c/Makefile Mon Jun 16 16:35:17 2008 +0100
+++ b/stubdom/c/Makefile Mon Jun 16 18:40:25 2008 +0100
@@ -4,10 +4,7 @@
all: main.a
-main-c.c:
- ln -sf $(XEN_ROOT)/extras/mini-os/main.c $@
-
-main.a: main-c.o main.o
+main.a: main.o
$(AR) cr $@ $^
clean:
diff -r 0df3bf8aac1e stubdom/caml/Makefile
--- a/stubdom/caml/Makefile Mon Jun 16 16:35:17 2008 +0100
+++ b/stubdom/caml/Makefile Mon Jun 16 18:40:25 2008 +0100
@@ -11,10 +11,7 @@
OBJS := hello.cmx
LIBS :=
-all: main-c.o main-caml.o caml.o
-
-main-c.c:
- ln -sf $(XEN_ROOT)/extras/mini-os/main.c $@
+all: main-caml.o caml.o
%.cmx: %.ml
$(OCAMLFIND) $(OCAMLOPT) -c $< -o $@
diff -r 0df3bf8aac1e tools/ioemu/Makefile.target
--- a/tools/ioemu/Makefile.target Mon Jun 16 16:35:17 2008 +0100
+++ b/tools/ioemu/Makefile.target Mon Jun 16 18:40:25 2008 +0100
@@ -355,13 +355,6 @@
endif
ifdef CONFIG_WIN32
VL_OBJS+=tap-win32.o
-endif
-
-ifdef CONFIG_STUBDOM
-VL_OBJS+=main-qemu.o
-CFLAGS += -DCONFIG_QEMU
-main-qemu.c:
- ln -s $(XEN_ROOT)/extras/mini-os/main.c $@
endif
ifdef CONFIG_STUBDOM
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|