debuggers.hg

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