ia64/xen-unstable

view stubdom/Makefile @ 17998:6f30a7367fa7

stubdom: do not build tapdisk as it it not supposed to build and we don't need it

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jul 08 17:15:23 2008 +0100 (2008-07-08)
parents e12df2e7bd43
children 5cd4fe68b6c2
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-vnc-tls
11 ZLIB_VERSION=1.2.3
12 LIBPCI_VERSION=2.2.9
13 NEWLIB_DATE=2008-01-01
14 LWIP_DATE=2008-06-01
15 GRUB_DATE=2008-06-01
17 WGET=wget -c
19 GNU_TARGET_ARCH:=$(XEN_TARGET_ARCH)
20 ifeq ($(XEN_TARGET_ARCH),x86_32)
21 GNU_TARGET_ARCH:=i686
22 endif
24 ifeq ($(GNU_TARGET_ARCH), i686)
25 TARGET_CFLAGS=
26 NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
27 endif
28 ifeq ($(GNU_TARGET_ARCH), x86_64)
29 TARGET_CFLAGS=-mno-red-zone
30 NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
31 endif
32 ifeq ($(GNU_TARGET_ARCH), ia64)
33 TARGET_CFLAGS=-mconstant-gp
34 endif
36 CROSS_ROOT=cross-root-$(GNU_TARGET_ARCH)
37 CROSS_PREFIX=$(CURDIR)/$(CROSS_ROOT)
39 # Disable PIE/SSP if GCC supports them. They can break us.
40 TARGET_CFLAGS += $(CFLAGS)
41 TARGET_CPPFLAGS += $(CPPFLAGS)
42 TARGET_CFLAGS += $(call cc-option,$(CC),-nopie,)
43 TARGET_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
44 TARGET_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
46 # Do not use host headers and libs
47 GCC_INSTALL = $(shell gcc -print-search-dirs | sed -n -e 's/install: \(.*\)/\1/p')
48 TARGET_CPPFLAGS += -U __linux__ -U __FreeBSD__ -U __sun__
49 TARGET_CFLAGS += -nostdinc
50 TARGET_CPPFLAGS += -isystem $(realpath $(MINI_OS)/include/posix)
51 TARGET_CPPFLAGS += -isystem $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include
52 TARGET_CPPFLAGS += -isystem $(GCC_INSTALL)include
54 TARGET_LDFLAGS += -nostdlib -L$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib
56 TARGETS=ioemu c caml grub
58 .PHONY: all
59 all: ioemu-stubdom c-stubdom pv-grub
61 ##############
62 # Cross-newlib
63 ##############
65 newlib-cvs:
66 cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/src co -D $(NEWLIB_DATE) newlib
67 mv src newlib-cvs
68 patch -d $@ -p0 < newlib.patch
70 NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a
71 .PHONY: cross-newlib
72 cross-newlib: $(NEWLIB_STAMPFILE)
73 $(NEWLIB_STAMPFILE): newlib-cvs
74 mkdir -p newlib-build
75 ( cd newlib-build && \
76 CC_FOR_TARGET="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(NEWLIB_CFLAGS)" AR_FOR_TARGET=$(AR) LD_FOR_TARGET=$(LD) RANLIB_FOR_TARGET=$(RANLIB) ../newlib-cvs/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-newlib-io-long-long --disable-multilib && \
77 $(MAKE) && \
78 $(MAKE) install )
80 ############
81 # Cross-zlib
82 ############
84 zlib-$(ZLIB_VERSION).tar.gz:
85 $(WGET) http://www.zlib.net/zlib-$(ZLIB_VERSION).tar.gz
87 ZLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libz.a
88 .PHONY: cross-zlib
89 cross-zlib: $(ZLIB_STAMPFILE)
90 $(ZLIB_STAMPFILE): zlib-$(ZLIB_VERSION).tar.gz $(NEWLIB_STAMPFILE)
91 tar xzf $<
92 ( cd zlib-$(ZLIB_VERSION) && \
93 CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(CC) ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf && \
94 $(MAKE) libz.a && \
95 $(MAKE) install )
97 ##############
98 # Cross-libpci
99 ##############
101 pciutils-$(LIBPCI_VERSION).tar.bz2:
102 $(WGET) http://www.kernel.org/pub/software/utils/pciutils/pciutils-$(LIBPCI_VERSION).tar.bz2
104 pciutils-$(LIBPCI_VERSION): pciutils-$(LIBPCI_VERSION).tar.bz2
105 tar xjf $<
106 patch -d $@ -p1 < pciutils.patch
107 touch $@
109 LIBPCI_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libpci.a
110 .PHONY: cross-libpci
111 cross-libpci: $(LIBPCI_STAMPFILE)
112 $(LIBPCI_STAMPFILE): pciutils-$(LIBPCI_VERSION) $(NEWLIB_STAMPFILE) $(ZLIB_STAMPFILE)
113 ( cd pciutils-$(LIBPCI_VERSION) && \
114 cp ../libpci.config.h lib/config.h && \
115 echo '#define PCILIB_VERSION "$(LIBPCI_VERSION)"' >> lib/config.h && \
116 cp ../libpci.config.mak lib/config.mk && \
117 $(MAKE) CC="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -I$(realpath $(MINI_OS)/include)" lib/libpci.a && \
118 $(INSTALL_DATA) lib/libpci.a $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib/ && \
119 $(INSTALL_DIR) $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci && \
120 $(INSTALL_DATA) lib/{config,header,pci,types}.h $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci/ \
121 )
123 ######
124 # lwIP
125 ######
127 lwip-cvs:
128 cvs -z 9 -d :pserver:anonymous@cvs.savannah.nongnu.org:/sources/lwip co -D $(LWIP_DATE) -d $@ lwip
130 #######
131 # Links
132 #######
134 .PHONY: $(CROSS_ROOT)
135 $(CROSS_ROOT): cross-newlib cross-zlib cross-libpci
137 .PHONY: mk-symlinks
138 mk-symlinks:
139 [ -h include ] || ln -sf ../tools/include .
140 mkdir -p libxc
141 [ -h libxc/Makefile ] || ( cd libxc && \
142 ln -sf ../$(XEN_ROOT)/tools/libxc/*.h . && \
143 ln -sf ../$(XEN_ROOT)/tools/libxc/*.c . && \
144 ln -sf ../$(XEN_ROOT)/tools/libxc/Makefile . )
145 mkdir -p libxc/$(XEN_TARGET_ARCH)
146 [ -h libxc/$(XEN_TARGET_ARCH) ] || ( cd libxc/$(XEN_TARGET_ARCH) && \
147 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
148 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
149 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
150 mkdir -p ioemu
151 [ -h ioemu/Makefile ] || ( cd ioemu && \
152 ln -sf ../$(XEN_ROOT)/tools/ioemu/* . && \
153 ([ ! -h config-host.h ] || rm -f config-host.h) && \
154 ([ ! -h config-host.mak ] || rm -f config-host.mak) )
155 $(MAKE) -C $(MINI_OS) links
157 TARGETS_MINIOS=$(addprefix mini-os-,$(TARGETS))
158 $(TARGETS_MINIOS): mini-os-%:
159 [ -d $@ ] || \
160 for i in $$(cd $(MINI_OS) ; find . -type d) ; do \
161 mkdir -p $@/$$i ; \
162 done
164 #######
165 # libxc
166 #######
168 .PHONY: libxc
169 libxc: libxc/libxenctrl.a libxc/libxenguest.a
170 libxc/libxenctrl.a libxc/libxenguest.a:: cross-zlib mk-symlinks
171 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C libxc
173 #######
174 # ioemu
175 #######
177 .PHONY: ioemu
178 ioemu: cross-zlib cross-libpci mk-symlinks libxc
179 [ -f ioemu/config-host.mak ] || \
180 ( cd ioemu ; \
181 XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) CFLAGS="$(TARGET_CFLAGS)" sh configure --prefix=/usr --enable-stubdom $(IOEMU_OPTIONS))
182 CPPFLAGS="$(TARGET_CPPFLAGS)" $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip-cvs TOOLS=
184 ######
185 # caml
186 ######
188 .PHONY: caml
189 caml: cross-newlib mk-symlinks
190 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-cvs
192 ###
193 # C
194 ###
196 .PHONY: c
197 c: cross-newlib mk-symlinks
198 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-cvs
200 ######
201 # Grub
202 ######
204 grub-cvs:
205 cvs -z 9 -d :pserver:anonymous@cvs.sv.gnu.org:/sources/grub co -D $(GRUB_DATE) -d $@ grub
206 for i in grub.patches/* ; do \
207 patch -d $@ -p1 < $$i ; \
208 done
210 .PHONY: grub
211 grub: grub-cvs cross-newlib mk-symlinks
212 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@
214 ########
215 # minios
216 ########
218 .PHONY: ioemu-stubdom
219 ioemu-stubdom: mini-os-ioemu lwip-cvs libxc ioemu
220 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="$(CURDIR)/ioemu/i386-dm-stubdom/qemu.a $(CURDIR)/ioemu/i386-dm-stubdom/libqemu.a"
222 CAMLLIB = $(shell ocamlc -where)
223 .PHONY: caml-stubdom
224 caml-stubdom: mini-os-caml lwip-cvs libxc caml
225 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"
227 .PHONY: c-stubdom
228 c-stubdom: mini-os-c lwip-cvs libxc c
229 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
231 .PHONY: pv-grub
232 pv-grub: mini-os-grub libxc grub
233 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
235 #########
236 # install
237 #########
239 install: install-ioemu install-grub
241 install-ioemu: mini-os-ioemu/mini-os.gz
242 $(INSTALL_PROG) stubdom-dm "$(DESTDIR)/usr/lib/xen/bin"
243 $(INSTALL_PROG) $< "$(DESTDIR)/usr/lib/xen/boot/ioemu-stubdom.gz"
245 install-grub: mini-os-grub/mini-os.gz
246 $(INSTALL_PROG) $< "$(DESTDIR)/usr/lib/xen/boot/pv-grub.gz"
248 #######
249 # clean
250 #######
252 # Only clean the libxc/ioemu/mini-os part
253 .PHONY: clean
254 clean:
255 rm -fr mini-os-ioemu
256 rm -fr mini-os-c
257 rm -fr mini-os-caml
258 rm -fr mini-os-grub
259 $(MAKE) -C caml clean
260 $(MAKE) -C c clean
261 $(MAKE) -C grub clean
262 rm -fr libxc ioemu mini-os include
264 # clean the cross-compilation result
265 .PHONY: crossclean
266 crossclean: clean
267 rm -fr $(CROSS_ROOT)
268 rm -fr newlib-build
269 rm -fr zlib-$(ZLIB_VERSION) pciutils-$(LIBPCI_VERSION)
271 # clean patched sources
272 .PHONY: patchclean
273 patchclean: crossclean
274 rm -fr newlib-cvs
275 rm -fr lwip-cvs
276 rm -fr grub-cvs
278 # clean downloads
279 .PHONY: downloadclean
280 downloadclean: patchclean
281 rm -f zlib-$(ZLIB_VERSION).tar.gz
282 rm -f pciutils-$(LIBPCI_VERSION).tar.bz2
284 .PHONY: distclean
285 distclean: downloadclean