ia64/xen-unstable

view stubdom/Makefile @ 19510:accf139b2eb9

tools/misc: Remove some obsolete scripts.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Apr 06 21:12:33 2009 +0100 (2009-04-06)
parents 6ad2b1ded12f
children b5522741f6b5
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 #ZLIB_URL?=http://www.zlib.net
11 ZLIB_URL=$(XEN_EXTFILES_URL)
12 ZLIB_VERSION=1.2.3
14 #LIBPCI_URL?=http://www.kernel.org/pub/software/utils/pciutils
15 LIBPCI_URL?=$(XEN_EXTFILES_URL)
16 LIBPCI_VERSION=2.2.9
18 #NEWLIB_URL?=ftp://sources.redhat.com/pub/newlib
19 NEWLIB_URL?=$(XEN_EXTFILES_URL)
20 NEWLIB_VERSION=1.16.0
22 #LWIP_URL?=http://download.savannah.gnu.org/releases/lwip
23 LWIP_URL?=$(XEN_EXTFILES_URL)
24 LWIP_VERSION=1.3.0
26 #GRUB_URL?=http://alpha.gnu.org/gnu/grub
27 GRUB_URL?=$(XEN_EXTFILES_URL)
28 GRUB_VERSION=0.97
30 WGET=wget -c
32 GNU_TARGET_ARCH:=$(XEN_TARGET_ARCH)
33 ifeq ($(XEN_TARGET_ARCH),x86_32)
34 GNU_TARGET_ARCH:=i686
35 endif
37 ifeq ($(GNU_TARGET_ARCH), i686)
38 TARGET_CFLAGS=
39 NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
40 STUBDOM_SUPPORTED=1
41 endif
42 ifeq ($(GNU_TARGET_ARCH), x86_64)
43 TARGET_CFLAGS=-mno-red-zone
44 NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
45 STUBDOM_SUPPORTED=1
46 endif
47 ifeq ($(GNU_TARGET_ARCH), ia64)
48 TARGET_CFLAGS=-mconstant-gp
49 endif
51 CROSS_ROOT=cross-root-$(GNU_TARGET_ARCH)
52 CROSS_PREFIX=$(CURDIR)/$(CROSS_ROOT)
54 # Disable PIE/SSP if GCC supports them. They can break us.
55 TARGET_CFLAGS += $(CFLAGS)
56 TARGET_CPPFLAGS += $(CPPFLAGS)
57 TARGET_CFLAGS += $(call cc-option,$(CC),-nopie,)
58 TARGET_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
59 TARGET_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
61 # Do not use host headers and libs
62 GCC_INSTALL = $(shell LANG=C gcc -print-search-dirs | sed -n -e 's/install: \(.*\)/\1/p')
63 TARGET_CPPFLAGS += -U __linux__ -U __FreeBSD__ -U __sun__
64 TARGET_CPPFLAGS += -nostdinc
65 TARGET_CPPFLAGS += -isystem $(CURDIR)/$(MINI_OS)/include/posix
66 TARGET_CPPFLAGS += -isystem $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include
67 TARGET_CPPFLAGS += -isystem $(GCC_INSTALL)include
68 TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip-$(XEN_TARGET_ARCH)/src/include
69 TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip-$(XEN_TARGET_ARCH)/src/include/ipv4
70 TARGET_CPPFLAGS += -I$(CURDIR)/include
72 TARGET_LDFLAGS += -nostdlib -L$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib
74 TARGETS=ioemu c caml grub
76 .PHONY: all
77 all: build
78 ifeq ($(STUBDOM_SUPPORTED),1)
79 build: ioemu-stubdom c-stubdom pv-grub
80 else
81 build:
82 endif
84 ##############
85 # Cross-newlib
86 ##############
88 newlib-$(NEWLIB_VERSION).tar.gz:
89 $(WGET) $(NEWLIB_URL)/$@
91 newlib-$(NEWLIB_VERSION): newlib-$(NEWLIB_VERSION).tar.gz
92 tar xzf $<
93 patch -d $@ -p0 < newlib.patch
94 patch -d $@ -p0 < newlib-chk.patch
95 touch $@
97 NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a
98 .PHONY: cross-newlib
99 cross-newlib: $(NEWLIB_STAMPFILE)
100 $(NEWLIB_STAMPFILE): mk-headers-$(XEN_TARGET_ARCH) newlib-$(NEWLIB_VERSION)
101 mkdir -p newlib-$(XEN_TARGET_ARCH)
102 ( cd newlib-$(XEN_TARGET_ARCH) && \
103 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 && \
104 $(MAKE) && \
105 DESTDIR= $(MAKE) install )
107 ############
108 # Cross-zlib
109 ############
111 zlib-$(ZLIB_VERSION).tar.gz:
112 $(WGET) $(ZLIB_URL)/$@
114 zlib-$(XEN_TARGET_ARCH): zlib-$(ZLIB_VERSION).tar.gz
115 tar xzf $<
116 mv zlib-$(ZLIB_VERSION) $@
118 ZLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libz.a
119 .PHONY: cross-zlib
120 cross-zlib: $(ZLIB_STAMPFILE)
121 $(ZLIB_STAMPFILE): zlib-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)
122 ( cd $< && \
123 CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(CC) ./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) $(LIBPCI_URL)/$@
134 pciutils-$(XEN_TARGET_ARCH): pciutils-$(LIBPCI_VERSION).tar.bz2
135 tar xjf $<
136 mv pciutils-$(LIBPCI_VERSION) $@
137 patch -d $@ -p1 < pciutils.patch
138 touch $@
140 LIBPCI_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libpci.a
141 .PHONY: cross-libpci
142 cross-libpci: $(LIBPCI_STAMPFILE)
143 $(LIBPCI_STAMPFILE): pciutils-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE) $(ZLIB_STAMPFILE)
144 ( cd $< && \
145 cp ../libpci.config.h lib/config.h && \
146 echo '#define PCILIB_VERSION "$(LIBPCI_VERSION)"' >> lib/config.h && \
147 cp ../libpci.config.mak lib/config.mk && \
148 $(MAKE) CC="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -I$(realpath $(MINI_OS)/include)" lib/libpci.a && \
149 $(INSTALL_DATA) lib/libpci.a $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib/ && \
150 $(INSTALL_DIR) $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci && \
151 $(INSTALL_DATA) lib/config.h lib/header.h lib/pci.h lib/types.h $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci/ \
152 )
154 ######
155 # lwIP
156 ######
158 lwip-$(LWIP_VERSION).tar.gz:
159 $(WGET) $(LWIP_URL)/$@
161 lwip-$(XEN_TARGET_ARCH): lwip-$(LWIP_VERSION).tar.gz
162 tar xzf $<
163 mv lwip $@
164 patch -d $@ -p0 < lwip.patch-cvs
165 touch $@
167 #######
168 # Links
169 #######
171 .PHONY: $(CROSS_ROOT)
172 $(CROSS_ROOT): cross-newlib cross-zlib cross-libpci
174 $(XEN_ROOT)/tools/ioemu-dir:
175 make -C $(XEN_ROOT)/tools ioemu-dir-find
177 ioemu/linkfarm.stamp: $(XEN_ROOT)/tools/ioemu-dir
178 mkdir -p ioemu
179 set -e; \
180 $(absolutify_xen_root); \
181 cd ioemu; \
182 src="$$XEN_ROOT/tools/ioemu-dir"; export src; \
183 (cd $$src && find * -type d -print) | xargs mkdir -p; \
184 (cd $$src && find * ! -type l -type f $(addprefix ! -name , \
185 '*.[oda1]' 'config-*' config.mak qemu-dm qemu-img-xen \
186 '*.html' '*.pod' \
187 )) | \
188 while read f; do rm -f "$$f"; ln -s "$$src/$$f" "$$f"; done
189 touch ioemu/linkfarm.stamp
191 mk-headers-$(XEN_TARGET_ARCH): ioemu/linkfarm.stamp
192 mkdir -p include/xen && \
193 ln -sf $(addprefix ../../,$(wildcard $(XEN_ROOT)/xen/include/public/*.h)) include/xen && \
194 ln -sf $(addprefix ../../$(XEN_ROOT)/xen/include/public/,arch-ia64 arch-x86 hvm io xsm) include/xen && \
195 ( [ -h include/xen/sys ] || ln -sf ../../$(XEN_ROOT)/tools/include/xen-sys/MiniOS include/xen/sys ) && \
196 ( [ -h include/xen/libelf ] || ln -sf ../../$(XEN_ROOT)/tools/include/xen/libelf include/xen/libelf ) && \
197 mkdir -p include/xen-foreign && \
198 ln -sf $(addprefix ../../,$(wildcard $(XEN_ROOT)/tools/include/xen-foreign/*)) include/xen-foreign/ && \
199 $(MAKE) -C include/xen-foreign/ && \
200 ( [ -h include/xen/foreign ] || ln -sf ../xen-foreign include/xen/foreign )
201 mkdir -p libxc-$(XEN_TARGET_ARCH)
202 [ -h libxc-$(XEN_TARGET_ARCH)/Makefile ] || ( cd libxc-$(XEN_TARGET_ARCH) && \
203 ln -sf ../$(XEN_ROOT)/tools/libxc/*.h . && \
204 ln -sf ../$(XEN_ROOT)/tools/libxc/*.c . && \
205 ln -sf ../$(XEN_ROOT)/tools/libxc/Makefile . )
206 mkdir -p libxc-$(XEN_TARGET_ARCH)/$(XEN_TARGET_ARCH)
207 [ -h libxc-$(XEN_TARGET_ARCH)/$(XEN_TARGET_ARCH) ] || ( cd libxc-$(XEN_TARGET_ARCH)/$(XEN_TARGET_ARCH) && \
208 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
209 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
210 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
211 $(MAKE) -C $(MINI_OS) links
212 touch mk-headers-$(XEN_TARGET_ARCH)
214 TARGETS_MINIOS=$(addprefix mini-os-$(XEN_TARGET_ARCH)-,$(TARGETS))
215 $(TARGETS_MINIOS): mini-os-%:
216 [ -d $@ ] || \
217 for i in $$(cd $(MINI_OS) ; find . -type d) ; do \
218 mkdir -p $@/$$i ; \
219 done
221 #######
222 # libxc
223 #######
225 .PHONY: libxc
226 libxc: libxc-$(XEN_TARGET_ARCH)/libxenctrl.a libxc-$(XEN_TARGET_ARCH)/libxenguest.a
227 libxc-$(XEN_TARGET_ARCH)/libxenctrl.a libxc-$(XEN_TARGET_ARCH)/libxenguest.a:: cross-zlib
228 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C libxc-$(XEN_TARGET_ARCH)
230 #######
231 # ioemu
232 #######
234 .PHONY: ioemu
235 ioemu: cross-zlib cross-libpci libxc
236 [ -f ioemu/config-host.mak ] || \
237 ( $(absolutify_xen_root); \
238 cd ioemu ; \
239 LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) \
240 TARGET_CPPFLAGS="$(TARGET_CPPFLAGS)" \
241 TARGET_CFLAGS="$(TARGET_CFLAGS)" \
242 TARGET_LDFLAGS="$(TARGET_LDFLAGS)" \
243 ./xen-setup-stubdom )
244 $(MAKE) -C ioemu
246 ######
247 # caml
248 ######
250 .PHONY: caml
251 caml: $(CROSS_ROOT)
252 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH)
254 ###
255 # C
256 ###
258 .PHONY: c
259 c: $(CROSS_ROOT)
260 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH)
262 ######
263 # Grub
264 ######
266 grub-$(GRUB_VERSION).tar.gz:
267 $(WGET) $(GRUB_URL)/$@
269 grub-upstream: grub-$(GRUB_VERSION).tar.gz
270 tar xzf $<
271 mv grub-$(GRUB_VERSION) $@
272 for i in grub.patches/* ; do \
273 patch -d $@ -p1 < $$i ; \
274 done
276 .PHONY: grub
277 grub: grub-upstream $(CROSS_ROOT)
278 mkdir -p grub-$(XEN_TARGET_ARCH)
279 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ OBJ_DIR=$(CURDIR)/grub-$(XEN_TARGET_ARCH)
281 ########
282 # minios
283 ########
285 .PHONY: ioemu-stubdom
286 ioemu-stubdom: APP_OBJS=$(CURDIR)/ioemu/i386-stubdom/qemu.a $(CURDIR)/ioemu/i386-stubdom/libqemu.a $(CURDIR)/ioemu/libqemu_common.a
287 ioemu-stubdom: mini-os-$(XEN_TARGET_ARCH)-ioemu lwip-$(XEN_TARGET_ARCH) libxc ioemu
288 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)"
290 CAMLLIB = $(shell ocamlc -where)
291 .PHONY: caml-stubdom
292 caml-stubdom: mini-os-$(XEN_TARGET_ARCH)-caml lwip-$(XEN_TARGET_ARCH) libxc caml
293 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"
295 .PHONY: c-stubdom
296 c-stubdom: mini-os-$(XEN_TARGET_ARCH)-c lwip-$(XEN_TARGET_ARCH) libxc c
297 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
299 .PHONY: pv-grub
300 pv-grub: mini-os-$(XEN_TARGET_ARCH)-grub libxc grub
301 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
303 #########
304 # install
305 #########
307 ifeq ($(STUBDOM_SUPPORTED),1)
308 install: install-readme install-ioemu install-grub
309 else
310 install:
311 endif
313 install-readme:
314 $(INSTALL_DIR) $(DESTDIR)$(DOCDIR)
315 $(INSTALL_DATA) README $(DESTDIR)$(DOCDIR)/README.stubdom
317 install-ioemu: ioemu-stubdom
318 $(INSTALL_DIR) "$(DESTDIR)$(LIBEXEC)"
319 $(INSTALL_PROG) stubdom-dm "$(DESTDIR)$(LIBEXEC)"
320 $(INSTALL_DIR) "$(DESTDIR)$(LIBDIR_x86_32)/xen/boot"
321 $(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-ioemu/mini-os.gz "$(DESTDIR)$(LIBDIR_x86_32)/xen/boot/ioemu-stubdom.gz"
323 install-grub: pv-grub
324 $(INSTALL_DIR) "$(DESTDIR)$(LIBDIR_x86_32)/xen/boot"
325 $(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-grub/mini-os.gz "$(DESTDIR)$(LIBDIR_x86_32)/xen/boot/pv-grub-$(XEN_TARGET_ARCH).gz"
327 #######
328 # clean
329 #######
331 # Only clean the libxc/ioemu/mini-os part
332 .PHONY: clean
333 clean:
334 rm -fr mini-os-$(XEN_TARGET_ARCH)-ioemu
335 rm -fr mini-os-$(XEN_TARGET_ARCH)-c
336 rm -fr mini-os-$(XEN_TARGET_ARCH)-caml
337 rm -fr mini-os-$(XEN_TARGET_ARCH)-grub
338 $(MAKE) -C caml clean
339 $(MAKE) -C c clean
340 rm -fr grub-$(XEN_TARGET_ARCH)
341 [ ! -d libxc-$(XEN_TARGET_ARCH) ] || $(MAKE) -C libxc-$(XEN_TARGET_ARCH) clean
342 -[ ! -d ioemu ] || $(MAKE) -C ioemu clean
344 # clean the cross-compilation result
345 .PHONY: crossclean
346 crossclean: clean
347 rm -fr $(CROSS_ROOT)
348 rm -fr newlib-$(XEN_TARGET_ARCH)
349 rm -fr zlib-$(XEN_TARGET_ARCH) pciutils-$(XEN_TARGET_ARCH)
350 rm -fr libxc-$(XEN_TARGET_ARCH) ioemu
351 rm -f mk-headers-$(XEN_TARGET_ARCH)
353 # clean patched sources
354 .PHONY: patchclean
355 patchclean: crossclean
356 rm -fr newlib-$(NEWLIB_VERSION)
357 rm -fr lwip-$(XEN_TARGET_ARCH)
358 rm -fr grub-upstream
360 # clean downloads
361 .PHONY: downloadclean
362 downloadclean: patchclean
363 rm -f newlib-$(NEWLIB_VERSION).tar.gz
364 rm -f zlib-$(ZLIB_VERSION).tar.gz
365 rm -f pciutils-$(LIBPCI_VERSION).tar.bz2
366 rm -f grub-$(GRUB_VERSION).tar.gz
367 rm -f lwip-$(LWIP_VERSION).tar.gz
369 .PHONY: distclean
370 distclean: downloadclean