ia64/xen-unstable

view stubdom/Makefile @ 18026:f454f2cac170

x86 hvm: New boot option 'softtsc' to cause RDTSC to be trapped-and-emulated.

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jul 10 15:45:18 2008 +0100 (2008-07-10)
parents 707e10c9a487
children 03f685b6356a
line source
1 XEN_ROOT = ..
2 MINI_OS = $(XEN_ROOT)/extras/mini-os
4 export XEN_OS=MiniOS
6 CONFIG_QEMU=ioemu
8 export stubdom=y
9 export debug=y
10 include $(XEN_ROOT)/Config.mk
12 IOEMU_OPTIONS=--disable-sdl --disable-opengl --disable-gfx-check --disable-vnc-tls --disable-brlapi --disable-kqemu
13 ZLIB_VERSION=1.2.3
14 LIBPCI_VERSION=2.2.9
15 NEWLIB_VERSION=1.16.0
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 STUBDOM_SUPPORTED=1
30 endif
31 ifeq ($(GNU_TARGET_ARCH), x86_64)
32 TARGET_CFLAGS=-mno-red-zone
33 NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
34 STUBDOM_SUPPORTED=1
35 endif
36 ifeq ($(GNU_TARGET_ARCH), ia64)
37 TARGET_CFLAGS=-mconstant-gp
38 endif
40 CROSS_ROOT=cross-root-$(GNU_TARGET_ARCH)
41 CROSS_PREFIX=$(CURDIR)/$(CROSS_ROOT)
43 # Disable PIE/SSP if GCC supports them. They can break us.
44 TARGET_CFLAGS += $(CFLAGS)
45 TARGET_CPPFLAGS += $(CPPFLAGS)
46 TARGET_CFLAGS += $(call cc-option,$(CC),-nopie,)
47 TARGET_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
48 TARGET_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
50 # Do not use host headers and libs
51 GCC_INSTALL = $(shell gcc -print-search-dirs | sed -n -e 's/install: \(.*\)/\1/p')
52 TARGET_CPPFLAGS += -U __linux__ -U __FreeBSD__ -U __sun__
53 TARGET_CPPFLAGS += -nostdinc
54 TARGET_CPPFLAGS += -isystem $(abspath $(MINI_OS)/include/posix)
55 TARGET_CPPFLAGS += -isystem $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include
56 TARGET_CPPFLAGS += -isystem $(GCC_INSTALL)include
57 TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip-cvs/src/include
58 TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip-cvs/src/include/ipv4
59 TARGET_CPPFLAGS += -I$(CURDIR)/include
61 TARGET_LDFLAGS += -nostdlib -L$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib
63 TARGETS=ioemu c caml grub
65 .PHONY: all
66 all: build
67 ifeq ($(STUBDOM_SUPPORTED),1)
68 build: ioemu-stubdom c-stubdom pv-grub
69 else
70 build:
71 endif
73 ##############
74 # Cross-newlib
75 ##############
77 newlib-$(NEWLIB_VERSION).tar.gz:
78 $(WGET) ftp://sources.redhat.com/pub/newlib/newlib-$(NEWLIB_VERSION).tar.gz
80 newlib-$(NEWLIB_VERSION): newlib-$(NEWLIB_VERSION).tar.gz
81 tar xzf $<
82 patch -d $@ -p0 < newlib.patch
83 touch $@
85 NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a
86 .PHONY: cross-newlib
87 cross-newlib: $(NEWLIB_STAMPFILE)
88 $(NEWLIB_STAMPFILE): newlib-$(NEWLIB_VERSION)
89 mkdir -p newlib-build
90 ( cd newlib-build && \
91 CC_FOR_TARGET="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(NEWLIB_CFLAGS)" AR_FOR_TARGET=$(AR) LD_FOR_TARGET=$(LD) RANLIB_FOR_TARGET=$(RANLIB) ../newlib-$(NEWLIB_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-newlib-io-long-long --disable-multilib && \
92 $(MAKE) && \
93 DESTDIR= $(MAKE) install )
95 ############
96 # Cross-zlib
97 ############
99 zlib-$(ZLIB_VERSION).tar.gz:
100 $(WGET) http://www.zlib.net/zlib-$(ZLIB_VERSION).tar.gz
102 ZLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libz.a
103 .PHONY: cross-zlib
104 cross-zlib: $(ZLIB_STAMPFILE)
105 $(ZLIB_STAMPFILE): zlib-$(ZLIB_VERSION).tar.gz $(NEWLIB_STAMPFILE)
106 tar xzf $<
107 ( cd zlib-$(ZLIB_VERSION) && \
108 CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(CC) ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf && \
109 $(MAKE) libz.a && \
110 $(MAKE) install )
112 ##############
113 # Cross-libpci
114 ##############
116 pciutils-$(LIBPCI_VERSION).tar.bz2:
117 $(WGET) http://www.kernel.org/pub/software/utils/pciutils/pciutils-$(LIBPCI_VERSION).tar.bz2
119 pciutils-$(LIBPCI_VERSION): pciutils-$(LIBPCI_VERSION).tar.bz2
120 tar xjf $<
121 patch -d $@ -p1 < pciutils.patch
122 touch $@
124 LIBPCI_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libpci.a
125 .PHONY: cross-libpci
126 cross-libpci: $(LIBPCI_STAMPFILE)
127 $(LIBPCI_STAMPFILE): pciutils-$(LIBPCI_VERSION) $(NEWLIB_STAMPFILE) $(ZLIB_STAMPFILE)
128 ( cd pciutils-$(LIBPCI_VERSION) && \
129 cp ../libpci.config.h lib/config.h && \
130 echo '#define PCILIB_VERSION "$(LIBPCI_VERSION)"' >> lib/config.h && \
131 cp ../libpci.config.mak lib/config.mk && \
132 $(MAKE) CC="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -I$(realpath $(MINI_OS)/include)" lib/libpci.a && \
133 $(INSTALL_DATA) lib/libpci.a $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib/ && \
134 $(INSTALL_DIR) $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci && \
135 $(INSTALL_DATA) lib/{config,header,pci,types}.h $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci/ \
136 )
138 ######
139 # lwIP
140 ######
142 lwip-cvs:
143 cvs -z 9 -d :pserver:anonymous@cvs.savannah.nongnu.org:/sources/lwip co -D $(LWIP_DATE) -d $@ lwip
145 #######
146 # Links
147 #######
149 .PHONY: $(CROSS_ROOT)
150 $(CROSS_ROOT): cross-newlib cross-zlib cross-libpci
152 .PHONY: mk-headers
153 mk-headers:
154 mkdir -p include/xen && \
155 ln -sf $(addprefix ../../,$(wildcard $(XEN_ROOT)/xen/include/public/*.h)) include/xen && \
156 ln -sf $(addprefix ../../$(XEN_ROOT)/xen/include/public/,arch-ia64 arch-x86 hvm io xsm) include/xen && \
157 ( [ -h include/xen/sys ] || ln -sf ../../$(XEN_ROOT)/tools/include/xen-sys/MiniOS include/xen/sys ) && \
158 mkdir -p include/xen-foreign && \
159 ln -sf $(addprefix ../../,$(wildcard $(XEN_ROOT)/tools/include/xen-foreign/*)) include/xen-foreign/ && \
160 $(MAKE) -C include/xen-foreign/ && \
161 ( [ -h include/xen/foreign ] || ln -sf ../xen-foreign include/xen/foreign )
162 mkdir -p libxc
163 [ -h libxc/Makefile ] || ( cd libxc && \
164 ln -sf ../$(XEN_ROOT)/tools/libxc/*.h . && \
165 ln -sf ../$(XEN_ROOT)/tools/libxc/*.c . && \
166 ln -sf ../$(XEN_ROOT)/tools/libxc/Makefile . )
167 mkdir -p libxc/$(XEN_TARGET_ARCH)
168 [ -h libxc/$(XEN_TARGET_ARCH) ] || ( cd libxc/$(XEN_TARGET_ARCH) && \
169 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
170 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
171 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
172 mkdir -p ioemu
173 ifeq ($(CONFIG_QEMU),ioemu)
174 [ -h ioemu/Makefile ] || ( cd ioemu && \
175 ln -sf ../$(XEN_ROOT)/tools/ioemu/* .)
176 else
177 [ -h ioemu/Makefile ] || ( cd ioemu && \
178 ln -sf $(CONFIG_QEMU)/* . && \
179 rm -fr i386-dm && \
180 rm -fr i386-stubdom && \
181 mkdir i386-dm && \
182 mkdir i386-stubdom && \
183 ln -sf $(CONFIG_QEMU)/i386-dm/* i386-dm/ && \
184 ln -sf $(CONFIG_QEMU)/i386-stubdom/* i386-stubdom/ )
185 endif
186 [ ! -h ioemu/config-host.h ] || rm -f ioemu/config-host.h
187 [ ! -h ioemu/config-host.mak ] || rm -f ioemu/config-host.mak
188 $(MAKE) -C $(MINI_OS) links
190 TARGETS_MINIOS=$(addprefix mini-os-,$(TARGETS))
191 $(TARGETS_MINIOS): mini-os-%:
192 [ -d $@ ] || \
193 for i in $$(cd $(MINI_OS) ; find . -type d) ; do \
194 mkdir -p $@/$$i ; \
195 done
197 #######
198 # libxc
199 #######
201 .PHONY: libxc
202 libxc: libxc/libxenctrl.a libxc/libxenguest.a
203 libxc/libxenctrl.a libxc/libxenguest.a:: cross-zlib mk-headers
204 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C libxc
206 #######
207 # ioemu
208 #######
210 .PHONY: ioemu
211 ioemu: cross-zlib cross-libpci mk-headers libxc
212 ifeq ($(CONFIG_QEMU),ioemu)
213 [ -f ioemu/config-host.mak ] || \
214 ( cd ioemu ; \
215 XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) CFLAGS="$(TARGET_CFLAGS)" sh configure --prefix=/usr --enable-stubdom $(IOEMU_OPTIONS))
216 CPPFLAGS="$(TARGET_CPPFLAGS)" $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip-cvs TOOLS=
217 else
218 [ -f ioemu/config-host.mak ] || \
219 ( cd ioemu ; \
220 CONFIG_STUBDOM=yes XEN_ROOT=$(abspath $(XEN_ROOT)) XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) CFLAGS="$(TARGET_CFLAGS)" sh ./xen-setup --cc=$(CC) --disable-gcc-check $(IOEMU_OPTIONS))
221 CPPFLAGS= TARGET_CPPFLAGS="$(TARGET_CPPFLAGS)" $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip-cvs TOOLS= CONFIG_STUBDOM=yes
222 endif
224 ######
225 # caml
226 ######
228 .PHONY: caml
229 caml: cross-newlib mk-headers
230 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-cvs
232 ###
233 # C
234 ###
236 .PHONY: c
237 c: cross-newlib mk-headers
238 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-cvs
240 ######
241 # Grub
242 ######
244 grub-cvs:
245 cvs -z 9 -d :pserver:anonymous@cvs.sv.gnu.org:/sources/grub co -D $(GRUB_DATE) -d $@ grub
246 for i in grub.patches/* ; do \
247 patch -d $@ -p1 < $$i ; \
248 done
250 .PHONY: grub
251 grub: grub-cvs cross-newlib mk-headers
252 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@
254 ########
255 # minios
256 ########
258 .PHONY: ioemu-stubdom
259 ifeq ($(CONFIG_QEMU),ioemu)
260 ioemu-stubdom: APP_OBJS=$(CURDIR)/ioemu/i386-dm-stubdom/qemu.a $(CURDIR)/ioemu/i386-dm-stubdom/libqemu.a
261 else
262 ioemu-stubdom: APP_OBJS=$(CURDIR)/ioemu/i386-stubdom/qemu.a $(CURDIR)/ioemu/i386-stubdom/libqemu.a $(CURDIR)/ioemu/libqemu_common.a
263 endif
264 ioemu-stubdom: mini-os-ioemu lwip-cvs libxc ioemu
265 DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_QEMU $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-cvs APP_OBJS="$(APP_OBJS)"
267 CAMLLIB = $(shell ocamlc -where)
268 .PHONY: caml-stubdom
269 caml-stubdom: mini-os-caml lwip-cvs libxc caml
270 DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_CAML $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(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"
272 .PHONY: c-stubdom
273 c-stubdom: mini-os-c lwip-cvs libxc c
274 DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_C $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-cvs APP_OBJS=$(CURDIR)/c/main.a
276 .PHONY: pv-grub
277 pv-grub: mini-os-grub libxc grub
278 DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_GRUB $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/grub/main.a
280 #########
281 # install
282 #########
284 ifeq ($(STUBDOM_SUPPORTED),1)
285 install: install-ioemu install-grub
286 else
287 install:
288 endif
290 install-ioemu: ioemu-stubdom
291 $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/bin"
292 $(INSTALL_PROG) stubdom-dm "$(DESTDIR)/usr/lib/xen/bin"
293 $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
294 $(INSTALL_PROG) mini-os-ioemu/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/ioemu-stubdom.gz"
296 install-grub: pv-grub
297 $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
298 $(INSTALL_PROG) mini-os-grub/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/pv-grub.gz"
300 #######
301 # clean
302 #######
304 # Only clean the libxc/ioemu/mini-os part
305 .PHONY: clean
306 clean:
307 rm -fr mini-os-ioemu
308 rm -fr mini-os-c
309 rm -fr mini-os-caml
310 rm -fr mini-os-grub
311 $(MAKE) -C caml clean
312 $(MAKE) -C c clean
313 $(MAKE) -C grub clean
314 rm -fr libxc ioemu mini-os include
316 # clean the cross-compilation result
317 .PHONY: crossclean
318 crossclean: clean
319 rm -fr $(CROSS_ROOT)
320 rm -fr newlib-build
321 rm -fr zlib-$(ZLIB_VERSION) pciutils-$(LIBPCI_VERSION)
323 # clean patched sources
324 .PHONY: patchclean
325 patchclean: crossclean
326 rm -fr newlib-$(NEWLIB_VERSION)
327 rm -fr lwip-cvs
328 rm -fr grub-cvs
330 # clean downloads
331 .PHONY: downloadclean
332 downloadclean: patchclean
333 rm -f newlib-$(NEWLIB_VERSION).tar.gz
334 rm -f zlib-$(ZLIB_VERSION).tar.gz
335 rm -f pciutils-$(LIBPCI_VERSION).tar.bz2
337 .PHONY: distclean
338 distclean: downloadclean