ia64/xen-unstable

view stubdom/Makefile @ 19244:e5c696aaf2a6

x86, hvm: gcc44 build fix.

Broken constrain in inline asm. Bytewise access works with a, b, c, d
registers only, thus "r" is wrong, it must be "q". gcc 4.4 tries to
use the si register, which doesn't work and thus fails the build.

From: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Sun Mar 01 14:58:07 2009 +0000 (2009-03-01)
parents b999142bca8c
children 0b1ce09f4577
line source
1 XEN_ROOT = ..
2 MINI_OS = $(XEN_ROOT)/extras/mini-os
4 export XEN_OS=MiniOS
6 export stubdom=y
7 export debug=y
8 include $(XEN_ROOT)/Config.mk
10 IOEMU_OPTIONS=--disable-sdl --disable-opengl --disable-vnc-tls --disable-brlapi --disable-kqemu
12 #ZLIB_URL?=http://www.zlib.net
13 ZLIB_URL=$(XEN_EXTFILES_URL)
14 ZLIB_VERSION=1.2.3
16 #LIBPCI_URL?=http://www.kernel.org/pub/software/utils/pciutils
17 LIBPCI_URL?=$(XEN_EXTFILES_URL)
18 LIBPCI_VERSION=2.2.9
20 #NEWLIB_URL?=ftp://sources.redhat.com/pub/newlib
21 NEWLIB_URL?=$(XEN_EXTFILES_URL)
22 NEWLIB_VERSION=1.16.0
24 #LWIP_URL?=http://download.savannah.gnu.org/releases/lwip
25 LWIP_URL?=$(XEN_EXTFILES_URL)
26 LWIP_VERSION=1.3.0
28 #GRUB_URL?=http://alpha.gnu.org/gnu/grub
29 GRUB_URL?=$(XEN_EXTFILES_URL)
30 GRUB_VERSION=0.97
32 WGET=wget -c
34 GNU_TARGET_ARCH:=$(XEN_TARGET_ARCH)
35 ifeq ($(XEN_TARGET_ARCH),x86_32)
36 GNU_TARGET_ARCH:=i686
37 endif
39 ifeq ($(GNU_TARGET_ARCH), i686)
40 TARGET_CFLAGS=
41 NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
42 STUBDOM_SUPPORTED=1
43 endif
44 ifeq ($(GNU_TARGET_ARCH), x86_64)
45 TARGET_CFLAGS=-mno-red-zone
46 NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
47 STUBDOM_SUPPORTED=1
48 endif
49 ifeq ($(GNU_TARGET_ARCH), ia64)
50 TARGET_CFLAGS=-mconstant-gp
51 endif
53 CROSS_ROOT=cross-root-$(GNU_TARGET_ARCH)
54 CROSS_PREFIX=$(CURDIR)/$(CROSS_ROOT)
56 # Disable PIE/SSP if GCC supports them. They can break us.
57 TARGET_CFLAGS += $(CFLAGS)
58 TARGET_CPPFLAGS += $(CPPFLAGS)
59 TARGET_CFLAGS += $(call cc-option,$(CC),-nopie,)
60 TARGET_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
61 TARGET_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
63 # Do not use host headers and libs
64 GCC_INSTALL = $(shell LANG=C gcc -print-search-dirs | sed -n -e 's/install: \(.*\)/\1/p')
65 TARGET_CPPFLAGS += -U __linux__ -U __FreeBSD__ -U __sun__
66 TARGET_CPPFLAGS += -nostdinc
67 TARGET_CPPFLAGS += -isystem $(CURDIR)/$(MINI_OS)/include/posix
68 TARGET_CPPFLAGS += -isystem $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include
69 TARGET_CPPFLAGS += -isystem $(GCC_INSTALL)include
70 TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip-$(XEN_TARGET_ARCH)/src/include
71 TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip-$(XEN_TARGET_ARCH)/src/include/ipv4
72 TARGET_CPPFLAGS += -I$(CURDIR)/include
74 TARGET_LDFLAGS += -nostdlib -L$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib
76 TARGETS=ioemu c caml grub
78 .PHONY: all
79 all: build
80 ifeq ($(STUBDOM_SUPPORTED),1)
81 build: ioemu-stubdom c-stubdom pv-grub
82 else
83 build:
84 endif
86 ##############
87 # Cross-newlib
88 ##############
90 newlib-$(NEWLIB_VERSION).tar.gz:
91 $(WGET) $(NEWLIB_URL)/$@
93 newlib-$(NEWLIB_VERSION): newlib-$(NEWLIB_VERSION).tar.gz
94 tar xzf $<
95 patch -d $@ -p0 < newlib.patch
96 touch $@
98 NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a
99 .PHONY: cross-newlib
100 cross-newlib: $(NEWLIB_STAMPFILE)
101 $(NEWLIB_STAMPFILE): mk-headers-$(XEN_TARGET_ARCH) newlib-$(NEWLIB_VERSION)
102 mkdir -p newlib-$(XEN_TARGET_ARCH)
103 ( cd newlib-$(XEN_TARGET_ARCH) && \
104 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 && \
105 $(MAKE) && \
106 DESTDIR= $(MAKE) install )
108 ############
109 # Cross-zlib
110 ############
112 zlib-$(ZLIB_VERSION).tar.gz:
113 $(WGET) $(ZLIB_URL)/$@
115 zlib-$(XEN_TARGET_ARCH): zlib-$(ZLIB_VERSION).tar.gz
116 tar xzf $<
117 mv zlib-$(ZLIB_VERSION) $@
119 ZLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libz.a
120 .PHONY: cross-zlib
121 cross-zlib: $(ZLIB_STAMPFILE)
122 $(ZLIB_STAMPFILE): zlib-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)
123 ( cd $< && \
124 CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(CC) ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf && \
125 $(MAKE) libz.a && \
126 $(MAKE) install )
128 ##############
129 # Cross-libpci
130 ##############
132 pciutils-$(LIBPCI_VERSION).tar.bz2:
133 $(WGET) $(LIBPCI_URL)/$@
135 pciutils-$(XEN_TARGET_ARCH): pciutils-$(LIBPCI_VERSION).tar.bz2
136 tar xjf $<
137 mv pciutils-$(LIBPCI_VERSION) $@
138 patch -d $@ -p1 < pciutils.patch
139 touch $@
141 LIBPCI_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libpci.a
142 .PHONY: cross-libpci
143 cross-libpci: $(LIBPCI_STAMPFILE)
144 $(LIBPCI_STAMPFILE): pciutils-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE) $(ZLIB_STAMPFILE)
145 ( cd $< && \
146 cp ../libpci.config.h lib/config.h && \
147 echo '#define PCILIB_VERSION "$(LIBPCI_VERSION)"' >> lib/config.h && \
148 cp ../libpci.config.mak lib/config.mk && \
149 $(MAKE) CC="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -I$(realpath $(MINI_OS)/include)" lib/libpci.a && \
150 $(INSTALL_DATA) lib/libpci.a $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib/ && \
151 $(INSTALL_DIR) $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci && \
152 $(INSTALL_DATA) lib/config.h lib/header.h lib/pci.h lib/types.h $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci/ \
153 )
155 ######
156 # lwIP
157 ######
159 lwip-$(LWIP_VERSION).tar.gz:
160 $(WGET) $(LWIP_URL)/$@
162 lwip-$(XEN_TARGET_ARCH): lwip-$(LWIP_VERSION).tar.gz
163 tar xzf $<
164 mv lwip $@
165 patch -d $@ -p0 < lwip.patch-cvs
166 touch $@
168 #######
169 # Links
170 #######
172 .PHONY: $(CROSS_ROOT)
173 $(CROSS_ROOT): cross-newlib cross-zlib cross-libpci
175 $(XEN_ROOT)/tools/ioemu-dir:
176 make -C $(XEN_ROOT)/tools ioemu-dir-find
178 ioemu/linkfarm.stamp: $(XEN_ROOT)/tools/ioemu-dir
179 mkdir -p ioemu
180 set -e; \
181 $(absolutify_xen_root); \
182 cd ioemu; \
183 src="$$XEN_ROOT/tools/ioemu-dir"; export src; \
184 (cd $$src && find * -type d -print) | xargs mkdir -p; \
185 (cd $$src && find * ! -type l -type f $(addprefix ! -name , \
186 '*.[oda1]' 'config-*' config.mak qemu-dm qemu-img-xen \
187 '*.html' '*.pod' \
188 )) | \
189 while read f; do rm -f "$$f"; ln -s "$$src/$$f" "$$f"; done
190 touch ioemu/linkfarm.stamp
192 mk-headers-$(XEN_TARGET_ARCH): ioemu/linkfarm.stamp
193 mkdir -p include/xen && \
194 ln -sf $(addprefix ../../,$(wildcard $(XEN_ROOT)/xen/include/public/*.h)) include/xen && \
195 ln -sf $(addprefix ../../$(XEN_ROOT)/xen/include/public/,arch-ia64 arch-x86 hvm io xsm) include/xen && \
196 ( [ -h include/xen/sys ] || ln -sf ../../$(XEN_ROOT)/tools/include/xen-sys/MiniOS include/xen/sys ) && \
197 ( [ -h include/xen/libelf ] || ln -sf ../../$(XEN_ROOT)/tools/include/xen/libelf include/xen/libelf ) && \
198 mkdir -p include/xen-foreign && \
199 ln -sf $(addprefix ../../,$(wildcard $(XEN_ROOT)/tools/include/xen-foreign/*)) include/xen-foreign/ && \
200 $(MAKE) -C include/xen-foreign/ && \
201 ( [ -h include/xen/foreign ] || ln -sf ../xen-foreign include/xen/foreign )
202 mkdir -p libxc-$(XEN_TARGET_ARCH)
203 [ -h libxc-$(XEN_TARGET_ARCH)/Makefile ] || ( cd libxc-$(XEN_TARGET_ARCH) && \
204 ln -sf ../$(XEN_ROOT)/tools/libxc/*.h . && \
205 ln -sf ../$(XEN_ROOT)/tools/libxc/*.c . && \
206 ln -sf ../$(XEN_ROOT)/tools/libxc/Makefile . )
207 mkdir -p libxc-$(XEN_TARGET_ARCH)/$(XEN_TARGET_ARCH)
208 [ -h libxc-$(XEN_TARGET_ARCH)/$(XEN_TARGET_ARCH) ] || ( cd libxc-$(XEN_TARGET_ARCH)/$(XEN_TARGET_ARCH) && \
209 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
210 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
211 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
212 $(MAKE) -C $(MINI_OS) links
213 touch mk-headers-$(XEN_TARGET_ARCH)
215 TARGETS_MINIOS=$(addprefix mini-os-$(XEN_TARGET_ARCH)-,$(TARGETS))
216 $(TARGETS_MINIOS): mini-os-%:
217 [ -d $@ ] || \
218 for i in $$(cd $(MINI_OS) ; find . -type d) ; do \
219 mkdir -p $@/$$i ; \
220 done
222 #######
223 # libxc
224 #######
226 .PHONY: libxc
227 libxc: libxc-$(XEN_TARGET_ARCH)/libxenctrl.a libxc-$(XEN_TARGET_ARCH)/libxenguest.a
228 libxc-$(XEN_TARGET_ARCH)/libxenctrl.a libxc-$(XEN_TARGET_ARCH)/libxenguest.a:: cross-zlib
229 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C libxc-$(XEN_TARGET_ARCH)
231 #######
232 # ioemu
233 #######
235 .PHONY: ioemu
236 ioemu: cross-zlib cross-libpci libxc
237 [ -f ioemu/config-host.mak ] || \
238 ( $(absolutify_xen_root); \
239 cd ioemu ; \
240 CONFIG_STUBDOM=yes XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) CFLAGS="$(TARGET_CFLAGS)" sh ./xen-setup --cc=$(CC) --disable-gcc-check $(IOEMU_OPTIONS))
241 CPPFLAGS= TARGET_CPPFLAGS="$(TARGET_CPPFLAGS)" $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) TOOLS= CONFIG_STUBDOM=yes
243 ######
244 # caml
245 ######
247 .PHONY: caml
248 caml: $(CROSS_ROOT)
249 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH)
251 ###
252 # C
253 ###
255 .PHONY: c
256 c: $(CROSS_ROOT)
257 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH)
259 ######
260 # Grub
261 ######
263 grub-$(GRUB_VERSION).tar.gz:
264 $(WGET) $(GRUB_URL)/$@
266 grub-upstream: grub-$(GRUB_VERSION).tar.gz
267 tar xzf $<
268 mv grub-$(GRUB_VERSION) $@
269 for i in grub.patches/* ; do \
270 patch -d $@ -p1 < $$i ; \
271 done
273 .PHONY: grub
274 grub: grub-upstream $(CROSS_ROOT)
275 mkdir -p grub-$(XEN_TARGET_ARCH)
276 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ OBJ_DIR=$(CURDIR)/grub-$(XEN_TARGET_ARCH)
278 ########
279 # minios
280 ########
282 .PHONY: ioemu-stubdom
283 ioemu-stubdom: APP_OBJS=$(CURDIR)/ioemu/i386-stubdom/qemu.a $(CURDIR)/ioemu/i386-stubdom/libqemu.a $(CURDIR)/ioemu/libqemu_common.a
284 ioemu-stubdom: mini-os-$(XEN_TARGET_ARCH)-ioemu lwip-$(XEN_TARGET_ARCH) libxc ioemu
285 DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_QEMU $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS="$(APP_OBJS)"
287 CAMLLIB = $(shell ocamlc -where)
288 .PHONY: caml-stubdom
289 caml-stubdom: mini-os-$(XEN_TARGET_ARCH)-caml lwip-$(XEN_TARGET_ARCH) libxc caml
290 DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_CAML $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS="$(CURDIR)/caml/main-caml.o $(CURDIR)/caml/caml.o $(CAMLLIB)/libasmrun.a"
292 .PHONY: c-stubdom
293 c-stubdom: mini-os-$(XEN_TARGET_ARCH)-c lwip-$(XEN_TARGET_ARCH) libxc c
294 DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_C $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS=$(CURDIR)/c/main.a
296 .PHONY: pv-grub
297 pv-grub: mini-os-$(XEN_TARGET_ARCH)-grub libxc grub
298 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-$(XEN_TARGET_ARCH)/main.a
300 #########
301 # install
302 #########
304 ifeq ($(STUBDOM_SUPPORTED),1)
305 install: install-readme install-ioemu install-grub
306 else
307 install:
308 endif
310 install-readme:
311 $(INSTALL_DIR) $(DESTDIR)$(DOCDIR)
312 $(INSTALL_DATA) README $(DESTDIR)$(DOCDIR)/README.stubdom
314 install-ioemu: ioemu-stubdom
315 $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/bin"
316 $(INSTALL_PROG) stubdom-dm "$(DESTDIR)/usr/lib/xen/bin"
317 $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
318 $(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-ioemu/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/ioemu-stubdom.gz"
320 install-grub: pv-grub
321 $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
322 $(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-grub/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/pv-grub-$(XEN_TARGET_ARCH).gz"
324 #######
325 # clean
326 #######
328 # Only clean the libxc/ioemu/mini-os part
329 .PHONY: clean
330 clean:
331 rm -fr mini-os-$(XEN_TARGET_ARCH)-ioemu
332 rm -fr mini-os-$(XEN_TARGET_ARCH)-c
333 rm -fr mini-os-$(XEN_TARGET_ARCH)-caml
334 rm -fr mini-os-$(XEN_TARGET_ARCH)-grub
335 $(MAKE) -C caml clean
336 $(MAKE) -C c clean
337 rm -fr grub-$(XEN_TARGET_ARCH)
338 [ ! -d libxc-$(XEN_TARGET_ARCH) ] || $(MAKE) -C libxc-$(XEN_TARGET_ARCH) clean
339 -[ ! -d ioemu ] || $(MAKE) -C ioemu clean
341 # clean the cross-compilation result
342 .PHONY: crossclean
343 crossclean: clean
344 rm -fr $(CROSS_ROOT)
345 rm -fr newlib-$(XEN_TARGET_ARCH)
346 rm -fr zlib-$(XEN_TARGET_ARCH) pciutils-$(XEN_TARGET_ARCH)
347 rm -fr libxc-$(XEN_TARGET_ARCH) ioemu
348 rm -f mk-headers-$(XEN_TARGET_ARCH)
350 # clean patched sources
351 .PHONY: patchclean
352 patchclean: crossclean
353 rm -fr newlib-$(NEWLIB_VERSION)
354 rm -fr lwip-$(XEN_TARGET_ARCH)
355 rm -fr grub-upstream
357 # clean downloads
358 .PHONY: downloadclean
359 downloadclean: patchclean
360 rm -f newlib-$(NEWLIB_VERSION).tar.gz
361 rm -f zlib-$(ZLIB_VERSION).tar.gz
362 rm -f pciutils-$(LIBPCI_VERSION).tar.bz2
363 rm -f grub-$(GRUB_VERSION).tar.gz
364 rm -f lwip-$(LWIP_VERSION).tar.gz
366 .PHONY: distclean
367 distclean: downloadclean