ia64/xen-unstable

view stubdom/Makefile @ 18817:e3a0c3c9fd7b

x86, hpet: Fix initialisation of secondary timers.

Each channel may have different settings, and in the original
implementation, other Tn configuration will accidently overwrite T0
configuration.

Signed-off-by: Guanqun Lu <guanqun.lu@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Nov 20 14:15:50 2008 +0000 (2008-11-20)
parents 71d3d3ac23b8
children d6889b3b6423
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
11 ZLIB_URL?=http://www.zlib.net
12 ZLIB_VERSION=1.2.3
13 LIBPCI_URL?=http://www.kernel.org/pub/software/utils/pciutils
14 LIBPCI_VERSION=2.2.9
15 NEWLIB_URL?=ftp://sources.redhat.com/pub/newlib
16 NEWLIB_VERSION=1.16.0
17 LWIP_URL?=http://download.savannah.gnu.org/releases/lwip
18 LWIP_VERSION=1.3.0
19 GRUB_URL?=http://alpha.gnu.org/gnu/grub
20 GRUB_VERSION=0.97
22 WGET=wget -c
24 GNU_TARGET_ARCH:=$(XEN_TARGET_ARCH)
25 ifeq ($(XEN_TARGET_ARCH),x86_32)
26 GNU_TARGET_ARCH:=i686
27 endif
29 ifeq ($(GNU_TARGET_ARCH), i686)
30 TARGET_CFLAGS=
31 NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
32 STUBDOM_SUPPORTED=1
33 endif
34 ifeq ($(GNU_TARGET_ARCH), x86_64)
35 TARGET_CFLAGS=-mno-red-zone
36 NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
37 STUBDOM_SUPPORTED=1
38 endif
39 ifeq ($(GNU_TARGET_ARCH), ia64)
40 TARGET_CFLAGS=-mconstant-gp
41 endif
43 CROSS_ROOT=cross-root-$(GNU_TARGET_ARCH)
44 CROSS_PREFIX=$(CURDIR)/$(CROSS_ROOT)
46 # Disable PIE/SSP if GCC supports them. They can break us.
47 TARGET_CFLAGS += $(CFLAGS)
48 TARGET_CPPFLAGS += $(CPPFLAGS)
49 TARGET_CFLAGS += $(call cc-option,$(CC),-nopie,)
50 TARGET_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
51 TARGET_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
53 # Do not use host headers and libs
54 GCC_INSTALL = $(shell LANG=C gcc -print-search-dirs | sed -n -e 's/install: \(.*\)/\1/p')
55 TARGET_CPPFLAGS += -U __linux__ -U __FreeBSD__ -U __sun__
56 TARGET_CPPFLAGS += -nostdinc
57 TARGET_CPPFLAGS += -isystem $(CURDIR)/$(MINI_OS)/include/posix
58 TARGET_CPPFLAGS += -isystem $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include
59 TARGET_CPPFLAGS += -isystem $(GCC_INSTALL)include
60 TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip-$(XEN_TARGET_ARCH)/src/include
61 TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip-$(XEN_TARGET_ARCH)/src/include/ipv4
62 TARGET_CPPFLAGS += -I$(CURDIR)/include
64 TARGET_LDFLAGS += -nostdlib -L$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib
66 TARGETS=ioemu c caml grub
68 .PHONY: all
69 all: build
70 ifeq ($(STUBDOM_SUPPORTED),1)
71 build: ioemu-stubdom c-stubdom pv-grub
72 else
73 build:
74 endif
76 ##############
77 # Cross-newlib
78 ##############
80 newlib-$(NEWLIB_VERSION).tar.gz:
81 $(WGET) $(NEWLIB_URL)/$@
83 newlib-$(NEWLIB_VERSION): newlib-$(NEWLIB_VERSION).tar.gz
84 tar xzf $<
85 patch -d $@ -p0 < newlib.patch
86 touch $@
88 NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a
89 .PHONY: cross-newlib
90 cross-newlib: $(NEWLIB_STAMPFILE)
91 $(NEWLIB_STAMPFILE): mk-headers-$(XEN_TARGET_ARCH) newlib-$(NEWLIB_VERSION)
92 mkdir -p newlib-$(XEN_TARGET_ARCH)
93 ( cd newlib-$(XEN_TARGET_ARCH) && \
94 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 && \
95 $(MAKE) && \
96 DESTDIR= $(MAKE) install )
98 ############
99 # Cross-zlib
100 ############
102 zlib-$(ZLIB_VERSION).tar.gz:
103 $(WGET) $(ZLIB_URL)/$@
105 zlib-$(XEN_TARGET_ARCH): zlib-$(ZLIB_VERSION).tar.gz
106 tar xzf $<
107 mv zlib-$(ZLIB_VERSION) $@
109 ZLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libz.a
110 .PHONY: cross-zlib
111 cross-zlib: $(ZLIB_STAMPFILE)
112 $(ZLIB_STAMPFILE): zlib-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)
113 ( cd $< && \
114 CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(CC) ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf && \
115 $(MAKE) libz.a && \
116 $(MAKE) install )
118 ##############
119 # Cross-libpci
120 ##############
122 pciutils-$(LIBPCI_VERSION).tar.bz2:
123 $(WGET) $(LIBPCI_URL)/$@
125 pciutils-$(XEN_TARGET_ARCH): pciutils-$(LIBPCI_VERSION).tar.bz2
126 tar xjf $<
127 mv pciutils-$(LIBPCI_VERSION) $@
128 patch -d $@ -p1 < pciutils.patch
129 touch $@
131 LIBPCI_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libpci.a
132 .PHONY: cross-libpci
133 cross-libpci: $(LIBPCI_STAMPFILE)
134 $(LIBPCI_STAMPFILE): pciutils-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE) $(ZLIB_STAMPFILE)
135 ( cd $< && \
136 cp ../libpci.config.h lib/config.h && \
137 echo '#define PCILIB_VERSION "$(LIBPCI_VERSION)"' >> lib/config.h && \
138 cp ../libpci.config.mak lib/config.mk && \
139 $(MAKE) CC="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -I$(realpath $(MINI_OS)/include)" lib/libpci.a && \
140 $(INSTALL_DATA) lib/libpci.a $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib/ && \
141 $(INSTALL_DIR) $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci && \
142 $(INSTALL_DATA) lib/config.h lib/header.h lib/pci.h lib/types.h $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci/ \
143 )
145 ######
146 # lwIP
147 ######
149 lwip-$(LWIP_VERSION).tar.gz:
150 $(WGET) $(LWIP_URL)/$@
152 lwip-$(XEN_TARGET_ARCH): lwip-$(LWIP_VERSION).tar.gz
153 tar xzf $<
154 mv lwip $@
155 patch -d $@ -p0 < lwip.patch-cvs
156 touch $@
158 #######
159 # Links
160 #######
162 .PHONY: $(CROSS_ROOT)
163 $(CROSS_ROOT): cross-newlib cross-zlib cross-libpci
165 $(XEN_ROOT)/tools/ioemu-dir:
166 make -C $(XEN_ROOT)/tools ioemu-dir-find
168 ioemu/linkfarm.stamp: $(XEN_ROOT)/tools/ioemu-dir
169 mkdir -p ioemu
170 set -e; \
171 $(absolutify_xen_root); \
172 cd ioemu; \
173 src="$$XEN_ROOT/tools/ioemu-dir"; export src; \
174 (cd $$src && find * -type d -print) | xargs mkdir -p; \
175 (cd $$src && find * ! -type l -type f $(addprefix ! -name , \
176 '*.[oda1]' 'config-*' config.mak qemu-dm qemu-img-xen \
177 '*.html' '*.pod' \
178 )) | \
179 while read f; do rm -f "$$f"; ln -s "$$src/$$f" "$$f"; done
180 touch ioemu/linkfarm.stamp
182 mk-headers-$(XEN_TARGET_ARCH): ioemu/linkfarm.stamp
183 mkdir -p include/xen && \
184 ln -sf $(addprefix ../../,$(wildcard $(XEN_ROOT)/xen/include/public/*.h)) include/xen && \
185 ln -sf $(addprefix ../../$(XEN_ROOT)/xen/include/public/,arch-ia64 arch-x86 hvm io xsm) include/xen && \
186 ( [ -h include/xen/sys ] || ln -sf ../../$(XEN_ROOT)/tools/include/xen-sys/MiniOS include/xen/sys ) && \
187 mkdir -p include/xen-foreign && \
188 ln -sf $(addprefix ../../,$(wildcard $(XEN_ROOT)/tools/include/xen-foreign/*)) include/xen-foreign/ && \
189 $(MAKE) -C include/xen-foreign/ && \
190 ( [ -h include/xen/foreign ] || ln -sf ../xen-foreign include/xen/foreign )
191 mkdir -p libxc-$(XEN_TARGET_ARCH)
192 [ -h libxc-$(XEN_TARGET_ARCH)/Makefile ] || ( cd libxc-$(XEN_TARGET_ARCH) && \
193 ln -sf ../$(XEN_ROOT)/tools/libxc/*.h . && \
194 ln -sf ../$(XEN_ROOT)/tools/libxc/*.c . && \
195 ln -sf ../$(XEN_ROOT)/tools/libxc/Makefile . )
196 mkdir -p libxc-$(XEN_TARGET_ARCH)/$(XEN_TARGET_ARCH)
197 [ -h libxc-$(XEN_TARGET_ARCH)/$(XEN_TARGET_ARCH) ] || ( cd libxc-$(XEN_TARGET_ARCH)/$(XEN_TARGET_ARCH) && \
198 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
199 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
200 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
201 $(MAKE) -C $(MINI_OS) links
202 touch mk-headers-$(XEN_TARGET_ARCH)
204 TARGETS_MINIOS=$(addprefix mini-os-$(XEN_TARGET_ARCH)-,$(TARGETS))
205 $(TARGETS_MINIOS): mini-os-%:
206 [ -d $@ ] || \
207 for i in $$(cd $(MINI_OS) ; find . -type d) ; do \
208 mkdir -p $@/$$i ; \
209 done
211 #######
212 # libxc
213 #######
215 .PHONY: libxc
216 libxc: libxc-$(XEN_TARGET_ARCH)/libxenctrl.a libxc-$(XEN_TARGET_ARCH)/libxenguest.a
217 libxc-$(XEN_TARGET_ARCH)/libxenctrl.a libxc-$(XEN_TARGET_ARCH)/libxenguest.a:: cross-zlib
218 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C libxc-$(XEN_TARGET_ARCH)
220 #######
221 # ioemu
222 #######
224 .PHONY: ioemu
225 ioemu: cross-zlib cross-libpci libxc
226 [ -f ioemu/config-host.mak ] || \
227 ( $(absolutify_xen_root); \
228 cd ioemu ; \
229 CONFIG_STUBDOM=yes XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) CFLAGS="$(TARGET_CFLAGS)" sh ./xen-setup --cc=$(CC) --disable-gcc-check $(IOEMU_OPTIONS))
230 CPPFLAGS= TARGET_CPPFLAGS="$(TARGET_CPPFLAGS)" $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) TOOLS= CONFIG_STUBDOM=yes
232 ######
233 # caml
234 ######
236 .PHONY: caml
237 caml: $(CROSS_ROOT)
238 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH)
240 ###
241 # C
242 ###
244 .PHONY: c
245 c: $(CROSS_ROOT)
246 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH)
248 ######
249 # Grub
250 ######
252 grub-$(GRUB_VERSION).tar.gz:
253 $(WGET) $(GRUB_URL)/$@
255 grub-upstream: grub-$(GRUB_VERSION).tar.gz
256 tar xzf $<
257 mv grub-$(GRUB_VERSION) $@
258 for i in grub.patches/* ; do \
259 patch -d $@ -p1 < $$i ; \
260 done
262 .PHONY: grub
263 grub: grub-upstream $(CROSS_ROOT)
264 mkdir -p grub-$(XEN_TARGET_ARCH)
265 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ OBJ_DIR=$(CURDIR)/grub-$(XEN_TARGET_ARCH)
267 ########
268 # minios
269 ########
271 .PHONY: ioemu-stubdom
272 ioemu-stubdom: APP_OBJS=$(CURDIR)/ioemu/i386-stubdom/qemu.a $(CURDIR)/ioemu/i386-stubdom/libqemu.a $(CURDIR)/ioemu/libqemu_common.a
273 ioemu-stubdom: mini-os-$(XEN_TARGET_ARCH)-ioemu lwip-$(XEN_TARGET_ARCH) libxc ioemu
274 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)"
276 CAMLLIB = $(shell ocamlc -where)
277 .PHONY: caml-stubdom
278 caml-stubdom: mini-os-$(XEN_TARGET_ARCH)-caml lwip-$(XEN_TARGET_ARCH) libxc caml
279 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"
281 .PHONY: c-stubdom
282 c-stubdom: mini-os-$(XEN_TARGET_ARCH)-c lwip-$(XEN_TARGET_ARCH) libxc c
283 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
285 .PHONY: pv-grub
286 pv-grub: mini-os-$(XEN_TARGET_ARCH)-grub libxc grub
287 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
289 #########
290 # install
291 #########
293 ifeq ($(STUBDOM_SUPPORTED),1)
294 install: install-readme install-ioemu install-grub
295 else
296 install:
297 endif
299 install-readme:
300 $(INSTALL_DIR) $(DESTDIR)$(DOCDIR)
301 $(INSTALL_DATA) README $(DESTDIR)$(DOCDIR)/README.stubdom
303 install-ioemu: ioemu-stubdom
304 $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/bin"
305 $(INSTALL_PROG) stubdom-dm "$(DESTDIR)/usr/lib/xen/bin"
306 $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
307 $(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-ioemu/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/ioemu-stubdom.gz"
309 install-grub: pv-grub
310 $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
311 $(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-grub/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/pv-grub-$(XEN_TARGET_ARCH).gz"
313 #######
314 # clean
315 #######
317 # Only clean the libxc/ioemu/mini-os part
318 .PHONY: clean
319 clean:
320 rm -fr mini-os-$(XEN_TARGET_ARCH)-ioemu
321 rm -fr mini-os-$(XEN_TARGET_ARCH)-c
322 rm -fr mini-os-$(XEN_TARGET_ARCH)-caml
323 rm -fr mini-os-$(XEN_TARGET_ARCH)-grub
324 $(MAKE) -C caml clean
325 $(MAKE) -C c clean
326 rm -fr grub-$(XEN_TARGET_ARCH)
327 [ ! -d libxc-$(XEN_TARGET_ARCH) ] || $(MAKE) -C libxc-$(XEN_TARGET_ARCH) clean
328 -[ ! -d ioemu ] || $(MAKE) -C ioemu clean
330 # clean the cross-compilation result
331 .PHONY: crossclean
332 crossclean: clean
333 rm -fr $(CROSS_ROOT)
334 rm -fr newlib-$(XEN_TARGET_ARCH)
335 rm -fr zlib-$(XEN_TARGET_ARCH) pciutils-$(XEN_TARGET_ARCH)
336 rm -fr libxc-$(XEN_TARGET_ARCH) ioemu
337 rm -f mk-headers-$(XEN_TARGET_ARCH)
339 # clean patched sources
340 .PHONY: patchclean
341 patchclean: crossclean
342 rm -fr newlib-$(NEWLIB_VERSION)
343 rm -fr lwip-$(XEN_TARGET_ARCH)
344 rm -fr grub-upstream
346 # clean downloads
347 .PHONY: downloadclean
348 downloadclean: patchclean
349 rm -f newlib-$(NEWLIB_VERSION).tar.gz
350 rm -f zlib-$(ZLIB_VERSION).tar.gz
351 rm -f pciutils-$(LIBPCI_VERSION).tar.bz2
352 rm -f grub-$(GRUB_VERSION).tar.gz
353 rm -f lwip-$(LWIP_VERSION).tar.gz
355 .PHONY: distclean
356 distclean: downloadclean