ia64/xen-unstable

view stubdom/Makefile @ 18109:092a15aa2430

stubdom: fix build dependencies

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jul 18 15:03:55 2008 +0100 (2008-07-18)
parents 226b04f0f1f9
children f0cd9df566ec
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_VERSION=1.3.0
17 GRUB_VERSION=0.97
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 $(CURDIR)/$(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/src/include
58 TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip/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/$@
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): mk-headers 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/$@
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/$@
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-$(LWIP_VERSION).tar.gz:
143 $(WGET) http://download.savannah.gnu.org/releases/lwip/$@
145 lwip: lwip-$(LWIP_VERSION).tar.gz
146 tar xzf $<
147 patch -d $@ -p0 < lwip.patch-cvs
148 touch $@
150 #######
151 # Links
152 #######
154 .PHONY: $(CROSS_ROOT)
155 $(CROSS_ROOT): cross-newlib cross-zlib cross-libpci
157 .PHONY: mk-headers
158 mk-headers:
159 mkdir -p include/xen && \
160 ln -sf $(addprefix ../../,$(wildcard $(XEN_ROOT)/xen/include/public/*.h)) include/xen && \
161 ln -sf $(addprefix ../../$(XEN_ROOT)/xen/include/public/,arch-ia64 arch-x86 hvm io xsm) include/xen && \
162 ( [ -h include/xen/sys ] || ln -sf ../../$(XEN_ROOT)/tools/include/xen-sys/MiniOS include/xen/sys ) && \
163 mkdir -p include/xen-foreign && \
164 ln -sf $(addprefix ../../,$(wildcard $(XEN_ROOT)/tools/include/xen-foreign/*)) include/xen-foreign/ && \
165 $(MAKE) -C include/xen-foreign/ && \
166 ( [ -h include/xen/foreign ] || ln -sf ../xen-foreign include/xen/foreign )
167 mkdir -p libxc
168 [ -h libxc/Makefile ] || ( cd libxc && \
169 ln -sf ../$(XEN_ROOT)/tools/libxc/*.h . && \
170 ln -sf ../$(XEN_ROOT)/tools/libxc/*.c . && \
171 ln -sf ../$(XEN_ROOT)/tools/libxc/Makefile . )
172 mkdir -p libxc/$(XEN_TARGET_ARCH)
173 [ -h libxc/$(XEN_TARGET_ARCH) ] || ( cd libxc/$(XEN_TARGET_ARCH) && \
174 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
175 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
176 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
177 mkdir -p ioemu
178 ifeq ($(CONFIG_QEMU),ioemu)
179 [ -h ioemu/Makefile ] || ( cd ioemu && \
180 ln -sf ../$(XEN_ROOT)/tools/ioemu/* .)
181 else
182 [ -h ioemu/Makefile ] || ( cd ioemu && \
183 ln -sf $(CONFIG_QEMU)/* . && \
184 rm -fr i386-dm && \
185 rm -fr i386-stubdom && \
186 mkdir i386-dm && \
187 mkdir i386-stubdom && \
188 ln -sf $(CONFIG_QEMU)/i386-dm/* i386-dm/ && \
189 ln -sf $(CONFIG_QEMU)/i386-stubdom/* i386-stubdom/ )
190 endif
191 [ ! -h ioemu/config-host.h ] || rm -f ioemu/config-host.h
192 [ ! -h ioemu/config-host.mak ] || rm -f ioemu/config-host.mak
193 $(MAKE) -C $(MINI_OS) links
195 TARGETS_MINIOS=$(addprefix mini-os-,$(TARGETS))
196 $(TARGETS_MINIOS): mini-os-%:
197 [ -d $@ ] || \
198 for i in $$(cd $(MINI_OS) ; find . -type d) ; do \
199 mkdir -p $@/$$i ; \
200 done
202 #######
203 # libxc
204 #######
206 .PHONY: libxc
207 libxc: libxc/libxenctrl.a libxc/libxenguest.a
208 libxc/libxenctrl.a libxc/libxenguest.a:: cross-zlib
209 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C libxc
211 #######
212 # ioemu
213 #######
215 .PHONY: ioemu
216 ioemu: cross-zlib cross-libpci libxc
217 ifeq ($(CONFIG_QEMU),ioemu)
218 [ -f ioemu/config-host.mak ] || \
219 ( cd ioemu ; \
220 XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) CFLAGS="$(TARGET_CFLAGS)" sh configure --prefix=/usr --enable-stubdom $(IOEMU_OPTIONS))
221 CPPFLAGS="$(TARGET_CPPFLAGS)" $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip TOOLS=
222 else
223 [ -f ioemu/config-host.mak ] || \
224 ( cd ioemu ; \
225 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))
226 CPPFLAGS= TARGET_CPPFLAGS="$(TARGET_CPPFLAGS)" $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip TOOLS= CONFIG_STUBDOM=yes
227 endif
229 ######
230 # caml
231 ######
233 .PHONY: caml
234 caml: $(CROSS_ROOT)
235 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip
237 ###
238 # C
239 ###
241 .PHONY: c
242 c: $(CROSS_ROOT)
243 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip
245 ######
246 # Grub
247 ######
249 grub-$(GRUB_VERSION).tar.gz:
250 $(WGET) ftp://alpha.gnu.org/gnu/grub/$@
252 grub-upstream: grub-$(GRUB_VERSION).tar.gz
253 tar xzf $<
254 mv grub-$(GRUB_VERSION) $@
255 for i in grub.patches/* ; do \
256 patch -d $@ -p1 < $$i ; \
257 done
259 .PHONY: grub
260 grub: grub-upstream $(CROSS_ROOT)
261 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@
263 ########
264 # minios
265 ########
267 .PHONY: ioemu-stubdom
268 ifeq ($(CONFIG_QEMU),ioemu)
269 ioemu-stubdom: APP_OBJS=$(CURDIR)/ioemu/i386-dm-stubdom/qemu.a $(CURDIR)/ioemu/i386-dm-stubdom/libqemu.a
270 else
271 ioemu-stubdom: APP_OBJS=$(CURDIR)/ioemu/i386-stubdom/qemu.a $(CURDIR)/ioemu/i386-stubdom/libqemu.a $(CURDIR)/ioemu/libqemu_common.a
272 endif
273 ioemu-stubdom: mini-os-ioemu lwip 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 APP_OBJS="$(APP_OBJS)"
276 CAMLLIB = $(shell ocamlc -where)
277 .PHONY: caml-stubdom
278 caml-stubdom: mini-os-caml lwip 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 APP_OBJS="$(CURDIR)/caml/main-caml.o $(CURDIR)/caml/caml.o $(CAMLLIB)/libasmrun.a"
281 .PHONY: c-stubdom
282 c-stubdom: mini-os-c lwip 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 APP_OBJS=$(CURDIR)/c/main.a
285 .PHONY: pv-grub
286 pv-grub: mini-os-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/main.a
289 #########
290 # install
291 #########
293 ifeq ($(STUBDOM_SUPPORTED),1)
294 install: install-ioemu install-grub
295 else
296 install:
297 endif
299 install-ioemu: ioemu-stubdom
300 $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/bin"
301 $(INSTALL_PROG) stubdom-dm "$(DESTDIR)/usr/lib/xen/bin"
302 $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
303 $(INSTALL_PROG) mini-os-ioemu/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/ioemu-stubdom.gz"
305 install-grub: pv-grub
306 $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
307 $(INSTALL_PROG) mini-os-grub/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/pv-grub.gz"
309 #######
310 # clean
311 #######
313 # Only clean the libxc/ioemu/mini-os part
314 .PHONY: clean
315 clean:
316 rm -fr mini-os-ioemu
317 rm -fr mini-os-c
318 rm -fr mini-os-caml
319 rm -fr mini-os-grub
320 $(MAKE) -C caml clean
321 $(MAKE) -C c clean
322 $(MAKE) -C grub clean
323 rm -fr libxc ioemu mini-os include
325 # clean the cross-compilation result
326 .PHONY: crossclean
327 crossclean: clean
328 rm -fr $(CROSS_ROOT)
329 rm -fr newlib-build
330 rm -fr zlib-$(ZLIB_VERSION) pciutils-$(LIBPCI_VERSION)
332 # clean patched sources
333 .PHONY: patchclean
334 patchclean: crossclean
335 rm -fr newlib-$(NEWLIB_VERSION)
336 rm -fr lwip
337 rm -fr grub-upstream
339 # clean downloads
340 .PHONY: downloadclean
341 downloadclean: patchclean
342 rm -f newlib-$(NEWLIB_VERSION).tar.gz
343 rm -f zlib-$(ZLIB_VERSION).tar.gz
344 rm -f pciutils-$(LIBPCI_VERSION).tar.bz2
345 rm -f grub-$(GRUB_VERSION).tar.gz
346 rm -f lwip-$(LWIP_VERSION).tar.gz
348 .PHONY: distclean
349 distclean: downloadclean