ia64/xen-unstable

changeset 17744:460f72ca97b6

stubdom: make the build more generic by moving as many stubdom parts
into stubdom/ as possible. That also permits to build all of
ioemu, c and caml stubdoms at the same time.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed May 28 09:30:48 2008 +0100 (2008-05-28)
parents 1e66fa5931ee
children 38ec0d674842
files extras/mini-os/Config.mk extras/mini-os/Makefile extras/mini-os/main-caml.c extras/mini-os/main.c stubdom/Makefile stubdom/c/Makefile stubdom/c/main.c stubdom/caml/Makefile stubdom/caml/main-caml.c tools/ioemu/Makefile.target
line diff
     1.1 --- a/extras/mini-os/Config.mk	Wed May 28 09:29:05 2008 +0100
     1.2 +++ b/extras/mini-os/Config.mk	Wed May 28 09:30:48 2008 +0100
     1.3 @@ -55,11 +55,3 @@ DEF_CPPFLAGS += -DHAVE_LWIP
     1.4  DEF_CPPFLAGS += -I$(LWIPDIR)/src/include
     1.5  DEF_CPPFLAGS += -I$(LWIPDIR)/src/include/ipv4
     1.6  endif
     1.7 -
     1.8 -ifneq ($(QEMUDIR),)
     1.9 -qemu=y
    1.10 -endif
    1.11 -
    1.12 -ifneq ($(CAMLDIR),)
    1.13 -caml=y
    1.14 -endif
     2.1 --- a/extras/mini-os/Makefile	Wed May 28 09:29:05 2008 +0100
     2.2 +++ b/extras/mini-os/Makefile	Wed May 28 09:30:48 2008 +0100
     2.3 @@ -73,44 +73,25 @@ lwip.a: $(LWO)
     2.4  OBJS += lwip.a
     2.5  endif
     2.6  
     2.7 -OBJS := $(filter-out lwip%.o $(LWO), $(OBJS))
     2.8 -
     2.9 -ifeq ($(caml),y)
    2.10 -CAMLLIB = $(shell ocamlc -where)
    2.11 -APP_OBJS += main-caml.o
    2.12 -APP_OBJS += $(CAMLDIR)/caml.o
    2.13 -APP_OBJS += $(CAMLLIB)/libasmrun.a
    2.14 -CFLAGS += -I$(CAMLLIB)
    2.15 -APP_LDLIBS += -lm
    2.16 -endif
    2.17 -OBJS := $(filter-out main-caml.o, $(OBJS))
    2.18 -
    2.19 -ifeq ($(qemu),y)
    2.20 -APP_OBJS += $(QEMUDIR)/i386-dm-stubdom/qemu.a $(QEMUDIR)/i386-dm-stubdom/libqemu.a
    2.21 -CFLAGS += -DCONFIG_QEMU
    2.22 -endif
    2.23 -
    2.24 -ifneq ($(CDIR),)
    2.25 -APP_OBJS += $(CDIR)/main.a
    2.26 -APP_LDLIBS += 
    2.27 -endif
    2.28 +OBJS := $(filter-out main.o lwip%.o $(LWO), $(OBJS))
    2.29  
    2.30  ifeq ($(libc),y)
    2.31  APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libxc -whole-archive -lxenguest -lxenctrl -no-whole-archive
    2.32  APP_LDLIBS += -lpci
    2.33  APP_LDLIBS += -lz
    2.34 +APP_LDLIBS += -lm
    2.35  LDLIBS += -lc
    2.36  endif
    2.37  
    2.38 -ifneq ($(caml)-$(qemu)-$(CDIR)-$(lwip),---y)
    2.39 +ifneq ($(APP_OBJS)-$(lwip),-y)
    2.40  OBJS := $(filter-out daytime.o, $(OBJS))
    2.41  endif
    2.42  
    2.43 -app.o: $(APP_OBJS) app.lds
    2.44 -	$(LD) -r -d $(LDFLAGS) $^ $(APP_LDLIBS) --undefined main -o $@
    2.45 +$(TARGET)_app.o: $(APP_OBJS) app.lds
    2.46 +	$(LD) -r -d $(LDFLAGS) $^ $(APP_LDLIBS) --undefined app_main -o $@
    2.47  
    2.48 -$(TARGET): links $(OBJS) app.o arch_lib
    2.49 -	$(LD) -r $(LDFLAGS) $(HEAD_OBJ) app.o $(OBJS) $(LDARCHLIB) $(LDLIBS) -o $@.o
    2.50 +$(TARGET): links $(OBJS) $(TARGET)_app.o arch_lib
    2.51 +	$(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(TARGET)_app.o $(OBJS) $(LDARCHLIB) $(LDLIBS) -o $@.o
    2.52  	$(OBJCOPY) -w -G $(GLOBAL_PREFIX)* -G _start $@.o $@.o
    2.53  	$(LD) $(LDFLAGS) $(LDFLAGS_FINAL) $@.o $(EXTRA_OBJS) -o $@
    2.54  	gzip -f -9 -c $@ >$@.gz
     3.1 --- a/extras/mini-os/main-caml.c	Wed May 28 09:29:05 2008 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,42 +0,0 @@
     3.4 -/*
     3.5 - * Caml bootstrap
     3.6 - *
     3.7 - * Samuel Thibault <Samuel.Thibault@eu.citrix.net>, January 2008
     3.8 - */
     3.9 -
    3.10 -#include <stdio.h>
    3.11 -#include <errno.h>
    3.12 -
    3.13 -#include <caml/mlvalues.h>
    3.14 -#include <caml/callback.h>
    3.15 -#include <unistd.h>
    3.16 -
    3.17 -/* Ugly binary compatibility with Linux */
    3.18 -FILE *_stderr asm("stderr");
    3.19 -int *__errno_location;
    3.20 -/* Will probably break everything, probably need to fetch from glibc */
    3.21 -void *__ctype_b_loc;
    3.22 -
    3.23 -int main(int argc, char *argv[], char *envp[])
    3.24 -{
    3.25 -    value *val;
    3.26 -
    3.27 -    /* Get current thread's value */
    3.28 -    _stderr = stderr;
    3.29 -    __errno_location = &errno;
    3.30 -
    3.31 -    printf("starting caml\n");
    3.32 -
    3.33 -    /* Wait before things might hang up */
    3.34 -    sleep(1);
    3.35 -
    3.36 -    caml_startup(argv);
    3.37 -    val = caml_named_value("main");
    3.38 -    if (!val) {
    3.39 -        printf("Couldn't find Caml main");
    3.40 -        return 1;
    3.41 -    }
    3.42 -    caml_callback(*val, Val_int(0));
    3.43 -    printf("callback returned\n");
    3.44 -    return 0;
    3.45 -}
     4.1 --- a/extras/mini-os/main.c	Wed May 28 09:29:05 2008 +0100
     4.2 +++ b/extras/mini-os/main.c	Wed May 28 09:30:48 2008 +0100
     4.3 @@ -4,7 +4,6 @@
     4.4   * Samuel Thibault <Samuel.Thibault@eu.citrix.net>, October 2007
     4.5   */
     4.6  
     4.7 -#ifdef HAVE_LIBC
     4.8  #include <os.h>
     4.9  #include <sched.h>
    4.10  #include <console.h>
    4.11 @@ -180,4 +179,3 @@ int app_main(start_info_t *si)
    4.12      main_thread = create_thread("main", call_main, si);
    4.13      return 0;
    4.14  }
    4.15 -#endif
     5.1 --- a/stubdom/Makefile	Wed May 28 09:29:05 2008 +0100
     5.2 +++ b/stubdom/Makefile	Wed May 28 09:30:48 2008 +0100
     5.3 @@ -37,7 +37,7 @@ export CROSS_COMPILE=$(GNU_TARGET_ARCH)-
     5.4  export PATH:=$(CROSS_PREFIX)/bin:$(PATH)
     5.5  
     5.6  .PHONY: all
     5.7 -all: qemu-stubdom
     5.8 +all: ioemu-stubdom c-stubdom
     5.9  
    5.10  ################
    5.11  # Cross-binutils
    5.12 @@ -174,6 +174,7 @@ mk-symlinks:
    5.13  	  ([ ! -h config-host.h ] || rm -f config-host.h) && \
    5.14  	  ([ ! -h config-host.mak ] || rm -f config-host.mak) )
    5.15  	[ -h mini-os ] || ln -sf ../extras/mini-os .
    5.16 +	[ -h mini-os/include/xen ] || ln -sf ../../../xen/include/public mini-os/include/xen
    5.17  
    5.18  #######
    5.19  # libxc
    5.20 @@ -198,40 +199,41 @@ ioemu: cross-zlib cross-libpci mk-symlin
    5.21  ######
    5.22  
    5.23  .PHONY: caml
    5.24 -caml:
    5.25 -	$(MAKE) -C $@
    5.26 +caml: mk-symlinks
    5.27 +	$(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-cvs 
    5.28  
    5.29  ###
    5.30  # C
    5.31  ###
    5.32  
    5.33  .PHONY: c
    5.34 -c:
    5.35 -	$(MAKE) -C $@
    5.36 +c: mk-symlinks
    5.37 +	$(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-cvs 
    5.38  
    5.39  ########
    5.40  # minios
    5.41  ########
    5.42  
    5.43 -.PHONY: qemu-stubdom
    5.44 -qemu-stubdom: mk-symlinks lwip-cvs libxc ioemu
    5.45 -	$(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip-cvs QEMUDIR=$(CURDIR)/ioemu
    5.46 +.PHONY: ioemu-stubdom
    5.47 +ioemu-stubdom: lwip-cvs libxc ioemu
    5.48 +	$(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"
    5.49  
    5.50 +CAMLLIB = $(shell ocamlc -where)
    5.51  .PHONY: caml-stubdom
    5.52 -caml-stubdom: mk-symlinks lwip-cvs libxc cross-libpci caml
    5.53 -	$(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip-cvs CAMLDIR=$(CURDIR)/caml
    5.54 +caml-stubdom: lwip-cvs libxc caml
    5.55 +	$(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"
    5.56  
    5.57  .PHONY: c-stubdom
    5.58 -c-stubdom: mk-symlinks lwip-cvs libxc cross-libpci c
    5.59 -	$(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip-cvs CDIR=$(CURDIR)/c
    5.60 +c-stubdom: lwip-cvs libxc c
    5.61 +	$(MAKE) -C mini-os TARGET=$@ LWIPDIR=$(CURDIR)/lwip-cvs APP_OBJS=$(CURDIR)/c/main.a
    5.62  
    5.63  #########
    5.64  # install
    5.65  #########
    5.66  
    5.67 -install: mini-os/mini-os.gz
    5.68 +install: mini-os/ioemu-stubdom.gz
    5.69  	$(INSTALL_PROG) stubdom-dm "$(DESTDIR)/usr/lib/xen/bin"
    5.70 -	$(INSTALL_PROG) mini-os/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/stubdom.gz"
    5.71 +	$(INSTALL_PROG) $< "$(DESTDIR)/usr/lib/xen/boot/stubdom.gz"
    5.72  
    5.73  #######
    5.74  # clean
    5.75 @@ -242,6 +244,7 @@ install: mini-os/mini-os.gz
    5.76  clean:
    5.77  	-$(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip-cvs clean
    5.78  	$(MAKE) -C caml clean
    5.79 +	$(MAKE) -C c clean
    5.80  	rm -fr libxc ioemu mini-os include
    5.81  
    5.82  # clean the cross-compilation result
     6.1 --- a/stubdom/c/Makefile	Wed May 28 09:29:05 2008 +0100
     6.2 +++ b/stubdom/c/Makefile	Wed May 28 09:30:48 2008 +0100
     6.3 @@ -2,7 +2,12 @@ XEN_ROOT = ../..
     6.4  
     6.5  include $(XEN_ROOT)/Config.mk
     6.6  
     6.7 -main.a: main.o
     6.8 +all: main.a
     6.9 +
    6.10 +main-c.c:
    6.11 +	ln -sf $(XEN_ROOT)/extras/mini-os/main.c $@
    6.12 +
    6.13 +main.a: main-c.o main.o 
    6.14  	$(AR) cr $@ $^
    6.15  
    6.16  clean:
     7.1 --- a/stubdom/c/main.c	Wed May 28 09:29:05 2008 +0100
     7.2 +++ b/stubdom/c/main.c	Wed May 28 09:30:48 2008 +0100
     7.3 @@ -1,4 +1,6 @@
     7.4  #include <stdio.h>
     7.5 +#include <unistd.h>
     7.6 +
     7.7  int main(void) {
     7.8          sleep(2);
     7.9          printf("Hello, world!\n");
     8.1 --- a/stubdom/caml/Makefile	Wed May 28 09:29:05 2008 +0100
     8.2 +++ b/stubdom/caml/Makefile	Wed May 28 09:30:48 2008 +0100
     8.3 @@ -2,12 +2,20 @@ XEN_ROOT = ../..
     8.4  
     8.5  include $(XEN_ROOT)/Config.mk
     8.6  
     8.7 +CAMLLIB = $(shell ocamlc -where)
     8.8 +DEF_CPPFLAGS += -I$(CAMLLIB)
     8.9 +
    8.10  OCAMLFIND=ocamlfind
    8.11  OCAMLOPT=ocamlopt
    8.12  
    8.13  OBJS := hello.cmx
    8.14  LIBS := 
    8.15  
    8.16 +all: main-c.o main-caml.o caml.o
    8.17 +
    8.18 +main-c.c:
    8.19 +	ln -sf $(XEN_ROOT)/extras/mini-os/main.c $@
    8.20 +
    8.21  %.cmx: %.ml
    8.22  	$(OCAMLFIND) $(OCAMLOPT) -c $< -o $@
    8.23  
    8.24 @@ -15,4 +23,4 @@ caml.o: $(OBJS)
    8.25  	$(OCAMLFIND) $(OCAMLOPT) $(LIBS) $^ -output-obj -o $@
    8.26  
    8.27  clean:
    8.28 -	rm -f *.o *.cmx *.cmi
    8.29 +	rm -f *.a *.o *.cmx *.cmi
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/stubdom/caml/main-caml.c	Wed May 28 09:30:48 2008 +0100
     9.3 @@ -0,0 +1,42 @@
     9.4 +/*
     9.5 + * Caml bootstrap
     9.6 + *
     9.7 + * Samuel Thibault <Samuel.Thibault@eu.citrix.net>, January 2008
     9.8 + */
     9.9 +
    9.10 +#include <stdio.h>
    9.11 +#include <errno.h>
    9.12 +
    9.13 +#include <caml/mlvalues.h>
    9.14 +#include <caml/callback.h>
    9.15 +#include <unistd.h>
    9.16 +
    9.17 +/* Ugly binary compatibility with Linux */
    9.18 +FILE *_stderr asm("stderr");
    9.19 +int *__errno_location;
    9.20 +/* Will probably break everything, probably need to fetch from glibc */
    9.21 +void *__ctype_b_loc;
    9.22 +
    9.23 +int main(int argc, char *argv[], char *envp[])
    9.24 +{
    9.25 +    value *val;
    9.26 +
    9.27 +    /* Get current thread's value */
    9.28 +    _stderr = stderr;
    9.29 +    __errno_location = &errno;
    9.30 +
    9.31 +    printf("starting caml\n");
    9.32 +
    9.33 +    /* Wait before things might hang up */
    9.34 +    sleep(1);
    9.35 +
    9.36 +    caml_startup(argv);
    9.37 +    val = caml_named_value("main");
    9.38 +    if (!val) {
    9.39 +        printf("Couldn't find Caml main");
    9.40 +        return 1;
    9.41 +    }
    9.42 +    caml_callback(*val, Val_int(0));
    9.43 +    printf("callback returned\n");
    9.44 +    return 0;
    9.45 +}
    10.1 --- a/tools/ioemu/Makefile.target	Wed May 28 09:29:05 2008 +0100
    10.2 +++ b/tools/ioemu/Makefile.target	Wed May 28 09:30:48 2008 +0100
    10.3 @@ -358,6 +358,13 @@ VL_OBJS+=tap-win32.o
    10.4  endif
    10.5  
    10.6  ifdef CONFIG_STUBDOM
    10.7 +VL_OBJS+=main-qemu.o
    10.8 +CFLAGS += -DCONFIG_QEMU
    10.9 +main-qemu.c:
   10.10 +	ln -s $(XEN_ROOT)/extras/mini-os/main.c $@
   10.11 +endif
   10.12 +
   10.13 +ifdef CONFIG_STUBDOM
   10.14  #CONFIG_PASSTHROUGH=1
   10.15  else
   10.16    ifeq (,$(wildcard /usr/include/pci))