debuggers.hg

annotate stubdom/Makefile @ 17984:b3d827e63a09

stubdom: PCI passthrough support via PV-PCI

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jul 02 13:54:20 2008 +0100 (2008-07-02)
parents c8d9ade45781
children 433d1b26fd51
rev   line source
keir@17066 1 XEN_ROOT = ..
keir@17905 2 MINI_OS = $(XEN_ROOT)/extras/mini-os
keir@17066 3
keir@17070 4 export XEN_OS=MiniOS
keir@17070 5
keir@17066 6 include $(XEN_ROOT)/Config.mk
keir@17066 7 export stubdom=y
keir@17066 8 export debug=y
keir@17066 9
keir@17066 10 IOEMU_OPTIONS=--disable-vnc-tls
keir@17066 11 BINUTILS_VERSION=2.18
keir@17066 12 GCC_VERSION=4.2.2
keir@17066 13 ZLIB_VERSION=1.2.3
keir@17066 14 LIBPCI_VERSION=2.2.9
keir@17066 15 NEWLIB_DATE=2008-01-01
keir@17823 16 LWIP_DATE=2008-06-01
keir@17909 17 GRUB_DATE=2008-06-01
keir@17066 18
keir@17066 19 WGET=wget -c
keir@17066 20
keir@17066 21 GNU_TARGET_ARCH:=$(XEN_TARGET_ARCH)
keir@17066 22 ifeq ($(XEN_TARGET_ARCH),x86_32)
keir@17066 23 GNU_TARGET_ARCH:=i686
keir@17066 24 endif
keir@17066 25
keir@17066 26 ifeq ($(GNU_TARGET_ARCH), i686)
keir@17066 27 TARGET_CFLAGS=
keir@17830 28 NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
keir@17066 29 endif
keir@17066 30 ifeq ($(GNU_TARGET_ARCH), x86_64)
keir@17066 31 TARGET_CFLAGS=-mno-red-zone
keir@17830 32 NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
keir@17066 33 endif
keir@17066 34 ifeq ($(GNU_TARGET_ARCH), ia64)
keir@17066 35 TARGET_CFLAGS=-mconstant-gp
keir@17066 36 endif
keir@17066 37
keir@17066 38 CROSS_ROOT=cross-root-$(GNU_TARGET_ARCH)
keir@17066 39 CROSS_PREFIX=$(CURDIR)/$(CROSS_ROOT)
keir@17066 40 export CROSS_COMPILE=$(GNU_TARGET_ARCH)-xen-elf-
keir@17066 41 export PATH:=$(CROSS_PREFIX)/bin:$(PATH)
keir@17066 42
keir@17909 43 TARGETS=ioemu c caml grub
keir@17905 44
keir@17066 45 .PHONY: all
keir@17909 46 all: ioemu-stubdom c-stubdom pv-grub
keir@17066 47
keir@17066 48 ################
keir@17066 49 # Cross-binutils
keir@17066 50 ################
keir@17066 51
keir@17066 52 binutils-$(BINUTILS_VERSION).tar.bz2:
keir@17066 53 $(WGET) http://ftp.gnu.org/gnu/binutils/$@
keir@17066 54 binutils-$(BINUTILS_VERSION): binutils-$(BINUTILS_VERSION).tar.bz2
keir@17905 55 tar xjf $<
keir@17905 56 patch -d $@ -p1 < binutils.patch
keir@17066 57 touch $@
keir@17066 58
keir@17066 59 BINUTILS_STAMPFILE=$(CROSS_ROOT)/bin/$(GNU_TARGET_ARCH)-xen-elf-ar
keir@17066 60 .PHONY: cross-binutils
keir@17066 61 cross-binutils: $(BINUTILS_STAMPFILE)
keir@17066 62 $(BINUTILS_STAMPFILE): binutils-$(BINUTILS_VERSION)
keir@17071 63 mkdir -p binutils-build
keir@17071 64 ( cd binutils-build && \
keir@17066 65 ../binutils-$(BINUTILS_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf && \
keir@17066 66 $(MAKE) && \
keir@17066 67 $(MAKE) check && \
keir@17066 68 $(MAKE) install )
keir@17066 69
keir@17066 70 ###########
keir@17066 71 # Cross-gcc
keir@17066 72 ###########
keir@17066 73
keir@17066 74 gcc-$(GCC_VERSION).tar.bz2:
keir@17066 75 $(WGET) http://ftp.gnu.org/gnu/gcc/gcc-$(GCC_VERSION)/gcc-$(GCC_VERSION).tar.bz2
keir@17066 76 gcc-$(GCC_VERSION): gcc-$(GCC_VERSION).tar.bz2
keir@17905 77 tar xjf $<
keir@17905 78 patch -d $@ -p1 < gcc.patch
keir@17066 79 touch $@
keir@17830 80
keir@17066 81 GCC_STAMPFILE=$(CROSS_ROOT)/bin/$(GNU_TARGET_ARCH)-xen-elf-gcc-$(GCC_VERSION)
keir@17066 82 .PHONY: cross-gcc
keir@17066 83 cross-gcc: $(GCC_STAMPFILE)
keir@17066 84 $(GCC_STAMPFILE): gcc-$(GCC_VERSION) $(BINUTILS_STAMPFILE)
keir@17071 85 mkdir -p gcc-build
keir@17071 86 ( cd gcc-build && \
keir@17066 87 ../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 88 $(MAKE) GCC_FOR_TARGET='$$$$r/gcc/xgcc -B$$$$r/gcc/ '"$(TARGET_CFLAGS)"' $$(FLAGS_FOR_TARGET)' && \
keir@17066 89 $(MAKE) install )
keir@17066 90
keir@17066 91 ##############
keir@17066 92 # Cross-newlib
keir@17066 93 ##############
keir@17066 94
keir@17072 95 newlib-cvs:
keir@17066 96 cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/src co -D $(NEWLIB_DATE) newlib
keir@17071 97 mv src newlib-cvs
keir@17905 98 patch -d $@ -p0 < newlib.patch
keir@17066 99
keir@17066 100 NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a
keir@17066 101 .PHONY: cross-newlib
keir@17066 102 cross-newlib: $(NEWLIB_STAMPFILE)
keir@17072 103 $(NEWLIB_STAMPFILE): newlib-cvs $(GCC_STAMPFILE)
keir@17071 104 mkdir -p newlib-build
keir@17071 105 ( cd newlib-build && \
keir@17830 106 CC_FOR_TARGET="$(GNU_TARGET_ARCH)-xen-elf-gcc $(TARGET_CFLAGS) $(NEWLIB_CFLAGS)" ../newlib-cvs/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-newlib-io-long-long && \
keir@17066 107 $(MAKE) && \
keir@17066 108 $(MAKE) install )
keir@17066 109
keir@17066 110 ############
keir@17066 111 # Cross-zlib
keir@17066 112 ############
keir@17066 113
keir@17066 114 zlib-$(ZLIB_VERSION).tar.gz:
keir@17066 115 $(WGET) http://www.zlib.net/zlib-$(ZLIB_VERSION).tar.gz
keir@17066 116
keir@17066 117 ZLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libz.a
keir@17066 118 .PHONY: cross-zlib
keir@17066 119 cross-zlib: $(ZLIB_STAMPFILE)
keir@17066 120 $(ZLIB_STAMPFILE): zlib-$(ZLIB_VERSION).tar.gz $(NEWLIB_STAMPFILE)
keir@17066 121 tar xzf $<
keir@17066 122 ( cd zlib-$(ZLIB_VERSION) && \
keir@17066 123 CFLAGS="$(TARGET_CFLAGS)" CC=$(GNU_TARGET_ARCH)-xen-elf-gcc ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf && \
keir@17066 124 $(MAKE) libz.a && \
keir@17066 125 $(MAKE) install )
keir@17066 126
keir@17066 127 ##############
keir@17066 128 # Cross-libpci
keir@17066 129 ##############
keir@17066 130
keir@17066 131 pciutils-$(LIBPCI_VERSION).tar.bz2:
keir@17066 132 $(WGET) http://www.kernel.org/pub/software/utils/pciutils/pciutils-$(LIBPCI_VERSION).tar.bz2
keir@17066 133
keir@17984 134 pciutils-$(LIBPCI_VERSION): pciutils-$(LIBPCI_VERSION).tar.bz2
keir@17984 135 tar xjf $<
keir@17984 136 patch -d $@ -p1 < pciutils.patch
keir@17984 137 touch $@
keir@17984 138
keir@17066 139 LIBPCI_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libpci.a
keir@17066 140 .PHONY: cross-libpci
keir@17066 141 cross-libpci: $(LIBPCI_STAMPFILE)
keir@17984 142 $(LIBPCI_STAMPFILE): pciutils-$(LIBPCI_VERSION) $(NEWLIB_STAMPFILE) $(ZLIB_STAMPFILE)
keir@17066 143 ( cd pciutils-$(LIBPCI_VERSION) && \
keir@17066 144 cp ../libpci.config.h lib/config.h && \
keir@17066 145 echo '#define PCILIB_VERSION "$(LIBPCI_VERSION)"' >> lib/config.h && \
keir@17066 146 cp ../libpci.config.mak lib/config.mk && \
keir@17984 147 $(MAKE) CC="$(GNU_TARGET_ARCH)-xen-elf-gcc $(TARGET_CFLAGS) -I$(realpath $(MINI_OS)/include)" lib/libpci.a && \
keir@17066 148 $(INSTALL_DATA) lib/libpci.a $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib/ && \
keir@17066 149 $(INSTALL_DIR) $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci && \
keir@17066 150 $(INSTALL_DATA) lib/{config,header,pci,types}.h $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci/ \
keir@17066 151 )
keir@17066 152
keir@17066 153 ######
keir@17066 154 # lwIP
keir@17066 155 ######
keir@17066 156
keir@17071 157 lwip-cvs:
keir@17905 158 cvs -z 9 -d :pserver:anonymous@cvs.savannah.nongnu.org:/sources/lwip co -D $(LWIP_DATE) -d $@ lwip
keir@17066 159
keir@17066 160 #######
keir@17066 161 # Links
keir@17066 162 #######
keir@17066 163
keir@17066 164 .PHONY: $(CROSS_ROOT)
keir@17066 165 $(CROSS_ROOT): cross-newlib cross-zlib cross-libpci
keir@17066 166
keir@17066 167 .PHONY: mk-symlinks
keir@17066 168 mk-symlinks:
keir@17066 169 [ -h include ] || ln -sf ../tools/include .
keir@17066 170 mkdir -p libxc
keir@17066 171 [ -h libxc/Makefile ] || ( cd libxc && \
keir@17905 172 ln -sf ../$(XEN_ROOT)/tools/libxc/*.h . && \
keir@17905 173 ln -sf ../$(XEN_ROOT)/tools/libxc/*.c . && \
keir@17905 174 ln -sf ../$(XEN_ROOT)/tools/libxc/Makefile . )
keir@17066 175 mkdir -p libxc/$(XEN_TARGET_ARCH)
keir@17066 176 [ -h libxc/$(XEN_TARGET_ARCH) ] || ( cd libxc/$(XEN_TARGET_ARCH) && \
keir@17905 177 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
keir@17905 178 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
keir@17905 179 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
keir@17066 180 mkdir -p ioemu
keir@17066 181 [ -h ioemu/Makefile ] || ( cd ioemu && \
keir@17905 182 ln -sf ../$(XEN_ROOT)/tools/ioemu/* . && \
keir@17066 183 ([ ! -h config-host.h ] || rm -f config-host.h) && \
keir@17066 184 ([ ! -h config-host.mak ] || rm -f config-host.mak) )
keir@17905 185 $(MAKE) -C $(MINI_OS) links
keir@17905 186
keir@17905 187 TARGETS_MINIOS=$(addprefix mini-os-,$(TARGETS))
keir@17905 188 $(TARGETS_MINIOS): mini-os-%:
keir@17905 189 [ -d $@ ] || \
keir@17905 190 for i in $$(cd $(MINI_OS) ; find . -type d) ; do \
keir@17905 191 mkdir -p $@/$$i ; \
keir@17905 192 done
keir@17066 193
keir@17066 194 #######
keir@17066 195 # libxc
keir@17066 196 #######
keir@17066 197
keir@17066 198 .PHONY: libxc
keir@17905 199 libxc: libxc/libxenctrl.a libxc/libxenguest.a
keir@17905 200 libxc/libxenctrl.a libxc/libxenguest.a: cross-zlib mk-symlinks
keir@17905 201 $(MAKE) -C libxc
keir@17066 202
keir@17066 203 #######
keir@17066 204 # ioemu
keir@17066 205 #######
keir@17066 206
keir@17066 207 .PHONY: ioemu
keir@17066 208 ioemu: cross-zlib cross-libpci mk-symlinks libxc
keir@17066 209 [ -f ioemu/config-host.mak ] || \
keir@17066 210 ( cd ioemu ; XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) sh configure --prefix=/usr --enable-stubdom $(IOEMU_OPTIONS))
keir@17071 211 $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip-cvs
keir@17066 212
keir@17066 213 ######
keir@17066 214 # caml
keir@17066 215 ######
keir@17066 216
keir@17066 217 .PHONY: caml
keir@17830 218 caml: cross-newlib mk-symlinks
keir@17778 219 $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-cvs
keir@17066 220
keir@17299 221 ###
keir@17299 222 # C
keir@17299 223 ###
keir@17299 224
keir@17299 225 .PHONY: c
keir@17830 226 c: cross-newlib mk-symlinks
keir@17778 227 $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-cvs
keir@17299 228
keir@17909 229 ######
keir@17909 230 # Grub
keir@17909 231 ######
keir@17909 232
keir@17909 233 grub-cvs:
keir@17909 234 cvs -z 9 -d :pserver:anonymous@cvs.sv.gnu.org:/sources/grub co -D $(GRUB_DATE) -d $@ grub
keir@17909 235 for i in grub.patches/* ; do \
keir@17909 236 patch -d $@ -p1 < $$i ; \
keir@17909 237 done
keir@17909 238
keir@17909 239 .PHONY: grub
keir@17909 240 grub: grub-cvs cross-newlib mk-symlinks
keir@17909 241 $(MAKE) -C $@
keir@17909 242
keir@17066 243 ########
keir@17066 244 # minios
keir@17066 245 ########
keir@17066 246
keir@17778 247 .PHONY: ioemu-stubdom
keir@17905 248 ioemu-stubdom: mini-os-ioemu lwip-cvs libxc ioemu
keir@17909 249 DEF_CFLAGS=-DCONFIG_QEMU $(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"
keir@17066 250
keir@17778 251 CAMLLIB = $(shell ocamlc -where)
keir@17066 252 .PHONY: caml-stubdom
keir@17905 253 caml-stubdom: mini-os-caml lwip-cvs libxc caml
keir@17909 254 DEF_CFLAGS=-DCONFIG_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"
keir@17299 255
keir@17299 256 .PHONY: c-stubdom
keir@17905 257 c-stubdom: mini-os-c lwip-cvs libxc c
keir@17909 258 DEF_CFLAGS=-DCONFIG_C $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-cvs APP_OBJS=$(CURDIR)/c/main.a
keir@17909 259
keir@17909 260 .PHONY: pv-grub
keir@17909 261 pv-grub: mini-os-grub libxc grub
keir@17909 262 DEF_CFLAGS=-DCONFIG_GRUB $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/grub/main.a
keir@17066 263
keir@17066 264 #########
keir@17066 265 # install
keir@17066 266 #########
keir@17066 267
keir@17909 268 install: install-ioemu install-grub
keir@17909 269
keir@17909 270 install-ioemu: mini-os-ioemu/mini-os.gz
keir@17066 271 $(INSTALL_PROG) stubdom-dm "$(DESTDIR)/usr/lib/xen/bin"
keir@17909 272 $(INSTALL_PROG) $< "$(DESTDIR)/usr/lib/xen/boot/ioemu-stubdom.gz"
keir@17909 273
keir@17909 274 install-grub: mini-os-grub/mini-os.gz
keir@17909 275 $(INSTALL_PROG) $< "$(DESTDIR)/usr/lib/xen/boot/pv-grub.gz"
keir@17066 276
keir@17066 277 #######
keir@17066 278 # clean
keir@17066 279 #######
keir@17066 280
keir@17066 281 # Only clean the libxc/ioemu/mini-os part
keir@17066 282 .PHONY: clean
keir@17066 283 clean:
keir@17905 284 rm -fr mini-os-ioemu
keir@17905 285 rm -fr mini-os-c
keir@17905 286 rm -fr mini-os-caml
keir@17909 287 rm -fr mini-os-grub
keir@17066 288 $(MAKE) -C caml clean
keir@17778 289 $(MAKE) -C c clean
keir@17909 290 $(MAKE) -C grub clean
keir@17066 291 rm -fr libxc ioemu mini-os include
keir@17066 292
keir@17066 293 # clean the cross-compilation result
keir@17066 294 .PHONY: crossclean
keir@17066 295 crossclean: clean
keir@17066 296 rm -fr $(CROSS_ROOT)
keir@17071 297 rm -fr binutils-build gcc-build newlib-build
keir@17066 298 rm -fr zlib-$(ZLIB_VERSION) pciutils-$(LIBPCI_VERSION)
keir@17066 299
keir@17066 300 # clean patched sources
keir@17066 301 .PHONY: patchclean
keir@17066 302 patchclean: crossclean
keir@17066 303 rm -fr binutils-$(BINUTILS_VERSION)
keir@17066 304 rm -fr gcc-$(GCC_VERSION)
keir@17071 305 rm -fr newlib-cvs
keir@17071 306 rm -fr lwip-cvs
keir@17909 307 rm -fr grub-cvs
keir@17066 308
keir@17066 309 # clean downloads
keir@17066 310 .PHONY: downloadclean
keir@17066 311 downloadclean: patchclean
keir@17066 312 rm -f binutils-$(BINUTILS_VERSION).tar.bz2
keir@17066 313 rm -f gcc-$(GCC_VERSION).tar.bz2
keir@17066 314 rm -f zlib-$(ZLIB_VERSION).tar.gz
keir@17066 315 rm -f pciutils-$(LIBPCI_VERSION).tar.bz2
keir@17066 316
keir@17066 317 .PHONY: distclean
keir@17066 318 distclean: downloadclean