debuggers.hg

annotate stubdom/Makefile @ 17066:a905c582a406

Add stubdomain support. See stubdom/README for usage details.

- Move PAGE_SIZE and STACK_SIZE into __PAGE_SIZE and __STACK_SIZE in
arch_limits.h so as to permit getting them from there without
pulling all the internal Mini-OS defines.
- Setup a xen-elf cross-compilation environment in stubdom/cross-root
- Add a POSIX layer on top of Mini-OS by linking against the newlib C
library and lwIP, and implementing the Unixish part in mini-os/lib/sys.c
- Cross-compile zlib and libpci too.
- Add an xs.h-compatible layer on top of Mini-OS' xenbus.
- Cross-compile libxc with an additional xc_minios.c and a few things
disabled.
- Cross-compile ioemu with an additional block-vbd, but without sound,
tpm and other details. A few hacks are needed:
- Align ide and scsi buffers at least on sector size to permit
direct transmission to the block backend. While we are at it, just
page-align it to possibly save a segment. Also, limit the scsi
buffer size because of limitations of the block paravirtualization
protocol.
- Allocate big tables dynamically rather that letting them go to
bss: when Mini-OS gets installed in memory, bss is not lazily
allocated, and doing so during Mini-OS is unnecessarily trick while
we can simply use malloc.
- Had to change the Mini-OS compilation somehow, so as to export
Mini-OS compilation flags to the Makefiles of libxc and ioemu.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Feb 12 14:35:39 2008 +0000 (2008-02-12)
parents
children 7e91007fa727
rev   line source
keir@17066 1 XEN_ROOT = ..
keir@17066 2
keir@17066 3 include $(XEN_ROOT)/Config.mk
keir@17066 4 export stubdom=y
keir@17066 5 export debug=y
keir@17066 6
keir@17066 7 IOEMU_OPTIONS=--disable-vnc-tls
keir@17066 8 BINUTILS_VERSION=2.18
keir@17066 9 GCC_VERSION=4.2.2
keir@17066 10 ZLIB_VERSION=1.2.3
keir@17066 11 LIBPCI_VERSION=2.2.9
keir@17066 12 NEWLIB_DATE=2008-01-01
keir@17066 13 LWIP_DATE=2008-02-08
keir@17066 14
keir@17066 15 WGET=wget -c
keir@17066 16
keir@17066 17 GNU_TARGET_ARCH:=$(XEN_TARGET_ARCH)
keir@17066 18 ifeq ($(XEN_TARGET_ARCH),x86_32)
keir@17066 19 GNU_TARGET_ARCH:=i686
keir@17066 20 endif
keir@17066 21
keir@17066 22 ifeq ($(GNU_TARGET_ARCH), i686)
keir@17066 23 TARGET_CFLAGS=
keir@17066 24 endif
keir@17066 25 ifeq ($(GNU_TARGET_ARCH), x86_64)
keir@17066 26 TARGET_CFLAGS=-mno-red-zone
keir@17066 27 endif
keir@17066 28 ifeq ($(GNU_TARGET_ARCH), ia64)
keir@17066 29 TARGET_CFLAGS=-mconstant-gp
keir@17066 30 endif
keir@17066 31
keir@17066 32 CROSS_ROOT=cross-root-$(GNU_TARGET_ARCH)
keir@17066 33 CROSS_PREFIX=$(CURDIR)/$(CROSS_ROOT)
keir@17066 34 export CROSS_COMPILE=$(GNU_TARGET_ARCH)-xen-elf-
keir@17066 35 export PATH:=$(CROSS_PREFIX)/bin:$(PATH)
keir@17066 36
keir@17066 37 .PHONY: all
keir@17066 38 all: qemu-stubdom
keir@17066 39
keir@17066 40 ################
keir@17066 41 # Cross-binutils
keir@17066 42 ################
keir@17066 43
keir@17066 44 binutils-$(BINUTILS_VERSION).tar.bz2:
keir@17066 45 $(WGET) http://ftp.gnu.org/gnu/binutils/$@
keir@17066 46 binutils-$(BINUTILS_VERSION): binutils-$(BINUTILS_VERSION).tar.bz2
keir@17066 47 tar xjf $@.tar.bz2
keir@17066 48 ( cd binutils-$(BINUTILS_VERSION) && patch -p1 < ../binutils.patch )
keir@17066 49 touch $@
keir@17066 50
keir@17066 51 BINUTILS_STAMPFILE=$(CROSS_ROOT)/bin/$(GNU_TARGET_ARCH)-xen-elf-ar
keir@17066 52 .PHONY: cross-binutils
keir@17066 53 cross-binutils: $(BINUTILS_STAMPFILE)
keir@17066 54 $(BINUTILS_STAMPFILE): binutils-$(BINUTILS_VERSION)
keir@17066 55 mkdir -p binutils.build
keir@17066 56 ( cd binutils.build && \
keir@17066 57 ../binutils-$(BINUTILS_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf && \
keir@17066 58 $(MAKE) && \
keir@17066 59 $(MAKE) check && \
keir@17066 60 $(MAKE) install )
keir@17066 61
keir@17066 62 ###########
keir@17066 63 # Cross-gcc
keir@17066 64 ###########
keir@17066 65
keir@17066 66 gcc-$(GCC_VERSION).tar.bz2:
keir@17066 67 $(WGET) http://ftp.gnu.org/gnu/gcc/gcc-$(GCC_VERSION)/gcc-$(GCC_VERSION).tar.bz2
keir@17066 68 gcc-$(GCC_VERSION): gcc-$(GCC_VERSION).tar.bz2
keir@17066 69 tar xjf gcc-$(GCC_VERSION).tar.bz2
keir@17066 70 ( cd gcc-$(GCC_VERSION) && patch -p1 < ../gcc.patch )
keir@17066 71 touch $@
keir@17066 72
keir@17066 73 GCC_STAMPFILE=$(CROSS_ROOT)/bin/$(GNU_TARGET_ARCH)-xen-elf-gcc-$(GCC_VERSION)
keir@17066 74 .PHONY: cross-gcc
keir@17066 75 cross-gcc: $(GCC_STAMPFILE)
keir@17066 76 $(GCC_STAMPFILE): gcc-$(GCC_VERSION) $(BINUTILS_STAMPFILE)
keir@17066 77 mkdir -p gcc.build
keir@17066 78 ( cd gcc.build && \
keir@17066 79 ../gcc-$(GCC_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-languages=c --disable-libssp --with-gnu-as --with-gnu-ld && \
keir@17066 80 $(MAKE) GCC_FOR_TARGET='$$$$r/gcc/xgcc -B$$$$r/gcc/ '"$(TARGET_CFLAGS)"' $$(FLAGS_FOR_TARGET)' && \
keir@17066 81 $(MAKE) install )
keir@17066 82
keir@17066 83 ##############
keir@17066 84 # Cross-newlib
keir@17066 85 ##############
keir@17066 86
keir@17066 87 newlib:
keir@17066 88 cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/src co -D $(NEWLIB_DATE) newlib
keir@17066 89 mv src newlib
keir@17066 90 ( cd newlib && patch -p0 < ../newlib.patch)
keir@17066 91
keir@17066 92 NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a
keir@17066 93 .PHONY: cross-newlib
keir@17066 94 cross-newlib: $(NEWLIB_STAMPFILE)
keir@17066 95 $(NEWLIB_STAMPFILE): newlib $(GCC_STAMPFILE)
keir@17066 96 mkdir -p newlib.build
keir@17066 97 ( cd newlib.build && \
keir@17066 98 CC_FOR_TARGET="$(GNU_TARGET_ARCH)-xen-elf-gcc $(TARGET_CFLAGS)" ../newlib/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-newlib-io-long-long && \
keir@17066 99 $(MAKE) && \
keir@17066 100 $(MAKE) install )
keir@17066 101
keir@17066 102 ############
keir@17066 103 # Cross-zlib
keir@17066 104 ############
keir@17066 105
keir@17066 106 zlib-$(ZLIB_VERSION).tar.gz:
keir@17066 107 $(WGET) http://www.zlib.net/zlib-$(ZLIB_VERSION).tar.gz
keir@17066 108
keir@17066 109 ZLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libz.a
keir@17066 110 .PHONY: cross-zlib
keir@17066 111 cross-zlib: $(ZLIB_STAMPFILE)
keir@17066 112 $(ZLIB_STAMPFILE): zlib-$(ZLIB_VERSION).tar.gz $(NEWLIB_STAMPFILE)
keir@17066 113 tar xzf $<
keir@17066 114 ( cd zlib-$(ZLIB_VERSION) && \
keir@17066 115 CFLAGS="$(TARGET_CFLAGS)" CC=$(GNU_TARGET_ARCH)-xen-elf-gcc ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf && \
keir@17066 116 $(MAKE) libz.a && \
keir@17066 117 $(MAKE) install )
keir@17066 118
keir@17066 119 ##############
keir@17066 120 # Cross-libpci
keir@17066 121 ##############
keir@17066 122
keir@17066 123 pciutils-$(LIBPCI_VERSION).tar.bz2:
keir@17066 124 $(WGET) http://www.kernel.org/pub/software/utils/pciutils/pciutils-$(LIBPCI_VERSION).tar.bz2
keir@17066 125
keir@17066 126 LIBPCI_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libpci.a
keir@17066 127 .PHONY: cross-libpci
keir@17066 128 cross-libpci: $(LIBPCI_STAMPFILE)
keir@17066 129 $(LIBPCI_STAMPFILE): pciutils-$(LIBPCI_VERSION).tar.bz2 $(NEWLIB_STAMPFILE) $(ZLIB_STAMPFILE)
keir@17066 130 tar xjf $<
keir@17066 131 ( cd pciutils-$(LIBPCI_VERSION) && \
keir@17066 132 cp ../libpci.config.h lib/config.h && \
keir@17066 133 echo '#define PCILIB_VERSION "$(LIBPCI_VERSION)"' >> lib/config.h && \
keir@17066 134 cp ../libpci.config.mak lib/config.mk && \
keir@17066 135 $(MAKE) CC="$(GNU_TARGET_ARCH)-xen-elf-gcc $(TARGET_CFLAGS)" lib/libpci.a && \
keir@17066 136 $(INSTALL_DATA) lib/libpci.a $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib/ && \
keir@17066 137 $(INSTALL_DIR) $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci && \
keir@17066 138 $(INSTALL_DATA) lib/{config,header,pci,types}.h $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci/ \
keir@17066 139 )
keir@17066 140
keir@17066 141 ######
keir@17066 142 # lwIP
keir@17066 143 ######
keir@17066 144
keir@17066 145 lwip:
keir@17066 146 cvs -z 9 -d :pserver:anonymous@cvs.savannah.nongnu.org:/sources/lwip co -D $(LWIP_DATE) lwip
keir@17066 147
keir@17066 148 #######
keir@17066 149 # Links
keir@17066 150 #######
keir@17066 151
keir@17066 152 .PHONY: $(CROSS_ROOT)
keir@17066 153 $(CROSS_ROOT): cross-newlib cross-zlib cross-libpci
keir@17066 154
keir@17066 155 .PHONY: mk-symlinks
keir@17066 156 mk-symlinks:
keir@17066 157 [ -h include ] || ln -sf ../tools/include .
keir@17066 158 mkdir -p libxc
keir@17066 159 [ -h libxc/Makefile ] || ( cd libxc && \
keir@17066 160 ln -sf ../../tools/libxc/*.h . && \
keir@17066 161 ln -sf ../../tools/libxc/*.c . && \
keir@17066 162 ln -sf ../../tools/libxc/Makefile . )
keir@17066 163 mkdir -p libxc/$(XEN_TARGET_ARCH)
keir@17066 164 [ -h libxc/$(XEN_TARGET_ARCH) ] || ( cd libxc/$(XEN_TARGET_ARCH) && \
keir@17066 165 ln -sf ../../tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
keir@17066 166 ln -sf ../../tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
keir@17066 167 ln -sf ../../tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
keir@17066 168 mkdir -p ioemu
keir@17066 169 [ -h ioemu/Makefile ] || ( cd ioemu && \
keir@17066 170 ln -sf ../../tools/ioemu/* . && \
keir@17066 171 ([ ! -h config-host.h ] || rm -f config-host.h) && \
keir@17066 172 ([ ! -h config-host.mak ] || rm -f config-host.mak) )
keir@17066 173 [ -h mini-os ] || ln -sf ../extras/mini-os .
keir@17066 174
keir@17066 175 #######
keir@17066 176 # libxc
keir@17066 177 #######
keir@17066 178
keir@17066 179 .PHONY: libxc
keir@17066 180 libxc: cross-zlib mk-symlinks
keir@17066 181 $(MAKE) -C $@
keir@17066 182
keir@17066 183 #######
keir@17066 184 # ioemu
keir@17066 185 #######
keir@17066 186
keir@17066 187 .PHONY: ioemu
keir@17066 188 ioemu: cross-zlib cross-libpci mk-symlinks libxc
keir@17066 189 [ -f ioemu/config-host.mak ] || \
keir@17066 190 ( cd ioemu ; XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) sh configure --prefix=/usr --enable-stubdom $(IOEMU_OPTIONS))
keir@17066 191 $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip
keir@17066 192
keir@17066 193 ######
keir@17066 194 # caml
keir@17066 195 ######
keir@17066 196
keir@17066 197 .PHONY: caml
keir@17066 198 caml:
keir@17066 199 $(MAKE) -C $@
keir@17066 200
keir@17066 201 ########
keir@17066 202 # minios
keir@17066 203 ########
keir@17066 204
keir@17066 205 .PHONY: qemu-stubdom
keir@17066 206 qemu-stubdom: mk-symlinks lwip libxc ioemu
keir@17066 207 $(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip QEMUDIR=$(CURDIR)/ioemu
keir@17066 208
keir@17066 209 .PHONY: caml-stubdom
keir@17066 210 caml-stubdom: mk-symlinks lwip libxc cross-libpci caml
keir@17066 211 $(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip CAMLDIR=$(CURDIR)/caml
keir@17066 212
keir@17066 213 #########
keir@17066 214 # install
keir@17066 215 #########
keir@17066 216
keir@17066 217 install: mini-os/mini-os.gz
keir@17066 218 $(INSTALL_PROG) stubdom-dm "$(DESTDIR)/usr/lib/xen/bin"
keir@17066 219 $(INSTALL_PROG) mini-os/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/stubdom.gz"
keir@17066 220
keir@17066 221 #######
keir@17066 222 # clean
keir@17066 223 #######
keir@17066 224
keir@17066 225 # Only clean the libxc/ioemu/mini-os part
keir@17066 226 .PHONY: clean
keir@17066 227 clean:
keir@17066 228 -$(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip clean
keir@17066 229 $(MAKE) -C caml clean
keir@17066 230 rm -fr libxc ioemu mini-os include
keir@17066 231
keir@17066 232 # clean the cross-compilation result
keir@17066 233 .PHONY: crossclean
keir@17066 234 crossclean: clean
keir@17066 235 rm -fr $(CROSS_ROOT)
keir@17066 236 rm -fr binutils.build gcc.build newlib.build
keir@17066 237 rm -fr zlib-$(ZLIB_VERSION) pciutils-$(LIBPCI_VERSION)
keir@17066 238
keir@17066 239 # clean patched sources
keir@17066 240 .PHONY: patchclean
keir@17066 241 patchclean: crossclean
keir@17066 242 rm -fr binutils-$(BINUTILS_VERSION)
keir@17066 243 rm -fr gcc-$(GCC_VERSION)
keir@17066 244 rm -fr newlib
keir@17066 245 rm -fr lwip
keir@17066 246
keir@17066 247 # clean downloads
keir@17066 248 .PHONY: downloadclean
keir@17066 249 downloadclean: patchclean
keir@17066 250 rm -f binutils-$(BINUTILS_VERSION).tar.bz2
keir@17066 251 rm -f gcc-$(GCC_VERSION).tar.bz2
keir@17066 252 rm -f zlib-$(ZLIB_VERSION).tar.gz
keir@17066 253 rm -f pciutils-$(LIBPCI_VERSION).tar.bz2
keir@17066 254
keir@17066 255 .PHONY: distclean
keir@17066 256 distclean: downloadclean